1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Merge remote-tracking branch 'cdt/master' into sd90

This commit is contained in:
Andrew Gvozdev 2012-04-03 18:06:49 -04:00
commit 3bd6a3eb46
59 changed files with 808 additions and 451 deletions

2
.gitignore vendored
View file

@ -1,2 +1,4 @@
/*/*/bin /*/*/bin
/*/*/index
/*/*/target /*/*/target
.DS_Store

View file

@ -1,3 +1,21 @@
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
Bug #371277
* src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java
(regenerateMakefiles): Fix setting of status on error.
(runScript): Switch to use sh -c for all script execution.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
Bug #372557
* src/org/eclipse/cdt/internal/autotools/core/AutotoolsNewMakeGenerator.java
(runScript): Fix index out of range exception when environment variable is
unknown.
2012-03-29 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/core/AutotoolsNewProjectNature.java: Fix old nature id to contain the .core specifier.
2012-01-03 Jeff Johnston <jjohnstn@redhat.com> 2012-01-03 Jeff Johnston <jjohnstn@redhat.com>
Refactor all packages to be org.eclipse.cdt.autotools.core. Refactor all packages to be org.eclipse.cdt.autotools.core.

View file

@ -36,7 +36,7 @@ import org.eclipse.core.runtime.jobs.Job;
public class AutotoolsNewProjectNature implements IProjectNature { public class AutotoolsNewProjectNature implements IProjectNature {
public static final String AUTOTOOLS_NATURE_ID = "org.eclipse.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$ public static final String AUTOTOOLS_NATURE_ID = "org.eclipse.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$
public static final String OLD_AUTOTOOLS_NATURE_ID = "org.eclipse.linuxtools.cdt.autotools.autotoolsNatureV2"; //$NON-NLS-1$ public static final String OLD_AUTOTOOLS_NATURE_ID = "org.eclipse.linuxtools.cdt.autotools.core.autotoolsNatureV2"; //$NON-NLS-1$
public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".genmakebuilder"; //$NON-NLS-1$ public final static String BUILDER_ID = ManagedBuilderCorePlugin.getUniqueIdentifier() + ".genmakebuilder"; //$NON-NLS-1$
public final static String OLD_AUTOTOOLS_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.genmakebuilder"; //$NON-NLS-1$ public final static String OLD_AUTOTOOLS_BUILDER_ID = "org.eclipse.linuxtools.cdt.autotools.genmakebuilder"; //$NON-NLS-1$

View file

@ -301,7 +301,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
} }
private Status regenerateMakefiles(IConfiguration icfg, boolean reconfigure) throws CoreException { private Status regenerateMakefiles(IConfiguration icfg, boolean reconfigure) throws CoreException {
Status status; MultiStatus status;
int rc = IStatus.OK; int rc = IStatus.OK;
String errMsg = new String(); String errMsg = new String();
boolean needFullConfigure = false; boolean needFullConfigure = false;
@ -615,6 +615,13 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
// getGenerationProblems().clear(); // getGenerationProblems().clear();
status = new MultiStatus(AutotoolsPlugin status = new MultiStatus(AutotoolsPlugin
.getUniqueIdentifier(), rc, errMsg, null); .getUniqueIdentifier(), rc, errMsg, null);
if (rc != IStatus.OK)
status.add(new Status (
rc,
AutotoolsPlugin.getUniqueIdentifier(),
0,
errMsg,
null));
} }
return status; return status;
} }
@ -1032,11 +1039,15 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
} }
configTargets[0] = getPathString(commandPath); configTargets[0] = getPathString(commandPath);
// Fix for bug #343731 // Fix for bug #343879
if (Platform.getOS().equals(Platform.OS_WIN32) if (Platform.getOS().equals(Platform.OS_WIN32)
|| Platform.getOS().equals(Platform.OS_MACOSX)) { || Platform.getOS().equals(Platform.OS_MACOSX))
removePWD = true; removePWD = true;
// Neither Mac or Windows support calling scripts directly.
// Fix for bug #343731 and bug #371277
// Always use sh -c for executing autotool scripts which should
// work on all Linux POSIX compliant shells including bash, dash, as
// well as Windows and Mac OSX.
String command = null; String command = null;
for (String arg : configTargets) { for (String arg : configTargets) {
// TODO check for spaces in args // TODO check for spaces in args
@ -1046,7 +1057,6 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
command += " " + arg; command += " " + arg;
} }
configTargets = new String[] { "-c", command }; configTargets = new String[] { "-c", command };
}
for (int i = 0; i < configTargets.length; ++i) { for (int i = 0; i < configTargets.length; ++i) {
// try to resolve the build macros in any argument // try to resolve the build macros in any argument
@ -1060,7 +1070,7 @@ public class AutotoolsNewMakeGenerator extends MarkerGenerator {
cfg); cfg);
// strip any env-var settings from options // strip any env-var settings from options
// fix for bug #356278 // fix for bug #356278
if (resolved.charAt(0) != '-') if (resolved.length() > 0 && resolved.charAt(0) != '-')
resolved = stripEnvVarsFromOption(resolved, additionalEnvs); resolved = stripEnvVarsFromOption(resolved, additionalEnvs);
configTargets[i] = resolved; configTargets[i] = resolved;
} catch (BuildMacroException e) { } catch (BuildMacroException e) {

View file

@ -1,3 +1,17 @@
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/tests/ProjectTools.java
(setup): Fix to return false when Workbench is null.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* zip/project2.zip: Fix autogen.sh to make the configure script executable.
2012-03-29 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/tests/ProjectTools.java (build): Refresh the workspace root so resource tests
will work consistently.
2012-01-03 Jeff Johnston <jjohnstn@redhat.com> 2012-01-03 Jeff Johnston <jjohnstn@redhat.com>
Refactor to org.eclipse.cdt.autotools.tests. Refactor to org.eclipse.cdt.autotools.tests.

View file

@ -13,6 +13,8 @@ import org.eclipse.cdt.core.CommandLauncher;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription; import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager; import org.eclipse.cdt.internal.autotools.core.configure.AutotoolsConfigurationManager;
import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration; import org.eclipse.cdt.internal.autotools.core.configure.IAConfiguration;
import org.eclipse.cdt.internal.autotools.ui.wizards.ConvertToAutotoolsProjectWizard;
import org.eclipse.cdt.internal.autotools.ui.wizards.ConvertToAutotoolsProjectWizardPage;
import org.eclipse.cdt.managedbuilder.core.IConfiguration; import org.eclipse.cdt.managedbuilder.core.IConfiguration;
import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo; import org.eclipse.cdt.managedbuilder.core.IManagedBuildInfo;
import org.eclipse.cdt.managedbuilder.core.IProjectType; import org.eclipse.cdt.managedbuilder.core.IProjectType;
@ -23,6 +25,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription; import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
@ -35,8 +38,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.cdt.internal.autotools.ui.wizards.ConvertToAutotoolsProjectWizard;
import org.eclipse.cdt.internal.autotools.ui.wizards.ConvertToAutotoolsProjectWizardPage;
import org.eclipse.ui.dialogs.IOverwriteQuery; import org.eclipse.ui.dialogs.IOverwriteQuery;
import org.eclipse.ui.wizards.datatransfer.ImportOperation; import org.eclipse.ui.wizards.datatransfer.ImportOperation;
import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider; import org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider;
@ -60,12 +61,12 @@ public class ProjectTools {
if (!setupComplete) { if (!setupComplete) {
IWorkspaceDescription desc; IWorkspaceDescription desc;
workspace = ResourcesPlugin.getWorkspace(); workspace = ResourcesPlugin.getWorkspace();
root = workspace.getRoot(); if (workspace == null) {
monitor = new NullProgressMonitor();
if(workspace == null) {
return false; return false;
} }
if(root == null) { root = workspace.getRoot();
monitor = new NullProgressMonitor();
if (root == null) {
return false; return false;
} }
desc = workspace.getDescription(); desc = workspace.getDescription();
@ -83,6 +84,7 @@ public class ProjectTools {
public static boolean build() { public static boolean build() {
try { try {
workspace.build(IncrementalProjectBuilder.FULL_BUILD, getMonitor()); workspace.build(IncrementalProjectBuilder.FULL_BUILD, getMonitor());
workspace.getRoot().refreshLocal(IResource.DEPTH_INFINITE, getMonitor());
} catch (CoreException e) { } catch (CoreException e) {
return false; return false;
} }

View file

@ -1,3 +1,37 @@
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java
(AutomakeEditor): Make constructor public so openEditor will work.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeErrorHandler.java
(AutomakeErrorHandler): Change constructor to accept an IEditorInput rather than
an IDocument.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakefileReconcilingStrategy.java
(AutomakefileReconcilingStrategy): Pass an IEditorInput to create the
AutomakeErrorHandler.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeDocumentProvider.java
(connect): Ditto.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
* src/org/eclipse/cdt/autotools/ui/editors/AutoconfMacro.java
(equals): Fix FindBugs error with missing null case.
(hashCode): New method to fix FindBugs error.
* src/org/eclipse/cdt/internal/autotools/ui/editors/automake/AutomakeEditor.java
(AutomakeEditor): Fix constructor to remove static variable.
(static initializer): Fix FindBugs error with static variable usage.
2012-03-30 Jeff Johnston <jjohnstn@redhat.com>
Bug #371277
* src/org/eclipse/cdt/internal/autotools/ui/actions/InvokeAction.java
(..run): Use sh -c to execute the autotool scripts.
2012-03-29 Jeff Johnston <jjohnstn@redhat.com>
Resolves: bug#374026
* src/org/eclipse/cdt/internal/autotools/ui/wizards/AutotoolsBuildWizard.java (createItems): Change to accept any
type of project that has at least one toolchain that is based upon the GNU Autotools toolchain.
2012-01-03 Jeff Johnston <jjohnstn@redhat.com> 2012-01-03 Jeff Johnston <jjohnstn@redhat.com>
Refactor entire plug-in to org.eclipse.cdt.autotools.ui. Refactor entire plug-in to org.eclipse.cdt.autotools.ui.

View file

@ -42,7 +42,14 @@ public class AutoconfMacro implements Comparable<Object> {
} }
public boolean equals(Object x) { public boolean equals(Object x) {
if (x == null)
return false;
AutoconfMacro y = (AutoconfMacro)x; AutoconfMacro y = (AutoconfMacro)x;
return getName().equals(y.getName()); return getName().equals(y.getName());
} }
public int hashCode() {
return getName().hashCode();
}
} }

View file

@ -41,7 +41,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.ISchedulingRule;
@ -259,7 +258,7 @@ public abstract class InvokeAction extends AbstractTargetAction {
Process process = cmdL.execute(command, argumentList, envList, Process process = cmdL.execute(command, argumentList, envList,
execDir, new NullProgressMonitor()); execDir, new NullProgressMonitor());
if (cmdL.waitAndRead(stdout, stderr) == CommandLauncher.OK) { if (cmdL.waitAndRead(stdout, stderr, new NullProgressMonitor()) == CommandLauncher.OK) {
try { try {
status = 0; status = 0;
monitor.done(); monitor.done();
@ -389,29 +388,17 @@ public abstract class InvokeAction extends AbstractTargetAction {
String[] newArgumentList; String[] newArgumentList;
// Fix for bug #343905 // Fix for bug #343905 and bug #371277
// For Windows and Mac, we cannot run a script directly (in this case, the // For Windows and Mac, we cannot run a script directly (in this case,
// autotools are scripts). We need to run "sh -c command args where command // autotools are scripts). We need to run "sh -c command args where command
// plus args is represented in a single string. // plus args is represented in a single string. The same applies for
if (Platform.getOS().equals(Platform.OS_WIN32) // some Linux shells such as dash. Using sh -c will work on all Linux
|| Platform.getOS().equals(Platform.OS_MACOSX)) { // POSIX-compliant shells.
// Neither Mac or Windows support calling scripts directly.
StringBuffer command = new StringBuffer(strippedCommand); StringBuffer command = new StringBuffer(strippedCommand);
for (String arg : argumentList) { for (String arg : argumentList) {
command.append(" " + arg); command.append(" " + arg);
} }
newArgumentList = new String[] { "-c", command.toString() }; newArgumentList = new String[] { "-c", command.toString() };
} else {
// Otherwise, we don't need the -c argument and can present the command
// name and arguments as individual arguments
if (argumentList == null)
newArgumentList = new String[1];
else
newArgumentList = new String[argumentList.length + 1];
newArgumentList[0] = strippedCommand;
if (argumentList != null)
System.arraycopy(argumentList, 0, newArgumentList, 1, argumentList.length);
}
OutputStream stdout = consoleOutStream; OutputStream stdout = consoleOutStream;
OutputStream stderr = consoleOutStream; OutputStream stderr = consoleOutStream;

View file

@ -17,6 +17,7 @@ import java.util.Iterator;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.IURIEditorInput; import org.eclipse.ui.IURIEditorInput;
import org.eclipse.ui.editors.text.TextFileDocumentProvider; import org.eclipse.ui.editors.text.TextFileDocumentProvider;
@ -105,8 +106,7 @@ public class AutomakeDocumentProvider extends TextFileDocumentProvider implement
public void connect(Object element) throws CoreException { public void connect(Object element) throws CoreException {
super.connect(element); super.connect(element);
IMakefile makefile = getWorkingCopy(element); IMakefile makefile = getWorkingCopy(element);
IDocument document = getDocument(element); AutomakeErrorHandler errorHandler = new AutomakeErrorHandler((IEditorInput)element);
AutomakeErrorHandler errorHandler = new AutomakeErrorHandler(document);
errorHandler.update(makefile); errorHandler.update(makefile);
} }

View file

@ -34,9 +34,12 @@ public class AutomakeEditor extends MakefileEditor {
private static AutomakeEditor fgInstance; private static AutomakeEditor fgInstance;
private IEditorInput input; private IEditorInput input;
static {
fgInstance = new AutomakeEditor();
}
public AutomakeEditor() { public AutomakeEditor() {
super(); super();
fgInstance = this;
} }
/** /**

View file

@ -52,9 +52,8 @@ public class AutomakeErrorHandler {
} }
public AutomakeErrorHandler(IDocument document) { public AutomakeErrorHandler(IEditorInput input) {
this.document = document; this.document = AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getDocument(input);
IEditorInput input = AutomakeEditor.getDefault().getEditorInput();
this.fAnnotationModel = (AnnotationModel)AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getAnnotationModel(input); this.fAnnotationModel = (AnnotationModel)AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider().getAnnotationModel(input);
} }

View file

@ -42,7 +42,7 @@ public class AutomakefileReconcilingStrategy implements IReconcilingStrategy {
input = (IEditorInput) fEditor.getEditorInput(); input = (IEditorInput) fEditor.getEditorInput();
fManager= AutomakeEditorFactory.getDefault().getWorkingCopyManager(); fManager= AutomakeEditorFactory.getDefault().getWorkingCopyManager();
fDocumentProvider= AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider(); fDocumentProvider= AutomakeEditorFactory.getDefault().getAutomakefileDocumentProvider();
fErrorHandler= new AutomakeErrorHandler(fDocumentProvider.getDocument(input)); fErrorHandler= new AutomakeErrorHandler(input);
fMakefileReconcilingParticipant= (IReconcilingParticipant)fEditor; fMakefileReconcilingParticipant= (IReconcilingParticipant)fEditor;
} }

View file

@ -40,6 +40,8 @@ public class AutotoolsBuildWizard extends AbstractCWizard {
* @since 5.1 * @since 5.1
*/ */
public static final String EMPTY_PROJECT = AutotoolsWizardMessages.getResourceString("AutotoolsBuildWizard.2"); //$NON-NLS-1$ public static final String EMPTY_PROJECT = AutotoolsWizardMessages.getResourceString("AutotoolsBuildWizard.2"); //$NON-NLS-1$
public static final String AUTOTOOLS_TOOLCHAIN_ID = "org.eclipse.linuxtools.cdt.autotools.core.toolChain"; //$NON-NLS-1$
/** /**
* Creates and returns an array of items to be displayed * Creates and returns an array of items to be displayed
*/ */
@ -50,16 +52,26 @@ public class AutotoolsBuildWizard extends AbstractCWizard {
Arrays.sort(vs, BuildListComparator.getInstance()); Arrays.sort(vs, BuildListComparator.getInstance());
ArrayList<EntryDescriptor> items = new ArrayList<EntryDescriptor>(); ArrayList<EntryDescriptor> items = new ArrayList<EntryDescriptor>();
// look for Autotools project type // look for project types that have a toolchain based on the Autotools toolchain
// and if so, add an entry for the project type.
// Fix for bug#374026
EntryDescriptor oldsRoot = null; EntryDescriptor oldsRoot = null;
SortedMap<String, IProjectType> sm = ManagedBuildManager.getExtensionProjectTypeMap(); SortedMap<String, IProjectType> sm = ManagedBuildManager.getExtensionProjectTypeMap();
for (Map.Entry<String, IProjectType> e : sm.entrySet()) { for (Map.Entry<String, IProjectType> e : sm.entrySet()) {
IProjectType pt = e.getValue(); IProjectType pt = e.getValue();
if (pt.getId().equals(AUTOTOOLS_PROJECTTYPE_ID)) {
AutotoolsBuildWizardHandler h = new AutotoolsBuildWizardHandler(pt, parent, wizard); AutotoolsBuildWizardHandler h = new AutotoolsBuildWizardHandler(pt, parent, wizard);
IToolChain[] tcs = ManagedBuildManager.getExtensionToolChains(pt); IToolChain[] tcs = ManagedBuildManager.getExtensionToolChains(pt);
for(int i = 0; i < tcs.length; i++){ for(int i = 0; i < tcs.length; i++){
IToolChain t = tcs[i]; IToolChain t = tcs[i];
IToolChain parent = t;
while (parent.getSuperClass() != null) {
parent = parent.getSuperClass();
}
if (!parent.getId().equals(AUTOTOOLS_TOOLCHAIN_ID))
continue;
if(t.isSystemObject()) if(t.isSystemObject())
continue; continue;
if (!isValid(t, supportedOnly, wizard)) if (!isValid(t, supportedOnly, wizard))
@ -78,9 +90,11 @@ public class AutotoolsBuildWizard extends AbstractCWizard {
} else { // do not group to <Others> } else { // do not group to <Others>
pId = null; pId = null;
} }
if (h.getToolChainsCount() > 0)
items.add(new EntryDescriptor(pt.getId(), pId, pt.getName(), true, h, null)); items.add(new EntryDescriptor(pt.getId(), pId, pt.getName(), true, h, null));
} }
}
return (EntryDescriptor[])items.toArray(new EntryDescriptor[items.size()]); return (EntryDescriptor[])items.toArray(new EntryDescriptor[items.size()]);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2010 IBM Corporation and others. * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -108,7 +108,7 @@ public abstract class AbstractDiscoveryPage extends DialogPage {
private void handleVariablesButtonSelected(Text textField) { private void handleVariablesButtonSelected(Text textField) {
String variable = getVariable(); String variable = getVariable();
if (variable != null) { if (variable != null) {
textField.append(variable); textField.insert(variable);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2010 QNX Software Systems and others. * Copyright (c) 2000, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -407,7 +407,7 @@ public class SettingsBlock extends AbstractCOptionPage {
private void handleVariablesButtonSelected(Text textField) { private void handleVariablesButtonSelected(Text textField) {
String variable = getVariable(); String variable = getVariable();
if (variable != null) { if (variable != null) {
textField.append(variable); textField.insert(variable);
} }
} }

View file

@ -263,6 +263,22 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
validateProblemCount(2); // the inclusions validateProblemCount(2); // the inclusions
} }
// #define UNFOLD(v,x) v:x
// UNFOLD("A",
// #ifdef X
// "B")
// #else
// "C") /* parse error in this line */
// #endif
public void testDirectiveInExpansion_Bug375739() throws Exception {
initializeScanner();
validateString("A");
validateToken(IToken.tCOLON);
validateString("C");
validateEOF();
validateProblemCount(0);
}
// #if 0xe000 // #if 0xe000
// ok // ok
// #endif // #endif

View file

@ -75,11 +75,6 @@ public class CParameter extends PlatformObject implements IParameter {
return null; return null;
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.core.dom.ast.IBinding#getName()
*/
@Override @Override
public String getName() { public String getName() {
IASTName name = getPrimaryDeclaration(); IASTName name = getPrimaryDeclaration();
@ -100,6 +95,9 @@ public class CParameter extends PlatformObject implements IParameter {
public IScope getScope() { public IScope getScope() {
// IASTParameterDeclaration or IASTSimpleDeclaration // IASTParameterDeclaration or IASTSimpleDeclaration
for (IASTName declaration : declarations) { for (IASTName declaration : declarations) {
if (declaration == null)
break; // Skip nulls at the end of the declarations array
IASTNode parent = declaration.getParent(); IASTNode parent = declaration.getParent();
if (parent instanceof ICASTKnRFunctionDeclarator) { if (parent instanceof ICASTKnRFunctionDeclarator) {
parent = parent.getParent(); parent = parent.getParent();
@ -120,7 +118,7 @@ public class CParameter extends PlatformObject implements IParameter {
} }
/** /**
* @param name * @param name the name from a parameter declaration
*/ */
public void addDeclaration(IASTName name) { public void addDeclaration(IASTName name) {
if (name != null && name.isActive()) if (name != null && name.isActive())

View file

@ -17,7 +17,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.TreeMap; import java.util.TreeMap;
@ -51,7 +50,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDefinition;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
import org.eclipse.cdt.core.formatter.CodeFormatter; import org.eclipse.cdt.core.formatter.CodeFormatter;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants; import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification;
@ -63,7 +61,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ASTWriter;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ContainerNode;
import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ProblemRuntimeException; import org.eclipse.cdt.internal.core.dom.rewrite.astwriter.ProblemRuntimeException;
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.BadLocationException;
@ -82,10 +79,10 @@ import org.eclipse.text.edits.TextEdit;
import org.eclipse.text.edits.TextEditGroup; import org.eclipse.text.edits.TextEditGroup;
public class ChangeGenerator extends ASTVisitor { public class ChangeGenerator extends ASTVisitor {
private final Map<String, Integer> sourceOffsets = new LinkedHashMap<String, Integer>();
private final Map<IASTNode, Map<ModificationKind, List<ASTModification>>> classifiedModifications = private final Map<IASTNode, Map<ModificationKind, List<ASTModification>>> classifiedModifications =
new HashMap<IASTNode, Map<ModificationKind, List<ASTModification>>>(); new HashMap<IASTNode, Map<ModificationKind, List<ASTModification>>>();
private final Map<IFile, MultiTextEdit> changes = new LinkedHashMap<IFile, MultiTextEdit>(); private int processedOffset;
private MultiTextEdit rootEdit;
private CompositeChange change; private CompositeChange change;
private final ASTModificationStore modificationStore; private final ASTModificationStore modificationStore;
@ -118,21 +115,21 @@ public class ChangeGenerator extends ASTVisitor {
generateChange(rootNode, this); generateChange(rootNode, this);
} }
public void generateChange(IASTNode rootNode, ASTVisitor pathProvider) private void generateChange(IASTNode rootNode, ASTVisitor pathProvider)
throws ProblemRuntimeException { throws ProblemRuntimeException {
change = new CompositeChange(ChangeGeneratorMessages.ChangeGenerator_compositeChange); change = new CompositeChange(ChangeGeneratorMessages.ChangeGenerator_compositeChange);
classifyModifications(); classifyModifications();
rootNode.accept(pathProvider); rootNode.accept(pathProvider);
for (IFile file : changes.keySet()) { if (rootEdit == null)
MultiTextEdit edit = changes.get(file); return;
IASTTranslationUnit ast = rootNode.getTranslationUnit(); IASTTranslationUnit ast = rootNode.getTranslationUnit();
ITranslationUnit tu = (ITranslationUnit) CoreModel.getDefault().create(file); String source = ast.getRawSignature();
edit = formatChangedCode(edit, ast.getRawSignature(), tu); ITranslationUnit tu = ast.getOriginatingTranslationUnit();
TextFileChange subchange= ASTRewriteAnalyzer.createCTextFileChange(file); formatChangedCode(source, tu);
subchange.setEdit(edit); TextFileChange subchange= ASTRewriteAnalyzer.createCTextFileChange((IFile) tu.getResource());
subchange.setEdit(rootEdit);
change.add(subchange); change.add(subchange);
} }
}
private void classifyModifications() { private void classifyModifications() {
ASTModificationMap rootModifications = modificationStore.getRootModifications(); ASTModificationMap rootModifications = modificationStore.getRootModifications();
@ -161,7 +158,7 @@ public class ChangeGenerator extends ASTVisitor {
@Override @Override
public int visit(IASTTranslationUnit tu) { public int visit(IASTTranslationUnit tu) {
IASTFileLocation location = tu.getFileLocation(); IASTFileLocation location = tu.getFileLocation();
sourceOffsets.put(location.getFileName(), Integer.valueOf(location.getNodeOffset())); processedOffset = location.getNodeOffset();
return super.visit(tu); return super.visit(tu);
} }
@ -318,24 +315,21 @@ public class ChangeGenerator extends ASTVisitor {
/** /**
* Applies the C++ code formatter to the code affected by refactoring. * Applies the C++ code formatter to the code affected by refactoring.
* *
* @param multiEdit The text edit produced by refactoring.
* @param code The code being modified. * @param code The code being modified.
* @param tu The translation unit containing the code. * @param tu The translation unit containing the code.
* @return The text edit containing formatted refactoring changes, or the original text edit
* in case of errors.
*/ */
private MultiTextEdit formatChangedCode(MultiTextEdit multiEdit, String code, ITranslationUnit tu) { private void formatChangedCode(String code, ITranslationUnit tu) {
IDocument document = new Document(code); IDocument document = new Document(code);
try { try {
// Apply refactoring changes to a temporary document. // Apply refactoring changes to a temporary document.
TextEdit edit = multiEdit.copy(); TextEdit edit = rootEdit.copy();
edit.apply(document, TextEdit.UPDATE_REGIONS); edit.apply(document, TextEdit.UPDATE_REGIONS);
// Expand regions affected by the changes to cover complete lines. We calculate two // Expand regions affected by the changes to cover complete lines. We calculate two
// sets of regions, reflecting the state of the document before and after // sets of regions, reflecting the state of the document before and after
// the refactoring changes. // the refactoring changes.
TextEdit[] edits = edit.getChildren(); TextEdit[] edits = edit.getChildren();
TextEdit[] originalEdits = multiEdit.getChildren(); TextEdit[] originalEdits = rootEdit.getChildren();
IRegion[] regionsAfter = new IRegion[edits.length]; IRegion[] regionsAfter = new IRegion[edits.length];
IRegion[] regionsBefore = new IRegion[edits.length]; IRegion[] regionsBefore = new IRegion[edits.length];
int numRegions = 0; int numRegions = 0;
@ -396,13 +390,11 @@ public class ChangeGenerator extends ASTVisitor {
edit = new ReplaceEdit(region.getOffset(), region.getLength(), document.get()); edit = new ReplaceEdit(region.getOffset(), region.getLength(), document.get());
resultEdit.addChild(edit); resultEdit.addChild(edit);
} }
return resultEdit; rootEdit = resultEdit;
} catch (MalformedTreeException e) { } catch (MalformedTreeException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
return multiEdit;
} catch (BadLocationException e) { } catch (BadLocationException e) {
CCorePlugin.log(e); CCorePlugin.log(e);
return multiEdit;
} }
} }
@ -461,10 +453,9 @@ public class ChangeGenerator extends ASTVisitor {
} }
String code = writer.toString(); String code = writer.toString();
ReplaceEdit edit = new ReplaceEdit(insertPos, length, code); ReplaceEdit edit = new ReplaceEdit(insertPos, length, code);
IFile file = FileHelper.getFileFromNode(anchorNode); addToRootEdit(anchorNode);
MultiTextEdit parentEdit = getEdit(anchorNode, file); rootEdit.addChild(edit);
parentEdit.addChild(edit); processedOffset = edit.getOffset();
sourceOffsets.put(file.getName(), edit.getOffset());
} }
private void handleReplace(IASTNode node) { private void handleReplace(IASTNode node) {
@ -474,8 +465,6 @@ public class ChangeGenerator extends ASTVisitor {
ChangeGeneratorWriterVisitor writer = ChangeGeneratorWriterVisitor writer =
new ChangeGeneratorWriterVisitor(modificationStore, commentMap); new ChangeGeneratorWriterVisitor(modificationStore, commentMap);
IASTFileLocation fileLocation = node.getFileLocation(); IASTFileLocation fileLocation = node.getFileLocation();
Integer val = sourceOffsets.get(fileLocation.getFileName());
int processedOffset = val != null ? val.intValue() : 0;
if (modifications.size() == 1 && modifications.get(0).getNewNode() == null) { if (modifications.size() == 1 && modifications.get(0).getNewNode() == null) {
int offset = getOffsetIncludingComments(node); int offset = getOffsetIncludingComments(node);
int endOffset = getEndOffsetIncludingComments(node); int endOffset = getEndOffsetIncludingComments(node);
@ -519,11 +508,9 @@ public class ChangeGenerator extends ASTVisitor {
} }
edit = new ReplaceEdit(offset, endOffset - offset, code); edit = new ReplaceEdit(offset, endOffset - offset, code);
} }
IFile file = FileHelper.getFileFromNode(node); addToRootEdit(node);
MultiTextEdit parentEdit = getEdit(node, file); rootEdit.addChild(edit);
parentEdit.addChild(edit); processedOffset = edit.getExclusiveEnd();
sourceOffsets.put(fileLocation.getFileName(), edit.getExclusiveEnd());
} }
private void handleAppends(IASTNode node) { private void handleAppends(IASTNode node) {
@ -551,32 +538,31 @@ public class ChangeGenerator extends ASTVisitor {
writer.newLine(); writer.newLine();
} }
String code = writer.toString(); String code = writer.toString();
IFile file = FileHelper.getFileFromNode(node); addToRootEdit(node);
MultiTextEdit parentEdit = getEdit(node, file);
ReplaceEdit edit = new ReplaceEdit(anchor.getOffset(), anchor.getLength(), ReplaceEdit edit = new ReplaceEdit(anchor.getOffset(), anchor.getLength(),
code + anchor.getText()); code + anchor.getText());
parentEdit.addChild(edit); rootEdit.addChild(edit);
IASTFileLocation fileLocation = node.getFileLocation(); IASTFileLocation fileLocation = node.getFileLocation();
sourceOffsets.put(fileLocation.getFileName(), endOffset(fileLocation)); processedOffset = endOffset(fileLocation);
} }
private void handleAppends(IASTTranslationUnit tu) { private void handleAppends(IASTTranslationUnit node) {
List<ASTModification> modifications = getModifications(tu, ModificationKind.APPEND_CHILD); List<ASTModification> modifications = getModifications(node, ModificationKind.APPEND_CHILD);
if (modifications.isEmpty()) if (modifications.isEmpty())
return; return;
IASTNode prevNode = null; IASTNode prevNode = null;
IASTDeclaration[] declarations = tu.getDeclarations(); IASTDeclaration[] declarations = node.getDeclarations();
if (declarations.length != 0) { if (declarations.length != 0) {
prevNode = declarations[declarations.length - 1]; prevNode = declarations[declarations.length - 1];
} else { } else {
IASTPreprocessorStatement[] preprocessorStatements = tu.getAllPreprocessorStatements(); IASTPreprocessorStatement[] preprocessorStatements = node.getAllPreprocessorStatements();
if (preprocessorStatements.length != 0) { if (preprocessorStatements.length != 0) {
prevNode = preprocessorStatements[preprocessorStatements.length - 1]; prevNode = preprocessorStatements[preprocessorStatements.length - 1];
} }
} }
int offset = prevNode != null ? getEndOffsetIncludingComments(prevNode) : 0; int offset = prevNode != null ? getEndOffsetIncludingComments(prevNode) : 0;
String source = tu.getRawSignature(); String source = node.getRawSignature();
int endOffset = skipTrailingBlankLines(source, offset); int endOffset = skipTrailingBlankLines(source, offset);
ChangeGeneratorWriterVisitor writer = ChangeGeneratorWriterVisitor writer =
@ -607,9 +593,8 @@ public class ChangeGenerator extends ASTVisitor {
} }
String code = writer.toString(); String code = writer.toString();
IFile file = FileHelper.getFileFromNode(tu); addToRootEdit(node);
MultiTextEdit parentEdit = getEdit(tu, file); rootEdit.addChild(new ReplaceEdit(offset, endOffset - offset, code));
parentEdit.addChild(new ReplaceEdit(offset, endOffset - offset, code));
} }
/** /**
@ -928,23 +913,20 @@ public class ChangeGenerator extends ASTVisitor {
return startPos; return startPos;
} }
private MultiTextEdit getEdit(IASTNode modifiedNode, IFile file) { private void addToRootEdit(IASTNode modifiedNode) {
MultiTextEdit edit = changes.get(file); if (rootEdit == null) {
if (edit == null) { rootEdit = new MultiTextEdit();
edit = new MultiTextEdit();
changes.put(file, edit);
} }
TextEditGroup editGroup = new TextEditGroup(ChangeGeneratorMessages.ChangeGenerator_group); TextEditGroup editGroup = new TextEditGroup(ChangeGeneratorMessages.ChangeGenerator_group);
for (List<ASTModification> modifications : getModifications(modifiedNode).values()) { for (List<ASTModification> modifications : getModifications(modifiedNode).values()) {
for (ASTModification modification : modifications) { for (ASTModification modification : modifications) {
if (modification.getAssociatedEditGroup() != null) { if (modification.getAssociatedEditGroup() != null) {
editGroup = modification.getAssociatedEditGroup(); editGroup = modification.getAssociatedEditGroup();
edit.addChildren(editGroup.getTextEdits()); rootEdit.addChildren(editGroup.getTextEdits());
return edit; return;
} }
} }
} }
return edit;
} }
private int getOffsetIncludingComments(IASTNode node) { private int getOffsetIncludingComments(IASTNode node) {

View file

@ -224,7 +224,7 @@ final class ScannerContext {
cond.fTakeElse= false; cond.fTakeElse= false;
newState= cond.fInitialState; newState= cond.fInitialState;
} else if (withinExpansion) { } else if (withinExpansion) {
newState= CodeState.eParseInactive; newState= CodeState.eSkipInactive;
} else { } else {
newState= fInactiveState; newState= fInactiveState;
} }

View file

@ -104,7 +104,9 @@ cxxHeaderName=C++ Header File
asmSourceName=Assembly Source File asmSourceName=Assembly Source File
binaryFileName=Binary File binaryFileName=Binary File
cdt_pathentry_var.description=CDT PathEntry Variable cdt_pathentry_var.description=CDT PathEntry variable
config_name_var.description=The name of the active configuration for the project specified as an argument
config_description_var.description=The description of the active configuration for the project specified as an argument
PDOMProviderName=PDOM Provider PDOMProviderName=PDOM Provider

View file

@ -588,6 +588,22 @@
description="%cdt_pathentry_var.description"> description="%cdt_pathentry_var.description">
</variable> </variable>
</extension> </extension>
<extension
point="org.eclipse.core.variables.dynamicVariables">
<variable
name="config_name"
resolver="org.eclipse.cdt.internal.core.ConfigurationNameVariableResolver"
description="%config_name_var.description">
</variable>
</extension>
<extension
point="org.eclipse.core.variables.dynamicVariables">
<variable
name="config_description"
resolver="org.eclipse.cdt.internal.core.ConfigurationDescriptionVariableResolver"
description="%config_description_var.description">
</variable>
</extension>
<extension <extension
point="org.eclipse.cdt.core.CBuildConsole"> point="org.eclipse.cdt.core.CBuildConsole">
<CBuildConsole <CBuildConsole

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2000, 2010 QNX Software Systems and others. # Copyright (c) 2000, 2010, 2012 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -9,6 +9,7 @@
# QNX Software Systems - Initial API and implementation # QNX Software Systems - Initial API and implementation
# Markus Schorn (Wind River Systems) # Markus Schorn (Wind River Systems)
# Anton Leherbauer (Wind River Systems) # Anton Leherbauer (Wind River Systems)
# Anton Gorenkov
############################################################################### ###############################################################################
ACBuilder.ProblemsView.Location=line {0}, external location: {1} ACBuilder.ProblemsView.Location=line {0}, external location: {1}
CBuilder.build_error= Build Error CBuilder.build_error= Build Error
@ -68,6 +69,9 @@ Util.unknownFormat=Unknown debug format
PathEntryVariableResolver.0=CDT PathEntry variable not specified PathEntryVariableResolver.0=CDT PathEntry variable not specified
ConfigurationInfoVariableResolver.noProjectName=Project name should be specified as variable argument for '${'{0}'}' variable
ConfigurationInfoVariableResolver.wrongProjectName=The "{0}" project referenced by the '${'{1}'}' variable does not exist
CTagsIndexMarker.fileMissing=CTags output file missing CTagsIndexMarker.fileMissing=CTags output file missing
CTagsIndexMarker.CTagsMissing=CTags not installed or not in path CTagsIndexMarker.CTagsMissing=CTags not installed or not in path
DOMIndexerMarker.EmptyScannerInfo=File not indexed because it was not built DOMIndexerMarker.EmptyScannerInfo=File not indexed because it was not built

View file

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2012 Anton Gorenkov and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Gorenkov - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
public class ConfigurationDescriptionVariableResolver extends ConfigurationInfoVariableResolver {
@Override
protected String fetchConfigurationInfo(ICConfigurationDescription configuration) {
return configuration.getDescription();
}
}

View file

@ -0,0 +1,45 @@
/*******************************************************************************
* Copyright (c) 2012 Anton Gorenkov and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Gorenkov - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core;
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.model.CoreModel;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
import org.eclipse.cdt.core.settings.model.ICProjectDescription;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.IDynamicVariable;
import org.eclipse.core.variables.IDynamicVariableResolver;
import org.eclipse.osgi.util.NLS;
public abstract class ConfigurationInfoVariableResolver implements IDynamicVariableResolver {
@Override
public String resolveValue(IDynamicVariable variable, String argument) throws CoreException {
if (argument == null) {
String message = NLS.bind(CCorePlugin.getResourceString("ConfigurationInfoVariableResolver.noProjectName"), //$NON-NLS-1$
variable.getName());
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, message, null));
}
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(argument);
if (!project.exists()) {
String message = NLS.bind(CCorePlugin.getResourceString("ConfigurationInfoVariableResolver.wrongProjectName"), //$NON-NLS-1$
argument, variable.getName());
throw new CoreException(new Status(IStatus.ERROR, CCorePlugin.PLUGIN_ID, message, null));
}
ICProjectDescription projectDescription = CoreModel.getDefault().getProjectDescription(project);
return fetchConfigurationInfo(projectDescription.getActiveConfiguration());
}
protected abstract String fetchConfigurationInfo(ICConfigurationDescription configuration);
}

View file

@ -0,0 +1,20 @@
/*******************************************************************************
* Copyright (c) 2012 Anton Gorenkov and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Anton Gorenkov - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core;
import org.eclipse.cdt.core.settings.model.ICConfigurationDescription;
public class ConfigurationNameVariableResolver extends ConfigurationInfoVariableResolver {
@Override
protected String fetchConfigurationInfo(ICConfigurationDescription configuration) {
return configuration.getName();
}
}

View file

@ -7,7 +7,7 @@
* *
* Contributors: * Contributors:
* IBM Corporation - initial API and implementation * IBM Corporation - initial API and implementation
* QnX Software System * QNX Software Systems
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.corext.template.c; package org.eclipse.cdt.internal.corext.template.c;
@ -28,12 +28,10 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.PreferenceConstants;
/** /**
* A context for C/C++. * A context for C/C++.
*/ */
public class CContext extends TranslationUnitContext { public class CContext extends TranslationUnitContext {
/** /**
* Creates a C/C++ code template context. * Creates a C/C++ code template context.
* *
@ -43,8 +41,8 @@ public class CContext extends TranslationUnitContext {
* @param completionLength the length of the context * @param completionLength the length of the context
* @param translationUnit the translation unit represented by the document * @param translationUnit the translation unit represented by the document
*/ */
public CContext(TemplateContextType type, IDocument document, int completionOffset, int completionLength, public CContext(TemplateContextType type, IDocument document, int completionOffset,
ITranslationUnit translationUnit) { int completionLength, ITranslationUnit translationUnit) {
super(type, document, completionOffset, completionLength, translationUnit); super(type, document, completionOffset, completionLength, translationUnit);
} }
@ -61,9 +59,6 @@ public class CContext extends TranslationUnitContext {
super(type, document, completionPosition, translationUnit); super(type, document, completionPosition, translationUnit);
} }
/*
* @see DocumentTemplateContext#getStart()
*/
@Override @Override
public int getStart() { public int getStart() {
if (fIsManaged && getCompletionLength() > 0) if (fIsManaged && getCompletionLength() > 0)
@ -75,7 +70,7 @@ public class CContext extends TranslationUnitContext {
int start= getCompletionOffset(); int start= getCompletionOffset();
int end= getCompletionOffset() + getCompletionLength(); int end= getCompletionOffset() + getCompletionLength();
while (start != 0 && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) while (start != 0 && isUnicodeIdentifierPartOrPoundSign(document.getChar(start - 1)))
start--; start--;
while (start != end && Character.isWhitespace(document.getChar(start))) while (start != end && Character.isWhitespace(document.getChar(start)))
@ -85,7 +80,6 @@ public class CContext extends TranslationUnitContext {
start= getCompletionOffset(); start= getCompletionOffset();
return start; return start;
} catch (BadLocationException e) { } catch (BadLocationException e) {
return super.getStart(); return super.getStart();
} }
@ -106,15 +100,11 @@ public class CContext extends TranslationUnitContext {
end--; end--;
return end; return end;
} catch (BadLocationException e) { } catch (BadLocationException e) {
return super.getEnd(); return super.getEnd();
} }
} }
/*
* @see TemplateContext#evaluate(Template)
*/
@Override @Override
public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException { public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
if (!canEvaluate(template)) if (!canEvaluate(template))
@ -130,10 +120,14 @@ public class CContext extends TranslationUnitContext {
ICProject project= getCProject(); ICProject project= getCProject();
int indentationLevel = isReadOnly() ? 0 : getIndentationLevel(); int indentationLevel = isReadOnly() ? 0 : getIndentationLevel();
CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()), indentationLevel, useCodeFormatter, project); CFormatter formatter= new CFormatter(TextUtilities.getDefaultLineDelimiter(getDocument()),
indentationLevel, useCodeFormatter, project);
formatter.format(buffer, this); formatter.format(buffer, this);
return buffer; return buffer;
} }
private boolean isUnicodeIdentifierPartOrPoundSign(char c) {
return Character.isUnicodeIdentifierPart(c) || c == '#';
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 QNX Software Systems and others. * Copyright (c) 2004, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -70,6 +70,7 @@ import org.eclipse.cdt.internal.ui.preferences.CodeTemplatePreferencePage;
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider; import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage; import org.eclipse.cdt.internal.ui.wizards.NewElementWizardPage;
import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog; import org.eclipse.cdt.internal.ui.wizards.SourceFolderSelectionDialog;
import org.eclipse.cdt.internal.ui.wizards.classwizard.NewClassWizardUtil;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.ComboDialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.ComboDialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField; import org.eclipse.cdt.internal.ui.wizards.dialogfields.DialogField;
import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener; import org.eclipse.cdt.internal.ui.wizards.dialogfields.IDialogFieldListener;
@ -83,14 +84,14 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
private static final int MAX_FIELD_CHARS = 50; private static final int MAX_FIELD_CHARS = 50;
private static final String NO_TEMPLATE = ""; //$NON-NLS-1$ private static final String NO_TEMPLATE = ""; //$NON-NLS-1$
private IWorkspaceRoot fWorkspaceRoot; private final IWorkspaceRoot fWorkspaceRoot;
// field IDs // field IDs
private static final int SOURCE_FOLDER_ID = 1; private static final int SOURCE_FOLDER_ID = 1;
protected static final int NEW_FILE_ID = 2; protected static final int NEW_FILE_ID = 2;
private static final int ALL_FIELDS = SOURCE_FOLDER_ID | NEW_FILE_ID; private static final int ALL_FIELDS = SOURCE_FOLDER_ID | NEW_FILE_ID;
int fLastFocusedField = 0; int fLastFocusedField = 0;
private StringButtonDialogField fSourceFolderDialogField; private final StringButtonDialogField fSourceFolderDialogField;
private IStatus fSourceFolderStatus; private IStatus fSourceFolderStatus;
private IStatus fNewFileStatus; private IStatus fNewFileStatus;
private final IStatus STATUS_OK = new StatusInfo(); private final IStatus STATUS_OK = new StatusInfo();
@ -383,28 +384,20 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
* @param elem the C element used to compute the initial folder * @param elem the C element used to compute the initial folder
*/ */
protected void initSourceFolder(ICElement elem) { protected void initSourceFolder(ICElement elem) {
ICContainer folder = null; IPath folderPath = null;
if (elem != null) { if (elem != null) {
folder = CModelUtil.getSourceFolder(elem); ICContainer folder = NewClassWizardUtil.getSourceFolder(elem);
if (folder == null) { if (folder == null) {
ICProject cproject = elem.getCProject(); ICProject cproject = elem.getCProject();
if (cproject != null) { if (cproject != null) {
try { folder = NewClassWizardUtil.getFirstSourceRoot(cproject);
if (cproject.exists()) {
ISourceRoot[] roots = cproject.getSourceRoots();
if (roots != null && roots.length > 0)
folder = roots[0];
}
} catch (CModelException e) {
CUIPlugin.log(e);
}
if (folder == null) {
folder = cproject.findSourceRoot(cproject.getResource());
} }
} }
if (folder != null) {
folderPath = folder.getResource().getFullPath();
} }
} }
setSourceFolderFullPath(folder != null ? folder.getResource().getFullPath() : null, false); setSourceFolderFullPath(folderPath, false);
} }
/** /**
@ -448,7 +441,7 @@ public abstract class AbstractFileCreationWizardPage extends NewElementWizardPag
} }
protected final class StatusFocusListener implements FocusListener { protected final class StatusFocusListener implements FocusListener {
private int fieldID; private final int fieldID;
public StatusFocusListener(int fieldID) { public StatusFocusListener(int fieldID) {
this.fieldID = fieldID; this.fieldID = fieldID;

View file

@ -18,6 +18,7 @@ import java.util.TreeSet;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.ActionContributionItem;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
@ -27,6 +28,8 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Menu; import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem; import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchWindow;
@ -148,6 +151,27 @@ public class ChangeBuildConfigActionBase {
return new ChangeConfigAction(fProjects, sName, builder.toString(), accel + 1); return new ChangeConfigAction(fProjects, sName, builder.toString(), accel + 1);
} }
/**
* Class used to efficiently special case the scenario where there's only a single project in the
* workspace. See bug 375760
*/
private static class ImaginarySelection implements ISelection {
private IProject fProject;
ImaginarySelection(IProject project) {
fProject = project;
}
@Override
public boolean isEmpty() {
return fProject == null;
}
IProject getProject() {
return fProject;
}
}
/** /**
* selectionChanged() event handler. Fills the list of managed-built projects * selectionChanged() event handler. Fills the list of managed-built projects
* based on the selection. If some non-managed-built projects are selected, * based on the selection. If some non-managed-built projects are selected,
@ -247,6 +271,9 @@ public class ChangeBuildConfigActionBase {
} }
} }
else if (selection instanceof ImaginarySelection) {
fProjects.add(((ImaginarySelection)selection).getProject());
}
} }
@ -278,6 +305,52 @@ public class ChangeBuildConfigActionBase {
} }
} }
action.setEnabled(enable); action.setEnabled(enable);
// Bug 375760
//
// We shouldn't require that the projects view have focus. If the selection switched
// to something that doesn't provide us a project context, query any of the three projects/resources
// view to see if they have a selection. If so, try again using that selection. We give precedence to
// the CDT projects view, then to the project explorer, and finally to the resource navigator
//
// Also, if the view has no selection, see if the workspace has only one project. If so, we don't need
// to rely on the selection mechanism to tell us which project to operate on!
//
if (badObject || fProjects.isEmpty()) {
IWorkbenchPage page = CUIPlugin.getActivePage();
if (page != null) {
IViewReference viewRef = page.findViewReference("org.eclipse.cdt.ui.CView"); //$NON-NLS-1$
if (viewRef == null) {
viewRef = page.findViewReference("org.eclipse.ui.navigator.ProjectExplorer"); //$NON-NLS-1$
if (viewRef == null) {
viewRef = page.findViewReference("org.eclipse.ui.views.ResourceNavigator"); //$NON-NLS-1$
}
}
if (viewRef != null) {
IViewPart view = viewRef.getView(false);
if (view != null) {
ISelection cdtSelection = view.getSite().getSelectionProvider().getSelection();
if (cdtSelection != null) {
if (cdtSelection.isEmpty()) {
IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
if (projects != null && projects.length == 1) {
IProject project = projects[0];
if (CoreModel.getDefault().isNewStyleProject(project) && (getCfgs(project).length > 0)) {
onSelectionChanged(action, new ImaginarySelection(project));
}
}
}
else {
if (!cdtSelection.equals(selection)) {
onSelectionChanged(action, cdtSelection);
}
}
}
}
}
}
}
} }
private ICConfigurationDescription[] getCfgs(IProject prj) { private ICConfigurationDescription[] getCfgs(IProject prj) {

View file

@ -27,7 +27,8 @@ Require-Bundle: org.eclipse.core.resources;bundle-version="[3.2.0,4.0.0)",
org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)", org.eclipse.debug.core;bundle-version="[3.2.0,4.0.0)",
org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)", org.eclipse.cdt.core;bundle-version="[5.0.0,6.0.0)",
org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)", org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.core.filesystem;bundle-version="1.2.0" org.eclipse.core.filesystem;bundle-version="1.2.0",
org.eclipse.core.variables;bundle-version="3.2.0"
Bundle-ActivationPolicy: lazy Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: com.ibm.icu.text Import-Package: com.ibm.icu.text

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2011 QNX Software Systems and others. * Copyright (c) 2000, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -52,6 +52,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.IStatusHandler; import org.eclipse.debug.core.IStatusHandler;
@ -542,7 +543,11 @@ public class CDebugUtils {
* @since 6.0 * @since 6.0
*/ */
public static String getProgramName(ILaunchConfiguration configuration) throws CoreException { public static String getProgramName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
if (programName != null) {
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
}
return programName;
} }
/** /**

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2010 Freescale and others. * Copyright (c) 2008, 2012 Freescale and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -24,6 +24,7 @@ import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage; import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
/** /**
@ -159,6 +160,7 @@ public class ProgramRelativePathSourceContainer extends AbstractSourceContainer{
if (programName == null) { if (programName == null) {
return fProgramPath; // return empty path return fProgramPath; // return empty path
} }
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
// get executable file // get executable file
IFile exeFile = null; IFile exeFile = null;

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 QNX Software Systems and others. * Copyright (c) 2004, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -33,14 +33,15 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IProcess;
public class CDebugAdapter implements ICDIDebugger { public class CDebugAdapter implements ICDIDebugger {
final ICDebugger fDebugger; final ICDebugger fDebugger;
/** /**
* @param debugger * @param debugger
*/ */
@ -48,8 +49,7 @@ public class CDebugAdapter implements ICDIDebugger {
fDebugger = debugger; fDebugger = debugger;
} }
/* /* (non-Javadoc)
* (non-Javadoc)
* *
* @see org.eclipse.cdt.debug.core.ICDIDebugger#createDebuggerSession(org.eclipse.debug.core.ILaunch, * @see org.eclipse.cdt.debug.core.ICDIDebugger#createDebuggerSession(org.eclipse.debug.core.ILaunch,
* org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable, * org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable,
@ -93,12 +93,13 @@ public class CDebugAdapter implements ICDIDebugger {
String format = "{0} ({1})"; //$NON-NLS-1$ String format = "{0} ({1})"; //$NON-NLS-1$
String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis())); String timestamp = DateFormat.getInstance().format(new Date(System.currentTimeMillis()));
String message = InternalDebugCoreMessages.getString("CDebugAdapter.1"); //$NON-NLS-1$ String message = InternalDebugCoreMessages.getString("CDebugAdapter.1"); //$NON-NLS-1$
return MessageFormat.format(format, new String[]{message, timestamp}); return MessageFormat.format(format, message, timestamp);
} }
protected void abort(String message, Throwable exception, int code) throws CoreException { protected void abort(String message, Throwable exception, int code) throws CoreException {
MultiStatus status = new MultiStatus(CDebugCorePlugin.getUniqueIdentifier(), code, message, exception); MultiStatus status = new MultiStatus(CDebugCorePlugin.getUniqueIdentifier(), code, message, exception);
status.add(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), code, exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$ status.add(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), code,
exception == null ? "" : exception.getLocalizedMessage(), //$NON-NLS-1$
exception)); exception));
throw new CoreException(status); throw new CoreException(status);
} }
@ -123,7 +124,11 @@ public class CDebugAdapter implements ICDIDebugger {
} }
public static String getProgramName(ILaunchConfiguration configuration) throws CoreException { public static String getProgramName(ILaunchConfiguration configuration) throws CoreException {
return configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); String programName = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String) null);
if (programName != null) {
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
}
return programName;
} }
public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException { public static IPath getProgramPath(ILaunchConfiguration configuration) throws CoreException {
@ -133,5 +138,4 @@ public class CDebugAdapter implements ICDIDebugger {
} }
return new Path(path); return new Path(path);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010 Freescale Semiconductor and others. * Copyright (c) 2010, 2012 Freescale Semiconductor and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -32,6 +32,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
@ -275,6 +276,7 @@ public class CSourceFinder implements ISourceFinder, ILaunchConfigurationListene
String programNameConfig = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$ String programNameConfig = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
IProject project = resource.getProject(); IProject project = resource.getProject();
if (project != null && project.getName().equals(projectNameConfig)) { if (project != null && project.getName().equals(projectNameConfig)) {
programNameConfig = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programNameConfig);
Path path = new Path(programNameConfig); Path path = new Path(programNameConfig);
if (!path.isEmpty()) { if (!path.isEmpty()) {
IFile file = project.getFile(path); IFile file = project.getFile(path);

View file

@ -38,7 +38,8 @@ ShowDebuggerConsoleAction.tooltip=Show Debugger Console On Target Selection
AddBreakpoint.label=Toggle &Breakpoint\tDouble Click AddBreakpoint.label=Toggle &Breakpoint\tDouble Click
AddBreakpointInteractive.label=&Add Breakpoint...\tCtrl+Double Click AddBreakpointInteractive.label=&Add Breakpoint...\tCtrl+Double Click
EnableBreakpoint.label=&Toggle Breakpoint Enabled\tShift+Double Click EnableBreakpoint.label=&Toggle Breakpoint Enabled\tShift+Double Click
BreakpointProperties.label=Breakpoint P&roperties...\tCtrl+Double Click BreakpointProperties.label=Breakpoint P&roperties
RulerBreakpointProperties.label=Breakpoint P&roperties...\tCtrl+Double Click
BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties BreakpointPropertiesCommand.name=C/C++ Breakpoint Properties
BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint BreakpointPropertiesCommand.description=View and edit properties for a given C/C++ breakpoint
ManageFunctionBreakpointAction.label=Toggle Breakpoint ManageFunctionBreakpointAction.label=Toggle Breakpoint

View file

@ -272,6 +272,17 @@
helpContextId="move_to_line_action_context" helpContextId="move_to_line_action_context"
label="%GlobalMoveToLineAction.label" label="%GlobalMoveToLineAction.label"
menubarPath="org.eclipse.ui.run/stepGroup"/> menubarPath="org.eclipse.ui.run/stepGroup"/>
<action
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
helpContextId="toggle_instruction_step_mode_action_context"
icon="icons/elcl16/instr_step.gif"
id="org.eclipse.cdt.debug.ui.actions.ToggleInstructionStepMode"
label="%ToggleInstructionStepModeAction.label"
menubarPath="org.eclipse.ui.run/stepGroup"
state="false"
style="toggle"
toolbarPath="org.eclipse.debug.ui.main.toolbar/renderGroup">
</action>
</actionSet> </actionSet>
</extension> </extension>
<extension <extension
@ -398,7 +409,6 @@
style="toggle" style="toggle"
id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate" id="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
enablesFor="1"
icon="icons/elcl16/instr_step.gif" icon="icons/elcl16/instr_step.gif"
helpContextId="toggle_instruction_step_mode_action_context" helpContextId="toggle_instruction_step_mode_action_context"
label="%ToggleInstructionStepModeAction.label" label="%ToggleInstructionStepModeAction.label"
@ -416,7 +426,7 @@
targetID="#CEditorRulerContext" targetID="#CEditorRulerContext"
id="org.eclipse.cdt.debug.ui.CEditorRulerActions"> id="org.eclipse.cdt.debug.ui.CEditorRulerActions">
<action <action
label="%BreakpointProperties.label" label="%RulerBreakpointProperties.label"
helpContextId="breakpoint_properties_action_context" helpContextId="breakpoint_properties_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate"
menubarPath="debug" menubarPath="debug"
@ -494,7 +504,7 @@
targetID="#ASMEditorRulerContext" targetID="#ASMEditorRulerContext"
id="org.eclipse.cdt.debug.ui.AsmEditorRulerActions"> id="org.eclipse.cdt.debug.ui.AsmEditorRulerActions">
<action <action
label="%BreakpointProperties.label" label="%RulerBreakpointProperties.label"
helpContextId="breakpoint_properties_action_context" helpContextId="breakpoint_properties_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.breakpoints.CBreakpointPropertiesRulerActionDelegate"
menubarPath="debug" menubarPath="debug"
@ -897,7 +907,6 @@
class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.ToggleInstructionStepModeActionDelegate"
disabledIcon="icons/dlcl16/instr_step.gif" disabledIcon="icons/dlcl16/instr_step.gif"
icon="icons/elcl16/instr_step.gif" icon="icons/elcl16/instr_step.gif"
enablesFor="1"
label="%ToggleInstructionStepModeAction.label" label="%ToggleInstructionStepModeAction.label"
helpContextId="toggle_instruction_step_mode_action_context" helpContextId="toggle_instruction_step_mode_action_context"
tooltip="%ToggleInstructionStepModeAction.tooltip"> tooltip="%ToggleInstructionStepModeAction.tooltip">
@ -1758,7 +1767,15 @@
id="org.eclipse.cdt.debug.menu.command.breakpointProperties" id="org.eclipse.cdt.debug.menu.command.breakpointProperties"
label="%BreakpointProperties.label" label="%BreakpointProperties.label"
tooltip="%BreakpointProperties.label"> tooltip="%BreakpointProperties.label">
<visibleWhen checkEnabled="true"> <visibleWhen>
<with variable="selection">
<count value="1"/>
<iterate>
<or>
<adapt type="org.eclipse.cdt.debug.core.model.ICBreakpoint"/>
</or>
</iterate>
</with>
</visibleWhen> </visibleWhen>
</command> </command>
</menuContribution> </menuContribution>
@ -1828,9 +1845,7 @@
<or> <or>
<test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/> <test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/>
<test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/> <test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/>
<test <test property="org.eclipse.cdt.debug.ui.isDisassemblyEditorSupportsCBreakpoint" />
property="org.eclipse.cdt.debug.ui.isDisassemblyEditorSupportsCBreakpoint">
</test>
<with variable="selection"> <with variable="selection">
<count value="1"/> <count value="1"/>
<test property="org.eclipse.cdt.debug.ui.isCDeclarationSupportsCBreakpoint"/> <test property="org.eclipse.cdt.debug.ui.isCDeclarationSupportsCBreakpoint"/>
@ -1850,6 +1865,7 @@
<or> <or>
<test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/> <test property="org.eclipse.cdt.debug.ui.isCEditorSupportsCBreakpoint"/>
<test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/> <test property="org.eclipse.cdt.debug.ui.isAsmEditorSupportsCBreakpoint"/>
<test property="org.eclipse.cdt.debug.ui.isDisassemblyEditorSupportsCBreakpoint" />
<with variable="selection"> <with variable="selection">
<count value="1"/> <count value="1"/>
<test property="org.eclipse.cdt.debug.ui.isCDeclarationSupportsCBreakpoint"/> <test property="org.eclipse.cdt.debug.ui.isCDeclarationSupportsCBreakpoint"/>

View file

@ -23,25 +23,33 @@ import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IDisconnect; import org.eclipse.debug.core.model.IDisconnect;
import org.eclipse.debug.core.model.ITerminate; import org.eclipse.debug.core.model.ITerminate;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.contexts.DebugContextEvent;
import org.eclipse.debug.ui.contexts.IDebugContextListener;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Event;
import org.eclipse.ui.IViewActionDelegate; import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart; import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PartInitException; import org.eclipse.ui.PartInitException;
import org.eclipse.ui.actions.ActionDelegate; import org.eclipse.ui.actions.ActionDelegate;
/** /**
* Turns instruction step mode on/off for selected target. * Turns instruction step mode on/off for selected target.
*/ */
public class ToggleInstructionStepModeActionDelegate extends ActionDelegate implements IViewActionDelegate, IPropertyChangeListener { public class ToggleInstructionStepModeActionDelegate extends ActionDelegate
implements IViewActionDelegate, IWorkbenchWindowActionDelegate, IPropertyChangeListener, IDebugContextListener
{
private ISteppingModeTarget fTarget = null; private ISteppingModeTarget fTarget = null;
private IAction fAction = null; private IAction fAction = null;
private IViewPart fView; private IWorkbenchWindow fWindow = null;
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent) * @see org.eclipse.core.runtime.Preferences.IPropertyChangeListener#propertyChange(org.eclipse.core.runtime.Preferences.PropertyChangeEvent)
@ -63,7 +71,14 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
*/ */
@Override @Override
public void init( IViewPart view ) { public void init( IViewPart view ) {
fView = view; fWindow = view.getSite().getWorkbenchWindow();
DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this);
}
@Override
public void init(IWorkbenchWindow window) {
fWindow = window;
DebugUITools.getDebugContextManager().getContextService(fWindow).addDebugContextListener(this);
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -71,6 +86,7 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
*/ */
@Override @Override
public void dispose() { public void dispose() {
DebugUITools.getDebugContextManager().getContextService(fWindow).removeDebugContextListener(this);
ISteppingModeTarget target = getTarget(); ISteppingModeTarget target = getTarget();
if ( target != null && target instanceof ITargetProperties ) { if ( target != null && target instanceof ITargetProperties ) {
((ITargetProperties)target).removePropertyChangeListener( this ); ((ITargetProperties)target).removePropertyChangeListener( this );
@ -100,7 +116,10 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
target.enableInstructionStepping( enabled ); target.enableInstructionStepping( enabled );
if ( enabled && target instanceof ICDebugTarget ) { if ( enabled && target instanceof ICDebugTarget ) {
try { try {
getView().getSite().getPage().showView( ICDebugUIConstants.ID_DSF_DISASSEMBLY_VIEW ); IWorkbenchPage page = fWindow.getActivePage();
if (page != null) {
page.showView( ICDebugUIConstants.ID_DSF_DISASSEMBLY_VIEW );
}
} }
catch( PartInitException e ) { catch( PartInitException e ) {
CDebugUIPlugin.log( e.getStatus() ); CDebugUIPlugin.log( e.getStatus() );
@ -117,11 +136,11 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
run( action ); run( action );
} }
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
@Override @Override
public void selectionChanged( IAction action, ISelection selection ) { public void debugContextChanged(DebugContextEvent event) {
if (fAction == null) return;
ISelection selection = event.getContext();
ISteppingModeTarget newTarget = null; ISteppingModeTarget newTarget = null;
if ( selection instanceof IStructuredSelection ) { if ( selection instanceof IStructuredSelection ) {
newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() ); newTarget = getTargetFromSelection( ((IStructuredSelection)selection).getFirstElement() );
@ -132,16 +151,16 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
((ITargetProperties)oldTarget).removePropertyChangeListener( this ); ((ITargetProperties)oldTarget).removePropertyChangeListener( this );
} }
setTarget( null ); setTarget( null );
action.setChecked( false ); fAction.setChecked( false );
} }
if ( newTarget != null && !isTerminated( newTarget ) ) { if ( newTarget != null && !isTerminated( newTarget ) ) {
setTarget( newTarget ); setTarget( newTarget );
if ( newTarget instanceof ITargetProperties ) { if ( newTarget instanceof ITargetProperties ) {
((ITargetProperties)newTarget).addPropertyChangeListener( this ); ((ITargetProperties)newTarget).addPropertyChangeListener( this );
} }
action.setChecked( newTarget.isInstructionSteppingEnabled() ); fAction.setChecked( newTarget.isInstructionSteppingEnabled() );
} }
action.setEnabled( fAction.setEnabled(
newTarget != null newTarget != null
&& newTarget.supportsInstructionStepping() && newTarget.supportsInstructionStepping()
&& !isTerminated( newTarget ) ); && !isTerminated( newTarget ) );
@ -184,7 +203,6 @@ public class ToggleInstructionStepModeActionDelegate extends ActionDelegate impl
return target; return target;
} }
private IViewPart getView() {
return fView;
}
} }

View file

@ -1,5 +1,5 @@
/***************************************************************** /*****************************************************************
* Copyright (c) 2011 Texas Instruments and others * Copyright (c) 2011, 2012 Texas Instruments and others
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* Patrick Chuong (Texas Instruments) - * Patrick Chuong (Texas Instruments) -
* Update CDT ToggleBreakpointTargetFactory enablement (340177) * Update CDT ToggleBreakpointTargetFactory enablement (340177)
* Patrick Chuong (Texas Instruments) - Bug 375871
*****************************************************************/ *****************************************************************/
package org.eclipse.cdt.debug.internal.ui.breakpoints; package org.eclipse.cdt.debug.internal.ui.breakpoints;
@ -20,6 +21,7 @@ import org.eclipse.cdt.core.model.IFunctionDeclaration;
import org.eclipse.cdt.core.model.IMethodDeclaration; import org.eclipse.cdt.core.model.IMethodDeclaration;
import org.eclipse.cdt.core.model.IVariableDeclaration; import org.eclipse.cdt.core.model.IVariableDeclaration;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.internal.ui.disassembly.editor.DisassemblyEditor;
import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor; import org.eclipse.cdt.internal.ui.editor.asm.AsmTextEditor;
import org.eclipse.core.expressions.PropertyTester; import org.eclipse.core.expressions.PropertyTester;
@ -87,12 +89,13 @@ public class ToggleCBreakpointTester extends PropertyTester {
return true; // can't figure the associated project, enable it by default. return true; // can't figure the associated project, enable it by default.
} }
} }
} else if ("isDisassemblyEditorSupportsCBreakpoint".equals(property) && (receiver instanceof DisassemblyEditor)) { //$NON-NLS-1$
if (!CDebugUtils.isCustomToggleBreakpointFactory())
return true;
// No additional check is required, the check for the receiver is enough.
// test for IVariableDeclaration, IFunctionDeclaration, IMethodDeclaration // test for IVariableDeclaration, IFunctionDeclaration, IMethodDeclaration
} else if ("isCDeclarationSupportsCBreakpoint".equals(property) && (receiver instanceof List<?>)) { //$NON-NLS-1$ } else if ("isCDeclarationSupportsCBreakpoint".equals(property) && (receiver instanceof List<?>)) { //$NON-NLS-1$
if (!CDebugUtils.isCustomToggleBreakpointFactory())
return true;
List<?> list = (List<?>) receiver; List<?> list = (List<?>) receiver;
if (list.size() == 1) { if (list.size() == 1) {
Object element = list.get(0); Object element = list.get(0);
@ -101,6 +104,9 @@ public class ToggleCBreakpointTester extends PropertyTester {
element instanceof IFunctionDeclaration || element instanceof IFunctionDeclaration ||
element instanceof IMethodDeclaration)) { element instanceof IMethodDeclaration)) {
if (!CDebugUtils.isCustomToggleBreakpointFactory())
return true;
IDeclaration cElement = (IDeclaration) element; IDeclaration cElement = (IDeclaration) element;
// Handles the case for external file, check to see whether the file exist. // Handles the case for external file, check to see whether the file exist.

View file

@ -1 +1,3 @@
/cdtconvert.txt .metadata
cdtconvert.txt
reference

View file

@ -1 +1,2 @@
/extension-points api
extension-points

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -142,7 +142,8 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
protected void handleVariablesButtonSelected(Text textField) { protected void handleVariablesButtonSelected(Text textField) {
String variable = getVariable(); String variable = getVariable();
if (variable != null) { if (variable != null) {
textField.append(variable); // We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
textField.insert(variable);
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2008, 2009 QNX Software Systems and others. * Copyright (c) 2008, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -26,6 +26,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
@ -54,6 +55,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
try { try {
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
if (programName != null) {
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
}
} catch (CoreException e) { } catch (CoreException e) {
} }
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$ if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$

View file

@ -12,6 +12,7 @@
* IBM Corporation * IBM Corporation
* Marc Khouzam (Ericsson) - Support setting the path in which the core file * Marc Khouzam (Ericsson) - Support setting the path in which the core file
* dialog should start (Bug 362039) * dialog should start (Bug 362039)
* Anton Gorenkov
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.dsf.gdb.internal.ui.launching; package org.eclipse.cdt.dsf.gdb.internal.ui.launching;
@ -139,7 +140,6 @@ public class CMainTab extends CAbstractMainTab {
protected void createExeFileGroup(Composite parent, int colSpan) { protected void createExeFileGroup(Composite parent, int colSpan) {
Composite mainComp = new Composite(parent, SWT.NONE); Composite mainComp = new Composite(parent, SWT.NONE);
GridLayout mainLayout = new GridLayout(); GridLayout mainLayout = new GridLayout();
mainLayout.numColumns = 3;
mainLayout.marginHeight = 0; mainLayout.marginHeight = 0;
mainLayout.marginWidth = 0; mainLayout.marginWidth = 0;
mainComp.setLayout(mainLayout); mainComp.setLayout(mainLayout);
@ -149,7 +149,6 @@ public class CMainTab extends CAbstractMainTab {
fProgLabel = new Label(mainComp, SWT.NONE); fProgLabel = new Label(mainComp, SWT.NONE);
fProgLabel.setText(LaunchMessages.getString("CMainTab.C/C++_Application")); //$NON-NLS-1$ fProgLabel.setText(LaunchMessages.getString("CMainTab.C/C++_Application")); //$NON-NLS-1$
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 3;
fProgLabel.setLayoutData(gd); fProgLabel.setLayoutData(gd);
fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
@ -161,7 +160,17 @@ public class CMainTab extends CAbstractMainTab {
} }
}); });
fSearchButton = createPushButton(mainComp, LaunchMessages.getString("CMainTab.Search..."), null); //$NON-NLS-1$ Composite buttonComp = new Composite(mainComp, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
buttonComp.setLayout(layout);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
buttonComp.setLayoutData(gd);
buttonComp.setFont(parent.getFont());
createVariablesButton(buttonComp, LaunchMessages.getString("CMainTab.Variables"), fProgText); //$NON-NLS-1$
fSearchButton = createPushButton(buttonComp, LaunchMessages.getString("CMainTab.Search..."), null); //$NON-NLS-1$
fSearchButton.addSelectionListener(new SelectionAdapter() { fSearchButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -171,7 +180,7 @@ public class CMainTab extends CAbstractMainTab {
}); });
Button browseForBinaryButton; Button browseForBinaryButton;
browseForBinaryButton = createPushButton(mainComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$ browseForBinaryButton = createPushButton(buttonComp, LaunchMessages.getString("Launch.common.Browse_2"), null); //$NON-NLS-1$
browseForBinaryButton.addSelectionListener(new SelectionAdapter() { browseForBinaryButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -444,6 +453,11 @@ public class CMainTab extends CAbstractMainTab {
if (!fDontCheckProgram) { if (!fDontCheckProgram) {
String programName = fProgText.getText().trim(); String programName = fProgText.getText().trim();
try {
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
} catch (CoreException e) {
// Silently ignore substitution failure (for consistency with "Arguments" and "Work directory" fields)
}
if (programName.length() == 0) { if (programName.length() == 0) {
setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$ setErrorMessage(LaunchMessages.getString("CMainTab.Program_not_specified")); //$NON-NLS-1$
return false; return false;

View file

@ -239,7 +239,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab {
protected void handleWorkingDirVariablesButtonSelected() { protected void handleWorkingDirVariablesButtonSelected() {
String variableText = getVariable(); String variableText = getVariable();
if (variableText != null) { if (variableText != null) {
fWorkingDirText.append(variableText); fWorkingDirText.insert(variableText);
} }
} }

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2008, 2010 QNX Software Systems and others. # Copyright (c) 2008, 2012 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -94,6 +94,7 @@ CMainTab.CoreFile_type=Core file
CMainTab.TraceFile_type=Trace file CMainTab.TraceFile_type=Trace file
CMainTab.CoreFile_path=Core file (leave blank or select root directory to trigger prompt): CMainTab.CoreFile_path=Core file (leave blank or select root directory to trigger prompt):
CMainTab.TraceFile_path=Trace data file (leave blank or select root directory to trigger prompt): CMainTab.TraceFile_path=Trace data file (leave blank or select root directory to trigger prompt):
CMainTab.Variables=&Variables...
CMainTab.Search...=Searc&h Project... CMainTab.Search...=Searc&h Project...
CMainTab.Choose_program_to_run=Choose a &program to run: CMainTab.Choose_program_to_run=Choose a &program to run:
CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}: CMainTab.Choose_program_to_run_from_NAME=Choose a program to run from {0}:

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Ericsson and others. * Copyright (c) 2010, 2012 Ericsson and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -105,6 +105,7 @@ public class LaunchUtils {
abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$ abort(LaunchMessages.getString("AbstractCLaunchDelegate.Program_file_not_specified"), null, //$NON-NLS-1$
ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT); ICDTLaunchConfigurationConstants.ERR_NOT_A_C_PROJECT);
} }
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
IPath programPath = new Path(programName); IPath programPath = new Path(programName);
if (programPath.isEmpty()) { if (programPath.isEmpty()) {

View file

@ -20,7 +20,7 @@ import org.junit.runners.Suite;
* want to run. When creating a new test class, it should be * want to run. When creating a new test class, it should be
* added to the list below. * added to the list below.
* *
* This suite is for tests to be run with GDB 7.4 * This suite is for tests to be run with GDB 7.4.
*/ */
@RunWith(Suite.class) @RunWith(Suite.class)

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 - 2010 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,11 +8,11 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946 * Andy Jin - Hardware debugging UI improvements, bug 229946
* Anna Dushistova(MontaVista) - bug 241279 * Anna Dushistova (MontaVista) - bug 241279
* - Hardware Debugging: Host name or ip address not saving in * - Hardware Debugging: Host name or ip address not saving in
* the debug configuration * the debug configuration
* Andy Jin (QNX) - Added DSF debugging, bug 248593 * Andy Jin (QNX) - Added DSF debugging, bug 248593
* Bruce Griffith,Sage Electronic Engineering, LLC - bug 305943 * Bruce Griffith, Sage Electronic Engineering, LLC - bug 305943
* - API generalization to become transport-independent (e.g. to * - API generalization to become transport-independent (e.g. to
* allow connections via serial ports and pipes). * allow connections via serial ports and pipes).
*******************************************************************************/ *******************************************************************************/
@ -141,7 +141,7 @@ public class GDBJtagDSFDebuggerTab extends AbstractLaunchConfigurationTab {
private void variablesButtonSelected(Text text) { private void variablesButtonSelected(Text text) {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell()); StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
if (dialog.open() == StringVariableSelectionDialog.OK) { if (dialog.open() == StringVariableSelectionDialog.OK) {
text.append(dialog.getVariableExpression()); text.insert(dialog.getVariableExpression());
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2007 - 2010 QNX Software Systems and others. * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,7 +8,7 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Andy Jin - Hardware debugging UI improvements, bug 229946 * Andy Jin - Hardware debugging UI improvements, bug 229946
* Anna Dushistova(MontaVista) - bug 241279 * Anna Dushistova (MontaVista) - bug 241279
* - Hardware Debugging: Host name or ip address not saving in * - Hardware Debugging: Host name or ip address not saving in
* the debug configuration * the debug configuration
* Andy Jin (QNX) - Added DSF debugging, bug 248593 * Andy Jin (QNX) - Added DSF debugging, bug 248593
@ -139,7 +139,7 @@ public class GDBJtagDebuggerTab extends AbstractLaunchConfigurationTab {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog( StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(
getShell()); getShell());
if (dialog.open() == StringVariableSelectionDialog.OK) { if (dialog.open() == StringVariableSelectionDialog.OK) {
text.append(dialog.getVariableExpression()); text.insert(dialog.getVariableExpression());
} }
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2011 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -60,6 +60,7 @@ import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.Job; import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
@ -645,6 +646,7 @@ abstract public class AbstractCLaunchDelegate extends LaunchConfigurationDelegat
if (configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, false)) { if (configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, false)) {
String programPath = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STR); String programPath = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, EMPTY_STR);
programPath = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programPath);
ICConfigurationDescription buildConfig = LaunchUtils.getBuildConfigByProgramPath(buildProject, programPath); ICConfigurationDescription buildConfig = LaunchUtils.getBuildConfigByProgramPath(buildProject, programPath);
if (buildConfig != null) if (buildConfig != null)
buildConfigID = buildConfig.getId(); buildConfigID = buildConfig.getId();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2010, 2011 Nokia and others. * Copyright (c) 2010, 2012 Nokia and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -43,6 +43,7 @@ import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.SubMonitor; import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
@ -253,6 +254,7 @@ public abstract class AbstractCLaunchDelegate2 extends LaunchConfigurationDelega
// If automatic configuration detection then discover the build config corresponding to the executable // If automatic configuration detection then discover the build config corresponding to the executable
if (configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, false)) { if (configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_BUILD_CONFIG_AUTO, false)) {
String programPath = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$ String programPath = configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, ""); //$NON-NLS-1$
programPath = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programPath);
ICConfigurationDescription buildConfig = LaunchUtils.getBuildConfigByProgramPath(project, programPath); ICConfigurationDescription buildConfig = LaunchUtils.getBuildConfigByProgramPath(project, programPath);
if (buildConfig != null) if (buildConfig != null)
buildConfigID = buildConfig.getId(); buildConfigID = buildConfig.getId();

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2009 QNX Software Systems and others. * Copyright (c) 2004, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -75,6 +75,7 @@ public class LaunchMessages extends NLS {
public static String CMainTab_ProjectColon; public static String CMainTab_ProjectColon;
public static String CMainTab_C_Application; public static String CMainTab_C_Application;
public static String CMainTab_CoreFile_path; public static String CMainTab_CoreFile_path;
public static String CMainTab_Variables;
public static String CMainTab_Search; public static String CMainTab_Search;
public static String CMainTab_Choose_program_to_run; public static String CMainTab_Choose_program_to_run;
public static String CMainTab_Choose_program_to_run_from_NAME; public static String CMainTab_Choose_program_to_run_from_NAME;

View file

@ -1,5 +1,5 @@
############################################################################### ###############################################################################
# Copyright (c) 2002, 2010 QNX Software Systems and others. # Copyright (c) 2002, 2012 QNX Software Systems and others.
# All rights reserved. This program and the accompanying materials # All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0 # are made available under the terms of the Eclipse Public License v1.0
# which accompanies this distribution, and is available at # which accompanies this distribution, and is available at
@ -81,6 +81,7 @@ CMainTab_Main=Main
CMainTab_ProjectColon=&Project: CMainTab_ProjectColon=&Project:
CMainTab_C_Application=C/C++ Application: CMainTab_C_Application=C/C++ Application:
CMainTab_CoreFile_path=Core file (leave blank to trigger prompt): CMainTab_CoreFile_path=Core file (leave blank to trigger prompt):
CMainTab_Variables=&Variables...
CMainTab_Search=Searc&h Project... CMainTab_Search=Searc&h Project...
CMainTab_Choose_program_to_run=Choose a &program to run: CMainTab_Choose_program_to_run=Choose a &program to run:
CMainTab_Choose_program_to_run_from_NAME=Choose a program to run from {0}: CMainTab_Choose_program_to_run_from_NAME=Choose a program to run from {0}:

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2000, 2009 IBM Corporation and others. * Copyright (c) 2000, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -26,7 +26,6 @@ import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.VariablesPlugin; import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleEvent;
@ -83,8 +82,6 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab {
handleWorkingDirBrowseButtonSelected(); handleWorkingDirBrowseButtonSelected();
} else if (source == fUseDefaultWorkingDirButton) { } else if (source == fUseDefaultWorkingDirButton) {
handleUseDefaultWorkingDirButtonSelected(); handleUseDefaultWorkingDirButtonSelected();
} else if (source == fVariablesButton) {
handleWorkingDirVariablesButtonSelected();
} }
} }
} }
@ -148,8 +145,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab {
fFileSystemButton = createPushButton(buttonComp, LaunchMessages.WorkingDirectoryBlock_1, null); fFileSystemButton = createPushButton(buttonComp, LaunchMessages.WorkingDirectoryBlock_1, null);
fFileSystemButton.addSelectionListener(fListener); fFileSystemButton.addSelectionListener(fListener);
fVariablesButton = createPushButton(buttonComp, LaunchMessages.WorkingDirectoryBlock_17, null); fVariablesButton = createVariablesButton(buttonComp, LaunchMessages.WorkingDirectoryBlock_17, null);
fVariablesButton.addSelectionListener(fListener);
} }
/* /*
@ -234,19 +230,6 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab {
fFileSystemButton.setEnabled(!def); fFileSystemButton.setEnabled(!def);
} }
protected void handleWorkingDirVariablesButtonSelected() {
String variableText = getVariable();
if (variableText != null) {
fWorkingDirText.append(variableText);
}
}
private String getVariable() {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
dialog.open();
return dialog.getVariableExpression();
}
/** /**
* Sets the default working directory * Sets the default working directory
*/ */

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2009 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -20,15 +20,12 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationDialog;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT; import org.eclipse.swt.SWT;
import org.eclipse.swt.accessibility.AccessibleAdapter; import org.eclipse.swt.accessibility.AccessibleAdapter;
import org.eclipse.swt.accessibility.AccessibleEvent; import org.eclipse.swt.accessibility.AccessibleEvent;
import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridData;
@ -120,43 +117,12 @@ public class CArgumentsTab extends CLaunchConfigurationTab {
updateLaunchConfigurationDialog(); updateLaunchConfigurationDialog();
} }
}); });
fArgumentVariablesButton= createPushButton(group, LaunchMessages.CArgumentsTab_Variables, null); fArgumentVariablesButton= createVariablesButton(group, LaunchMessages.CArgumentsTab_Variables, fPrgmArgumentsText);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END); gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
fArgumentVariablesButton.setLayoutData(gd); fArgumentVariablesButton.setLayoutData(gd);
fArgumentVariablesButton.addSelectionListener(new SelectionAdapter() {
/* (non-Javadoc)
* @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
*/
@Override
public void widgetSelected(SelectionEvent arg0) {
handleVariablesButtonSelected(fPrgmArgumentsText);
}
});
addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons addControlAccessibleListener(fArgumentVariablesButton, fArgumentVariablesButton.getText()); // need to strip the mnemonic from buttons
} }
/**
* A variable entry button has been pressed for the given text
* field. Prompt the user for a variable and enter the result
* in the given field.
*/
protected void handleVariablesButtonSelected(Text textField) {
String variable = getVariable();
if (variable != null) {
textField.append(variable);
}
}
/**
* Prompts the user to choose and configure a variable and returns
* the resulting string, suitable to be used as an attribute.
*/
private String getVariable() {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
dialog.open();
return dialog.getVariableExpression();
}
public void addControlAccessibleListener(Control control, String controlName) { public void addControlAccessibleListener(Control control, String controlName) {
//strip mnemonic (&) //strip mnemonic (&)
String[] strs = controlName.split("&"); //$NON-NLS-1$ String[] strs = controlName.split("&"); //$NON-NLS-1$

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2009 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -35,6 +35,7 @@ import org.eclipse.cdt.launch.internal.ui.LaunchUIPlugin;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.jface.dialogs.Dialog; import org.eclipse.jface.dialogs.Dialog;
@ -375,6 +376,9 @@ public class CDebuggerTab extends AbstractCDebuggerTab {
try { try {
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
if (programName != null) {
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
}
} catch (CoreException e) { } catch (CoreException e) {
} }
if (programName != null) { if (programName != null) {

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2009 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -8,6 +8,7 @@
* Contributors: * Contributors:
* QNX Software Systems - Initial API and implementation * QNX Software Systems - Initial API and implementation
* Ken Ryall (Nokia) - bug 178731 * Ken Ryall (Nokia) - bug 178731
* Anton Gorenkov
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.launch.ui; package org.eclipse.cdt.launch.ui;
@ -26,11 +27,18 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.debug.ui.StringVariableSelectionDialog;
import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IFileEditorInput;
@ -54,6 +62,9 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
try { try {
projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null); projectName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, (String)null);
programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null); programName = config.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, (String)null);
if (programName != null) {
programName = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(programName);
}
} catch (CoreException e) { } catch (CoreException e) {
} }
if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$ if (projectName != null && !projectName.equals("")) { //$NON-NLS-1$
@ -160,4 +171,44 @@ public abstract class CLaunchConfigurationTab extends AbstractLaunchConfiguratio
return platform; return platform;
} }
} }
/**
* Creates a button that allows user to insert build variables.
*
* @since 7.0
*/
protected Button createVariablesButton(Composite parent, String label, final Text textField) {
Button variablesButton = createPushButton(parent, label, null);
variablesButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent arg0) {
handleVariablesButtonSelected(textField);
}
});
return variablesButton;
}
/**
* A variable entry button has been pressed for the given text
* field. Prompt the user for a variable and enter the result
* in the given field.
*/
private void handleVariablesButtonSelected(Text textField) {
String variable = getVariable();
if (variable != null) {
// We should use insert() but not append() to be consistent with the Platform behavior (e.g. Common tab)
textField.insert(variable);
}
}
/**
* Prompts the user to choose and configure a variable and returns
* the resulting string, suitable to be used as an attribute.
*/
private String getVariable() {
StringVariableSelectionDialog dialog = new StringVariableSelectionDialog(getShell());
dialog.open();
return dialog.getVariableExpression();
}
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2010 QNX Software Systems and others. * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -10,6 +10,7 @@
* Ken Ryall (Nokia) - bug 178731 * Ken Ryall (Nokia) - bug 178731
* IBM Corporation * IBM Corporation
* Sergey Prigogin (Google) * Sergey Prigogin (Google)
* Anton Gorenkov
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.launch.ui; package org.eclipse.cdt.launch.ui;
@ -31,6 +32,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
import org.eclipse.core.variables.VariablesPlugin;
import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
@ -343,7 +345,6 @@ public class CMainTab extends CAbstractMainTab {
protected void createExeFileGroup(Composite parent, int colSpan) { protected void createExeFileGroup(Composite parent, int colSpan) {
Composite mainComp = new Composite(parent, SWT.NONE); Composite mainComp = new Composite(parent, SWT.NONE);
GridLayout mainLayout = new GridLayout(); GridLayout mainLayout = new GridLayout();
mainLayout.numColumns = 3;
mainLayout.marginHeight = 0; mainLayout.marginHeight = 0;
mainLayout.marginWidth = 0; mainLayout.marginWidth = 0;
mainComp.setLayout(mainLayout); mainComp.setLayout(mainLayout);
@ -353,7 +354,6 @@ public class CMainTab extends CAbstractMainTab {
fProgLabel = new Label(mainComp, SWT.NONE); fProgLabel = new Label(mainComp, SWT.NONE);
fProgLabel.setText(LaunchMessages.CMainTab_C_Application); fProgLabel.setText(LaunchMessages.CMainTab_C_Application);
gd = new GridData(); gd = new GridData();
gd.horizontalSpan = 3;
fProgLabel.setLayoutData(gd); fProgLabel.setLayoutData(gd);
fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); fProgText = new Text(mainComp, SWT.SINGLE | SWT.BORDER);
gd = new GridData(GridData.FILL_HORIZONTAL); gd = new GridData(GridData.FILL_HORIZONTAL);
@ -365,7 +365,17 @@ public class CMainTab extends CAbstractMainTab {
} }
}); });
fSearchButton = createPushButton(mainComp, LaunchMessages.CMainTab_Search, null); Composite buttonComp = new Composite(mainComp, SWT.NONE);
GridLayout layout = new GridLayout(3, false);
layout.marginHeight = 0;
layout.marginWidth = 0;
buttonComp.setLayout(layout);
gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
buttonComp.setLayoutData(gd);
buttonComp.setFont(parent.getFont());
createVariablesButton(buttonComp, LaunchMessages.CMainTab_Variables, fProgText);
fSearchButton = createPushButton(buttonComp, LaunchMessages.CMainTab_Search, null);
fSearchButton.addSelectionListener(new SelectionAdapter() { fSearchButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -375,7 +385,7 @@ public class CMainTab extends CAbstractMainTab {
}); });
Button fBrowseForBinaryButton; Button fBrowseForBinaryButton;
fBrowseForBinaryButton = createPushButton(mainComp, LaunchMessages.Launch_common_Browse_2, null); fBrowseForBinaryButton = createPushButton(buttonComp, LaunchMessages.Launch_common_Browse_2, null);
fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() { fBrowseForBinaryButton.addSelectionListener(new SelectionAdapter() {
@Override @Override
public void widgetSelected(SelectionEvent evt) { public void widgetSelected(SelectionEvent evt) {
@ -432,6 +442,11 @@ public class CMainTab extends CAbstractMainTab {
} }
name = fProgText.getText().trim(); name = fProgText.getText().trim();
try {
name = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(name);
} catch (CoreException e) {
// Silently ignore substitution failure (for consistency with "Arguments" and "Work directory" fields)
}
if (name.length() == 0) { if (name.length() == 0) {
setErrorMessage(LaunchMessages.CMainTab_Program_not_specified); setErrorMessage(LaunchMessages.CMainTab_Program_not_specified);
return false; return false;