Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restarting workspace should take into account changes to eclipse.ini #1307

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.window.IShellProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.osgi.internal.location.LocationHelper;

Check warning on line 142 in bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java

View check run for this annotation

Jenkins - Eclipse Platform / Eclipse ECJ

Restriction

NORMAL: Discouraged access: The type 'LocationHelper' is not API (restriction on classpath entry '/home/jenkins/agent/workspace/eclipse.platform.ui_PR-1307/.m2/repository/p2/osgi/bundle/org.eclipse.osgi/3.19.0.v20240115-1446/org.eclipse.osgi-3.19.0.v20240115-1446.jar')
import org.eclipse.osgi.service.runnable.StartupMonitor;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
Expand Down Expand Up @@ -279,7 +280,7 @@
* Note that any code that is run during the creation of a workbench instance
* should not required access to the display.
* </p>
*/

Check warning on line 283 in bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java

View check run for this annotation

Jenkins - Eclipse Platform / Eclipse ECJ

Other

NORMAL: Workbench illegally implements IWorkbench
public final class Workbench extends EventManager implements IWorkbench, org.eclipse.e4.ui.workbench.IWorkbench {

public static final String WORKBENCH_AUTO_SAVE_JOB = "Workbench Auto-Save Job"; //$NON-NLS-1$
Expand All @@ -290,12 +291,8 @@

public static final String EDITOR_TAG = "Editor"; //$NON-NLS-1$

private static final String PROP_VM = "eclipse.vm"; //$NON-NLS-1$
private static final String PROP_VMARGS = "eclipse.vmargs"; //$NON-NLS-1$
private static final String PROP_COMMANDS = "eclipse.commands"; //$NON-NLS-1$
public static final String PROP_EXIT_CODE = "eclipse.exitcode"; //$NON-NLS-1$
private static final String CMD_DATA = "-data"; //$NON-NLS-1$
private static final String CMD_VMARGS = "-vmargs"; //$NON-NLS-1$

private static final class StartupProgressBundleListener implements SynchronousBundleListener {

Expand Down Expand Up @@ -667,10 +664,10 @@

private static void setSearchContribution(MApplication app, boolean enabled) {
for (MTrimContribution contribution : app.getTrimContributions()) {
if ("org.eclipse.ui.ide.application.trimcontribution.QuickAccess".contains(contribution //$NON-NLS-1$

Check warning on line 667 in bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java

View check run for this annotation

Jenkins - Eclipse Platform / Eclipse ECJ

Other

NORMAL: Workbench illegally references method MApplicationElement.getElementId()
.getElementId())) {
// allows us to handle the case where someone opens a workspace
// with Luna and then with Kepler

Check warning on line 670 in bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java

View check run for this annotation

Jenkins - Eclipse Platform / Eclipse ECJ

Other

NORMAL: Workbench illegally references method MUIElement.setToBeRendered(boolean)
contribution.setToBeRendered(enabled);
}
}
Expand Down Expand Up @@ -2593,64 +2590,16 @@
* is not set
*/
private static String buildCommandLine(String workspace) {
String property = System.getProperty(PROP_VM);
if (property == null) {
if (!Platform.inDevelopmentMode()) {
// Don't log this when in development mode, since 'eclipse.vm'
// is never set in this case
WorkbenchPlugin.log(NLS.bind(WorkbenchMessages.Workbench_missingPropertyMessage, PROP_VM));
}
return null;
}

StringBuilder result = new StringBuilder(512);
result.append(property);
result.append('\n');

// append the vmargs and commands. Assume that these already end in \n
String vmargs = System.getProperty(PROP_VMARGS);
if (vmargs != null) {
result.append(vmargs);
}
String userData = System.getProperty(IApplicationContext.EXIT_DATA_PROPERTY);
if (userData != null && !userData.isBlank())
result.append(userData);

// append the rest of the args, replacing or adding -data as required
property = System.getProperty(PROP_COMMANDS);
if (property == null) {
result.append(CMD_DATA);
result.append('\n');
result.append(workspace);
result.append('\n');
} else {
// find the index of the arg to add/replace its value
int cmd_data_pos = property.lastIndexOf(CMD_DATA);
if (cmd_data_pos != -1) {
cmd_data_pos += CMD_DATA.length() + 1;
result.append(property.substring(0, cmd_data_pos));
result.append(workspace);
// append from the next arg
int nextArg = property.indexOf("\n-", cmd_data_pos - 1); //$NON-NLS-1$
if (nextArg != -1) {
result.append(property.substring(nextArg));
}
} else {
result.append(CMD_DATA);
result.append('\n');
result.append(workspace);
result.append('\n');
result.append(property);
}
}

// put the vmargs back at the very end (the eclipse.commands property
// already contains the -vm arg)
if (vmargs != null) {
if (result.charAt(result.length() - 1) != '\n') {
result.append('\n');
}
result.append(CMD_VMARGS);
result.append('\n');
result.append(vmargs);
}
result.append(CMD_DATA);
result.append('\n');
result.append(workspace);
result.append('\n');

return result.toString();
}
Expand All @@ -2662,13 +2611,15 @@
* @param workspacePath the new workspace location
* @return {@link IApplication#EXIT_OK} or {@link IApplication#EXIT_RELAUNCH}
*/
@SuppressWarnings("restriction")
public static Object setRestartArguments(String workspacePath) {
String property = System.getProperty(Workbench.PROP_VM);
if (property == null) {
if (Platform.inDevelopmentMode()
&& !Platform.getInstanceLocation().getURL().equals(LocationHelper.buildURL(workspacePath, true))) {
MessageDialog.openError(null, WorkbenchMessages.Workbench_problemsRestartErrorTitle,
NLS.bind(WorkbenchMessages.Workbench_problemsRestartErrorMessage, Workbench.PROP_VM));
return IApplication.EXIT_OK;
WorkbenchMessages.Workbench_problemsRestartErrorMessage);
return null;
}

String command_line = Workbench.buildCommandLine(workspacePath);
if (command_line == null) {
return IApplication.EXIT_OK;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ public class WorkbenchMessages extends NLS {
public static String SaveAll_toolTip;
public static String Workbench_revert;
public static String Workbench_revertToolTip;
public static String Workbench_missingPropertyMessage;
public static String Workbench_move;

public static String Workbench_moveToolTip;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ SaveAll_text = Sav&e All
SaveAll_toolTip = Save All
Workbench_revert = Rever&t
Workbench_revertToolTip = Revert
Workbench_missingPropertyMessage=Unable to relaunch the platform with the current workspace because the ''{0}'' property has not been set.
Workbench_move = Mo&ve...
Workbench_moveToolTip = Move
Workbench_rename = Rena&me...
Expand Down Expand Up @@ -693,8 +692,8 @@ Startup_Loading_Workbench=Loading Workbench
Workbench_problemsSavingMsg=Could not save workbench layout.
Workbench_problemsRestoring=Problems occurred restoring workbench.
Workbench_problemsSaving=Problems occurred saving workbench.
Workbench_problemsRestartErrorTitle = Missing System Property
Workbench_problemsRestartErrorMessage = Unable to relaunch the workbench because the {0} property has not been set.
Workbench_problemsRestartErrorTitle = Restart with different workspace
Workbench_problemsRestartErrorMessage = Restarting with different workspace does not work in development mode.

PageLayout_missingRefPart=Referenced part does not exist yet: {0}.

Expand Down
Loading