diff --git a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java index 92f34491ac5..089f7a15401 100644 --- a/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java +++ b/build/org.eclipse.cdt.make.core/src/org/eclipse/cdt/make/core/MakeCorePlugin.java @@ -128,12 +128,7 @@ public class MakeCorePlugin extends Plugin { public static void log(Throwable e) { if (e instanceof InvocationTargetException) e = ((InvocationTargetException) e).getTargetException(); - IStatus status = null; - if (e instanceof CoreException) - status = ((CoreException) e).getStatus(); - else - status = new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), e); - log(status); + log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.OK, e.getMessage(), new Exception())); } public static void log(IStatus status) { diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeContentProvider.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeContentProvider.java index 366738cc997..e601ccabe87 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeContentProvider.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/MakeContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems 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 @@ -45,11 +45,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; import org.eclipse.core.runtime.preferences.InstanceScope; -import org.eclipse.jface.viewers.AbstractTreeViewer; import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.StructuredViewer; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; /** @@ -65,7 +63,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis /** presentation of the content, i.e. for MakeView tree of for BuildTargetDialog table */ protected boolean bFlatten; - protected StructuredViewer viewer; + protected TreeViewer viewer; /** * Default constructor. @@ -84,9 +82,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis bFlatten = flat; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) - */ @Override public Object[] getChildren(Object obj) { if (obj instanceof IWorkspaceRoot) { @@ -154,9 +149,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis return new Object[0]; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) - */ @Override public Object getParent(Object obj) { if (obj instanceof IMakeTarget) { @@ -173,17 +165,11 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) - */ @Override public boolean hasChildren(Object obj) { return getChildren(obj).length > 0; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ITreeContentProvider#getElements(java.lang.Object) - */ @Override public Object[] getElements(Object obj) { if (bFlatten) { @@ -198,9 +184,6 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis return getChildren(obj); } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ @Override public void dispose() { if (viewer != null) { @@ -208,15 +191,12 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis } } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { if (this.viewer == null) { MakeCorePlugin.getDefault().getTargetManager().addListener(this); } - this.viewer = (StructuredViewer) viewer; + this.viewer = (TreeViewer) viewer; IWorkspace oldWorkspace = null; IWorkspace newWorkspace = null; if (oldInput instanceof IWorkspace) { @@ -248,147 +228,123 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis } } - /* (non-Javadoc) - * @see org.eclipse.cdt.make.core.IMakeTargetListener#targetChanged(org.eclipse.cdt.make.core.MakeTargetEvent) + /** + * Refresh the whole view. */ - @Override - public void targetChanged(final MakeTargetEvent event) { - final Control ctrl = viewer.getControl(); - if (ctrl != null && !ctrl.isDisposed()) { - switch (event.getType()) { - case MakeTargetEvent.PROJECT_ADDED : - case MakeTargetEvent.PROJECT_REMOVED : - ctrl.getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - if (!ctrl.isDisposed()) { - viewer.refresh(); - } - } - }); - break; - case MakeTargetEvent.TARGET_ADD : - case MakeTargetEvent.TARGET_CHANGED : - case MakeTargetEvent.TARGET_REMOVED : - ctrl.getDisplay().asyncExec(new Runnable() { - - @Override - public void run() { - if (!ctrl.isDisposed()) { - if (bFlatten) { - viewer.refresh(); - } else { - //We can't just call refresh on the container target that - //has been created since it may be that the container has - //been filtered out and the filters in the viewer don't know - //any better how to call out to the filter selection again. - //Instead we walk to the root project container and refresh it. - Set containers = new HashSet(); - IMakeTarget[] targets = event.getTargets(); - for (IMakeTarget target : targets) { - IContainer container = target.getContainer(); - while(!(container instanceof IProject) && container.getParent()!=null) { - container = container.getParent(); - } - containers.add(container); - } - for (IContainer container : containers) { - viewer.refresh(container); - } - } - } - } - }); - break; + private void refreshView() { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + viewer.refresh(); } - } + }); } - private void processDelta(IResourceDelta delta) { - // Bail out if the widget was disposed. - Control ctrl = viewer.getControl(); - if (ctrl == null || ctrl.isDisposed() || delta == null) { + /** + * Refresh the project tree or the project subtree (in case of drill-down adapter) in the view. + */ + private void refreshProjectTree(final IProject project) { + Display.getDefault().asyncExec(new Runnable() { + @Override + public void run() { + if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed()) + return; + + if (viewer.getTree().getItemCount() <= 0) { + return; + } + + Object firstItem = viewer.getTree().getItem(0).getData(); + IContainer parentContainer = null; + + boolean isDrilledDown = !(firstItem instanceof IProject); + if (!isDrilledDown) { + // view shows projects + viewer.refresh(project); + } else { + // drill-down adapter in the game + if (firstItem instanceof IResource) { + parentContainer = ((IResource) firstItem).getParent(); + } else if (firstItem instanceof TargetSourceContainer) { + parentContainer = ((TargetSourceContainer) firstItem).getContainer().getParent(); + } else if (firstItem instanceof IMakeTarget) { + parentContainer = ((IMakeTarget) firstItem).getContainer(); + } + + if (parentContainer != null && project.equals(parentContainer.getProject())) { + viewer.refresh(); + } + } + } + }); + } + + @Override + public void targetChanged(MakeTargetEvent event) { + // Additions/removal of projects. Only notifications for projects having applicable builder come here. + int type = event.getType(); + if (type == MakeTargetEvent.PROJECT_ADDED || type == MakeTargetEvent.PROJECT_REMOVED) { + refreshView(); return; } - IResourceDelta[] affectedChildren = delta.getAffectedChildren(IResourceDelta.CHANGED); - - // Not interested in Content changes. - for (int i = 0; i < affectedChildren.length; i++) { - if ((affectedChildren[i].getFlags() & IResourceDelta.TYPE) != 0) { - return; - } + IMakeTarget[] targets = event.getTargets(); + if (targets == null) { + return; } - // Handle changed children recursively. - for (int i = 0; i < affectedChildren.length; i++) { - processDelta(affectedChildren[i]); + Set affectedProjects = new HashSet(); + for (IMakeTarget target : event.getTargets()) { + IContainer container = target.getContainer(); + affectedProjects.add(container.getProject()); } - // Get the affected resource - final IResource resource = delta.getResource(); - - // Handle removed children. Issue one update for all removals. - affectedChildren = delta.getAffectedChildren(IResourceDelta.REMOVED); - if (affectedChildren.length > 0) { - final ArrayList affected = new ArrayList(affectedChildren.length); - for (int i = 0; i < affectedChildren.length; i++) { - if (affectedChildren[i].getResource().getType() == IResource.FOLDER) { - affected.add(affectedChildren[i].getResource()); - } - } - if (!affected.isEmpty()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed()) - return; - if (viewer instanceof AbstractTreeViewer) { - ((AbstractTreeViewer) viewer).remove(affected.toArray()); - } else { - viewer.refresh(resource); - } - } - }); - } - } - - // Handle added children. Issue one update for all insertions. - affectedChildren = delta.getAffectedChildren(IResourceDelta.ADDED); - if (affectedChildren.length > 0) { - final ArrayList affected = new ArrayList(affectedChildren.length); - for (int i = 0; i < affectedChildren.length; i++) { - if (affectedChildren[i].getResource().getType() == IResource.FOLDER) { - affected.add(affectedChildren[i].getResource()); - } - } - if (!affected.isEmpty()) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - if (viewer == null || viewer.getControl() == null || viewer.getControl().isDisposed()) - return; - if (viewer instanceof AbstractTreeViewer) { - ((AbstractTreeViewer) viewer).add(resource, affected.toArray()); - } else { - viewer.refresh(resource); - } - } - }); - } + // If the view is being filtered, adding/removing targets can + // result in showing or hiding containers or the project itself + for (IProject project : affectedProjects) { + refreshProjectTree(project); + } + } + + private void collectAffectedProjects(IResourceDelta delta, Set affectedProjects) { + if (affectedProjects.contains(delta.getResource().getProject())) { + return; + } + + for (IResourceDelta d : delta.getAffectedChildren(IResourceDelta.ADDED | IResourceDelta.REMOVED)) { + // handle folders only, additions/removal of projects are dealt with in #targetChanged(MakeTargetEvent) + IResource rc = d.getResource(); + if (rc.getType() == IResource.FOLDER) { + IProject project = rc.getProject(); + if (MakeCorePlugin.getDefault().getTargetManager().hasTargetBuilder(project)) { + affectedProjects.add(project); + return; + } + } + } + + for (IResourceDelta d : delta.getAffectedChildren(IResourceDelta.CHANGED)) { + collectAffectedProjects(d, affectedProjects); } } - /* (non-Javadoc) - * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent) - */ @Override public void resourceChanged(IResourceChangeEvent event) { - final IResourceDelta delta = event.getDelta(); - Control ctrl = viewer.getControl(); - if (ctrl != null && !ctrl.isDisposed()) - processDelta(delta); + IResourceDelta delta = event.getDelta(); + if (delta == null) { + return; + } + + Set affectedProjects = new HashSet(); + collectAffectedProjects(delta, affectedProjects); + + // If the view is being filtered or source roots shown, + // adding/removing resources can structurally affect the tree + // starting with the project + for (IProject project : affectedProjects) { + refreshProjectTree(project); + } + } /** @@ -397,34 +353,29 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis * @since 7.1 */ @Override - public void handleEvent(final CProjectDescriptionEvent event) { - Display display = Display.getDefault(); - display.asyncExec(new Runnable() { - @Override - public void run() { - ICDescriptionDelta delta = event.getDefaultSettingCfgDelta(); - if (delta==null) - return; + public void handleEvent(CProjectDescriptionEvent event) { + ICDescriptionDelta delta = event.getDefaultSettingCfgDelta(); + if (delta==null) + return; - int flags = delta.getChangeFlags(); - if ( ((flags & ICDescriptionDelta.SOURCE_ADDED) != 0) || - ((flags & ICDescriptionDelta.SOURCE_REMOVED) != 0) ) { + int flags = delta.getChangeFlags(); + if ( ((flags & ICDescriptionDelta.SOURCE_ADDED) != 0) || + ((flags & ICDescriptionDelta.SOURCE_REMOVED) != 0) ) { - IProject project = null; - ICSettingObject setting = delta.getOldSetting(); - if (setting==null) - setting = delta.getNewSetting(); + IProject project = null; + ICSettingObject setting = delta.getOldSetting(); + if (setting == null) { + setting = delta.getNewSetting(); + } - if (setting instanceof ICConfigurationDescription) - project = ((ICConfigurationDescription) setting).getProjectDescription().getProject(); - - if (project!=null) - viewer.refresh(project); - else - viewer.refresh(); + if (setting instanceof ICConfigurationDescription) { + project = ((ICConfigurationDescription) setting).getProjectDescription().getProject(); + if (project != null) { + // refresh source roots under the project + refreshProjectTree(project); } } - }); + } } /** @@ -435,12 +386,7 @@ public class MakeContentProvider implements ITreeContentProvider, IMakeTargetLis @Override public void preferenceChange(PreferenceChangeEvent event) { if (event.getKey().equals(CCorePreferenceConstants.SHOW_SOURCE_ROOTS_AT_TOP_LEVEL_OF_PROJECT)) { - Display.getDefault().asyncExec(new Runnable() { - @Override - public void run() { - viewer.refresh(); - } - }); + refreshView(); } } diff --git a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/FilterEmtpyFoldersAction.java b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/FilterEmtpyFoldersAction.java index 325682c4147..bb158557d45 100644 --- a/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/FilterEmtpyFoldersAction.java +++ b/build/org.eclipse.cdt.make.ui/src/org/eclipse/cdt/make/ui/views/FilterEmtpyFoldersAction.java @@ -23,7 +23,6 @@ import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceProxy; import org.eclipse.core.resources.IResourceProxyVisitor; -import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IAction; import org.eclipse.jface.dialogs.IDialogSettings; @@ -57,54 +56,66 @@ public class FilterEmtpyFoldersAction extends Action { setToolTipText(MakeUIPlugin.getResourceString("FilterEmptyFolderAction.tooltip")); //$NON-NLS-1$ setChecked(getSettings().getBoolean(FILTER_EMPTY_FOLDERS)); MakeUIImages.setImageDescriptors(this, "tool16", MakeUIImages.IMG_TOOLS_MAKE_TARGET_FILTER); //$NON-NLS-1$ - fViewer.addFilter(new ViewerFilter() { - //Check the make targets of the specified container, and if they don't exist, run - //through the children looking for the first match that we can find that contains - //a make target. - private boolean hasMakeTargets(IContainer container) throws CoreException { - IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(container); - if(targets != null && targets.length > 0) { - return true; - } + fViewer.addFilter(new ViewerFilter() { + /** + * Run through the children looking for the first match that we can find that contains + * a make target. + */ + private boolean hasMakeTargets(final IContainer parentContainer) { final boolean [] haveTargets = new boolean[1]; haveTargets[0] = false; IResourceProxyVisitor visitor = new IResourceProxyVisitor() { @Override - public boolean visit(IResourceProxy proxy) throws CoreException { + public boolean visit(IResourceProxy proxy) { if(haveTargets[0]) { - return false; //We found what we were looking for + return false; // We found what we were looking for } - if(proxy.getType() != IResource.FOLDER) { - return true; //We only look at folders for content + int rcType = proxy.getType(); + if(rcType != IResource.PROJECT && rcType != IResource.FOLDER) { + return false; // Ignore non-containers } - IContainer folder = (IContainer) proxy.requestResource(); - IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(folder); - if(targets != null && targets.length > 0) { - haveTargets[0] = true; - return false; + IContainer subFolder = (IContainer) proxy.requestResource(); + + if (!(parentContainer instanceof IProject) && !subFolder.equals(parentContainer) + && CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(subFolder)) { + return false; // Skip source folders showing up second time as regular folders } - return true; //Keep looking + + try { + IMakeTarget [] targets = MakeCorePlugin.getDefault().getTargetManager().getTargets(subFolder); + if(targets != null && targets.length > 0) { + haveTargets[0] = true; + return false; // Found a target + } + } catch (Exception e) { + // log any problem then ignore it + MakeUIPlugin.log(e); + } + return true; // Keep looking } }; - container.accept(visitor, IResource.NONE); + + try { + parentContainer.accept(visitor, IResource.NONE); + } catch (Exception e) { + // log any problem then ignore it + MakeUIPlugin.log(e); + } return haveTargets[0]; } - /* (non-Javadoc) - * @see org.eclipse.jface.viewers.ViewerFilter#select(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) - */ @Override public boolean select(Viewer viewer, Object parentElement, Object element) { if (isChecked()) { IContainer container = null; if (element instanceof IContainer) { - container = (IContainer)element; - if (!(container instanceof IProject)) { + container = (IContainer) element; + if (parentElement instanceof IProject && !(container instanceof IProject)) { // under subfolders do not show source roots second time (when filtered) if (CCorePlugin.showSourceRootsAtTopOfProject() && MakeContentProvider.isSourceEntry(container)) return false; @@ -113,12 +124,8 @@ public class FilterEmtpyFoldersAction extends Action { container = ((TargetSourceContainer) element).getContainer(); } - if (container!=null) { - try { - return hasMakeTargets(container); - } catch(Exception ex) { - return false; - } + if (container != null) { + return hasMakeTargets(container); } } return true; @@ -126,9 +133,6 @@ public class FilterEmtpyFoldersAction extends Action { }); } - /* (non-Javadoc) - * @see org.eclipse.jface.action.Action#run() - */ @Override public void run() { fViewer.refresh(); diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties index b6eb4cb9230..ea1c1abd6ae 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.properties @@ -141,7 +141,9 @@ Option.Posix.Warn.Pedandic=Pedantic (-pedantic) Option.Posix.Warn.PedErrors=Pedantic warnings as errors (-pedantic-errors) Option.Posix.Warn.nowarn=Inhibit all warnings (-w) Option.Posix.Warn.allwarn=All warnings (-Wall) +Option.Posix.Warn.extrawarn=Extra warnings (-Wextra) Option.Posix.Warn.toerrs=Warnings as errors (-Werror) +Option.Posix.Warn.wconversion=Implicit conversion warnings (-Wconversion) Option.Posix.Verbose=Verbose (-v) Option.OtherFlags=Other flags diff --git a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml index 7a0e84ae36e..b5324df8991 100644 --- a/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml +++ b/build/org.eclipse.cdt.managedbuilder.gnu.ui/plugin.xml @@ -1202,6 +1202,14 @@ id="gnu.c.compiler.option.warnings.allwarn" valueType="boolean"> + + + + - diff --git a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF index 66699fb547f..4bdfe1306e8 100644 --- a/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF +++ b/core/org.eclipse.cdt.core.tests/META-INF/MANIFEST.MF @@ -32,7 +32,6 @@ Export-Package: org.eclipse.cdt.core.cdescriptor.tests, org.eclipse.cdt.core.testplugin, org.eclipse.cdt.core.testplugin.util, org.eclipse.cdt.core.tests, - org.eclipse.cdt.core.tests.templateengine, org.eclipse.cdt.core.winreg.tests, org.eclipse.cdt.internal.index.tests;x-internal:=true, org.eclipse.cdt.internal.pdom.tests;x-internal:=true, diff --git a/core/org.eclipse.cdt.core.tests/build.properties b/core/org.eclipse.cdt.core.tests/build.properties index 016d8b57403..4f12cd40852 100644 --- a/core/org.eclipse.cdt.core.tests/build.properties +++ b/core/org.eclipse.cdt.core.tests/build.properties @@ -25,8 +25,7 @@ source.. = model/,\ parser/,\ suite/,\ misc/,\ - regression/,\ - templateengine/ + regression/ jre.compilation.profile=JavaSE-1.6 javacSource=1.6 diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java index a0e7f90ae94..ed79ab1c023 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2CPPTests.java @@ -9367,6 +9367,33 @@ public class AST2CPPTests extends AST2BaseTest { parseAndCheckBindings(); } + // namespace std { + // template struct pair { + // T1 first; + // T2 second; + // }; + // + // template T begin(const pair& p) { + // return p.first; + // } + // template U end(const pair& p) { + // return p.second; + // } + // } + // struct S { + // int x; + // }; + // + // int main() { + // S arr[5]; + // std::pair p{arr, arr + 5}; + // for (const auto& r : p) + // r.x; + // } + public void testAutoTypeInRangeBasedFor_332883c() throws Exception { + parseAndCheckBindings(); + } + // struct S { // void f(); // }; diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java index 141ba5d68db..ff97cb66220 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2TemplateTests.java @@ -5638,4 +5638,55 @@ public class AST2TemplateTests extends AST2BaseTest { public void testTemplateAmbiguityInDeleteExpression_364225() throws Exception { parseAndCheckBindings(); } + + // template void foo(T); + // template void foo(T, typename T::type* = 0); + // int main() { + // foo(0); + // } + public void testSyntaxFailureInstantiatingFunctionTemplate_365981a() throws Exception { + parseAndCheckBindings(); + } + + // template bool bar(T); + // template bool bar(T, void(T::*)() = 0); + // void test() { + // bar(0); + // } + public void testSyntaxFailureInstantiatingFunctionTemplate_365981b() throws Exception { + parseAndCheckBindings(); + } + + // template class vector {}; + // template struct bar { + // void foo() { + // vector index; + // for (const auto& entry : index) { + // } + // } + // }; + public void testResolvingAutoTypeWithDependentExpression_367472() throws Exception { + parseAndCheckBindings(); + } + + // void foo(int, int); + // template void bar(Args... args) { + // foo(1,2,args...); + // foo(args...); + // } + public void testPackExpansionsAsArguments_367560() throws Exception { + parseAndCheckBindings(); + } + + // template class A; + // template class A {}; + // template class A {}; + // + // struct S {}; + // int main() { + // A m; + // } + public void testDeductionForConstFunctionType_367562() throws Exception { + parseAndCheckBindings(); + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java index ffe5e705c22..5e0d7a9d55a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBindingResolutionTestBase.java @@ -84,6 +84,8 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } protected IASTName findName(String section, int len) { + if (len == 0) + len= section.length(); for (int i = 0; i < strategy.getAstCount(); i++) { IASTTranslationUnit ast = strategy.getAst(i); final IASTNodeSelector nodeSelector = ast.getNodeSelector(null); @@ -260,30 +262,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { this.cpp = cpp; } + @Override public ICProject getCProject() { return cproject; } + @Override public StringBuilder[] getTestData() { return testData; } + @Override public int getAstCount() { return 1; } + @Override public IASTTranslationUnit getAst(int index) { if (index != 0) throw new IllegalArgumentException(); return ast; } + @Override public StringBuilder getAstSource(int index) { if (index != 0) throw new IllegalArgumentException(); return testData[1]; } + @Override public void setUp() throws Exception { cproject = cpp ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); @@ -308,6 +316,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile); } + @Override public void tearDown() throws Exception { if (index != null) { index.releaseReadLock(); @@ -317,10 +326,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } + @Override public IIndex getIndex() { return index; } + @Override public boolean isCompositeIndex() { return false; } @@ -337,30 +348,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { this.cpp = cpp; } + @Override public ICProject getCProject() { return cproject; } + @Override public StringBuilder[] getTestData() { return testData; } + @Override public int getAstCount() { return 1; } + @Override public IASTTranslationUnit getAst(int index) { if (index != 0) throw new IllegalArgumentException(); return ast; } + @Override public StringBuilder getAstSource(int index) { if (index != 0) throw new IllegalArgumentException(); return testData[1]; } + @Override public void setUp() throws Exception { cproject = cpp ? CProjectHelper.createCCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCProject(getName()+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); @@ -385,6 +402,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { ast = TestSourceReader.createIndexBasedAST(index, cproject, cppfile); } + @Override public void tearDown() throws Exception { if (index != null) { index.releaseReadLock(); @@ -394,10 +412,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } + @Override public IIndex getIndex() { return index; } + @Override public boolean isCompositeIndex() { return false; } @@ -425,26 +445,32 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { asts = new ArrayList(); } + @Override public ICProject getCProject() { return cproject; } + @Override public StringBuilder[] getTestData() { return testData; } + @Override public int getAstCount() { return asts.size(); } + @Override public IASTTranslationUnit getAst(int index) { return asts.get(index); } + @Override public StringBuilder getAstSource(int index) { return astSources.get(index); } + @Override public void setUp() throws Exception { cproject = cpp ? CProjectHelper.createCCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCProject(getName() + System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); @@ -487,6 +513,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } + @Override public void tearDown() throws Exception { if (index != null) { index.releaseReadLock(); @@ -496,10 +523,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } + @Override public IIndex getIndex() { return index; } + @Override public boolean isCompositeIndex() { return false; } @@ -516,10 +545,12 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { this.cpp = cpp; } + @Override public ICProject getCProject() { return cproject; } + @Override public void tearDown() throws Exception { if (index != null) { index.releaseReadLock(); @@ -532,6 +563,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { } } + @Override public void setUp() throws Exception { cproject= cpp ? CProjectHelper.createCCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER) : CProjectHelper.createCProject("OnlineContent"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); @@ -580,30 +612,36 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase { return referenced; } + @Override public int getAstCount() { return 1; } + @Override public IASTTranslationUnit getAst(int index) { if (index != 0) throw new IllegalArgumentException(); return ast; } + @Override public StringBuilder getAstSource(int index) { if (index != 0) throw new IllegalArgumentException(); return testData[1]; } + @Override public IIndex getIndex() { return index; } + @Override public StringBuilder[] getTestData() { return testData; } + @Override public boolean isCompositeIndex() { return true; } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java index 293cbc8ae73..86963579eaf 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexBugsTests.java @@ -2394,7 +2394,8 @@ public class IndexBugsTests extends BaseTestCase { final Set folders = new HashSet(); folders.add(root); root.accept(new IResourceVisitor() { - public boolean visit(final IResource resource) throws CoreException { + @Override + public boolean visit(final IResource resource) throws CoreException { if (resource instanceof IFile) { files.add((IFile) resource); } else if (resource instanceof IFolder) { @@ -2431,4 +2432,42 @@ public class IndexBugsTests extends BaseTestCase { index.releaseReadLock(); } } + + // // context.c + // #define A B + // #include "b.h" // file name is important to reproduce the issue + // #include "a.h" // file name is important to reproduce the issue + + // // a.h and b.h + // int A; + public void testUpdatingHeaderInContext_367315() throws Exception { + String[] contents= getContentsForTest(2); + final IIndexManager indexManager = CCorePlugin.getIndexManager(); + TestSourceReader.createFile(fCProject.getProject(), "context.c", contents[0]); + IFile ah= TestSourceReader.createFile(fCProject.getProject(), "a.h", contents[1]); + IFile bh= TestSourceReader.createFile(fCProject.getProject(), "b.h", contents[1]); + indexManager.reindex(fCProject); + waitForIndexer(); + fIndex.acquireReadLock(); + try { + IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor()); + assertEquals(1, vars.length); + assertEquals(2, fIndex.findDefinitions(vars[0]).length); + } finally { + fIndex.releaseReadLock(); + } + + final CoreModel coreModel = CCorePlugin.getDefault().getCoreModel(); + ICElement[] selection = new ICElement[] {coreModel.create(ah), coreModel.create(bh)}; + indexManager.update(selection, IIndexManager.UPDATE_ALL); + waitForIndexer(); + fIndex.acquireReadLock(); + try { + IIndexBinding[] vars = fIndex.findBindings("B".toCharArray(), IndexFilter.ALL_DECLARED, new NullProgressMonitor()); + assertEquals(1, vars.length); + assertEquals(2, fIndex.findDefinitions(vars[0]).length); + } finally { + fIndex.releaseReadLock(); + } + } } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java index 93f1cf2edd2..b837c87a7a6 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexCPPTemplateResolutionTest.java @@ -76,13 +76,6 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public ProjectWithDepProj() {setStrategy(new ReferencedProject(true));} public static TestSuite suite() {return suite(ProjectWithDepProj.class);} - // template class XT; - - // #include "header.h" - // template class XT {}; - // void test() { - // XT<> x; - // }; @Override public void testDefaultTemplateArgInHeader_264988() throws Exception { // Not supported across projects (the composite index does not merge @@ -1908,4 +1901,33 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa public void testUsageOfClassTemplateOutsideOfClassBody_357320() throws Exception { getBindingFromASTName("m1", 0, ICPPMethod.class); } + + // template struct foo; + // template <> struct foo { + // typedef int type; + // }; + + // #include "header.h" + // template struct foo {}; + // int main() { + // typedef foo::type type; // ERROR HERE: 'foo::type' could not be + // } + public void testSpecializationInIndex_367563a() throws Exception { + getBindingFromASTName("type type", 4, ITypedef.class); + } + + // template struct foo; + // template struct foo { + // typedef int type; + // }; + + // #include "header.h" + // template struct foo {}; + // int main() { + // typedef foo::type type; // ERROR HERE: 'foo::type' could not be + // } + public void testSpecializationInIndex_367563b() throws Exception { + getBindingFromASTName("type type", 4, ITypedef.class); + } + } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java index c798cdebc11..e572ea15688 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/index/tests/IndexMultiVariantHeaderTest.java @@ -12,6 +12,8 @@ package org.eclipse.cdt.internal.index.tests; import junit.framework.TestSuite; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement; import org.eclipse.cdt.core.dom.ast.IFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunction; import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable; @@ -131,12 +133,55 @@ public class IndexMultiVariantHeaderTest extends IndexBindingResolutionTestBase // y = 0; // z = 0; // } - public void _testSignificantMacroDetection() throws Exception { - // TODO(sprigogin): For this test to work REPORT_SIGNIFICANT_MACROS flag - // should be passed to CPreprocessor.expandMacro method. See - // http://bugs.eclipse.org/bugs/show_bug.cgi?id=197989#c92 for details. + public void testSignificantMacroDetection() throws Exception { getBindingFromASTName("x = 0", 1, ICPPVariable.class); getBindingFromASTName("y = 0", 1, ICPPVariable.class); getBindingFromASTName("z = 0", 1, ICPPVariable.class); } + + // b.h + // #ifndef _B + // #define _B + // #define SIG // This internal modification is not propagated + // #endif + + // a.h + // #include "b.h" + // #ifdef SIG // Not significant, because it is defined in "b.h" + // #endif + + // a.cpp * + // #include "a.h" + public void testSignificantMacroDetection_367753a() throws Exception { + IASTName includeName= findName("a.h", 0); + IASTPreprocessorIncludeStatement inc= (IASTPreprocessorIncludeStatement) includeName.getParent(); + assertTrue(inc.isResolved()); + assertEquals("{}", inc.getSignificantMacros().toString()); + assertNotNull(inc.getImportedIndexFile()); + } + + // c.h + // #define SIG // This internal modification is not propagated + + // b.h + // #ifndef _B + // #define _B + // #include "c.h" + // #endif + + // a.h + // #include "b.h" + // #ifdef SIG // Not significant, because it is defined in "c.h" + // #endif + + // a.cpp * + // #include "a.h" + public void testSignificantMacroDetection_367753b() throws Exception { + IASTName includeName= findName("a.h", 0); + IASTPreprocessorIncludeStatement inc= (IASTPreprocessorIncludeStatement) includeName.getParent(); + assertTrue(inc.isResolved()); + assertEquals("{}", inc.getSignificantMacros().toString()); + assertNotNull(inc.getImportedIndexFile()); + } + } diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java index 932fc73b827..08275ed495a 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/DBTest.java @@ -136,10 +136,12 @@ public class DBTest extends BaseTestCase { this.key = key; } + @Override public int compare(long record) throws CoreException { return db.getString(db.getRecPtr(record + 4)).compare(key, true); } + @Override public boolean visit(long record) throws CoreException { this.record = record; return false; @@ -185,6 +187,7 @@ public class DBTest extends BaseTestCase { }; IBTreeComparator comparator = new IBTreeComparator() { + @Override public int compare(long record1, long record2) throws CoreException { IString string1 = db.getString(db.getRecPtr(record1 + 4)); IString string2 = db.getString(db.getRecPtr(record2 + 4)); @@ -221,9 +224,10 @@ public class DBTest extends BaseTestCase { assertCMP("", EQ, "", true); assertCMP("", EQ, "", false); - doTrials(1000, 1, ShortString.MAX_LENGTH, r, true); - - doTrials(1000, 1, ShortString.MAX_LENGTH, r, false); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH/2, r, true); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH/2, r, false); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, true); + doTrials(1000, 1, ShortString.MAX_BYTE_LENGTH, r, false); assertCMP("a", LT, "b", true); assertCMP("aa", LT, "ab", true); @@ -239,8 +243,8 @@ public class DBTest extends BaseTestCase { public void testLongStringComparison() throws CoreException { Random r= new Random(314159265); - doTrials(100, ShortString.MAX_LENGTH+1, ShortString.MAX_LENGTH*2, r, true); - doTrials(100, ShortString.MAX_LENGTH+1, ShortString.MAX_LENGTH*2, r, false); + doTrials(100, ShortString.MAX_BYTE_LENGTH+1, ShortString.MAX_BYTE_LENGTH*2, r, true); + doTrials(100, ShortString.MAX_BYTE_LENGTH+1, ShortString.MAX_BYTE_LENGTH*2, r, false); } private void doTrials(int n, int min, int max, Random r, boolean caseSensitive) throws CoreException { diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java index a6f3912954b..fd3d21f10ee 100644 --- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java +++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/PDOMLocationTests.java @@ -21,14 +21,11 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.core.testplugin.CProjectHelper; -import org.eclipse.cdt.core.testplugin.CTestPlugin; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; -import org.eclipse.cdt.core.testplugin.util.TestSourceReader; import org.eclipse.cdt.internal.core.pdom.dom.PDOMProjectIndexLocationConverter; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Platform; -import org.osgi.framework.Bundle; /** * Tests behavior related to location representation in the PDOM @@ -40,15 +37,13 @@ public class PDOMLocationTests extends BaseTestCase { return suite(PDOMLocationTests.class); } + @Override protected void setUp() throws Exception { cproject= CProjectHelper.createCCProject("PDOMLocationTests"+System.currentTimeMillis(), "bin", IPDOMManager.ID_NO_INDEXER); - - Bundle b = CTestPlugin.getDefault().getBundle(); - CharSequence[] testData = TestSourceReader.getContentsForTest(b, "parser", getClass(), getName(), 3); - super.setUp(); } + @Override protected void tearDown() throws Exception { if (cproject != null) { cproject.getProject().delete(IResource.FORCE | IResource.ALWAYS_DELETE_PROJECT_CONTENT, new NullProgressMonitor()); diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java index 80f2946e55e..c40a37e2dc0 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/suite/AutomatedIntegrationSuite.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM Corporation - initial API and implementation - * Markus Schorn (Wind River Systems) - * Norbert Ploett (Siemens AG) + * IBM Corporation - initial API and implementation + * Markus Schorn (Wind River Systems) + * Norbert Ploett (Siemens AG) *******************************************************************************/ package org.eclipse.cdt.core.suite; @@ -30,7 +30,6 @@ import org.eclipse.cdt.core.model.tests.WorkingCopyTests; import org.eclipse.cdt.core.parser.tests.ParserTestSuite; import org.eclipse.cdt.core.parser.tests.rewrite.RewriteTests; import org.eclipse.cdt.core.resources.tests.RefreshScopeTests; -import org.eclipse.cdt.core.tests.templateengine.AllTemplateEngineTests; import org.eclipse.cdt.internal.index.tests.IndexTests; import org.eclipse.cdt.internal.pdom.tests.PDOMTests; import org.eclipse.cdt.utils.CdtVariableResolverTest; @@ -82,12 +81,9 @@ public class AutomatedIntegrationSuite extends TestSuite { // Add in PDOM tests suite.addTest(PDOMTests.suite()); suite.addTest(IndexTests.suite()); - - suite.addTest(AllTemplateEngineTests.suite()); suite.addTest(RefreshScopeTests.suite()); return suite; } - } diff --git a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java index 5c8ea899085..e6a90d99bf7 100644 --- a/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java +++ b/core/org.eclipse.cdt.core.tests/suite/org/eclipse/cdt/core/testplugin/util/TestSourceReader.java @@ -105,9 +105,12 @@ public class TestSourceReader { contents.remove(0); content = new StringBuilder(); } - int idx= line.indexOf(testName); - if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) { - return contents.toArray(new StringBuilder[contents.size()]); + if (line.length() > 0 && !contents.isEmpty()) { + int idx= line.indexOf(testName); + if (idx != -1 && !Character.isJavaIdentifierPart(line.charAt(idx + testName.length()))) { + return contents.toArray(new StringBuilder[contents.size()]); + } + contents.clear(); } } } @@ -229,6 +232,7 @@ public class TestSourceReader { final IWorkspace ws = ResourcesPlugin.getWorkspace(); final IFile result[] = new IFile[1]; ws.run(new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { //Obtain file handle IFile file = container.getFile(filePath); diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java index 761fa3f0cfb..0a1b40c9e06 100644 --- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java +++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/settings/model/util/CDataUtil.java @@ -14,6 +14,7 @@ import java.lang.reflect.Array; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; @@ -72,7 +73,7 @@ import org.eclipse.core.runtime.preferences.IScopeContext; public class CDataUtil { private static final String EMPTY = ""; //$NON-NLS-1$ private static final String DELIM = " "; //$NON-NLS-1$ - + private static Random randomNumber; public static final String[] EMPTY_STRING_ARRAY = new String[0]; @@ -96,14 +97,14 @@ public class CDataUtil { } return i; } - + public static String genId(String baseId){ String suffix = new Integer(genRandomNumber()).toString(); - return baseId != null ? + return baseId != null ? new StringBuffer(baseId).append(".").append(suffix).toString() //$NON-NLS-1$ : suffix; } - + public static boolean objectsEqual(Object o1, Object o2){ if(o1 == null) return o2 == null; @@ -126,7 +127,7 @@ public class CDataUtil { for(int i = 1; i < array.length; i++){ buf.append(separator).append(array[i]); } - + return buf.toString(); } @@ -146,7 +147,7 @@ public class CDataUtil { public static ICSettingEntry[] resolveEntries(ICSettingEntry entries[], ICConfigurationDescription cfgDes){ if(entries.length == 0) return entries; - + ArrayList out = new ArrayList(entries.length); ICdtVariableManager mngr = CCorePlugin.getDefault().getCdtVariableManager(); @@ -190,14 +191,14 @@ public class CDataUtil { private static ICSettingEntry[] createResolvedEntry(ICSettingEntry entry, ICConfigurationDescription cfg, ICdtVariableManager mngr){ if(entry.isResolved()) return new ICSettingEntry[] { entry }; - + String name = entry.getName(); - + String[] names = new String[] { name }; // default value try { if ((entry.getKind() != ICSettingEntry.MACRO) && mngr.isStringListValue(name, cfg)) { - names = mngr.resolveStringListValue(name, EMPTY, DELIM, cfg); + names = mngr.resolveStringListValue(name, EMPTY, DELIM, cfg); } else { names[0] = mngr.resolveValue(name, EMPTY, DELIM, cfg); } @@ -206,7 +207,7 @@ public class CDataUtil { } ICSettingEntry[] result = new ICSettingEntry[names.length]; - + for (int k=0; k map = mngr.getContentTypeIdToLanguageDescriptionsMap(); - + CResourceData[] rcDatas = cfg.getResourceDatas(); for(int i = 0; i < rcDatas.length; i++){ if(rcDatas[i].getType() == ICSettingBase.SETTING_FOLDER){ adjustFolderData(cfg, (CFolderData)rcDatas[i], factory, dess, new HashMap(map)); } } - + return cfg; } - + private static void adjustFolderData(CConfigurationData cfgData, CFolderData data, CDataFactory factory, ILanguageDescriptor dess[], HashMap map){ Map langMap = new HashMap(); for(int i = 0; i < dess.length; i++){ @@ -551,38 +552,38 @@ public class CDataUtil { for(int q = 0; q < langs.length; q++){ langMap.remove(langs[q].getId()); } - + adjustLanguageData(data, lData, langs[0]); } } } } - + if(!langMap.isEmpty()){ addLangs(cfgData, data, factory, langMap, map); } - + } - + private static CLanguageData adjustLanguageData(CFolderData data, CLanguageData lData, ILanguageDescriptor des){ String [] cTypeIds = des.getContentTypeIds(); String srcIds[] = lData.getSourceContentTypeIds(); - + Set landTypes = new HashSet(Arrays.asList(cTypeIds)); landTypes.removeAll(Arrays.asList(srcIds)); - + if(landTypes.size() != 0){ List srcList = new ArrayList(); srcList.addAll(landTypes); lData.setSourceContentTypeIds(srcList.toArray(new String[srcList.size()])); } - + if(!des.getId().equals(lData.getLanguageId())){ lData.setLanguageId(des.getId()); } return lData; } - + private static void addLangs(CConfigurationData cfgData, CFolderData data, CDataFactory factory, Map langMap, Map cTypeToLangMap){ List list = new ArrayList(langMap.values()); ILanguageDescriptor des; @@ -599,10 +600,10 @@ public class CDataUtil { } } } - + if(addLang){ - CLanguageData lData = factory.createLanguageData(cfgData, data, genId(data.getId()), des.getName(), des.getId(), - ICLanguageSettingEntry.INCLUDE_FILE + CLanguageData lData = factory.createLanguageData(cfgData, data, genId(data.getId()), des.getName(), des.getId(), + ICLanguageSettingEntry.INCLUDE_FILE | ICLanguageSettingEntry.INCLUDE_PATH | ICLanguageSettingEntry.MACRO | ICLanguageSettingEntry.MACRO_FILE, @@ -611,7 +612,7 @@ public class CDataUtil { } } } - + public static boolean isExcluded(IPath path, ICSourceEntry[] entries){ for(int i = 0; i < entries.length; i++){ if(!isExcluded(path, entries[i])) @@ -619,16 +620,16 @@ public class CDataUtil { } return true; } - + public static boolean isExcluded(IPath path, ICSourceEntry entry){ IPath entryPath = new Path(entry.getName()); - + if(path.isPrefixOf(entryPath)) return false; - + if(!entryPath.isPrefixOf(path)) return true; - + if(path.segmentCount() == 0) return false; char[][] exclusions = entry.fullExclusionPatternChars(); @@ -637,13 +638,13 @@ public class CDataUtil { public static boolean isOnSourceEntry(IPath path, ICSourceEntry entry){ IPath entryPath = new Path(entry.getName()); - + if(path.equals(entryPath)) return true; - + if(!entryPath.isPrefixOf(path)) return false; - + if(path.segmentCount() == 0) return true; char[][] exclusions = entry.fullExclusionPatternChars(); @@ -659,10 +660,10 @@ public class CDataUtil { } /** - * + * * @param ein - initial source entries * @param aus - resulting source entries - * @return - true if they are equal + * @return - true if they are equal */ public static boolean isEqual(ICSourceEntry[] ein, ICSourceEntry[] aus) { if (ein == null || aus == null) return (ein == null && aus == null); @@ -676,14 +677,14 @@ public class CDataUtil { found = true; break; } - return false; // contents is changed ! + return false; // contents is changed ! } - if (!found) + if (!found) return false; // name is not found ! } return true; // all entries are equal by name and contents } - + public static ICSourceEntry[] setExcluded(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries) throws CoreException { return setExcluded(path, isFolder, excluded, entries, true); } @@ -702,14 +703,14 @@ public class CDataUtil { public static ICSourceEntry[] setExcluded(IPath path, boolean isFolder, boolean excluded, ICSourceEntry[] entries, boolean throwExceptionOnErr) throws CoreException { if(isExcluded(path, entries) == excluded) return entries; - + ICSourceEntry[] newEntries; if(excluded){ List includeList = new ArrayList(entries.length); List excludeList = new ArrayList(entries.length); - + sortEntries(path, false, entries, includeList, excludeList); - + for(int i = 0; i < includeList.size(); i++){ ICSourceEntry oldEntry = includeList.get(i); List tmp = new ArrayList(1); @@ -718,7 +719,7 @@ public class CDataUtil { if(newEntry != null) excludeList.add(newEntry); } - + newEntries = excludeList.toArray(new ICSourceEntry[excludeList.size()]); } else { List includeList = new ArrayList(entries.length + 1); @@ -730,7 +731,7 @@ public class CDataUtil { if(includeExclusion(path, includeList) >= 0) included = true; } - + if(!included){ if(isFolder){ includeList.add(new CSourceEntry(path, null, ICSettingEntry.VALUE_WORKSPACE_PATH | ICSettingEntry.RESOLVED)); @@ -740,14 +741,14 @@ public class CDataUtil { return null; } } - + includeList.addAll(excludeList); newEntries = includeList.toArray(new ICSourceEntry[includeList.size()]); } - + return newEntries; } - + private static int includeExclusion(IPath path, List entries){ for(int i = 0; i < entries.size(); i++){ ICSourceEntry entry = entries.get(i); @@ -759,7 +760,7 @@ public class CDataUtil { } return -1; } - + private static ICSourceEntry include(IPath path, ICSourceEntry entry){ IPath[] exclusions = entry.getExclusionPatterns(); IPath entryPath = new Path(entry.getName()); @@ -778,7 +779,7 @@ public class CDataUtil { } return null; } - + private static void sortIncludingExcludingEntries(IPath path, ICSourceEntry[] entries, List including, List excluding){ for(int i = 0; i < entries.length; i++){ IPath entryPath = new Path(entries[i].getName()); @@ -805,7 +806,7 @@ public class CDataUtil { } return new ICSourceEntry[]{entry}; } - + private static ICOutputEntry[] getDefaultOutputEntries(boolean absolute, IProject project){ ICOutputEntry entry; if(absolute){ @@ -822,14 +823,14 @@ public class CDataUtil { public static ICOutputEntry[] adjustEntries(ICOutputEntry entries[], boolean makeAbsolute, IProject project){ if(entries == null || entries.length == 0) return getDefaultOutputEntries(makeAbsolute, project); - + return makeAbsolute ? makeAbsolute(project, entries) : makeRelative(project, entries); } public static ICSourceEntry[] adjustEntries(ICSourceEntry entries[], boolean makeAbsolute, IProject project){ if(entries == null || entries.length == 0) return getDefaultSourceEntries(makeAbsolute, project); - + ICSourceEntry ei, ej; LinkedHashMap> map = new LinkedHashMap>(); for(int i = 0; i < entries.length; i++){ @@ -839,7 +840,7 @@ public class CDataUtil { ej = entries[j]; if(ei == ej) continue; - + IPath ejPath = new Path(ej.getName()); if(!isExcluded(ejPath, ei)){ if(list == null) @@ -847,7 +848,7 @@ public class CDataUtil { list.add(ejPath); } } - + map.put(ei, list); } List resultList = new ArrayList(entries.length); @@ -863,19 +864,28 @@ public class CDataUtil { resultList.add(se); } } - + if(makeAbsolute){ if(project != null) resultList = makeAbsolute(project, resultList); } else { resultList = makeRelative(project, resultList); } - return resultList.toArray(new ICSourceEntry[resultList.size()]); + + ICSourceEntry[] resultArray = resultList.toArray(new ICSourceEntry[resultList.size()]); + Arrays.sort(resultArray, new Comparator() { + @Override + public int compare(ICSourceEntry o1, ICSourceEntry o2) { + return o1.getFullPath().toString().compareTo(o2.getFullPath().toString()); + } + }); + + return resultArray; } private static List makeRelative(IProject project, List list){ int size = list.size(); - + for(int i = 0; i < size; i++){ list.set(i, makeRelative(project, list.get(i))); } @@ -884,7 +894,7 @@ public class CDataUtil { private static List makeAbsolute(IProject project, List list){ int size = list.size(); - + for(int i = 0; i < size; i++){ list.set(i, makeAbsolute(project, list.get(i))); } @@ -939,26 +949,26 @@ public class CDataUtil { public static ICSourceEntry addExcludePaths(ICSourceEntry entry, Collection paths, boolean removePrefix){ IPath entryPath = new Path(entry.getName()); IPath[] oldExclusions = entry.getExclusionPatterns(); -// List newExList = new ArrayList(oldExclusions.length + paths.size()); +// List newExList = new ArrayList(oldExclusions.length + paths.size()); LinkedHashSet newSet = new LinkedHashSet(); if(removePrefix){ removePrefix(entryPath, paths, newSet); } else { newSet.addAll(paths); } - + for(Iterator iter = newSet.iterator(); iter.hasNext();){ IPath path = iter.next(); if(path.segmentCount() == 0) return null; } - + newSet.addAll(Arrays.asList(oldExclusions)); - + IPath[] newExclusions = newSet.toArray(new IPath[newSet.size()]); return new CSourceEntry(entry.getName(), newExclusions, entry.getFlags()); } - + private static void sortEntries(IPath path, boolean byExclude, ICSourceEntry[] entries, List included, List excluded){ for(int i = 0; i < entries.length; i++){ if(byExclude ? isExcluded(path, entries[i]) : !isOnSourceEntry(path, entries[i])){ @@ -970,11 +980,11 @@ public class CDataUtil { } } } - + public static Map fillEntriesMapByNameKey(Map map, ICSettingEntry[] entries){ if(map == null) map = new LinkedHashMap(); - + for(int i = 0; i < entries.length; i++){ ICSettingEntry entry = entries[i]; map.put(new EntryNameKey(entry), entry); @@ -985,14 +995,14 @@ public class CDataUtil { public static Map fillEntriesMapByContentsKey(Map map, ICSettingEntry[] entries){ if(map == null) map = new LinkedHashMap(); - + for(int i = 0; i < entries.length; i++){ ICSettingEntry entry = entries[i]; map.put(new EntryContentsKey(entry), entry); } return map; } - + public static boolean getBoolean(ICStorageElement el, String attr, boolean defaultValue){ if(el != null){ String tmp = el.getAttribute(attr); @@ -1023,14 +1033,14 @@ public class CDataUtil { public static void setInteger(ICStorageElement el, String attr, int value){ el.setAttribute(attr, new Integer(value).toString()); } - + public static ICExclusionPatternPathEntry addRemoveExclusionsToEntry(ICExclusionPatternPathEntry entry, IPath[] paths, boolean add) throws IllegalArgumentException{ if(paths == null || paths.length == 0) return entry; - + Set set = mergeRemovingDups(entry.getExclusionPatterns(), paths, add); IPath exclusions[] = set.toArray(new IPath[set.size()]); - + return (ICExclusionPatternPathEntry)createEntry(entry.getKind(), entry.getName(), null, exclusions, entry.getFlags()); } @@ -1043,7 +1053,7 @@ public class CDataUtil { set.removeAll(Arrays.asList(o2)); return set; } - + public static ICExclusionPatternPathEntry makeAbsolute(IProject project, ICExclusionPatternPathEntry entry, boolean force){ if(!entry.isValueWorkspacePath() && !force) return entry; @@ -1056,14 +1066,14 @@ public class CDataUtil { } return entry; } - + public static ICExclusionPatternPathEntry makeRelative(IProject project, ICExclusionPatternPathEntry entry, boolean force){ if(!entry.isValueWorkspacePath() && !force) return entry; - + IPath path = new Path(entry.getName()); IPath projPath = project.getFullPath(); - + if(path.isAbsolute()){ if(projPath.isPrefixOf(path)) path = path.removeFirstSegments(projPath.segmentCount()).makeRelative(); @@ -1073,22 +1083,22 @@ public class CDataUtil { } return entry; } - + public static ICExclusionPatternPathEntry[] makeRelative(IProject project, ICExclusionPatternPathEntry[] entries, boolean force){ if(entries == null) return null; - + ICExclusionPatternPathEntry[] relEntries = (ICExclusionPatternPathEntry[])Array.newInstance(entries.getClass().getComponentType(), entries.length); for(int i = 0; i < entries.length; i++){ relEntries[i] = makeRelative(project, entries[i], force); } return relEntries; } - + public static ICExclusionPatternPathEntry[] makeAbsolute(IProject project, ICExclusionPatternPathEntry[] entries, boolean force){ if(entries == null) return null; - + ICExclusionPatternPathEntry[] relEntries = (ICExclusionPatternPathEntry[])Array.newInstance(entries.getClass().getComponentType(), entries.length); for(int i = 0; i < entries.length; i++){ relEntries[i] = makeAbsolute(project, entries[i], force); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java index 7bf1a5595e1..969f7275f22 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTBinaryExpression.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Doug Schaefer (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * Doug Schaefer (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -19,7 +19,6 @@ package org.eclipse.cdt.core.dom.ast; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTBinaryExpression extends IASTExpression { - /** * Node property that describes the relationship between an * IASTBinaryExpression and an IASTExpression @@ -271,10 +270,12 @@ public interface IASTBinaryExpression extends IASTExpression { /** * @since 5.1 */ + @Override public IASTBinaryExpression copy(); /** * @since 5.3 */ + @Override public IASTBinaryExpression copy(CopyStyle style); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java index 73726cdb10b..7c23794ee9e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTName.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Bryan Wilkinson (QNX) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.core.dom.ast; @@ -23,7 +23,6 @@ import org.eclipse.cdt.core.dom.IName; * @noimplement This interface is not intended to be implemented by clients. */ public interface IASTName extends IASTNode, IName { - /** * Constant sentinel. */ @@ -32,12 +31,14 @@ public interface IASTName extends IASTNode, IName { /** * Returns the name including qualification and template arguments. */ + @Override public char[] toCharArray(); /** * Same as {@link #toCharArray()}. * @since 5.1 */ + @Override public String toString(); /** @@ -101,11 +102,13 @@ public interface IASTName extends IASTNode, IName { /** * @since 5.1 */ + @Override public IASTName copy(); /** * @since 5.3 */ + @Override public IASTName copy(CopyStyle style); /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplate.java index 081f8a203ff..d15b346c59b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/cpp/ICPPClassTemplate.java @@ -18,7 +18,7 @@ import org.eclipse.cdt.core.dom.ast.DOMException; * @noimplement This interface is not intended to be implemented by clients. */ public interface ICPPClassTemplate extends ICPPTemplateDefinition, ICPPClassType { - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException; + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations(); /** * Returns a deferred instance that allows lookups within this class template. diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java index 952ca286712..4d3ce346104 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/AbstractCLikeLanguage.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Anton Leherbauer (Wind River Systems) - initial API and implementation - * Markus Schorn (Wind River Systems) - * Mike Kucera (IBM) + * Anton Leherbauer (Wind River Systems) - initial API and implementation + * Markus Schorn (Wind River Systems) + * Mike Kucera (IBM) *******************************************************************************/ package org.eclipse.cdt.core.dom.parser; @@ -106,14 +106,15 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements protected abstract ParserLanguage getParserLanguage(); @Deprecated + @Override public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, IParserLogService log) throws CoreException { return getASTTranslationUnit(reader, scanInfo, fileCreator, index, 0, log); } - @Override @Deprecated + @Override public IASTTranslationUnit getASTTranslationUnit(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory codeReaderFactory, IIndex index, int options, IParserLogService log) throws CoreException { @@ -136,6 +137,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements if (log instanceof ICanceler) { canceler= (ICanceler) log; canceler.setCancelable(new ICancelable() { + @Override public void cancel() { scanner.cancel(); parser.cancel(); @@ -155,6 +157,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements } @Deprecated + @Override public IASTCompletionNode getCompletionNode(org.eclipse.cdt.core.parser.CodeReader reader, IScannerInfo scanInfo, org.eclipse.cdt.core.dom.ICodeReaderFactory fileCreator, IIndex index, IParserLogService log, int offset) throws CoreException { @@ -189,12 +192,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements */ protected ISourceCodeParser createParser(IScanner scanner, IParserLogService log, IIndex index, boolean forCompletion, int options) { ParserMode mode; - if (forCompletion) + if (forCompletion) { mode= ParserMode.COMPLETION_PARSE; - else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) + } else if ((options & OPTION_SKIP_FUNCTION_BODIES) != 0) { mode= ParserMode.STRUCTURAL_PARSE; - else + } else { mode= ParserMode.COMPLETE_PARSE; + } ISourceCodeParser parser= createParser(scanner, mode, log, index); if ((options & OPTION_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS) != 0) { @@ -224,6 +228,7 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements return new CPreprocessor(content, scanInfo, getParserLanguage(), log, getScannerExtensionConfiguration(scanInfo), fcp); } + @Override @Deprecated public IASTName[] getSelectedNames(IASTTranslationUnit ast, int start, int length) { IASTNode selectedNode= ast.getNodeSelector(null).findNode(start, length); @@ -243,12 +248,13 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements return collector.getNames(); } + @Override public IContributedModelBuilder createModelBuilder(ITranslationUnit tu) { // use default model builder return null; } - private ICLanguageKeywords cLanguageKeywords = null; + private ICLanguageKeywords cLanguageKeywords; private synchronized ICLanguageKeywords getCLanguageKeywords() { if (cLanguageKeywords == null) @@ -265,15 +271,18 @@ public abstract class AbstractCLikeLanguage extends AbstractLanguage implements return super.getAdapter(adapter); } - // for backwards compatibility + // For backwards compatibility + @Override public String[] getBuiltinTypes() { return getCLanguageKeywords().getBuiltinTypes(); } + @Override public String[] getKeywords() { return getCLanguageKeywords().getKeywords(); } + @Override public String[] getPreprocessorKeywords() { return getCLanguageKeywords().getPreprocessorKeywords(); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java index 3f120cd7fed..625cbfbe92e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/parser/util/CharArrayObjectMap.java @@ -20,7 +20,7 @@ import java.util.List; * @author Doug Schaefer */ public class CharArrayObjectMap extends CharTable { - public static final CharArrayObjectMap EMPTY_MAP = new CharArrayObjectMap(0) { + public static final CharArrayObjectMap EMPTY_MAP = new CharArrayObjectMap(0) { @Override public Object clone() { return this; } @Override diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java index ad80a6934df..485e092db80 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/Linkage.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom; @@ -15,15 +15,14 @@ import org.eclipse.cdt.core.dom.ILinkage; import org.eclipse.core.runtime.CoreException; public class Linkage implements ILinkage { - public static final ILinkage NO_LINKAGE = new Linkage(NO_LINKAGE_ID, NO_LINKAGE_NAME); public static final ILinkage C_LINKAGE = new Linkage(C_LINKAGE_ID, C_LINKAGE_NAME); public static final ILinkage CPP_LINKAGE = new Linkage(CPP_LINKAGE_ID, CPP_LINKAGE_NAME); public static final ILinkage FORTRAN_LINKAGE = new Linkage(FORTRAN_LINKAGE_ID, FORTRAN_LINKAGE_NAME); public static final ILinkage OBJC_LINKAGE = new Linkage(OBJC_LINKAGE_ID, OBJC_LINKAGE_NAME); - private static final ILinkage[] LINKAGES= {C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE, OBJC_LINKAGE}; - private static final ILinkage[] INDEX_LINKAGES= {C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE}; + private static final ILinkage[] LINKAGES= { C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE, OBJC_LINKAGE }; + private static final ILinkage[] INDEX_LINKAGES= { C_LINKAGE, CPP_LINKAGE, FORTRAN_LINKAGE }; public static final ILinkage[] getIndexerLinkages() { return INDEX_LINKAGES; @@ -46,13 +45,18 @@ public class Linkage implements ILinkage { private int fID; private String fName; + private Linkage(int id, String name) { fID= id; fName= name; } + + @Override public int getLinkageID() { return fID; } + + @Override public String getLinkageName() { return fName; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java index 6af97c235c8..b05019ca30a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java @@ -6,10 +6,10 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM Rational Software) - Initial API and implementation - * Markus Schorn (Wind River Systems) - * Yuan Zhang / Beth Tibbitts (IBM Research) - * Bryan Wilkinson (QNX) + * John Camelon (IBM Rational Software) - Initial API and implementation + * Markus Schorn (Wind River Systems) + * Yuan Zhang / Beth Tibbitts (IBM Research) + * Bryan Wilkinson (QNX) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.c; @@ -31,14 +31,12 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner; * Implementation for names in C translation units. */ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext { - private final char[] name; private static final char[] EMPTY_CHAR_ARRAY = {}; private static final String EMPTY_STRING = ""; //$NON-NLS-1$ - private IBinding binding = null; - + private IBinding binding; public CASTName(char[] name) { this.name = name; @@ -48,10 +46,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext name = EMPTY_CHAR_ARRAY; } - public CASTName copy() { + @Override + public CASTName copy() { return copy(CopyStyle.withoutLocations); } + @Override public CASTName copy(CopyStyle style) { CASTName copy = new CASTName(name == null ? null : name.clone()); copy.setOffsetAndLength(this); @@ -61,7 +61,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return copy; } - public IBinding resolveBinding() { + @Override + public IBinding resolveBinding() { if (binding == null) { CVisitor.createBinding(this); } @@ -69,19 +70,23 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return binding; } - public IBinding resolvePreBinding() { + @Override + public IBinding resolvePreBinding() { return resolveBinding(); } - public IBinding getBinding() { + @Override + public IBinding getBinding() { return binding; } - public IBinding getPreBinding() { + @Override + public IBinding getPreBinding() { return binding; } - public IASTCompletionContext getCompletionContext() { + @Override + public IASTCompletionContext getCompletionContext() { IASTNode node = getParent(); while (node != null) { if (node instanceof IASTCompletionContext) { @@ -95,7 +100,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return null; } - public void setBinding(IBinding binding) { + @Override + public void setBinding(IBinding binding) { this.binding = binding; } @@ -107,14 +113,17 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return new String(name); } - public char[] toCharArray() { + @Override + public char[] toCharArray() { return name; } + @Override public char[] getSimpleID() { return name; } + @Override public char[] getLookupKey() { return name; } @@ -146,6 +155,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext } + @Override public int getRoleOfName(boolean allowResolution) { IASTNode parent = getParent(); if (parent instanceof IASTInternalNameOwner) { @@ -157,7 +167,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return IASTNameOwner.r_unclear; } - public boolean isDeclaration() { + @Override + public boolean isDeclaration() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); @@ -172,8 +183,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return false; } - - public boolean isReference() { + @Override + public boolean isReference() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); @@ -187,7 +198,8 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return false; } - public boolean isDefinition() { + @Override + public boolean isDefinition() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); @@ -201,10 +213,12 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return false; } + @Override public ILinkage getLinkage() { return Linkage.C_LINKAGE; } + @Override public IBinding[] findBindings(IASTName n, boolean isPrefix) { IASTNode parent = getParent(); if (parent instanceof IASTElaboratedTypeSpecifier) { @@ -247,6 +261,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext return (IBinding[])ArrayUtil.removeNulls(IBinding.class, bindings); } + @Override public IASTName getLastName() { return this; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java index dab0f96ed7b..65ec3d317b3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTFunctionDefinition.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * IBM - Initial API and implementation - * Markus Schorn (Wind River Systems) + * IBM - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -35,10 +35,10 @@ public class CPPASTFunctionDefinition extends ASTNode private IASTDeclSpecifier declSpecifier; private IASTFunctionDeclarator declarator; private IASTStatement bodyStatement; - private ICPPASTConstructorChainInitializer[] memInits = null; + private ICPPASTConstructorChainInitializer[] memInits; private int memInitPos= -1; - private boolean fDeleted= false; - private boolean fDefaulted= false; + private boolean fDeleted; + private boolean fDefaulted; public CPPASTFunctionDefinition() { } @@ -50,10 +50,12 @@ public class CPPASTFunctionDefinition extends ASTNode setBody(bodyStatement); } + @Override public CPPASTFunctionDefinition copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTFunctionDefinition copy(CopyStyle style) { CPPASTFunctionDefinition copy = new CPPASTFunctionDefinition(); copy.setDeclSpecifier(declSpecifier == null ? null : declSpecifier.copy(style)); @@ -61,8 +63,7 @@ public class CPPASTFunctionDefinition extends ASTNode if (declarator != null) { IASTDeclarator outer = ASTQueries.findOutermostDeclarator(declarator); outer = outer.copy(style); - copy.setDeclarator((IASTFunctionDeclarator) ASTQueries - .findTypeRelevantDeclarator(outer)); + copy.setDeclarator((IASTFunctionDeclarator) ASTQueries.findTypeRelevantDeclarator(outer)); } copy.setBody(bodyStatement == null ? null : bodyStatement.copy(style)); @@ -79,11 +80,13 @@ public class CPPASTFunctionDefinition extends ASTNode return copy; } + @Override public IASTDeclSpecifier getDeclSpecifier() { return declSpecifier; } - public void setDeclSpecifier(IASTDeclSpecifier declSpec) { + @Override + public void setDeclSpecifier(IASTDeclSpecifier declSpec) { assertNotFrozen(); declSpecifier = declSpec; if (declSpec != null) { @@ -92,11 +95,13 @@ public class CPPASTFunctionDefinition extends ASTNode } } - public IASTFunctionDeclarator getDeclarator() { + @Override + public IASTFunctionDeclarator getDeclarator() { return declarator; } - public void setDeclarator(IASTFunctionDeclarator declarator) { + @Override + public void setDeclarator(IASTFunctionDeclarator declarator) { assertNotFrozen(); this.declarator = declarator; if (declarator != null) { @@ -106,11 +111,13 @@ public class CPPASTFunctionDefinition extends ASTNode } } - public IASTStatement getBody() { + @Override + public IASTStatement getBody() { return bodyStatement; } - public void setBody(IASTStatement statement) { + @Override + public void setBody(IASTStatement statement) { assertNotFrozen(); bodyStatement = statement; if (statement != null) { @@ -119,6 +126,7 @@ public class CPPASTFunctionDefinition extends ASTNode } } + @Override public void addMemberInitializer(ICPPASTConstructorChainInitializer initializer) { assertNotFrozen(); if (initializer != null) { @@ -128,6 +136,7 @@ public class CPPASTFunctionDefinition extends ASTNode } } + @Override public ICPPASTConstructorChainInitializer[] getMemberInitializers() { if (memInits == null) return ICPPASTConstructorChainInitializer.EMPTY_CONSTRUCTORCHAININITIALIZER_ARRAY; @@ -136,23 +145,28 @@ public class CPPASTFunctionDefinition extends ASTNode ICPPASTConstructorChainInitializer.class, memInits, memInitPos); } + @Override public IScope getScope() { return ((ICPPASTFunctionDeclarator) declarator).getFunctionScope(); } + @Override public boolean isDefaulted() { return fDefaulted; } + @Override public boolean isDeleted() { return fDeleted; } + @Override public void setIsDefaulted(boolean isDefaulted) { assertNotFrozen(); fDefaulted= isDefaulted; } + @Override public void setIsDeleted(boolean isDeleted) { assertNotFrozen(); fDeleted= isDeleted; @@ -203,6 +217,7 @@ public class CPPASTFunctionDefinition extends ASTNode return true; } + @Override public void replace(IASTNode child, IASTNode other) { if (bodyStatement == child) { other.setPropertyInParent(bodyStatement.getPropertyInParent()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java index 30c6359b9ed..fc3710bfa63 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTNameBase.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -46,9 +46,9 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { } } - private IBinding fBinding = null; - private byte fResolutionDepth = 0; - private boolean fIsFinal= false; + private IBinding fBinding; + private byte fResolutionDepth; + private boolean fIsFinal; public final void incResolutionDepth() { if (fBinding == null && ++fResolutionDepth > MAX_RESOLUTION_DEPTH) { @@ -66,6 +66,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { * Resolves the name at least up to the intermediate binding and returns it. * @see ICPPTwoPhaseBinding */ + @Override public IBinding resolvePreBinding() { if (fBinding == null) { if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) { @@ -77,7 +78,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return fBinding; } - public IBinding resolveBinding() { + @Override + public IBinding resolveBinding() { if (fBinding == null) { if (++fResolutionDepth > MAX_RESOLUTION_DEPTH) { setBinding(new RecursionResolvingBinding(this)); @@ -105,7 +107,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { * Otherwise the intermediate or final binding for this name is returned. * @see ICPPTwoPhaseBinding */ - public IBinding getPreBinding() { + @Override + public IBinding getPreBinding() { return fBinding; } @@ -114,7 +117,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { * Otherwise the final binding for this name is returned. * @see ICPPTwoPhaseBinding */ - public IBinding getBinding() { + @Override + public IBinding getBinding() { final IBinding cand= fBinding; if (cand == null) return null; @@ -137,11 +141,13 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { fIsFinal= true; } + @Override public void setBinding(IBinding binding) { fBinding= binding; fResolutionDepth= 0; } + @Override public IASTName getLastName() { return this; } @@ -151,6 +157,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return new String(toCharArray()); } + @Override public IASTCompletionContext getCompletionContext() { IASTNode node = getParent(); while (node != null) { @@ -163,6 +170,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return null; } + @Override public int getRoleOfName(boolean allowResolution) { IASTNode parent = getParent(); if (parent instanceof IASTInternalNameOwner) { @@ -174,7 +182,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return IASTNameOwner.r_unclear; } - public boolean isDeclaration() { + @Override + public boolean isDeclaration() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); @@ -189,7 +198,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return false; } - public boolean isReference() { + @Override + public boolean isReference() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); @@ -198,7 +208,8 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return false; } - public boolean isDefinition() { + @Override + public boolean isDefinition() { IASTNode parent = getParent(); if (parent instanceof IASTNameOwner) { int role = ((IASTNameOwner) parent).getRoleForName(this); @@ -207,9 +218,7 @@ public abstract class CPPASTNameBase extends ASTNode implements IASTName { return false; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IASTName#getLinkage() - */ + @Override public ILinkage getLinkage() { return Linkage.CPP_LINKAGE; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java index 11915db84f6..2d604599d65 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTemplateDeclaration.java @@ -6,8 +6,8 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * John Camelon (IBM) - Initial API and implementation - * Markus Schorn (Wind River Systems) + * John Camelon (IBM) - Initial API and implementation + * Markus Schorn (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.parser.cpp; @@ -24,15 +24,14 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; /** * Represents a template declaration. */ -public class CPPASTTemplateDeclaration extends ASTNode implements - ICPPASTInternalTemplateDeclaration, IASTAmbiguityParent { - +public class CPPASTTemplateDeclaration extends ASTNode + implements ICPPASTInternalTemplateDeclaration, IASTAmbiguityParent { private boolean exported; private byte isAssociatedWithLastName= -1; private short nestingLevel= -1; private IASTDeclaration declaration; private ICPPTemplateScope templateScope; - private ICPPASTTemplateParameter[] parameters = null; + private ICPPASTTemplateParameter[] parameters; private int parametersPos= -1; public CPPASTTemplateDeclaration() { @@ -42,10 +41,12 @@ public class CPPASTTemplateDeclaration extends ASTNode implements setDeclaration(declaration); } + @Override public CPPASTTemplateDeclaration copy() { return copy(CopyStyle.withoutLocations); } + @Override public CPPASTTemplateDeclaration copy(CopyStyle style) { CPPASTTemplateDeclaration copy = new CPPASTTemplateDeclaration(); copy.setDeclaration(declaration == null ? null : declaration.copy(style)); @@ -59,20 +60,24 @@ public class CPPASTTemplateDeclaration extends ASTNode implements return copy; } + @Override public boolean isExported() { return exported; } - public void setExported(boolean value) { + @Override + public void setExported(boolean value) { assertNotFrozen(); exported = value; } - public IASTDeclaration getDeclaration() { + @Override + public IASTDeclaration getDeclaration() { return declaration; } - public void setDeclaration(IASTDeclaration declaration) { + @Override + public void setDeclaration(IASTDeclaration declaration) { assertNotFrozen(); this.declaration = declaration; if (declaration != null) { @@ -81,13 +86,15 @@ public class CPPASTTemplateDeclaration extends ASTNode implements } } - public ICPPASTTemplateParameter[] getTemplateParameters() { + @Override + public ICPPASTTemplateParameter[] getTemplateParameters() { if (parameters == null) return ICPPASTTemplateParameter.EMPTY_TEMPLATEPARAMETER_ARRAY; parameters = (ICPPASTTemplateParameter[]) ArrayUtil.removeNullsAfter(ICPPASTTemplateParameter.class, parameters, parametersPos); return parameters; } - public void addTemplateParameter(ICPPASTTemplateParameter parm) { + @Override + public void addTemplateParameter(ICPPASTTemplateParameter parm) { assertNotFrozen(); if (parm != null) { parameters = (ICPPASTTemplateParameter[]) ArrayUtil.append(ICPPASTTemplateParameter.class, parameters, ++parametersPos, parm); @@ -97,6 +104,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements } @Deprecated + @Override public void addTemplateParamter(ICPPASTTemplateParameter param) { addTemplateParameter(param); } @@ -128,13 +136,15 @@ public class CPPASTTemplateDeclaration extends ASTNode implements return true; } + @Override public ICPPTemplateScope getScope() { if (templateScope == null) templateScope = new CPPTemplateScope(this); return templateScope; } - public void replace(IASTNode child, IASTNode other) { + @Override + public void replace(IASTNode child, IASTNode other) { if (declaration == child) { other.setParent(child.getParent()); other.setPropertyInParent(child.getPropertyInParent()); @@ -142,6 +152,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements } } + @Override public short getNestingLevel() { if (nestingLevel == -1) { CPPTemplates.associateTemplateDeclarations(this); @@ -150,6 +161,7 @@ public class CPPASTTemplateDeclaration extends ASTNode implements return nestingLevel; } + @Override public boolean isAssociatedWithLastName() { if (isAssociatedWithLastName == -1) CPPTemplates.associateTemplateDeclarations(this); @@ -158,10 +170,12 @@ public class CPPASTTemplateDeclaration extends ASTNode implements return isAssociatedWithLastName != 0; } + @Override public void setAssociatedWithLastName(boolean value) { isAssociatedWithLastName= value ? (byte) 1 : (byte) 0; } + @Override public void setNestingLevel(short level) { assert level >= 0; nestingLevel= level; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java index 4a6d8243e02..6d9718665e8 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassScope.java @@ -77,6 +77,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { super(physicalNode); } + @Override public EScopeKind getKind() { return EScopeKind.eClassType; } @@ -270,6 +271,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { return true; } + @Override public ICPPConstructor[] getConstructors() { return getConstructors(null, true); } @@ -277,7 +279,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { private ICPPConstructor[] getConstructors(IASTName forName, boolean forceResolve) { populateCache(); - final CharArrayObjectMap nameMap = bindings; + final CharArrayObjectMap nameMap = bindings; if (nameMap == null) return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; @@ -365,6 +367,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getClassType() */ + @Override public ICPPClassType getClassType() { ICPPASTCompositeTypeSpecifier compSpec = (ICPPASTCompositeTypeSpecifier) getPhysicalNode(); final IASTName name = compSpec.getName(); @@ -378,6 +381,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope#getImplicitMethods() */ + @Override public ICPPMethod[] getImplicitMethods() { if (implicits == null) return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index 09640c55525..dbf7c43a78b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -17,7 +17,6 @@ import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IField; import org.eclipse.cdt.core.dom.ast.IScope; @@ -36,8 +35,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; -import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.index.IIndexBinding; +import org.eclipse.cdt.core.index.IIndexFileSet; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; @@ -47,26 +46,26 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates; public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClassTemplate, ICPPInternalClassTemplate, ICPPInternalClassTypeMixinHost { - private ICPPClassTemplate fIndexBinding= null; - private boolean checkedIndex= false; - - private ICPPClassTemplatePartialSpecialization[] partialSpecializations = null; private ICPPDeferredClassInstance fDeferredInstance; + private boolean addedPartialSpecializationsOfIndex; public CPPClassTemplate(IASTName name) { super(name); } - public void checkForDefinition() { + @Override + public void checkForDefinition() { // Ambiguity resolution ensures that definitions are resolved. } + @Override public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) { partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append( ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec); } + @Override public ICPPASTCompositeTypeSpecifier getCompositeTypeSpecifier() { if (definition != null) { IASTNode node = definition.getParent(); @@ -78,6 +77,7 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return null; } + @Override public ICPPClassScope getCompositeScope() { if (definition == null) { checkForDefinition(); @@ -93,15 +93,16 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass } // Forward declarations must be backed up from the index. - checkForIndexBinding(); - if (fIndexBinding != null) { - IScope scope = fIndexBinding.getCompositeScope(); + ICPPClassTemplate ib = getIndexBinding(); + if (ib != null) { + IScope scope = ib.getCompositeScope(); if (scope instanceof ICPPClassScope) return (ICPPClassScope) scope; } return null; } + @Override public int getKey() { if (definition != null) { ICPPASTCompositeTypeSpecifier cts= getCompositeTypeSpecifier(); @@ -124,11 +125,25 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return ICPPASTElaboratedTypeSpecifier.k_class; } + @Override public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { + if (!addedPartialSpecializationsOfIndex) { + addedPartialSpecializationsOfIndex= true; + ICPPClassTemplate ib = getIndexBinding(); + if (ib != null) { + IIndexFileSet fs = getTemplateName().getTranslationUnit().getIndexFileSet(); + for (ICPPClassTemplatePartialSpecialization spec : ib.getPartialSpecializations()) { + if (spec instanceof IIndexBinding && fs.containsDeclaration((IIndexBinding) spec)) { + addPartialSpecialization(spec); + } + } + } + } partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim(ICPPClassTemplatePartialSpecialization.class, partialSpecializations); return partialSpecializations; } + @Override public boolean isSameType(IType type) { if (type == this) return true; @@ -137,42 +152,52 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return false; } + @Override public ICPPBase[] getBases() { return ClassTypeHelper.getBases(this); } + @Override public IField[] getFields() { return ClassTypeHelper.getFields(this); } + @Override public ICPPField[] getDeclaredFields() { return ClassTypeHelper.getDeclaredFields(this); } + @Override public ICPPMethod[] getMethods() { return ClassTypeHelper.getMethods(this); } + @Override public ICPPMethod[] getAllDeclaredMethods() { return ClassTypeHelper.getAllDeclaredMethods(this); } + @Override public ICPPMethod[] getDeclaredMethods() { return ClassTypeHelper.getDeclaredMethods(this); } + @Override public ICPPConstructor[] getConstructors() { return ClassTypeHelper.getConstructors(this); } + @Override public IBinding[] getFriends() { return ClassTypeHelper.getFriends(this); } + @Override public ICPPClassType[] getNestedClasses() { return ClassTypeHelper.getNestedClasses(this); } + @Override public IField findField(String name) { return ClassTypeHelper.findField(this, name); } @@ -194,10 +219,12 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return ASTTypeUtil.getType(this); } + @Override public boolean isAnonymous() { return false; } + @Override public final ICPPDeferredClassInstance asDeferredInstance() throws DOMException { if (fDeferredInstance == null) { fDeferredInstance= createDeferredInstance(); @@ -210,10 +237,11 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass return new CPPDeferredClassInstance(this, args, getCompositeScope()); } + @Override public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException { - checkForIndexBinding(); - if (fIndexBinding != null) { - ICPPTemplateParameter[] params = fIndexBinding.getTemplateParameters(); + ICPPClassTemplate ib = getIndexBinding(); + if (ib != null) { + ICPPTemplateParameter[] params = ib.getTemplateParameters(); if (paramPos < params.length) { ICPPTemplateParameter param = params[paramPos]; return param.getDefaultValue(); @@ -221,21 +249,4 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements ICPPClass } return null; } - - private void checkForIndexBinding() { - if (checkedIndex) - return; - - checkedIndex= true; - IASTTranslationUnit tu; - if (definition != null) { - tu= definition.getTranslationUnit(); - } else { - tu= declarations[0].getTranslationUnit(); - } - IIndex index= tu.getIndex(); - if (index != null) { - fIndexBinding= (ICPPClassTemplate) index.adaptBinding(this); - } - } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java index da05c75aa7e..5a2698fb02c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplatePartialSpecializationSpecialization.java @@ -40,11 +40,13 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas fClassTemplate= template; } + @Override public ICPPTemplateParameter[] getTemplateParameters() { ICPPClassTemplatePartialSpecialization template = (ICPPClassTemplatePartialSpecialization) getSpecializedBinding(); return template.getTemplateParameters(); } + @Override public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { if (instances == null) instances = new ObjectMap(2); @@ -52,6 +54,7 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas instances.put(key, instance); } + @Override public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { if (instances != null) { String key= ASTTypeUtil.getArgumentListString(arguments, true); @@ -60,6 +63,7 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas return null; } + @Override public synchronized ICPPTemplateInstance[] getAllInstances() { if (instances != null) { ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()]; @@ -71,10 +75,12 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY; } + @Override public IBinding resolveTemplateParameter(ICPPTemplateParameter param) { return param; } + @Override public ICPPDeferredClassInstance asDeferredInstance() throws DOMException { if (fDeferredInstance == null) { ICPPTemplateArgument[] args = CPPTemplates.templateParametersAsArguments(getTemplateParameters()); @@ -83,10 +89,12 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas return fDeferredInstance; } + @Override public ICPPClassTemplate getPrimaryClassTemplate() { return fClassTemplate; } + @Override public ICPPTemplateArgument[] getTemplateArguments() throws DOMException { ICPPTemplateArgument[] args = ((ICPPClassTemplatePartialSpecialization) getSpecializedBinding()).getTemplateArguments(); final IBinding owner = getOwner(); @@ -96,10 +104,12 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas return CPPTemplates.instantiateArguments(args, getTemplateParameterMap(), -1, null); } + @Override public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) { } - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + @Override + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; } @@ -118,11 +128,13 @@ public class CPPClassTemplatePartialSpecializationSpecialization extends CPPClas return CPPTemplates.getArgumentMap(getPrimaryClassTemplate(), getTemplateParameterMap()); } + @Override @Deprecated public IType[] getArguments() throws DOMException { return CPPTemplates.getArguments(getTemplateArguments()); } + @Override public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException { // no default arguments for partial specializations return null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java index 8d142cffb2c..1e971a0d7a1 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java @@ -39,7 +39,8 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization super(orig, owner, argumentMap); } - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + @Override + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { if (fPartialSpecs == null) { ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding(); ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations(); @@ -52,6 +53,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization return fPartialSpecs; } + @Override public ICPPTemplateParameter[] getTemplateParameters() { // mstodo if we specialize the template parameters (because of its default values), it will // be less error prone to use the defaults. @@ -59,6 +61,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization return template.getTemplateParameters(); } + @Override public synchronized final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { if (instances == null) instances = new ObjectMap(2); @@ -66,6 +69,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization instances.put(key, instance); } + @Override public synchronized final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { if (instances != null) { String key= ASTTypeUtil.getArgumentListString(arguments, true); @@ -74,6 +78,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization return null; } + @Override public synchronized ICPPTemplateInstance[] getAllInstances() { if (instances != null) { ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()]; @@ -85,6 +90,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY; } + @Override public void addPartialSpecialization(ICPPClassTemplatePartialSpecialization spec) { } @@ -93,10 +99,12 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization return getName(); } + @Override public IBinding resolveTemplateParameter(ICPPTemplateParameter param) { return param; } + @Override public ICPPDeferredClassInstance asDeferredInstance() throws DOMException { if (fDeferredInstance == null) { ICPPTemplateArgument[] args = CPPTemplates.templateParametersAsArguments(getTemplateParameters()); @@ -105,6 +113,7 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization return fDeferredInstance; } + @Override public ICPPTemplateArgument getDefaultArgFromIndex(int paramPos) throws DOMException { return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java index 2c74766f7a4..4efe88076c5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionScope.java @@ -38,7 +38,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; */ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { - private CharArrayObjectMap labels = CharArrayObjectMap.EMPTY_MAP; + private CharArrayObjectMap labels = CharArrayObjectMap.emptyMap(); /** * @param physicalNode @@ -47,6 +47,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { super(physicalNode); } + @Override public EScopeKind getKind() { return EScopeKind.eLocal; } @@ -61,7 +62,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { return; if (labels == CharArrayObjectMap.EMPTY_MAP) - labels = new CharArrayObjectMap(2); + labels = new CharArrayObjectMap(2); labels.put(binding.getNameCharArray(), binding); } @@ -70,7 +71,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPScope#getBinding(int, char[]) */ public IBinding getBinding(IASTName name) { - return (IBinding) labels.get(name.getLookupKey()); + return labels.get(name.getLookupKey()); } /* (non-Javadoc) @@ -84,7 +85,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { for (int i = 0; i < labels.size(); i++) { char[] key = labels.keyAt(i); if (CharArrayUtils.equals(key, n)) { - bindings.add((IBinding) labels.get(key)); + bindings.add(labels.get(key)); } } @@ -108,7 +109,8 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope { /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionScope#getBodyScope() */ - public IScope getBodyScope() { + @Override + public IScope getBodyScope() { IASTFunctionDeclarator fnDtor = (IASTFunctionDeclarator) getPhysicalNode(); IASTNode parent = fnDtor.getParent(); if (parent instanceof IASTFunctionDefinition) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java index 507c814dd11..c914bbe3eb2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateDefinition.java @@ -21,6 +21,7 @@ import org.eclipse.cdt.core.dom.ast.IASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier; @@ -28,11 +29,14 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.index.IIndex; +import org.eclipse.cdt.core.index.IIndexBinding; import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; import org.eclipse.cdt.internal.core.dom.Linkage; @@ -48,6 +52,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC public CPPTemplateProblem(IASTNode node, int id, char[] arg) { super(node, id, arg); } + @Override public ICPPTemplateParameter[] getTemplateParameters() { return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY; } @@ -62,6 +67,10 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC private ICPPTemplateParameter[] templateParameters; private ObjectMap instances; + private ICPPClassTemplate indexBinding= null; + private boolean checkedIndex= false; + + public CPPTemplateDefinition(IASTName name) { if (name != null) { ASTNodeProperty prop = name.getPropertyInParent(); @@ -85,6 +94,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC } } + @Override public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { if (instances == null) instances = new ObjectMap(2); @@ -92,14 +102,46 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC instances.put(key, instance); } + @Override public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { if (instances != null) { String key= ASTTypeUtil.getArgumentListString(arguments, true); - return (ICPPTemplateInstance) instances.get(key); + ICPPTemplateInstance cand = (ICPPTemplateInstance) instances.get(key); + if (cand != null) + return cand; + } + + final ICPPClassTemplate ib = getIndexBinding(); + if (ib instanceof ICPPInstanceCache) { + ICPPTemplateInstance cand= ((ICPPInstanceCache) ib).getInstance(arguments); + if (cand instanceof IIndexBinding && + getTemplateName().getTranslationUnit().getIndexFileSet().containsDeclaration((IIndexBinding) cand)) { + return cand; + } } return null; } + protected ICPPClassTemplate getIndexBinding() { + if (!checkedIndex) { + checkedIndex= true; + IASTName name= getTemplateName(); + if (name != null) { + IASTTranslationUnit tu = name.getTranslationUnit(); + if (tu != null) { + IIndex index= tu.getIndex(); + if (index != null) { + IIndexBinding ib = index.adaptBinding(this); + if (ib instanceof ICPPClassTemplate) + indexBinding= (ICPPClassTemplate) ib; + } + } + } + } + return indexBinding; + } + + @Override public ICPPTemplateInstance[] getAllInstances() { if (instances != null) { ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()]; @@ -122,6 +164,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getName() */ + @Override public String getName() { return new String(getNameCharArray()); } @@ -129,6 +172,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getNameCharArray() */ + @Override public char[] getNameCharArray() { return getTemplateName().getSimpleID(); } @@ -136,6 +180,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.IBinding#getScope() */ + @Override public IScope getScope() { return CPPVisitor.getContainingScope(getTemplateName()); } @@ -143,6 +188,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedName() */ + @Override public String[] getQualifiedName() { return CPPVisitor.getQualifiedName(this); } @@ -150,6 +196,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#getQualifiedNameCharArray() */ + @Override public char[][] getQualifiedNameCharArray() { return CPPVisitor.getQualifiedNameCharArray(this); } @@ -157,6 +204,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding#isGloballyQualified() */ + @Override public boolean isGloballyQualified() { return true; } @@ -164,6 +212,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getParameters() */ + @Override public ICPPTemplateParameter[] getTemplateParameters() { if (templateParameters == null) { ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(getTemplateName()); @@ -186,6 +235,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDefinition(org.eclipse.cdt.core.dom.ast.IASTNode) */ + @Override public void addDefinition(IASTNode node) { if (node instanceof ICPPASTCompositeTypeSpecifier) { node = ((ICPPASTCompositeTypeSpecifier)node).getName(); @@ -203,6 +253,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#addDeclaration(org.eclipse.cdt.core.dom.ast.IASTNode) */ + @Override public void addDeclaration(IASTNode node) { if (node instanceof ICPPASTElaboratedTypeSpecifier) { node = ((ICPPASTElaboratedTypeSpecifier)node).getName(); @@ -227,6 +278,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC } } + @Override public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) { int pos= templateParameter.getParameterPosition(); @@ -286,6 +338,7 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDeclarations() */ + @Override public IASTNode[] getDeclarations() { return declarations; } @@ -293,14 +346,17 @@ public abstract class CPPTemplateDefinition extends PlatformObject implements IC /* (non-Javadoc) * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding#getDefinition() */ + @Override public IASTNode getDefinition() { return definition; } + @Override public ILinkage getLinkage() { return Linkage.CPP_LINKAGE; } + @Override public final IBinding getOwner() { IASTName templateName= getTemplateName(); if (templateName == null) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java index 93e731538bf..38afe6913f3 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplateTemplateParameter.java @@ -57,10 +57,12 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement fIsParameterPack= isPack; } + @Override public final boolean isParameterPack() { return fIsParameterPack; } + @Override public ICPPScope asScope() { if (unknownScope == null) { IASTName n = null; @@ -72,6 +74,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return unknownScope; } + @Override public ICPPTemplateParameter[] getTemplateParameters() { if (templateParameters == null) { ICPPASTTemplatedTypeTemplateParameter template = (ICPPASTTemplatedTypeTemplateParameter) getPrimaryDeclaration().getParent(); @@ -88,6 +91,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return templateParameters; } + @Override public IBinding resolveTemplateParameter(ICPPTemplateParameter templateParameter) { return templateParameter; } @@ -96,6 +100,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; } + @Override public IType getDefault() { IASTName[] nds = getDeclarations(); if (nds == null || nds.length == 0) @@ -120,6 +125,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return null; } + @Override public ICPPTemplateArgument getDefaultValue() { IType d= getDefault(); if (d == null) @@ -128,46 +134,59 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return new CPPTemplateArgument(d); } + @Override public ICPPBase[] getBases() { return ICPPBase.EMPTY_BASE_ARRAY; } + @Override public IField[] getFields() { return IField.EMPTY_FIELD_ARRAY; } + @Override public IField findField(String name) { return null; } + @Override public ICPPField[] getDeclaredFields() { return ICPPField.EMPTY_CPPFIELD_ARRAY; } + @Override public ICPPMethod[] getMethods() { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } + @Override public ICPPMethod[] getAllDeclaredMethods() { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } + @Override public ICPPMethod[] getDeclaredMethods() { return ICPPMethod.EMPTY_CPPMETHOD_ARRAY; } + @Override public ICPPConstructor[] getConstructors() { return ICPPConstructor.EMPTY_CONSTRUCTOR_ARRAY; } + @Override public IBinding[] getFriends() { return IBinding.EMPTY_BINDING_ARRAY; } + @Override public ICPPClassType[] getNestedClasses() { return ICPPClassType.EMPTY_CLASS_ARRAY; } + @Override public int getKey() { return 0; } + @Override public IScope getCompositeScope() { return null; } - public boolean isSameType(IType type) { + @Override + public boolean isSameType(IType type) { if (type == this) return true; if (type instanceof ITypedef) @@ -178,10 +197,12 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return getParameterID() == ((ICPPTemplateParameter) type).getParameterID(); } - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + @Override + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; } + @Override public final void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { if (instances == null) instances = new ObjectMap(2); @@ -189,6 +210,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement instances.put(key, instance); } + @Override public final ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { if (instances != null) { String key= ASTTypeUtil.getArgumentListString(arguments, true); @@ -197,6 +219,7 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return null; } + @Override public ICPPTemplateInstance[] getAllInstances() { if (instances != null) { ICPPTemplateInstance[] result= new ICPPTemplateInstance[instances.size()]; @@ -208,14 +231,17 @@ public class CPPTemplateTemplateParameter extends CPPTemplateParameter implement return ICPPTemplateInstance.EMPTY_TEMPLATE_INSTANCE_ARRAY; } + @Override public IASTName getUnknownName() { return new CPPASTName(getNameCharArray()); } + @Override public boolean isAnonymous() { return false; } + @Override public ICPPDeferredClassInstance asDeferredInstance() { return null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java index b1377c38173..d32e6cd443d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownScope.java @@ -44,7 +44,7 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { * This field needs to be protected when used in PDOMCPPUnknownScope, * don't use it outside of {@link #getOrCreateBinding(IASTName, int)} */ - private CharArrayObjectMap map; + private CharArrayObjectMap map; public CPPUnknownScope(ICPPUnknownBinding binding, IASTName name) { super(); @@ -57,41 +57,26 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { return EScopeKind.eClassType; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getScopeName() - */ @Override public IName getScopeName() { return scopeName; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getParent() - */ @Override public IScope getParent() throws DOMException { return binding.getScope(); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#find(java.lang.String) - */ @Override public IBinding[] find(String name) { - return null; + return IBinding.EMPTY_BINDING_ARRAY; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getPhysicalNode() - */ @Override public IASTNode getPhysicalNode() { return scopeName; } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#addName(org.eclipse.cdt.core.dom.ast.IASTName) - */ @Override public void addName(IASTName name) { } @@ -101,9 +86,6 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { return getBinding(name, resolve, IIndexFileSet.EMPTY); } - /* (non-Javadoc) - * @see org.eclipse.cdt.core.dom.ast.IScope#getBinding(org.eclipse.cdt.core.dom.ast.IASTName, boolean) - */ @Override public IBinding getBinding(final IASTName name, boolean resolve, IIndexFileSet fileSet) { boolean type= false; @@ -152,10 +134,10 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { protected IBinding getOrCreateBinding(final IASTName name, int idx) { if (map == null) - map = new CharArrayObjectMap(2); + map = new CharArrayObjectMap(2); final char[] c = name.getLookupKey(); - IBinding[] o = (IBinding[]) map.get(c); + IBinding[] o = map.get(c); if (o == null) { o = new IBinding[3]; map.put(c, o); @@ -210,9 +192,6 @@ public class CPPUnknownScope implements ICPPInternalUnknownScope { // do nothing, this is part of template magic and not a normal scope } - /* (non-Javadoc) - * @see org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope#getUnknownBinding() - */ @Override public ICPPBinding getScopeBinding() { return binding; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java index 82ffa89a563..66a3f4e395b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/BaseClassLookup.java @@ -320,7 +320,9 @@ class BaseClassLookup { return; fCollected= true; - data.foundItems = CPPSemantics.mergePrefixResults((CharArrayObjectMap) data.foundItems, fBindings, true); + @SuppressWarnings("unchecked") + final CharArrayObjectMap resultMap = (CharArrayObjectMap) data.foundItems; + data.foundItems = CPPSemantics.mergePrefixResults(resultMap, fBindings, true); for (int i= 0; i < fChildren.size(); i++) { BaseClassLookup child = fChildren.get(i); child.collectResultForContentAssist(data); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java index 102acf013a7..8641f5e5c6e 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPSemantics.java @@ -2276,7 +2276,8 @@ public class CPPSemantics { private static ICPPFunction[] selectByArgumentCount(LookupData data, ICPPFunction[] functions) throws DOMException { assert data.forDeclaration() == null; - int argumentCount = data.getFunctionArgumentCount(); + final int argumentCount = data.getFunctionArgumentCount(); + final int packExpansionCount= data.getFunctionArgumentPackExpansionCount(); // Trim the list down to the set of viable functions ICPPFunction[] result= new ICPPFunction[functions.length]; @@ -2300,11 +2301,11 @@ public class CPPSemantics { numArgs--; boolean ok; - if (numArgs > numPars) { - // more arguments than parameters --> need ellipsis or parameter pack + if (numArgs-packExpansionCount > numPars) { + // More arguments than parameters --> need ellipsis or parameter pack ok= fn.takesVarArgs() || fn.hasParameterPack(); } else { - ok = numArgs >= fn.getRequiredArgumentCount(); + ok = numArgs >= fn.getRequiredArgumentCount() || packExpansionCount > 0; } if (ok) { if (fn instanceof IIndexBinding) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java index bdc7c70adcf..c8255cfca5a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPTemplates.java @@ -98,6 +98,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTQueries; import org.eclipse.cdt.internal.core.dom.parser.IASTInternalScope; import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer; import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding; +import org.eclipse.cdt.internal.core.dom.parser.ProblemType; import org.eclipse.cdt.internal.core.dom.parser.Value; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType; @@ -1143,7 +1144,7 @@ public class CPPTemplates { IType newMemberOfClass = instantiateType(memberOfClass, tpMap, packOffset, within); if (!(newMemberOfClass instanceof ICPPClassType || newMemberOfClass instanceof UniqueType || newMemberOfClass instanceof ICPPUnknownBinding)) { - newMemberOfClass = memberOfClass; + return new ProblemType(ISemanticProblem.BINDING_INVALID_TYPE); } if (newNestedType != nestedType || newMemberOfClass != memberOfClass) { return new CPPPointerToMemberType(newNestedType, newMemberOfClass, @@ -2342,6 +2343,8 @@ public class CPPTemplates { } } } + } else if (t != owner) { + return new ProblemBinding(unknown.getUnknownName(), IProblemBinding.SEMANTIC_BAD_SCOPE); } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index d5e531c20ed..bb05ecc1157 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -1927,7 +1927,7 @@ public class CPPVisitor extends ASTQueries { beginExpr= expr.copy(); } else if (type instanceof ICPPClassType) { ICPPClassType ct= (ICPPClassType) type; - if (ct.getCompositeScope().find(BEGIN_STR).length > 0) { + if (CPPSemantics.findBindings(ct.getCompositeScope(), BEGIN_STR, true).length > 0) { final CPPASTName name = new CPPASTName(BEGIN); name.setOffset(((ASTNode) forInit).getOffset()); beginExpr= new CPPASTFunctionCallExpression( diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java index 201d5c4a69d..90bbd338099 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/LookupData.java @@ -52,6 +52,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTInitializerList; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPackExpansionExpression; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId; @@ -341,7 +342,7 @@ public class LookupData { if (foundItems instanceof Object[]) return ((Object[]) foundItems).length != 0; if (foundItems instanceof CharArrayObjectMap) - return ((CharArrayObjectMap) foundItems).size() != 0; + return ((CharArrayObjectMap) foundItems).size() != 0; return false; } @@ -533,6 +534,17 @@ public class LookupData { return 0; } + public int getFunctionArgumentPackExpansionCount() { + int count= 0; + if (functionArgs != null) { + for (IASTInitializerClause arg : functionArgs) { + if (arg instanceof ICPPASTPackExpansionExpression) + count++; + } + } + return count; + } + public boolean hasFunctionArguments() { return functionArgs != null; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java index d80a85d3c36..81d7ddfdac5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/TemplateArgumentDeduction.java @@ -293,7 +293,7 @@ public class TemplateArgumentDeduction { p= getArgumentTypeForDeduction(p, a instanceof ICPPReferenceType); a= SemanticUtil.getNestedType(a, SemanticUtil.REF | SemanticUtil.TDEF); TemplateArgumentDeduction deduct= new TemplateArgumentDeduction(tmplParams, null, map, 0); - if (!deduct.fromType(p, a, false)) { + if (!deduct.fromType(p, a, true)) { return null; } @@ -664,18 +664,24 @@ public class TemplateArgumentDeduction { } else if (p instanceof ICPPPointerToMemberType) { if (!(a instanceof ICPPPointerToMemberType)) return false; - if (!fromType(((ICPPPointerToMemberType) p).getMemberOfClass(), - ((ICPPPointerToMemberType) a).getMemberOfClass(), false)) { + final ICPPPointerToMemberType ptrP = (ICPPPointerToMemberType) p; + final ICPPPointerToMemberType ptrA = (ICPPPointerToMemberType) a; + if (!allowCVQConversion && (ptrP.isConst() != ptrA.isConst() || ptrP.isVolatile() != ptrA.isVolatile())) + return false; + if (!fromType(ptrP.getMemberOfClass(), ptrA.getMemberOfClass(), false)) { return false; } - p = ((ICPPPointerToMemberType) p).getType(); - a = ((ICPPPointerToMemberType) a).getType(); + p = ptrP.getType(); + a = ptrA.getType(); } else if (p instanceof IPointerType) { - if (!(a instanceof IPointerType)) { + if (!(a instanceof IPointerType)) return false; - } - p = ((IPointerType) p).getType(); - a = ((IPointerType) a).getType(); + final IPointerType ptrP = (IPointerType) p; + final IPointerType ptrA = (IPointerType) a; + if (!allowCVQConversion && (ptrP.isConst() != ptrA.isConst() || ptrP.isVolatile() != ptrA.isVolatile())) + return false; + p = ptrP.getType(); + a = ptrA.getType(); } else if (p instanceof ICPPReferenceType) { if (!(a instanceof ICPPReferenceType)) { return false; @@ -730,10 +736,10 @@ public class TemplateArgumentDeduction { if (remaining != CVQualifier.NONE) { a= SemanticUtil.addQualifiers(a, remaining.isConst(), remaining.isVolatile(), remaining.isRestrict()); } - } else if (p instanceof IFunctionType) { - if (!(a instanceof IFunctionType)) + } else if (p instanceof ICPPFunctionType) { + if (!(a instanceof ICPPFunctionType)) return false; - return fromFunctionType((IFunctionType) p, (IFunctionType) a); + return fromFunctionType((ICPPFunctionType) p, (ICPPFunctionType) a); } else if (p instanceof ICPPTemplateParameter) { ICPPTemplateArgument current= fDeducedArgs.getArgument(((ICPPTemplateParameter) p).getParameterID(), fPackOffset); if (current != null) { @@ -820,7 +826,10 @@ public class TemplateArgumentDeduction { return true; } - private boolean fromFunctionType(IFunctionType ftp, IFunctionType fta) throws DOMException { + private boolean fromFunctionType(ICPPFunctionType ftp, ICPPFunctionType fta) throws DOMException { + if (ftp.isConst() != fta.isConst() || ftp.isVolatile() != fta.isVolatile()) + return false; + if (!fromType(ftp.getReturnType(), fta.getReturnType(), false)) return false; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java index 7d7b5b74e5f..642cdb1d414 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/ASTLiteralNode.java @@ -30,7 +30,7 @@ public class ASTLiteralNode implements IASTNode { public ASTLiteralNode(String code) { fCode= code; } - + @Override public String getRawSignature() { return fCode; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java index dc19453bfbc..83dd18fdf43 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriter.java @@ -12,6 +12,8 @@ *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.astwriter; +import java.util.List; + import org.eclipse.cdt.core.dom.ast.IASTASMDeclaration; import org.eclipse.cdt.core.dom.ast.IASTCompoundStatement; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; @@ -144,6 +146,24 @@ public class ASTWriter { * @return true if the blank line between the nodes is needed. */ public static boolean requireBlankLineInBetween(IASTNode node1, IASTNode node2) { + if (node1 instanceof ContainerNode) { + List nodes = ((ContainerNode) node1).getNodes(); + if (!nodes.isEmpty()) { + node1 = nodes.get(nodes.size() - 1); + } + } + if (node2 instanceof ContainerNode) { + List nodes = ((ContainerNode) node2).getNodes(); + if (!nodes.isEmpty()) { + node2 = nodes.get(0); + } + } + while (node1 instanceof ICPPASTTemplateDeclaration) { + node1 = ((ICPPASTTemplateDeclaration) node1).getDeclaration(); + } + while (node2 instanceof ICPPASTTemplateDeclaration) { + node2 = ((ICPPASTTemplateDeclaration) node2).getDeclaration(); + } if (node1 instanceof ICPPASTVisibilityLabel && node2 instanceof ICPPASTVisibilityLabel) { return true; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java index 4ff5321d55a..cd1e5c363d9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/astwriter/ASTWriterVisitor.java @@ -132,6 +132,7 @@ public class ASTWriterVisitor extends ASTVisitor { } public void visit(ASTLiteralNode lit) { + insertBlankLineIfNeeded(lit); scribe.print(lit.getRawSignature()); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java index 2f98b27c77d..db3ed821391 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/ChangeGenerator.java @@ -58,16 +58,14 @@ import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationMap; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModificationStore; import org.eclipse.cdt.internal.core.dom.rewrite.ASTRewriteAnalyzer; 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.ProblemRuntimeException; import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap; import org.eclipse.cdt.internal.core.dom.rewrite.util.FileHelper; -import org.eclipse.cdt.internal.core.resources.ResourceLookup; import org.eclipse.cdt.internal.formatter.CCodeFormatter; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.Assert; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.IDocument; @@ -77,7 +75,6 @@ import org.eclipse.jface.text.TextUtilities; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.CompositeChange; import org.eclipse.ltk.core.refactoring.TextFileChange; -import org.eclipse.text.edits.InsertEdit; import org.eclipse.text.edits.MalformedTreeException; import org.eclipse.text.edits.MultiTextEdit; import org.eclipse.text.edits.ReplaceEdit; @@ -557,36 +554,51 @@ public class ChangeGenerator extends ASTVisitor { } private void handleAppends(IASTTranslationUnit tu) { - ASTWriter synthWriter = new ASTWriter(); - synthWriter.setModificationStore(modificationStore); + List modifications = getModifications(tu, ModificationKind.APPEND_CHILD); + if (modifications.isEmpty()) + return; - for (ASTModification modification : getModifications(tu, ModificationKind.APPEND_CHILD)) { - IASTNode targetNode = modification.getTargetNode(); - IASTFileLocation targetLocation = targetNode.getFileLocation(); - String currentFile = targetLocation.getFileName(); - IPath implPath = new Path(currentFile); - IFile relevantFile= ResourceLookup.selectFileForLocation(implPath, null); - if (relevantFile == null || !relevantFile.exists()) { // If not in workspace or local file system - throw new UnhandledASTModificationException(modification); + IASTNode prevNode = null; + IASTDeclaration[] declarations = tu.getDeclarations(); + if (declarations.length != 0) { + prevNode = declarations[declarations.length - 1]; + } else { + IASTPreprocessorStatement[] preprocessorStatements = tu.getAllPreprocessorStatements(); + if (preprocessorStatements.length != 0) { + prevNode = preprocessorStatements[preprocessorStatements.length - 1]; } - MultiTextEdit edit; - if (changes.containsKey(relevantFile)) { - edit = changes.get(relevantFile); - } else { - edit = new MultiTextEdit(); - changes.put(relevantFile, edit); - } - String code = synthWriter.write(modification.getNewNode(), commentMap); - - if (targetNode instanceof IASTTranslationUnit && - ((IASTTranslationUnit) targetNode).getDeclarations().length > 0) { - IASTTranslationUnit targetTu = (IASTTranslationUnit) targetNode; - IASTDeclaration lastDecl = targetTu.getDeclarations()[targetTu.getDeclarations().length - 1]; - targetLocation = lastDecl.getFileLocation(); - } - String lineDelimiter = FileHelper.determineLineDelimiter(tu.getRawSignature()); - edit.addChild(new InsertEdit(endOffset(targetLocation), lineDelimiter + lineDelimiter + code)); } + int offset = prevNode != null ? getEndOffsetIncludingComments(prevNode) : 0; + String source = tu.getRawSignature(); + int endOffset = skipTrailingBlankLines(source, offset); + + ChangeGeneratorWriterVisitor writer = + new ChangeGeneratorWriterVisitor(modificationStore, commentMap); + IASTNode newNode = null; + for (ASTModification modification : modifications) { + boolean first = newNode == null; + newNode = modification.getNewNode(); + if (first) { + if (prevNode != null) { + writer.newLine(); + if (ASTWriter.requireBlankLineInBetween(prevNode, newNode)) { + writer.newLine(); + } + } + } + newNode.accept(writer); + } + if (prevNode != null) { + IASTNode nextNode = getNextSiblingOrPreprocessorNode(prevNode); + if (nextNode != null && ASTWriter.requireBlankLineInBetween(newNode, nextNode)) { + writer.newLine(); + } + } + + String code = writer.toString(); + IFile file = FileHelper.getFileFromNode(tu); + MultiTextEdit parentEdit = getEdit(tu, file); + parentEdit.addChild(new ReplaceEdit(offset, endOffset - offset, code)); } /** @@ -1016,6 +1028,13 @@ public class ChangeGenerator extends ASTVisitor { if (modification.getKind() != ModificationKind.APPEND_CHILD) return false; IASTNode node = modification.getNewNode(); + if (node instanceof ContainerNode) { + for (IASTNode containedNode : ((ContainerNode) node).getNodes()) { + if (!(containedNode instanceof IASTDeclaration || containedNode instanceof IASTStatement)) + return false; + } + return true; + } return node instanceof IASTDeclaration || node instanceof IASTStatement; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/UnhandledASTModificationException.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/UnhandledASTModificationException.java index fee2ecd60b1..f39783711e9 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/UnhandledASTModificationException.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/rewrite/changegenerator/UnhandledASTModificationException.java @@ -7,15 +7,13 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.core.dom.rewrite.changegenerator; import org.eclipse.cdt.internal.core.dom.rewrite.ASTModification; public class UnhandledASTModificationException extends RuntimeException { - - private static final long serialVersionUID = 1L; private final ASTModification illegalModification; public UnhandledASTModificationException(ASTModification illegalModification) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java index ccfc664eed6..1f4d1358277 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedFileContentProvider.java @@ -47,7 +47,6 @@ import org.eclipse.core.runtime.CoreException; * Code reader factory, that fakes code readers for header files already stored in the index. */ public final class IndexBasedFileContentProvider extends InternalFileContentProvider { - private static final class NeedToParseException extends Exception {} private static final String GAP = "__gap__"; //$NON-NLS-1$ private final IIndex fIndex; @@ -135,7 +134,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv // Report pragma once inclusions, only if no exception was thrown. fPragmaOnce.putAll(newPragmaOnce); return new InternalFileContent(path, macros, directives, files, toList(preLoaded)); - } catch (NeedToParseException e) { + } catch (DependsOnOutdatedFileException e) { } } } catch (CoreException e) { @@ -188,7 +187,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv Map newPragmaOnce, LinkedHashSet preLoaded, List files, List macros, List usingDirectives, - Set preventRecursion) throws CoreException, NeedToParseException { + Set preventRecursion) throws CoreException, DependsOnOutdatedFileException { if (file.equals(stopAt)) return true; @@ -211,8 +210,6 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv final Object[] pds; if (fRelatedIndexerTask != null) { IndexFileContent content= fRelatedIndexerTask.getFileContent(fLinkage, ifl, file); - if (content == null) - throw new NeedToParseException(); uds= content.getUsingDirectives(); pds= content.getPreprocessingDirectives(); } else { @@ -252,7 +249,7 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv @Override public InternalFileContent getContentForContextToHeaderGap(String path, - IMacroDictionary macroDictionary) { + IMacroDictionary macroDictionary) throws DependsOnOutdatedFileException { if (fContextToHeaderGap == null) { return null; } @@ -268,12 +265,8 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv ArrayList macros= new ArrayList(); ArrayList directives= new ArrayList(); LinkedHashSet preLoaded= new LinkedHashSet(); - try { - if (!collectFileContent(contextFile, targetFile, newPragmaOnce, preLoaded, - filesIncluded, macros, directives, new HashSet())) { - return null; - } - } catch (NeedToParseException e) { + if (!collectFileContent(contextFile, targetFile, newPragmaOnce, preLoaded, + filesIncluded, macros, directives, new HashSet())) { return null; } @@ -302,4 +295,14 @@ public final class IndexBasedFileContentProvider extends InternalFileContentProv } return IIndexFile.EMPTY_FILE_ARRAY; } + + @Override + public String getContextPath() { + if (fContextToHeaderGap != null) + try { + return fPathResolver.getASTPath(fContextToHeaderGap[0].getLocation()); + } catch (CoreException e) { + } + return null; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java index 63d63da979e..455ea46095d 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplate.java @@ -36,7 +36,8 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType super(cf, ct); } - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + @Override + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { try { final CIndex cIndex = (CIndex) ((CPPCompositesFactory) cf).getContext(); IIndexFragmentBinding[] bindings = cIndex.findEquivalentBindings(rbinding); @@ -59,22 +60,27 @@ public class CompositeCPPClassTemplate extends CompositeCPPClassType } } + @Override public ICPPTemplateParameter[] getTemplateParameters() { return TemplateInstanceUtil.convert(cf, ((ICPPClassTemplate) rbinding).getTemplateParameters()); } + @Override public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments); } + @Override public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance); } + @Override public ICPPTemplateInstance[] getAllInstances() { return CompositeInstanceCache.getCache(cf, rbinding).getAllInstances(); } + @Override public ICPPDeferredClassInstance asDeferredInstance() throws DOMException { CompositeInstanceCache cache= CompositeInstanceCache.getCache(cf, rbinding); synchronized (cache) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplateSpecialization.java index 112644297ae..4d419dd02a6 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPClassTemplateSpecialization.java @@ -32,8 +32,8 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInstanceCache{ super(cf, rbinding); } - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() - throws DOMException { + @Override + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { ICPPClassTemplatePartialSpecialization[] result= ((ICPPClassTemplate) rbinding).getPartialSpecializations(); for (int i= 0; i < result.length; i++) { result[i]= (ICPPClassTemplatePartialSpecialization) cf.getCompositeBinding((IIndexFragmentBinding)result[i]); @@ -41,23 +41,28 @@ CompositeCPPClassSpecialization implements ICPPClassTemplate, ICPPInstanceCache{ return result; } + @Override public ICPPTemplateParameter[] getTemplateParameters() { return TemplateInstanceUtil.convert(cf, ((ICPPClassTemplate) rbinding).getTemplateParameters()); } + @Override public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { return CompositeInstanceCache.getCache(cf, rbinding).getInstance(arguments); } + @Override public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { CompositeInstanceCache.getCache(cf, rbinding).addInstance(arguments, instance); } + @Override public ICPPTemplateInstance[] getAllInstances() { return CompositeInstanceCache.getCache(cf, rbinding).getAllInstances(); } + @Override public ICPPDeferredClassInstance asDeferredInstance() throws DOMException { CompositeInstanceCache cache= CompositeInstanceCache.getCache(cf, rbinding); synchronized (cache) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java index 0cd5d9e9944..89a574118af 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java @@ -57,6 +57,7 @@ import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.FileVersion; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; +import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider.DependsOnOutdatedFileException; import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions; import org.eclipse.cdt.internal.core.parser.scanner.MacroDefinitionParser.InvalidMacroDefinitionException; import org.eclipse.cdt.internal.core.parser.scanner.ScannerContext.BranchKind; @@ -133,7 +134,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { @Override public boolean visitValue(char[] macro, char[] value) { PreprocessorMacro m = fMacroDictionary.get(macro); - return m != null && CharArrayUtils.equals(m.getExpansion(), value); + return m != null && CharArrayUtils.equals(SignificantMacros.shortenValue(m.getExpansion()), value); } private boolean isDefined(char[] macro) { @@ -246,7 +247,6 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { private final LocationMap fLocationMap; private CharArraySet fPreventInclusion= new CharArraySet(0); - private final Lexer fRootLexer; private final ScannerContext fRootContext; protected ScannerContext fCurrentContext; @@ -297,13 +297,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { fMacroExpander= new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions); fIncludeFileResolutionHeuristics= fFileContentProvider.getIncludeHeuristics(); - final String filePath= fRootContent.getFileLocation(); - configureIncludeSearchPath(new File(filePath).getParentFile(), info); + String contextPath= fFileContentProvider.getContextPath(); + if (contextPath == null) { + contextPath= fRootContent.getFileLocation(); + } + configureIncludeSearchPath(new File(contextPath).getParentFile(), info); setupMacroDictionary(configuration, info, language); - ILocationCtx ctx= fLocationMap.pushTranslationUnit(filePath, fRootContent.getSource()); - fRootLexer= new Lexer(fRootContent.getSource(), fLexOptions, this, this); - fRootContext= fCurrentContext= new ScannerContext(ctx, null, fRootLexer); + ILocationCtx ctx= fLocationMap.pushTranslationUnit(fRootContent.getFileLocation(), fRootContent.getSource()); + Lexer lexer = new Lexer(fRootContent.getSource(), fLexOptions, this, this); + fRootContext= fCurrentContext= new ScannerContext(ctx, null, lexer); if (info instanceof IExtendedScannerInfo) { final IExtendedScannerInfo einfo= (IExtendedScannerInfo) info; fPreIncludedFiles= new String[][] { einfo.getMacroFiles(), einfo.getIncludeFiles() }; @@ -346,11 +349,11 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { @Override public void setContentAssistMode(int offset) { fContentAssistLimit= offset; - fRootLexer.setContentAssistMode(offset); + fRootContext.getLexer().setContentAssistMode(offset); } public boolean isContentAssistMode() { - return fRootLexer.isContentAssistMode(); + return fRootContext.getLexer().isContentAssistMode(); } @Override @@ -466,10 +469,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { fPreIncludedFiles= null; } final String location = fLocationMap.getTranslationUnitPath(); - InternalFileContent content= fFileContentProvider.getContentForContextToHeaderGap(location, - fMacroDictionaryFacade); + InternalFileContent content; + try { + content = fFileContentProvider.getContentForContextToHeaderGap(location, + fMacroDictionaryFacade); + } catch (DependsOnOutdatedFileException e) { + // Abort the parser, handled by the abstract indexer task. + throw new RuntimeException(e); + } if (content != null && content.getKind() == InclusionKind.FOUND_IN_INDEX) { - processInclusionFromIndex(0, location, content, false); + processInclusionFromIndex(0, content, false); } detectIncludeGuard(location, fRootContent.getSource(), fRootContext); @@ -577,7 +586,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } try { - t= internalFetchToken(fRootContext, CHECK_NUMBERS, false); + t= internalFetchToken(fRootContext, CHECK_NUMBERS | REPORT_SIGNIFICANT_MACROS | IGNORE_UNDEFINED_SIGNIFICANT_MACROS, false); } catch (OffsetLimitReachedException e) { fHandledCompletion= true; throw e; @@ -1463,7 +1472,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } catch (CoreException e) { } - processInclusionFromIndex(poundOffset, path, fi, true); + processInclusionFromIndex(poundOffset, fi, true); break; case USE_SOURCE: // Will be parsed @@ -1502,7 +1511,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable { } } - private void processInclusionFromIndex(int offset, String path, InternalFileContent fi, boolean updateContext) { + private void processInclusionFromIndex(int offset, InternalFileContent fi, boolean updateContext) { List mdefs= fi.getMacroDefinitions(); for (IIndexMacro macro : mdefs) { addMacroDefinition(macro); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java index 82668c6293b..1899ef3bc29 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/InternalFileContentProvider.java @@ -25,6 +25,7 @@ import org.eclipse.cdt.core.index.IIndexFileLocation; import org.eclipse.cdt.core.parser.ISignificantMacros; import org.eclipse.cdt.core.parser.IncludeFileContentProvider; import org.eclipse.cdt.internal.core.dom.IIncludeFileResolutionHeuristics; +import org.eclipse.cdt.internal.core.index.IIndexFragmentFile; import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.InclusionKind; @@ -32,6 +33,15 @@ import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContent.Inclusio * Internal implementation of the file content providers */ public abstract class InternalFileContentProvider extends IncludeFileContentProvider { + public static final class DependsOnOutdatedFileException extends Exception { + public final Object fTu; + public final IIndexFragmentFile fIndexFile; + public DependsOnOutdatedFileException(Object tu, IIndexFragmentFile file) { + fTu= tu; + fIndexFile= file; + } + } + private IIncludeFileResolutionHeuristics fIncludeResolutionHeuristics; private final Map fPragmaOnce= new HashMap(); private final Map> fLoadedVersions= new HashMap>(); @@ -64,9 +74,10 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv * or null if this cannot be done. * @param filePath the absolute location of the file. * @param macroDictionary macros defined at the inclusion point. + * @throws DependsOnOutdatedFileException */ public InternalFileContent getContentForContextToHeaderGap(String filePath, - IMacroDictionary macroDictionary) { + IMacroDictionary macroDictionary) throws DependsOnOutdatedFileException { return null; } @@ -123,5 +134,12 @@ public abstract class InternalFileContentProvider extends IncludeFileContentProv } list.add(sig); } + } + + /** + * Return the path of the context of null, if there is no context. + */ + public String getContextPath() { + return null; } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java index 256fb07825e..7b387bc886b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/ScannerContext.java @@ -330,14 +330,29 @@ final class ScannerContext { } public void internalModification(char[] macroName) { - if (fInternalModifications != null) - fInternalModifications.put(macroName); + final CharArraySet collector = findModificationCollector(); + if (collector != null) + collector.put(macroName); } + private CharArraySet findModificationCollector() { + ScannerContext ctx= this; + do { + final CharArraySet collector = ctx.fInternalModifications; + if (collector != null) + return collector; + ctx= ctx.getParent(); + } while (ctx != null); + + return null; + } + public void significantMacro(IMacroBinding macro) { final char[] macroName= macro.getNameCharArray(); if (fInternalModifications != null && !fInternalModifications.containsKey(macroName)) { - fSignificantMacros.put(macroName, macro.getExpansion()); + final char[] expansion = macro.getExpansion(); + if (expansion != null) + fSignificantMacros.put(macroName, SignificantMacros.shortenValue(expansion)); } } @@ -370,23 +385,28 @@ final class ScannerContext { return; if (fParent != null) { - final CharArraySet local = fParent.fInternalModifications; - if (local != null) { - final CharArrayObjectMap significant = fParent.fSignificantMacros; - for (int i=0; i significant = fParent.fSignificantMacros; + for (int i=0; inull string is encoded as a single comma. */ public class SignificantMacros implements ISignificantMacros { - public static final char[] UNDEFINED = {}; - public static final char[] DEFINED = {}; - private static final int ENCODED_UNDEFINED = Character.MAX_VALUE; - private static final int ENCODED_DEFINED = Character.MAX_VALUE-1; + public static final char[] DEFINED = {0}; + public static final char[] UNDEFINED = {1}; private static final Comparator SORTER = new Comparator() { + @Override public int compare(Object o1, Object o2) { return CharArrayUtils.compare((char[])o1, (char[])o2); } @@ -58,13 +57,7 @@ public class SignificantMacros implements ISignificantMacros { char[] name= (char[]) key; char[] value= sigMacros.get(name); buffer.append((char) name.length).append(name); - if (value == DEFINED) { - buffer.append((char) ENCODED_DEFINED); - } else if (value == UNDEFINED) { - buffer.append((char) ENCODED_UNDEFINED); - } else { - buffer.append((char) value.length).append(value); - } + buffer.append((char) value.length).append(value); } int len= buffer.length(); char[] result= new char[len]; @@ -93,6 +86,7 @@ public class SignificantMacros implements ISignificantMacros { && CharArrayUtils.equals(fEncoded, ((SignificantMacros) obj).fEncoded); } + @Override public boolean accept(IVisitor visitor) { final char[] encoded = fEncoded; final int len = encoded.length; @@ -102,28 +96,27 @@ public class SignificantMacros implements ISignificantMacros { int v= i + len1; if (v >= len) break; + final int len2 = encoded[v++]; + if (v+len2 > len) + break; char[] macro= extract(encoded, i, len1); - final int len2 = encoded[v++]; - switch(len2) { - case ENCODED_UNDEFINED: - i= v; - if (!visitor.visitUndefined(macro)) - return false; - break; - case ENCODED_DEFINED: - i= v; - if (!visitor.visitDefined(macro)) - return false; - break; - default: - i= v+len2; - if (i > len) - break; - if (!visitor.visitValue(macro, extract(encoded, v, len2))) - return false; - break; - } + i= v+len2; + if (len2 == 1) { + if (encoded[v] == UNDEFINED[0]) { + if (!visitor.visitUndefined(macro)) + return false; + continue; + } + if (encoded[v] == DEFINED[0]) { + if (!visitor.visitDefined(macro)) + return false; + continue; + } + } + final char[] value = extract(encoded, v, len2); + if (!visitor.visitValue(macro, value)) + return false; } return true; } @@ -134,6 +127,7 @@ public class SignificantMacros implements ISignificantMacros { return value; } + @Override public char[] encode() { return fEncoded; } @@ -147,14 +141,17 @@ public class SignificantMacros implements ISignificantMacros { final StringBuilder buf= new StringBuilder(); buf.append('{'); accept(new IVisitor() { + @Override public boolean visitValue(char[] macro, char[] value) { buf.append(macro).append('=').append(value).append(','); return true; } + @Override public boolean visitUndefined(char[] macro) { buf.append(macro).append('=').append("null,"); return true; } + @Override public boolean visitDefined(char[] macro) { buf.append(macro).append('=').append("*,"); return true; @@ -166,4 +163,19 @@ public class SignificantMacros implements ISignificantMacros { buf.append('}'); return buf.toString(); } + + public static char[] shortenValue(char[] expansion) { + if (expansion.length <= 16) + return expansion; + char[] result= new char[16]; + System.arraycopy(expansion, 0, result, 0, 8); + StreamHasher hasher= new StreamHasher(); + hasher.addChunk(expansion); + long hash= hasher.computeHash(); + for(int i= 0; i<8; i++) { + result[8+i]= (char) (hash & 0xff); + hash= hash >> 1; + } + return result; + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java index 841882a5e13..ffc4d33176f 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/AbstractIndexerTask.java @@ -24,6 +24,7 @@ import java.util.LinkedHashSet; import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Set; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.IPDOMIndexerTask; @@ -54,6 +55,7 @@ import org.eclipse.cdt.internal.core.index.IWritableIndex; import org.eclipse.cdt.internal.core.index.IndexBasedFileContentProvider; import org.eclipse.cdt.internal.core.parser.IMacroDictionary; import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider; +import org.eclipse.cdt.internal.core.parser.scanner.InternalFileContentProvider.DependsOnOutdatedFileException; import org.eclipse.cdt.internal.core.parser.util.LRUCache; import org.eclipse.cdt.utils.EFSExtensionManager; import org.eclipse.core.runtime.CoreException; @@ -783,7 +785,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return; final Object tu = locTask.fTu; final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); - parseFile(tu, linkageID, ifl, scannerInfo, null, monitor); + parseFile(tu, getLanguage(tu, linkageID), ifl, scannerInfo, null, monitor); } } @@ -817,7 +819,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return; final Object tu = locTask.fTu; final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, tu); - parseFile(tu, linkageID, ifl, scannerInfo, null, monitor); + parseFile(tu, getLanguage(tu, linkageID), ifl, scannerInfo, null, monitor); if (locTask.isCompleted()) it.remove(); @@ -870,8 +872,24 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return; final IScannerInfo scannerInfo= fResolver.getBuildConfiguration(linkageID, contextTu); - FileContext ctx= new FileContext(ctxFile, headerFile); - parseFile(tu, linkageID, ifl, scannerInfo, ctx, monitor); + final AbstractLanguage language = getLanguage(contextTu, linkageID); + final FileContext ctx= new FileContext(ctxFile, headerFile); + Set dependencies= null; + boolean done= false; + while (!done) { + done= true; + DependsOnOutdatedFileException d= parseFile(tu, language, ifl, scannerInfo, ctx, monitor); + if (d != null) { + // File was not parsed, because there is a dependency that needs to be + // handled before + if (dependencies == null) + dependencies= new HashSet(); + if (dependencies.add(d.fIndexFile)) { + if (parseFile(d.fTu, language, d.fIndexFile.getLocation(), scannerInfo, new FileContext(ctxFile, d.fIndexFile), monitor) == null) + done= false; + } + } + } if (!ctx.fLostPragmaOnceSemantics) return; @@ -929,21 +947,9 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } - private void parseFile(Object tu, int linkageID, IIndexFileLocation ifl, IScannerInfo scanInfo, + private DependsOnOutdatedFileException parseFile(Object tu, AbstractLanguage lang, IIndexFileLocation ifl, IScannerInfo scanInfo, FileContext ctx, IProgressMonitor pm) throws CoreException, InterruptedException { IPath path= getLabel(ifl); - AbstractLanguage[] langs= fResolver.getLanguages(tu, true); - AbstractLanguage lang= null; - for (AbstractLanguage lang2 : langs) { - if (lang2.getLinkageID() == linkageID) { - lang= lang2; - break; - } - } - if (lang == null) { - return; - } - Throwable th= null; try { if (fShowActivity) { @@ -951,18 +957,21 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } pm.subTask(getMessage(MessageKind.parsingFileTask, path.lastSegment(), path.removeLastSegments(1).toString())); - long start= System.currentTimeMillis(); FileContent codeReader= fResolver.getCodeReader(tu); - IIndexFile[] ctxFiles = ctx == null ? null : new IIndexFile[] {ctx.fContext, ctx.fOldFile}; + final boolean isSource = fResolver.isSourceUnit(tu); - IASTTranslationUnit ast= createAST(tu, lang, codeReader, scanInfo, fASTOptions, ctxFiles, pm); + long start= System.currentTimeMillis(); + IASTTranslationUnit ast= createAST(lang, codeReader, scanInfo, isSource, fASTOptions, ctx, pm); fStatistics.fParsingTime += System.currentTimeMillis() - start; if (ast != null) { - writeToIndex(linkageID, ast, codeReader.getContentsHash(), ctx, pm); + writeToIndex(lang.getLinkageID(), ast, codeReader.getContentsHash(), ctx, pm); } } catch (CoreException e) { th= e; } catch (RuntimeException e) { + final Throwable cause = e.getCause(); + if (cause instanceof DependsOnOutdatedFileException) + return (DependsOnOutdatedFileException) cause; th= e; } catch (StackOverflowError e) { th= e; @@ -976,6 +985,16 @@ public abstract class AbstractIndexerTask extends PDOMWriter { if (th != null) { swallowError(path, th); } + return null; + } + + private AbstractLanguage getLanguage(Object tu, int linkageID) { + for (AbstractLanguage language : fResolver.getLanguages(tu, true)) { + if (language.getLinkageID() == linkageID) { + return language; + } + } + return null; } private IPath getLabel(IIndexFileLocation ifl) { @@ -1033,13 +1052,13 @@ public abstract class AbstractIndexerTask extends PDOMWriter { return e; } - private final IASTTranslationUnit createAST(Object tu, AbstractLanguage language, - FileContent codeReader, IScannerInfo scanInfo, int options, - IIndexFile[] ctx2header, IProgressMonitor pm) throws CoreException { + private final IASTTranslationUnit createAST(AbstractLanguage language, FileContent codeReader, + IScannerInfo scanInfo, boolean isSource, int options, + FileContext ctx, IProgressMonitor pm) throws CoreException { if (codeReader == null) { return null; } - if (fResolver.isSourceUnit(tu)) { + if (isSource) { options |= ILanguage.OPTION_IS_SOURCE_UNIT; } if (fFileSizeLimit > 0 && fResolver.getFileSize(codeReader.getFileLocation()) > fFileSizeLimit) { @@ -1048,6 +1067,7 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } return null; } + final IIndexFile[] ctx2header = ctx == null ? null : new IIndexFile[] {ctx.fContext, ctx.fOldFile}; if (fCodeReaderFactory == null) { InternalFileContentProvider fileContentProvider = createInternalFileContentProvider(); if (fIsFastIndexer) { @@ -1163,14 +1183,14 @@ public abstract class AbstractIndexerTask extends PDOMWriter { } public final IndexFileContent getFileContent(int linkageID, IIndexFileLocation ifl, - IIndexFile file) throws CoreException { + IIndexFile file) throws CoreException, DependsOnOutdatedFileException { LinkageTask map = findRequestMap(linkageID); if (map != null) { LocationTask request= map.find(ifl); if (request != null) { FileVersionTask task= request.findVersion(file); if (task != null && task.fOutdated) - return null; + throw new DependsOnOutdatedFileException(request.fTu, task.fIndexFile); } } IndexFileContent fc= fIndexContentCache.get(file); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java index 3b588970ca5..decb09a25c5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/PDOM.java @@ -212,10 +212,11 @@ public class PDOM extends PlatformObject implements IPDOM { * 120.0 - Enumerators in global index, bug 356235 * 120.1 - Specializations of using declarations, bug 357293. * 121.0 - Multiple variants of included header file, bug 197989. + * 122.0 - Compacting strings */ - private static final int MIN_SUPPORTED_VERSION= version(121, 0); - private static final int MAX_SUPPORTED_VERSION= version(121, Short.MAX_VALUE); - private static final int DEFAULT_VERSION = version(121, 0); + private static final int MIN_SUPPORTED_VERSION= version(122, 0); + private static final int MAX_SUPPORTED_VERSION= version(122, Short.MAX_VALUE); + private static final int DEFAULT_VERSION = version(122, 0); private static int version(int major, int minor) { return (major << 16) + minor; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java index cc366d97fa0..a7402792bfd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Chunk.java @@ -252,17 +252,47 @@ final class Chunk { fBuffer[++idx]= (byte)(value); } + public void putChars(final long offset, char[] chars, int start, int len) { + assert fLocked; + fDirty= true; + int idx= recPtrToIndex(offset)-1; + final int end= start+len; + for (int i = start; i < end; i++) { + char value= chars[i]; + fBuffer[++idx]= (byte)(value >> 8); + fBuffer[++idx]= (byte)(value); + } + } + + public void putCharsAsBytes(final long offset, char[] chars, int start, int len) { + assert fLocked; + fDirty= true; + int idx= recPtrToIndex(offset)-1; + final int end= start+len; + for (int i = start; i < end; i++) { + char value= chars[i]; + fBuffer[++idx]= (byte)(value); + } + } + public char getChar(final long offset) { int idx= recPtrToIndex( offset ); return (char) (((fBuffer[idx] << 8) | (fBuffer[++idx] & 0xff))); } - public void getCharArray(final long offset, final char[] result) { + public void getChars(final long offset, final char[] result, int start, int len) { final ByteBuffer buf= ByteBuffer.wrap(fBuffer); buf.position(recPtrToIndex( offset )); - buf.asCharBuffer().get(result); + buf.asCharBuffer().get(result, start, len); } - + + public void getCharsFromBytes(final long offset, final char[] result, int start, int len) { + final int pos = recPtrToIndex(offset); + for (int i = 0; i < len; i++) { + result[start+i] = (char) (fBuffer[pos+i] & 0xff); + } + } + void clear(final long offset, final int length) { assert fLocked; fDirty= true; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java index fe34fa1ca35..4c883a97467 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/Database.java @@ -530,25 +530,42 @@ public class Database { } public IString newString(String string) throws CoreException { - if (string.length() > ShortString.MAX_LENGTH) - return new LongString(this, string); - else - return new ShortString(this, string); + return newString(string.toCharArray()); } public IString newString(char[] chars) throws CoreException { - if (chars.length > ShortString.MAX_LENGTH) - return new LongString(this, chars); + int len= chars.length; + int bytelen; + final boolean useBytes = useBytes(chars); + if (useBytes) { + bytelen= len; + } else { + bytelen= 2*len; + } + + if (bytelen > ShortString.MAX_BYTE_LENGTH) + return new LongString(this, chars, useBytes); else - return new ShortString(this, chars); + return new ShortString(this, chars, useBytes); + } + + private boolean useBytes(char[] chars) { + for (char c : chars) { + if ((c & 0xff00) != 0) + return false; + } + return true; } + + public IString getString(long offset) throws CoreException { - int length = getInt(offset); - if (length > ShortString.MAX_LENGTH) + final int l = getInt(offset); + int bytelen= l<0 ? -l : 2*l; + if (bytelen > ShortString.MAX_BYTE_LENGTH) { return new LongString(this, offset); - else - return new ShortString(this, offset); + } + return new ShortString(this, offset); } /** diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java index ebf5eda9383..6b9751836b2 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/db/LongString.java @@ -13,8 +13,6 @@ package org.eclipse.cdt.internal.core.pdom.db; -import java.util.NoSuchElementException; - import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.core.runtime.CoreException; @@ -48,73 +46,117 @@ public class LongString implements IString { this.record = record; } - private interface IWriter { - public void writeChars(int start, int length, long p) throws CoreException; - } + public LongString(Database db, final char[] chars, boolean useBytes) throws CoreException { + final int numChars1 = useBytes ? NUM_CHARS1*2 : NUM_CHARS1; + final int numCharsn = useBytes ? NUM_CHARSN*2 : NUM_CHARSN; - private long createString(int length, IWriter writer) throws CoreException { - // write the first record - long firstRecord = db.malloc(Database.MAX_MALLOC_SIZE); - int start = 0; - db.putInt(firstRecord, length); - writer.writeChars(start, NUM_CHARS1, firstRecord + CHARS1); + this.db = db; + this.record = db.malloc(Database.MAX_MALLOC_SIZE); + + // Write the first record + final int length = chars.length; + db.putInt(this.record, useBytes ? -length : length); + Chunk chunk= db.getChunk(this.record); + + if (useBytes) { + chunk.putCharsAsBytes(this.record + CHARS1, chars, 0, numChars1); + } else { + chunk.putChars(this.record + CHARS1, chars, 0, numChars1); + } // write the subsequent records - long lastNext = firstRecord + NEXT1; - start += NUM_CHARS1; - while (length - start > NUM_CHARSN) { + long lastNext = this.record + NEXT1; + int start = numChars1; + while (length-start > numCharsn) { long nextRecord = db.malloc(Database.MAX_MALLOC_SIZE); db.putRecPtr(lastNext, nextRecord); - writer.writeChars(start, NUM_CHARSN, nextRecord + CHARSN); - start += NUM_CHARSN; + chunk= db.getChunk(nextRecord); + if (useBytes) { + chunk.putCharsAsBytes(nextRecord + CHARSN, chars, start, numCharsn); + } else { + chunk.putChars(nextRecord + CHARSN, chars, start, numCharsn); + } + start += numCharsn; lastNext = nextRecord + NEXTN; } - // Write the final record - length -= start; - long finalRecord = db.malloc(CHARSN + (length) * 2); - db.putRecPtr(lastNext, finalRecord); - writer.writeChars(start, length, finalRecord + CHARSN); - - return firstRecord; - } - - public LongString(Database db, final String string) throws CoreException { - this.db = db; - this.record = createString(string.length(), new IWriter() { - public void writeChars(int start, int length, long p) throws CoreException { - for (int i = start; i < start + length; ++i) { - LongString.this.db.putChar(p, string.charAt(i)); - p += 2; - } - } - }); - } - - public LongString(Database db, final char[] chars) throws CoreException { - this.db = db; - this.record = createString(chars.length, new IWriter() { - public void writeChars(int start, int length, long p) throws CoreException { - for (int i = start; i < start + length; ++i) { - LongString.this.db.putChar(p, chars[i]); - p += 2; - } - } - }); + // Write last record + int remaining= length - start; + long nextRecord = db.malloc(CHARSN + (useBytes ? remaining : remaining*2)); + db.putRecPtr(lastNext, nextRecord); + chunk= db.getChunk(nextRecord); + if (useBytes) { + chunk.putCharsAsBytes(nextRecord + CHARSN, chars, start, remaining); + } else { + chunk.putChars(nextRecord + CHARSN, chars, start, remaining); + } } + @Override public long getRecord() { return record; } + @Override + public char[] getChars() throws CoreException { + int length = db.getInt(record + LENGTH); + final boolean useBytes = length < 0; + int numChars1 = NUM_CHARS1; + int numCharsn = NUM_CHARSN; + if (useBytes) { + length= -length; + numChars1 *= 2; + numCharsn *= 2; + } + + final char[] chars = new char[length]; + + // First record + long p = record; + Chunk chunk= db.getChunk(p); + if (useBytes) { + chunk.getCharsFromBytes(p+CHARS1, chars, 0, numChars1); + } else { + chunk.getChars(p+CHARS1, chars, 0, numChars1); + } + + int start= numChars1; + p= record + NEXT1; + + // Other records + while (start < length) { + p = db.getRecPtr(p); + int partLen= Math.min(length-start, numCharsn); + chunk= db.getChunk(p); + if (useBytes) { + chunk.getCharsFromBytes(p+CHARSN, chars, start, partLen); + } else { + chunk.getChars(p+CHARSN, chars, start, partLen); + } + start+= partLen; + p=p+NEXTN; + } + return chars; + } + + @Override public void delete() throws CoreException { - int length = db.getInt(record + LENGTH) - NUM_CHARS1; + int length = db.getInt(record + LENGTH); + final boolean useBytes = length < 0; + int numChars1 = NUM_CHARS1; + int numCharsn = NUM_CHARSN; + if (useBytes) { + length= -length; + numChars1 *= 2; + numCharsn *= 2; + } long nextRecord = db.getRecPtr(record + NEXT1); db.free(record); + length-= numChars1; // Middle records - while (length > NUM_CHARSN) { - length -= NUM_CHARSN; + while (length > numCharsn) { + length -= numCharsn; long nextnext = db.getRecPtr(nextRecord + NEXTN); db.free(nextRecord); nextRecord = nextnext; @@ -147,19 +189,6 @@ public class LongString implements IString { return false; } - - private class HashCodeComputer implements IReader { - private int fHashcode= 0; - - public int getHashcode() { - return fHashcode; - } - - public void appendChar(char c) { - fHashcode = 31*fHashcode + c; - } - } - /** * Compatible with {@link String#hashCode()} */ @@ -167,224 +196,53 @@ public class LongString implements IString { public int hashCode() { int h = hash; if (h == 0) { - HashCodeComputer hcc; + char chars[]; try { - int length = db.getInt(record + LENGTH); - hcc = new HashCodeComputer(); - readChars(length, hcc); - h= hcc.getHashcode(); - hash = h; + chars = getChars(); + final int len = chars.length; + for (int i = 0; i < len; i++) { + h = 31*h + chars[i]; + } } catch (CoreException e) { } + hash = h; } return h; } + @Override public int compare(IString string, boolean caseSensitive) throws CoreException { - if (string instanceof LongString) - return compare((LongString)string, caseSensitive); - else if (string instanceof ShortString) - return compare((ShortString)string, caseSensitive); - else - throw new IllegalArgumentException(); + return ShortString.compare(getChars(), string.getChars(), caseSensitive); } - - public int compare(char[] other, boolean caseSensitive) throws CoreException { - CharIterator i1 = new CharIterator(); - int i2 = 0; - int n2 = other.length; - while (i1.hasNext() && i2 < n2) { - int cmp= ShortString.compareChars(i1.next(), other[i2], caseSensitive); - if(cmp!=0) - return cmp; - - ++i2; - } - - if (!i1.hasNext() && i2 != n2) - return -1; - else if (i2 == n2 && i1.hasNext()) - return 1; - else - return 0; - } - - public int compare(ShortString other, boolean caseSensitive) throws CoreException { - CharIterator i1 = new CharIterator(); - int index2 = 0; - int length2 = other.getLength(); - - while (i1.hasNext() && index2 NUM_CHARSN) { - p = nextRecord + CHARSN; - for (int i = 0; i < NUM_CHARSN; ++i) { - reader.appendChar(db.getChar(p)); - p += 2; - } - length -= NUM_CHARSN; - nextRecord = db.getRecPtr(nextRecord + NEXTN); - } - - // Last record - p = nextRecord + CHARSN; - for (int i = 0; i < length; ++i) { - reader.appendChar(db.getChar(p)); - p += 2; - } - } - - /** - * Convenience class for sequential access to LongString characters - */ - private class CharIterator { - long p; - int count; - int length; - - public CharIterator() throws CoreException { - p = record + CHARS1; - length = db.getInt(record + LENGTH); - } - - public char next() throws CoreException { - char result = db.getChar(p); - p += 2; - count++; - if(count>length) { - throw new NoSuchElementException(); - } - if(count == NUM_CHARS1) { - p = db.getRecPtr(record + NEXT1) + CHARSN; - } - if(count > NUM_CHARS1 && ((count-NUM_CHARS1) % NUM_CHARSN)==0) { - p = db.getRecPtr(p-(NUM_CHARSN*2)-4) + CHARSN; - } - return result; - } - - public boolean hasNext() { - return count partials = new ArrayList(); @@ -262,18 +264,22 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType return SemanticUtil.isSameOwner(getOwner(), ctype.getOwner()); } + @Override public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { return PDOMInstanceCache.getCache(this).getInstance(arguments); } + @Override public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { PDOMInstanceCache.getCache(this).addInstance(arguments, instance); } + @Override public ICPPTemplateInstance[] getAllInstances() { return PDOMInstanceCache.getCache(this).getAllInstances(); } + @Override public ICPPTemplateParameter adaptTemplateParameter(ICPPTemplateParameter param) { // Template parameters are identified by their position in the parameter list. int pos = param.getParameterPosition(); @@ -296,6 +302,7 @@ public class PDOMCPPClassTemplate extends PDOMCPPClassType return null; } + @Override public ICPPDeferredClassInstance asDeferredInstance() throws DOMException { PDOMInstanceCache cache= PDOMInstanceCache.getCache(this); synchronized (cache) { diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java index 1fe83dd4e0c..5f8780bad84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplatePartialSpecializationSpecialization.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.core.pdom.dom.cpp; import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IType; import org.eclipse.cdt.core.dom.ast.ITypedef; import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate; @@ -67,7 +66,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla } @Override - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; } @@ -102,6 +101,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla return CPPClassTemplatePartialSpecialization.isSamePartialClassSpecialization(this, rhs); } + @Override public ICPPClassTemplate getPrimaryClassTemplate() { if (fPrimaryTemplate == null) { try { @@ -114,6 +114,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla return fPrimaryTemplate; } + @Override public void setArguments(ICPPTemplateArgument[] templateArguments) throws CoreException { final Database db = getPDOM().getDB(); long oldRec = db.getRecPtr(record+ARGUMENTS); @@ -124,6 +125,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla } } + @Override public ICPPTemplateArgument[] getTemplateArguments() { try { final long rec= getPDOM().getDB().getRecPtr(record+ARGUMENTS); @@ -134,6 +136,7 @@ class PDOMCPPClassTemplatePartialSpecializationSpecialization extends PDOMCPPCla } } + @Override @Deprecated public IType[] getArguments() { return CPPTemplates.getArguments(getTemplateArguments()); diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java index 4ace683587b..4e2c110e1bd 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPClassTemplateSpecialization.java @@ -64,19 +64,23 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization return IIndexCPPBindingConstants.CPP_CLASS_TEMPLATE_SPECIALIZATION; } + @Override public ICPPTemplateParameter[] getTemplateParameters() { ICPPClassTemplate template = (ICPPClassTemplate) getSpecializedBinding(); return template.getTemplateParameters(); } + @Override public ICPPTemplateInstance getInstance(ICPPTemplateArgument[] arguments) { return PDOMInstanceCache.getCache(this).getInstance(arguments); } + @Override public void addInstance(ICPPTemplateArgument[] arguments, ICPPTemplateInstance instance) { PDOMInstanceCache.getCache(this).addInstance(arguments, instance); } + @Override public ICPPTemplateInstance[] getAllInstances() { return PDOMInstanceCache.getCache(this).getAllInstances(); } @@ -153,7 +157,8 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization return ((ICPPClassType) owner1).isSameType((ICPPClassType) owner2); } - public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() throws DOMException { + @Override + public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { ICPPClassTemplate origTemplate= (ICPPClassTemplate) getSpecializedBinding(); ICPPClassTemplatePartialSpecialization[] orig = origTemplate.getPartialSpecializations(); ICPPClassTemplatePartialSpecialization[] spec = new ICPPClassTemplatePartialSpecialization[orig.length]; @@ -163,6 +168,7 @@ class PDOMCPPClassTemplateSpecialization extends PDOMCPPClassSpecialization return spec; } + @Override public ICPPDeferredClassInstance asDeferredInstance() throws DOMException { PDOMInstanceCache cache= PDOMInstanceCache.getCache(this); synchronized (cache) { diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java index fa373722958..cf6502358f7 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/CodeFormatterVisitor.java @@ -2623,61 +2623,91 @@ public class CodeFormatterVisitor extends ASTVisitor implements ICPPASTVisitor, return formatOverloadedLeftShiftChain(node); } + // To improve speed of the algorithm we flatten homogeneous nested binary expressions + // to reduce overall depth of the expression tree. + List operands = getOperandsOfMultiExpression(node); + Runnable tailFormatter = endsWithMacroExpansion(node) ? null : scribe.takeTailFormatter(); - Alignment expressionAlignment= scribe.createAlignment( + Alignment alignment= scribe.createAlignment( Alignment.BINARY_EXPRESSION, preferences.alignment_for_binary_expression, Alignment.R_OUTERMOST, - 2, + operands.size(), scribe.scanner.getCurrentPosition()); - scribe.enterAlignment(expressionAlignment); + scribe.enterAlignment(alignment); boolean ok = false; do { try { - final IASTExpression op1= node.getOperand1(); - // Left operand - op1.accept(this); - scribe.printTrailingComment(); + for (int i = 0; i < operands.size(); i++) { + final IASTExpression operand = operands.get(i); + // In case of macros we may have already passed the operator position. + if (i > 0 && scribe.scanner.getCurrentPosition() < operand.getFileLocation().getNodeOffset()) { + scribe.alignFragment(alignment, i); - // In case of macros we may have already passed the operator position. - if (scribe.scanner.getCurrentPosition() < node.getOperand2().getFileLocation().getNodeOffset()) { - scribe.alignFragment(expressionAlignment, 1); + // Operator + final int nextToken= peekNextToken(); + // In case of C++ alternative operators, like 'and', 'or', etc. a space + boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar()); - // Operator - final int nextToken= peekNextToken(); - // In case of C++ alternative operators, like 'and', 'not', etc. a space - boolean forceSpace= Character.isJavaIdentifierStart(peekNextChar()); + switch (node.getOperator()) { + case IASTBinaryExpression.op_pmdot: + case IASTBinaryExpression.op_pmarrow: + scribe.printNextToken(nextToken, false); + break; - switch (node.getOperator()) { - case IASTBinaryExpression.op_pmdot: - case IASTBinaryExpression.op_pmarrow: - scribe.printNextToken(nextToken, false); - break; - default: - scribe.printNextToken(nextToken, forceSpace || preferences.insert_space_before_binary_operator); - if (forceSpace || preferences.insert_space_after_binary_operator) { - scribe.space(); - } - } - } + default: + scribe.printNextToken(nextToken, forceSpace || preferences.insert_space_before_binary_operator); + if (forceSpace || preferences.insert_space_after_binary_operator) { + scribe.space(); + } + } + scribe.printTrailingComment(); + } + if (i == alignment.fragmentCount - 1) { + scribe.setTailFormatter(tailFormatter); + } + operand.accept(this); + scribe.restartAtOffset(getNodeEndLocation(operand)); + scribe.printTrailingComment(); + } - // Right operand - final IASTExpression op2= node.getOperand2(); - op2.accept(this); - - if (tailFormatter != null) - tailFormatter.run(); + scribe.runTailFormatter(); ok = true; } catch (AlignmentException e) { scribe.redoAlignment(e); } } while (!ok); - scribe.exitAlignment(expressionAlignment, true); + scribe.exitAlignment(alignment, true); return PROCESS_SKIP; } + /** + * Traverses a chain of nested homogeneous left-to-right-associative binary expressions and + * returns a list of their operands in left-to-right order. For example, for the expression + * a + b * c + d, it will return a list containing expressions: a, b * c, and d. + * + * @param binaryExpression the top-level binary expression + * @return a list of expression operands from left to right + */ + private List getOperandsOfMultiExpression(IASTBinaryExpression binaryExpression) { + int operator = binaryExpression.getOperator(); + List operands = new ArrayList(2); + IASTExpression node; + do { + operands.add(binaryExpression.getOperand2()); + node = binaryExpression.getOperand1(); + if (!(node instanceof IASTBinaryExpression)) { + break; + } + binaryExpression = (IASTBinaryExpression) node; + } while (binaryExpression.getOperator() == operator); + operands.add(node); + Collections.reverse(operands); + return operands; + } + private int formatAssignment(IASTBinaryExpression node) { Runnable tailFormatter = scribe.takeTailFormatter(); final IASTExpression op1= node.getOperand1(); diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java index cee153fe123..16cfa690e16 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/align/Alignment.java @@ -311,7 +311,7 @@ public class Alignment { this.fragmentIndentations[i] = this.breakIndentationLevel; return wasSplit = true; } - } while (--i >= 0); + } while ((this.fragmentBreaks[i] != BREAK || (this.mode & M_INDENT_ON_COLUMN) != 0) && --i >= 0); break; /* # aligned fragment diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties index 63cc89c65dc..08d89dd50bf 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/messages.properties @@ -29,4 +29,4 @@ ProcessRunner.argumentsMismatch=Argument type mismatch: ProcessRunner.error=-->Error: ProcessRunner.success=-->Success: ProcessRunner.info=-->Info: -ProcessHelper.fileNotFound=File not found: +ProcessHelper.fileNotFound=File not found: ''{0}'' diff --git a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java index 1e6eb795ce7..465432cac9a 100644 --- a/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java +++ b/core/org.eclipse.cdt.core/templateengine/org/eclipse/cdt/core/templateengine/process/ProcessHelper.java @@ -6,8 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation - * Mark Espiritu (VastSystems) - bug 215283 + * Bala Torati (Symbian) - Initial API and implementation + * Mark Espiritu (VastSystems) - bug 215283 + * Raphael Zulliger (Indel AG) - [367482] fixed resource leak *******************************************************************************/ package org.eclipse.cdt.core.templateengine.process; @@ -20,7 +21,6 @@ import java.io.InputStreamReader; import java.io.RandomAccessFile; import java.net.URL; import java.util.HashSet; -import java.util.Iterator; import java.util.Map; import java.util.Set; @@ -29,9 +29,10 @@ import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; +import com.ibm.icu.text.MessageFormat; + /** - * Acts as Helper class for process the processes i.e., copy, replace and append - * files. + * Acts as helper class for process the processes i.e., copy, replace and append files. */ public class ProcessHelper { public static final String CONDITION = "condition"; //$NON-NLS-1$ @@ -45,15 +46,15 @@ public class ProcessHelper { * * @param fileContents contents which are appended to the file. * @param toFile a file to append contents. - * @throws IOException, - * exception while writing contents into a file - * + * @throws IOException exception while writing contents into a file * @since 4.0 */ public static void appendFile(String fileContents, File toFile) throws IOException { RandomAccessFile raf = null; if (!toFile.exists()) { - throw new FileNotFoundException(" The specified destination file does not exists "); //$NON-NLS-1$ + throw new FileNotFoundException(MessageFormat.format( + TemplateEngineMessages.getString("ProcessHelper.fileNotFound"), //$NON-NLS-1$ + toFile.getPath())); } else { try { raf = new RandomAccessFile(toFile, "rw"); //$NON-NLS-1$ @@ -69,7 +70,7 @@ public class ProcessHelper { /** * This method returns a vector of all replace marker strings. (e.g., - * $(item), vector contains 'item' as one item. , ) is the end pattern. + * $(item), vector contains 'item' as one item) is the end pattern. * * @param str A given string possibly containing markers. * @return the set of names occurring within markers @@ -77,14 +78,16 @@ public class ProcessHelper { */ public static Set getReplaceKeys(String str) { Set replaceStrings = new HashSet(); - int start= 0, end= 0; + int start= 0; + int end= 0; while ((start = str.indexOf(START_PATTERN, start)) >= 0) { end = str.indexOf(END_PATTERN, start); if (end != -1) { replaceStrings.add(str.substring(start + START_PATTERN.length(), end)); start = end + END_PATTERN.length(); - } else + } else { start++; + } } return replaceStrings; } @@ -93,19 +96,18 @@ public class ProcessHelper { * This method takes a URL as parameter to read the contents, and to add * into a string buffer. * - * @param source - * URL to read the contents. - * @return string, contents of a file specified in the URL source path. - * @throws IOException - * + * @param source URL to read the contents. + * @return string contents of a file specified in the URL source path. * @since 4.0 */ public static String readFromFile(URL source) throws IOException { char[] chars = new char[4092]; InputStreamReader contentsReader = null; - StringBuffer buffer = new StringBuffer(); + StringBuilder buffer = new StringBuilder(); if (!new java.io.File(source.getFile()).exists()) { - throw new FileNotFoundException(TemplateEngineMessages.getString("ProcessHelper.fileNotFound") + source.getFile()); //$NON-NLS-1$ + throw new FileNotFoundException(MessageFormat.format( + TemplateEngineMessages.getString("ProcessHelper.fileNotFound"), //$NON-NLS-1$ + source.getFile())); } else { contentsReader = new InputStreamReader(source.openStream()); int c; @@ -124,12 +126,8 @@ public class ProcessHelper { * This method reads contents from source, and writes the contents into * destination file. * - * @param source - * URL to read the contents. - * @param dest - * destination file to write the contents. - * @throws IOException - * + * @param source URL to read the contents. + * @param dest destination file to write the contents. * @since 4.0 */ public static void copyBinaryFile(URL source, File dest) throws IOException { @@ -137,22 +135,30 @@ public class ProcessHelper { if (source != null && dest != null) { File file = new File(source.getFile()); if (file.isFile()) { - FileInputStream fis = new FileInputStream(file); - FileOutputStream fos = new FileOutputStream(dest); - int ch; - while (true) { - ch = fis.read(bytes); - if (ch == -1) { - break; + FileInputStream in = null; + FileOutputStream out = null; + try { + in = new FileInputStream(file); + out = new FileOutputStream(dest); + int len; + while ((len = in.read(bytes)) != -1) { + out.write(bytes, 0, len); + } + } finally { + try { + if (in != null) + in.close(); + } finally { + if (out != null) + out.close(); } - fos.write(bytes, 0, ch); } } } } /** - * This method Creates the Directories in the parent Folder. + * This method creates the directories in the parent folder. * @param projectHandle * @param parentFolder * @throws CoreException @@ -169,18 +175,17 @@ public class ProcessHelper { parentFolder.create(true, true, null); } - /** * @param string * @param macros * @param valueStore - * @return the Macro Value after expanding the Macros. + * @return the macro value after expanding the macros. * * @since 4.0 */ - public static String getValueAfterExpandingMacros(String string, Set macros, Map valueStore) { - for (Iterator i = macros.iterator(); i.hasNext();) { - String key = i.next(); + public static String getValueAfterExpandingMacros(String string, Set macros, + Map valueStore) { + for (String key : macros) { String value = valueStore.get(key); if (value != null) { string = string.replace(START_PATTERN + key + END_PATTERN, value); diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts index bac0e169ad0..9d55f345d59 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/GenerateGettersAndSetters.rts @@ -467,14 +467,14 @@ public: return name; } - int getSystemId() const { - return systemId; - } - void setName(char* name) { this->name = name; } + int getSystemId() const { + return systemId; + } + void setSystemId(int systemId) { this->systemId = systemId; } @@ -542,14 +542,14 @@ public: return i; } - bool isOk() const { - return ok; - } - void setI(int i) { this->i = i; } + bool isOk() const { + return ok; + } + void setOk(bool ok) { this->ok = ok; } @@ -1173,7 +1173,6 @@ private: }; #endif /* A_H_ */ - //= #ifndef A_H_ #define A_H_ @@ -1195,9 +1194,7 @@ inline void Person::setId(int id) { this->id = id; } - #endif /* A_H_ */ - //!No Methods Separate Definition //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config @@ -1248,7 +1245,6 @@ inline void test::setI(int i) { this->i = i; } - #endif /* TEST_H_ */ //!Bug 323780 "Generate Getters and Setters..." crashes //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest @@ -1349,7 +1345,6 @@ public: //@Test.cxx //= - int Test::getTestField() const { return testField; } @@ -1390,7 +1385,6 @@ public: //@component_b/implementation/Test.cpp //= - int Test::getTestField() const { return testField; } @@ -1451,7 +1445,7 @@ public: int test; }; #endif /* A_H_ */ -//!Bug ??? - Getter for an array field +//!Bug 319278 - Getter for an array field //#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest //@.config filename=A.h @@ -1479,3 +1473,36 @@ public: } }; #endif /* A_H_ */ +//!Bug 352258 - Avoiding reserved names +//#org.eclipse.cdt.ui.tests.refactoring.gettersandsetters.GenerateGettersAndSettersTest +//@.config +filename=A.h +getters=mClass +setters=mClass +//@A.h +#ifndef A_H_ +#define A_H_ + +class getClass { +private: + int /*$*/mClass/*$$*/; +}; +#endif /* A_H_ */ +//= +#ifndef A_H_ +#define A_H_ + +class getClass { +private: + int mClass; + +public: + int getClass1() const { + return mClass; + } + + void setClass(int _class) { + mClass = _class; + } +}; +#endif /* A_H_ */ diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts index df5711bf73b..43703879fe8 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ImplementMethod.rts @@ -17,8 +17,6 @@ public: inline bool X::a(int int1) const { } - - //!Param const and reference and pointer two params //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -38,8 +36,6 @@ public: inline bool X::xy(int int1, int i) const { } - - //!Test if TemplateMethod stays in header //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -62,15 +58,13 @@ public: template inline void A::test() { } - - //@A.cpp #include "A.h" //= #include "A.h" -//!class template member functions +//!Class template member functions //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -102,9 +96,7 @@ A::A() { template inline void A::test() { } - - -//!member class +//!Member class //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -144,8 +136,6 @@ public: inline void A::test() { } - - //!Method declared in otherwise empty class //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -165,7 +155,6 @@ public: //@A.cpp //= - void A::test() { } //!Implement in existing namespace @@ -205,7 +194,7 @@ void ClassInNamespace::test2() { } } -//!virtual method in the middle of con/destructor, without parameters and void return value +//!Virtual method in the middle of con/destructor, without parameters and void return value //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -287,8 +276,6 @@ A::A() { void A::foo() { } - - //!Method at beginning, without parameters, void return value and const //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -348,8 +335,6 @@ A::A() { int A::foo() { } - - //!Method with two int parameters //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -379,8 +364,6 @@ A::A() { int A::foo(int param1, int param2) { } - - //!Method defined in header //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -408,8 +391,6 @@ A::A() { inline void A::test() { } - - //!Implement a function at end of source file //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -426,7 +407,6 @@ void function_with_impl() { void function() { } - //!Implement with namespace //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -453,7 +433,6 @@ void Namespace::ClassInNamespace::other_test() { void Namespace::ClassInNamespace::test() { } - //!Implement function within namespace //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -524,7 +503,7 @@ int test2() { } } -//!class template member functions with multiple templates +//!Class template member functions with multiple templates //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -538,7 +517,7 @@ public: }; template -A::A() { +A::A() { } //= @@ -550,15 +529,13 @@ public: }; template -A::A() { +A::A() { } template inline void A::test() { } - - -//!with default parameters +//!With default parameters //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -578,7 +555,7 @@ public: void Class::test(int param1, int param2, int param3) { } -//!static method +//!Static method //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config filename=A.h @@ -672,7 +649,6 @@ class TestClass { inline void nspace::TestClass::testMethod() { } - #endif /* TESTCLASS_H_ */ //!Bug 290110 Source-> Implement Method @@ -736,8 +712,6 @@ A::~A() { void n1::n2::A::B::testmethod2() { } - - //!Bug 337040 - Insert definition in empty implementation file (.cxx) //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -753,7 +727,6 @@ public: //@A.cxx //= - void TestClass::foo() { } //!Bug 355006 - NPE implementing template function @@ -773,7 +746,6 @@ void func(T&); template inline void func(T&) { } - //!Bug 363111 - Remove explicit in constructor definition //#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest //@.config @@ -789,6 +761,5 @@ public: //@A.cpp //= - TestClass::TestClass() { } \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts index 30546140280..f84ae165492 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsClassToHeader.rts @@ -18,7 +18,6 @@ inline void A::member() { // return comment return; } - //!ClassToHeaderTopCommentOrder //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -41,7 +40,6 @@ class A { inline void A::member() { return; } - //!ClassToHeaderCatchComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -68,7 +66,6 @@ try { catch (int i) { // catch comment } - //!ClassToHeaderTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -89,7 +86,6 @@ class A { inline void A::member() { return; } - //!ClassToHeaderTemplateTopComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -114,7 +110,6 @@ template inline T A::member() { return T(); } - //!ClassToHeaderTrailingComment //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -133,7 +128,6 @@ class A { inline void A::member() { return; } // Trailing comment - //!ClassToHeaderTrailingCommentWithTryBlock //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts index 628d3debd6b..64a295bb055 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCommentsImplToHeader.rts @@ -93,7 +93,6 @@ void /*$*/member/*$$*/() { //@A.h //= - void member() { // body comment return; @@ -115,7 +114,6 @@ void /*$*/member/*$$*/() { //@A.h //= - // Top comment void member() { // body comment diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts index ffef1312d81..f4832deaec6 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleCtorDtorRefactoring.rts @@ -34,7 +34,6 @@ public: inline A::A(int x, int y) : a(x), b(y) { } - //!TestConstructorToggleInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -85,7 +84,6 @@ int main() { A::A(int x, int y) : a(x), b(y) { } - //!TestConstructorToggleInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -154,7 +152,6 @@ public: inline A::~A() { } - //!TestDestructorToggleInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -199,7 +196,6 @@ int main() { A::~A() { } - //!TestDestructorToggleInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts index 7a1eeb54057..8c7d3b7c23a 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleDefaultParameterRefactoring.rts @@ -20,7 +20,6 @@ class A { inline void A::member(int a, int b) { return; } - //!TestDefaultParameterInitializerInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -57,7 +56,6 @@ int main() { void A::member(int a, int b) { return; } - //!TestDefaultParameterInitializerInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts index 7000fe3ac22..d17f1fb9365 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleFreeFunction.rts @@ -54,7 +54,6 @@ int main() { int freeFunction(int* a, int& b) { return 42; } - //!TestFreeFunctionToggleFromImplementationToHeaderWithDeclaration //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -172,7 +171,6 @@ try { } catch (std::exception& e) { } - //!TestFreeFunction //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -260,4 +258,3 @@ void freefunction() { } } - diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts index e002c3cffde..ec4baa9d2ce 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNamespaceRefactoring.rts @@ -1,4 +1,4 @@ -//!TestSimpleNamespaceInClassToInHeader +//!Test simple namespace in class to in header //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -30,7 +30,7 @@ inline void A::foo() { } } -//!TestSimpleNamespaceInHeaderToImplementationWithinNSDefinition +//!Test simple namespace in header to implementation within namespace definition //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -80,8 +80,7 @@ void A::foo() { } } - -//!TestSimpleNamespaceInHeaderToImplementationWithNSDefinitionInImpl +//!Test simple namespace in header to implementation with namespace definition in implementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -134,7 +133,7 @@ void A::foo() { } } -//!TestSimpleNamespaceInHeaderToImplementationWithNamespaceQualifiedName +//!Test simple namespace in header to implementation with namespace qualified name //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -184,7 +183,6 @@ void A::foo() { } } - //!TestSimpleNamespaceFromImplementationToInHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts index 3e53d81da6d..c2e2372d430 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleNestedRefactoring.rts @@ -24,7 +24,6 @@ class A { inline void A::B::member(int a, int b) { return; } - //!TestNestedClassInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -65,7 +64,6 @@ int main() { void A::B::member(int a, int b) { return; } - //!TestNestedClassInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts index 8551a6ca67e..0518f02bad3 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSelection.rts @@ -1,4 +1,4 @@ -//!TestZeroLengthSelection +//!Test zero length selection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -16,8 +16,7 @@ class A { inline void A::member() { return; } - -//!TestSubstringSelection +//!Test substring selection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -35,8 +34,7 @@ class A { inline void A::member() { return; } - -//!TestBodySelection +//!Test body selection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -54,8 +52,7 @@ class A { inline void A::member() { return; } - -//!TestBodySelectionWithConfusingName +//!Test body selection with confusing name //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -75,8 +72,7 @@ inline void A::member() { int abcd = 42; return; } - -//!TestLeftBorderSelection +//!Test left border selection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -94,8 +90,7 @@ class A { inline void A::member() { return; } - -//!TestRightBorderSelection +//!Test right border selection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -113,8 +108,7 @@ class A { inline void A::member() { return; } - -//!TestOverlappingSelection +//!Test overlapping selection //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -132,4 +126,3 @@ class A { inline void A::member() { return; } - diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts index aaec086264d..b15bc2123c5 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleSimpleFunctionRefactoring.rts @@ -1,4 +1,4 @@ -//!TestSimpleFunctionInClassToInHeader +//!Test simple function in class to in header //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -28,8 +28,7 @@ private: inline int A::function() { return 0; } - -//!TestSimpleFunctionInHeaderToImplementation +//!Test simple function in header to implementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -73,7 +72,6 @@ int main() { int A::function() { return 0; } - //!TestSimpleFunctionInImplementationToInClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts index af12e2930d3..b3249535f8d 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTemplateRefactoring.rts @@ -1,4 +1,4 @@ -//!TestTemplateFunctionInClassToInHeader +//!Test template function in class to in header //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -27,8 +27,7 @@ template inline T A::B::member() { return T(); } - -//!TestTemplateFunctionInHeaderToInClass +//!Test template function in header to in class //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -57,7 +56,7 @@ class A { } }; }; -//!TestTemplateFunctionInHeaderToInClassWithTemplateSelected +//!Test template function in header to in class with template selected //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -78,8 +77,7 @@ template inline T A::foo() { return T(); } - -//!TestComplexTemplateFunctionFromInClassToInheader +//!Test complex template function from in class to in header //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h @@ -105,8 +103,7 @@ template inline void A::foo(const U& u, const V& v) { return; } - -//!TestComplexTemplateFunctionFromInHeaderToInClass +//!Test complex template function from in header to in class //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config filename=A.h diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts index d5777071018..1aa25624edb 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleTryCatchRefactoring.rts @@ -30,7 +30,6 @@ try { catch (std::exception& e1) { return; } - //!TestTryCatchFromInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -77,7 +76,6 @@ try { catch (std::exception& e1) { return; } - //!TestTryCatchFromInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -160,7 +158,6 @@ catch (std::exception& e1) { catch (std::exception& e2) { return; } - //!TestMultipleTryCatchFromInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -213,7 +210,6 @@ catch (std::exception& e1) { catch (std::exception& e2) { return; } - //!TestMultipleTryCatchFromInImplementationToClass //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config @@ -263,4 +259,4 @@ class A { catch (std::exception& e2) { return; } -}; \ No newline at end of file +}; diff --git a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts index a0af0150b1b..5be3a7a7612 100644 --- a/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts +++ b/core/org.eclipse.cdt.ui.tests/resources/refactoring/ToggleVirtualFunction.rts @@ -18,7 +18,6 @@ class A { inline int A::foo() { return 0; } - //!TestVirtualSpecifierFromInHeaderToImplementation //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //%CPP @@ -52,7 +51,6 @@ int main() { int A::foo() { return 0; } - //!TestVirtualSpecifierFromImplementationToHeader //#org.eclipse.cdt.ui.tests.refactoring.togglefunction.ToggleRefactoringTest //@.config diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/AllTemplateEngineTests.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTests.java similarity index 93% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/AllTemplateEngineTests.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTests.java index 13b8cd7c4b6..3643398cb32 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/AllTemplateEngineTests.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/AllTemplateEngineTests.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation + * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import junit.framework.Test; import junit.framework.TestSuite; @@ -20,7 +20,6 @@ import junit.framework.TestSuite; * * @since 4.0 */ - public class AllTemplateEngineTests extends TestSuite { public static void main(String[] args) { @@ -31,7 +30,7 @@ public class AllTemplateEngineTests extends TestSuite { * Since the TemplateEngine consists of UI(Wizard). * A TestWizard is created to which the dynamically generated * UIPages are added. The Wizard is launched from here. - * The TestCases created to test the TemplateEngine is initialised here. + * The TestCases created to test the TemplateEngine is initialized here. * @return * * @since 4.0 diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TemplateEngineTestsHelper.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TemplateEngineTestsHelper.java similarity index 82% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TemplateEngineTestsHelper.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TemplateEngineTestsHelper.java index 41fd7ca8ed9..d7371c89ab1 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TemplateEngineTestsHelper.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TemplateEngineTestsHelper.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation + * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import java.io.IOException; import java.net.URL; @@ -34,26 +34,22 @@ import org.w3c.dom.Element; import org.w3c.dom.NamedNodeMap; /** - * * All supporting functions which are not part of Testing class. * * @since 4.0 */ - public class TemplateEngineTestsHelper { - - public static final String LOGGER_FILE_NAME="TemplateEngineTests"; //$NON-NLS-1$ + public static final String LOGGER_FILE_NAME = "TemplateEngineTests"; //$NON-NLS-1$ /** - * get the url of a xml template, by passing the xml file name. + * Returns the url of a xml template, by passing the xml file name. * @param templateName * @return URL */ public static URL getTemplateURL(String templateName){ Bundle bundle = Platform.getBundle(CTestPlugin.PLUGIN_ID); - URL url = FileLocator.find(bundle, new Path("resources/templateengine/"+templateName), null); //$NON-NLS-1$ - if ( url != null ) - { + URL url = FileLocator.find(bundle, new Path("resources/templateengine/" + templateName), null); //$NON-NLS-1$ + if (url != null) { try { url = FileLocator.toFileURL(url); } catch (IOException e) { @@ -65,19 +61,19 @@ public class TemplateEngineTestsHelper { public static TemplateCore[] getTestTemplates() { TemplateCore[] templates = TemplateEngine.getDefault().getTemplates(); - List testTemplates = new ArrayList(); - for (int i =0; i < templates.length; i++) { + List testTemplates = new ArrayList(); + for (int i = 0; i < templates.length; i++) { if (templates[i].getTemplateType().equals("TestTemplate")) { testTemplates.add(templates[i]); } } - return (TemplateCore[]) testTemplates.toArray(new TemplateCore[testTemplates.size()]); + return testTemplates.toArray(new TemplateCore[testTemplates.size()]); } public static int getChildCount(TemplateDescriptor templateDescriptor, String propertyGroupID){ - List list = templateDescriptor.getPropertyGroupList(); + List list = templateDescriptor.getPropertyGroupList(); for (int i = 0, l = list.size(); i < l; i++) { - Element element = (Element) list.get(i); + Element element = list.get(i); NamedNodeMap attributes = element.getAttributes(); for (int j = 0, l1 = attributes.getLength(); j < l1; j++) { String value = attributes.item(j).getNodeValue(); @@ -90,7 +86,7 @@ public class TemplateEngineTestsHelper { } public static boolean failIfErrorStatus(IStatus[] statuses) { - for(int i=0; i getPageData() { return Collections.singletonMap(dataKey, dataValue); } diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestProcesses.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestProcesses.java similarity index 94% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestProcesses.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestProcesses.java index 2bb9af58ad6..2879e691361 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestProcesses.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestProcesses.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation + * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import java.io.File; import java.util.Map; @@ -28,7 +28,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Platform; public class TestProcesses extends BaseTestCase { - private static final String workspaceLocation = ResourcesPlugin.getWorkspace().getRoot().getRawLocation().toOSString(); private static final String PROJECT_NAME = "TemplateEngineTestsProject"; //$NON-NLS-1$ private static final String SOURCE_FOLDER = "Source"; //$NON-NLS-1$ @@ -63,7 +62,7 @@ public class TestProcesses extends BaseTestCase { public void testAddFile() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFile"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -84,7 +83,7 @@ public class TestProcesses extends BaseTestCase { public void testAddFiles() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddFiles"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -105,7 +104,7 @@ public class TestProcesses extends BaseTestCase { public void testAddLink() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AddLink"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -131,7 +130,7 @@ public class TestProcesses extends BaseTestCase { public void testAppend() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Append"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -160,7 +159,7 @@ public class TestProcesses extends BaseTestCase { public void testAppendCreate() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*AppendCreate"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -184,7 +183,7 @@ public class TestProcesses extends BaseTestCase { public void testCopy() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*Copy"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -213,7 +212,7 @@ public class TestProcesses extends BaseTestCase { public void testCreateResourceIdentifier() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateResourceIdentifier"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ @@ -237,7 +236,7 @@ public class TestProcesses extends BaseTestCase { public void testCreateSourceFolder() { TemplateCore template = TemplateEngine.getDefault().getFirstTemplate(PROJECT_TYPE, null, ".*CreateSourceFolder"); //$NON-NLS-1$ - Map valueStore = template.getValueStore(); + Map valueStore = template.getValueStore(); valueStore.put("projectName", PROJECT_NAME); //$NON-NLS-1$ valueStore.put("projectType", PROJECT_TYPE); //$NON-NLS-1$ valueStore.put("location", ""); //$NON-NLS-1$ //$NON-NLS-2$ diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestSharedDefaults.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java similarity index 67% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestSharedDefaults.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java index f38821233dd..0f41d57bfab 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestSharedDefaults.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestSharedDefaults.java @@ -6,10 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation + * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; - +package org.eclipse.cdt.ui.tests.templateengine; import java.util.Iterator; import java.util.Map; @@ -18,7 +17,6 @@ import java.util.Set; import org.eclipse.cdt.core.templateengine.SharedDefaults; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - /** * Executes all the test cases of SharedDefaults backend functionality */ @@ -36,7 +34,6 @@ public class TestSharedDefaults extends BaseTestCase { /* * @see TestCase#tearDown() */ - protected void tearDown(){ sharedDefaults = null; } @@ -45,47 +42,39 @@ public class TestSharedDefaults extends BaseTestCase { * This test checks if data gets added to the back end * New data gets persisted in SharedDefault XML file */ - public void testAddToBackEndStorage() { - Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap(); + Map actualSharedDefaults= sharedDefaults.getSharedDefaultsMap(); actualSharedDefaults.put("provider.name","eclipse"); //$NON-NLS-1$ //$NON-NLS-2$ actualSharedDefaults.put("copyright","Symbian Software Ltd."); //$NON-NLS-1$ //$NON-NLS-2$ actualSharedDefaults.put("author","Bala Torati"); //$NON-NLS-1$ //$NON-NLS-2$ - Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); + Map expectedSharedDefaults= sharedDefaults.getSharedDefaultsMap(); assertEquals("Contents are different :", //$NON-NLS-1$ expectedSharedDefaults, actualSharedDefaults); - } - /** * This tests the updateToBackEndStorage of SharedDefaults * to verify whether the key-value pair gets updated with new value * New data gets persisted in SharedDefault XML file */ - public void testUpdateToBackEndStorage() { - Map actualSharedDefaults = sharedDefaults.getSharedDefaultsMap(); - Set keySet = actualSharedDefaults.keySet(); - Iterator iterator = keySet.iterator(); + Map actualSharedDefaults = sharedDefaults.getSharedDefaultsMap(); - while (iterator.hasNext()) { - Object key = iterator.next(); - Object value = actualSharedDefaults.get(key); - String keyName = (String)key; - String valueName = (String)value; - if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")){ //$NON-NLS-1$ - valueName = "Astala Vista"; //$NON-NLS-1$ - actualSharedDefaults.put(keyName, valueName); - sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", valueName); //$NON-NLS-1$ + for (Map.Entry entry : actualSharedDefaults.entrySet()) { + String key = entry.getKey(); + String value = entry.getValue(); + if (key.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$ + entry.setValue("Astala Vista"); //$NON-NLS-1$ + sharedDefaults.updateToBackEndStorage("org.eclipse.cdt.templateengine.project.HelloWorld.basename", value); //$NON-NLS-1$ + break; } } - Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); + Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); assertEquals("Contents are different :", //$NON-NLS-1$ expectedSharedDefaults, @@ -96,25 +85,23 @@ public class TestSharedDefaults extends BaseTestCase { * This tests the deleteBackEndStorage of SharedDefaults * to verify whether the key-value pair gets deleted at the backend */ - public void testDeleteBackEndStorage() { - Map actualSharedDefaults=sharedDefaults.getSharedDefaultsMap(); - Set keySet = actualSharedDefaults.keySet(); - Iterator iterator = keySet.iterator(); + Map actualSharedDefaults= sharedDefaults.getSharedDefaultsMap(); + Set keySet = actualSharedDefaults.keySet(); + Iterator iterator = keySet.iterator(); String keyName = null; while (iterator.hasNext()) { - - Object key = iterator.next(); - keyName = (String)key; + String key = iterator.next(); + keyName = key; if (keyName.equals("org.eclipse.cdt.templateengine.project.HelloWorld.basename")) { //$NON-NLS-1$ actualSharedDefaults.remove(keyName); break; } } - sharedDefaults.deleteBackEndStorage(new String[]{keyName}); - Map expectedSharedDefaults=sharedDefaults.getSharedDefaultsMap(); + sharedDefaults.deleteBackEndStorage(new String[] { keyName }); + Map expectedSharedDefaults= sharedDefaults.getSharedDefaultsMap(); assertEquals("Contents are different :", //$NON-NLS-1$ expectedSharedDefaults, diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateCore.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateCore.java similarity index 97% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateCore.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateCore.java index 6073e8aa739..c4b53a0ef7c 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateCore.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateCore.java @@ -8,7 +8,7 @@ * Contributors: * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import org.eclipse.cdt.core.templateengine.TemplateCore; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngine.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateEngine.java similarity index 92% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngine.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateEngine.java index 9c313c66565..85cbaab95b0 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngine.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateEngine.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation + * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import org.eclipse.cdt.core.templateengine.TemplateEngine; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; @@ -17,8 +17,6 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase; * Test the functionality of TemplateEngine. */ public class TestTemplateEngine extends BaseTestCase { - - TemplateEngine templateEngine = null; /* @@ -26,7 +24,6 @@ public class TestTemplateEngine extends BaseTestCase { */ protected void setUp() throws Exception { super.setUp(); - templateEngine = TemplateEngine.getDefault(); } @@ -59,5 +56,4 @@ public class TestTemplateEngine extends BaseTestCase { public void testSingleton() { assertSame(templateEngine, TemplateEngine.getDefault()); } - } diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngineBugs.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateEngineBugs.java similarity index 96% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngineBugs.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateEngineBugs.java index a11dfebed19..da1edf430b6 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestTemplateEngineBugs.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestTemplateEngineBugs.java @@ -8,7 +8,7 @@ * Contributors: * Andrew Ferguson (Symbian) - Initial Implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import java.util.Arrays; import java.util.HashSet; diff --git a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestValueStore.java b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestValueStore.java similarity index 73% rename from core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestValueStore.java rename to core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestValueStore.java index 42f0e45c710..e8f220d178a 100644 --- a/core/org.eclipse.cdt.core.tests/templateengine/org/eclipse/cdt/core/tests/templateengine/TestValueStore.java +++ b/core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/templateengine/TestValueStore.java @@ -6,9 +6,9 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Bala Torati (Symbian) - Initial API and implementation + * Bala Torati (Symbian) - Initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.core.tests.templateengine; +package org.eclipse.cdt.ui.tests.templateengine; import java.util.Iterator; import java.util.Map; @@ -17,13 +17,10 @@ import org.eclipse.cdt.core.templateengine.TemplateCore; import org.eclipse.cdt.core.templateengine.TemplateDescriptor; import org.eclipse.cdt.core.testplugin.util.BaseTestCase; - /** * Test the functionality of the ValueStore class. */ public class TestValueStore extends BaseTestCase { - - /** * setUp is called before execution of test method. */ @@ -44,12 +41,11 @@ public class TestValueStore extends BaseTestCase { /** * Test ValueStore for Not Null condition. - * */ public void testValueStoreNotNull(){ TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates(); - for (int i=0; i valueStore = templates[i].getValueStore(); assertNotNull(valueStore); } } @@ -60,18 +56,16 @@ public class TestValueStore extends BaseTestCase { */ public void testCompareValueStoreWithTemplateDefaluts(){ TemplateCore[] templates = TemplateEngineTestsHelper.getTestTemplates(); - for (int i=0; i valueStore = templates[i].getValueStore(); TemplateDescriptor templateDescriptor = templates[i].getTemplateDescriptor(); - Map templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()); + Map templateDefaults = templateDescriptor.getTemplateDefaults(templateDescriptor.getRootElement()); - Iterator defaultsIterator = templateDefaults.keySet().iterator(); - while(defaultsIterator.hasNext()){ - String key = (String)defaultsIterator.next(); + Iterator defaultsIterator = templateDefaults.keySet().iterator(); + while (defaultsIterator.hasNext()){ + String key = defaultsIterator.next(); assertNotNull(valueStore.get(key)); } } } - - } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java index 356fe88b0eb..7b5affd6f35 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/AutomatedSuite.java @@ -24,6 +24,7 @@ import org.eclipse.cdt.ui.tests.outline.OutlineTestSuite; import org.eclipse.cdt.ui.tests.quickfix.AssistQuickFixTest; import org.eclipse.cdt.ui.tests.refactoring.RefactoringTestSuite; import org.eclipse.cdt.ui.tests.search.SearchTestSuite; +import org.eclipse.cdt.ui.tests.templateengine.AllTemplateEngineTests; import org.eclipse.cdt.ui.tests.text.TextTestSuite; import org.eclipse.cdt.ui.tests.text.contentassist.ContentAssistTestSuite; import org.eclipse.cdt.ui.tests.text.contentassist2.ContentAssist2TestSuite; @@ -101,5 +102,7 @@ public class AutomatedSuite extends TestSuite { // tests from package org.eclipse.cdt.ui.tests.misc addTest(MiscTestSuite.suite()); + + addTest(AllTemplateEngineTests.suite()); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java index 01d43779f2f..6b9cbf91d44 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/refactoring/gettersandsetters/GenerateGettersAndSettersTest.java @@ -13,9 +13,7 @@ ******************************************************************************/ package org.eclipse.cdt.ui.tests.refactoring.gettersandsetters; -import java.util.ArrayList; import java.util.Collection; -import java.util.List; import java.util.Properties; import org.eclipse.core.resources.IFile; @@ -23,12 +21,12 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.ltk.core.refactoring.Change; import org.eclipse.ltk.core.refactoring.RefactoringStatus; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.ui.tests.refactoring.RefactoringTest; import org.eclipse.cdt.ui.tests.refactoring.TestSourceFile; +import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind; import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GenerateGettersAndSettersRefactoring; import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterContext; @@ -38,11 +36,11 @@ import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterCon public class GenerateGettersAndSettersTest extends RefactoringTest { protected boolean fatalError; private int warnings; - private List selectedGetters; - private List selectedSetters; + private int infos; + private String[] selectedGetters; + private String[] selectedSetters; private GenerateGettersAndSettersRefactoring refactoring; private boolean definitionSeparate; - private int infos; /** * @param name @@ -88,17 +86,11 @@ public class GenerateGettersAndSettersTest extends RefactoringTest { private void selectFields() { GetterSetterContext context = refactoring.getContext(); - for (IASTSimpleDeclaration currentDecl : context.existingFields) { - String name = currentDecl.getDeclarators()[0].getName().getRawSignature(); - if (selectedGetters.contains(name)) { - selectedGetters.remove(name); - context.selectedFunctions.add(context.createGetterInserter(currentDecl)); - } - - if (selectedSetters.contains(name)) { - selectedSetters.remove(name); - context.selectedFunctions.add(context.createSetterInserter(currentDecl)); - } + for (String name : selectedGetters) { + context.selectAccessorForField(name, AccessorKind.GETTER); + } + for (String name : selectedSetters) { + context.selectAccessorForField(name, AccessorKind.SETTER); } } @@ -111,13 +103,7 @@ public class GenerateGettersAndSettersTest extends RefactoringTest { String setters = refactoringProperties.getProperty("setters", ""); //$NON-NLS-1$ //$NON-NLS-2$ definitionSeparate = Boolean.valueOf(refactoringProperties.getProperty("definitionSeparate", "false")); - selectedGetters = new ArrayList(); - for (String getterName : getters.split(",")) { //$NON-NLS-1$ - selectedGetters.add(getterName); - } - selectedSetters = new ArrayList(); - for (String setterName : setters.split(",")) { //$NON-NLS-1$ - selectedSetters.add(setterName); - } + selectedGetters = getters.split(","); + selectedSetters = setters.split(","); } } diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java index 76a264530f3..8ebc81e6da8 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/BasicCEditorTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2010 Wind River Systems, Inc. and others. + * Copyright (c) 2006, 2011 Wind River Systems, Inc. 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 @@ -12,6 +12,7 @@ package org.eclipse.cdt.ui.tests.text; import java.io.File; +import java.lang.ref.WeakReference; import java.net.URI; import java.net.URISyntaxException; @@ -110,8 +111,8 @@ public class BasicCEditorTest extends BaseUITestCase { } } - private static CEditor fEditor; - private static SourceViewer fSourceViewer; + private CEditor fEditor; + private SourceViewer fSourceViewer; private ICProject fCProject; private IProject fNonCProject; private StyledText fTextWidget; @@ -443,6 +444,24 @@ public class BasicCEditorTest extends BaseUITestCase { assertTrue(part instanceof CEditor); } + public void testLeakingInstanceAfterClose() throws Exception { + final String file= "/ceditor/src/main.cpp"; + fCProject= EditorTestHelper.createCProject("ceditor", "resources/ceditor", false, false); + setUpEditor(file); + fSourceViewer= EditorTestHelper.getSourceViewer(fEditor); + assertTrue(EditorTestHelper.joinReconciler(fSourceViewer, 0, 10000, 100)); + WeakReference ref = new WeakReference(fEditor); + EditorTestHelper.closeEditor(fEditor); + fEditor = null; + fSourceViewer = null; + int ngc = 10; + while (ref.get() != null && ngc-- > 0) { + System.gc(); + Thread.sleep(200); + } + assertNull("CEditor instance seems to be leaking after close", ref.get()); + } + /** * Type characters into the styled text. * diff --git a/core/org.eclipse.cdt.ui/plugin.properties b/core/org.eclipse.cdt.ui/plugin.properties index 9a3bc8c32ac..b68047862f3 100644 --- a/core/org.eclipse.cdt.ui/plugin.properties +++ b/core/org.eclipse.cdt.ui/plugin.properties @@ -328,15 +328,22 @@ HideCFiles.description= Hides all C files HideHeaderFiles.label= Header files HideHeaderFiles.description= Hides all Header files -HideUsingDirective.label= Using directive -HideUsingDirective.description= Hides using directives - -HideMacroDirective.label= Macro directive -HideMacroDirective.description= Hides Macro directives +HideAnonymousStruct.label= Anonymous structs and enums +HideAnonymousStruct.navigator.label= C/C++ anonymous structs and enums +HideAnonymousStruct.description= Hides all anonymous structs and enums ForwardDeclarationFilter.label= Forward declaration +ForwardDeclarationFilter.navigator.label= C/C++ forward declaration ForwardDeclarationFilter.description= Hides forward declarations, unless found in a header file. +HideMacroDirective.label= Macro directive +HideMacroDirective.navigator.label= C/C++ macro directive +HideMacroDirective.description= Hides Macro directives + +HideUsingDirective.label= Using directive +HideUsingDirective.navigator.label= C/C++ using directive +HideUsingDirective.description= Hides using directives + # WorkInProgress.name=Work In Progress diff --git a/core/org.eclipse.cdt.ui/plugin.xml b/core/org.eclipse.cdt.ui/plugin.xml index 105406c2347..4098d3c082a 100644 --- a/core/org.eclipse.cdt.ui/plugin.xml +++ b/core/org.eclipse.cdt.ui/plugin.xml @@ -136,14 +136,54 @@ class="org.eclipse.cdt.internal.ui.filters.NonCElementFilter" id="org.eclipse.cdt.internal.ui.CView.NonCElementFilter"> - + + + + + + + id="org.eclipse.cdt.internal.ui.CView.UsingDeclarationFilter"> + + + + + + description="%HideUsingDirective.description" + class="org.eclipse.cdt.internal.ui.filters.UsingDirectiveFilter" + id="org.eclipse.cdt.ui.COutlinePage.UsingDeclarationFilter"> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -2958,10 +3414,6 @@ point="org.eclipse.core.runtime.preferences"> - - - + + + + diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java index 9672a1c9beb..1e795615de8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/BaseCElementContentProvider.java @@ -52,7 +52,7 @@ import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.CElementGrouping; import org.eclipse.cdt.ui.IncludesGrouping; import org.eclipse.cdt.ui.NamespacesGrouping; - + /** * A base content provider for C elements. It provides access to the * C element hierarchy without listening to changes in the C model. @@ -83,11 +83,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider { protected boolean fNamespacesGrouping= false; protected boolean fMemberGrouping= false; protected boolean fMacroGrouping= false; - + public BaseCElementContentProvider() { this(false, false); } - + public BaseCElementContentProvider(boolean provideMembers, boolean provideWorkingCopy) { fProvideMembers= provideMembers; fProvideWorkingCopy= provideWorkingCopy; @@ -161,7 +161,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { public boolean isMemberGroupingEnabled() { return fMemberGrouping; } - + /** * Enable/disable member grouping by common namespace. * @param enable @@ -169,14 +169,14 @@ public class BaseCElementContentProvider implements ITreeContentProvider { public void setMemberGrouping(boolean enable) { fMemberGrouping = enable; } - + /** * @return whether grouping of macros is enabled */ public boolean isMacroGroupingEnabled() { return fMacroGrouping; } - + /** * Enable/disable marco grouping * @param enable @@ -188,25 +188,29 @@ public class BaseCElementContentProvider implements ITreeContentProvider { /* (non-Cdoc) * Method declared on IContentProvider. */ + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } /* (non-Cdoc) * Method declared on IContentProvider. */ + @Override public void dispose() { } /* (non-Cdoc) * Method declared on IStructuredContentProvider. */ + @Override public Object[] getElements(Object parent) { return getChildren(parent); } - + /* (non-Cdoc) * Method declared on ITreeContentProvider. */ + @Override public Object[] getChildren(Object element) { if (!exists(element)) return NO_CHILDREN; @@ -263,6 +267,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { * * @see ITreeContentProvider */ + @Override public boolean hasChildren(Object element) { if (fProvideMembers) { // assume TUs and binary files are never empty @@ -303,7 +308,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { return true; } } - + if (element instanceof CElementGrouping) { return true; } @@ -311,10 +316,11 @@ public class BaseCElementContentProvider implements ITreeContentProvider { Object[] children= getChildren(element); return (children != null) && children.length > 0; } - + /* (non-Cdoc) * Method declared on ITreeContentProvider. */ + @Override public Object getParent(Object element) { if (!exists(element)) { return null; @@ -398,7 +404,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } return parent; } - + protected Object[] getCProjects(ICModel cModel) throws CModelException { Object[] objects = cModel.getCProjects(); try { @@ -415,7 +421,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { protected Object[] getSourceRoots(ICProject cproject) throws CModelException { if (!cproject.getProject().isOpen()) return NO_CHILDREN; - + List list= new ArrayList(); ICElement[] children = cproject.getChildren(); for (ICElement child : children) { @@ -426,8 +432,8 @@ public class BaseCElementContentProvider implements ITreeContentProvider { list.add(c2[k]); } else if (CCorePlugin.showSourceRootsAtTopOfProject()) { list.add(child); - } else if (child instanceof ISourceRoot && - child.getResource().getParent().equals(cproject.getProject())) { + } else if (child instanceof ISourceRoot && + child.getResource().getParent().equals(cproject.getProject())) { list.add(child); } } @@ -579,7 +585,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } } catch (CModelException e) { } - + Object[] result = children; if (missingElements.size() > 0) { result = concatenate(result, missingElements.toArray()); @@ -593,7 +599,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } private List getMissingElements(ICContainer container, ICElement[] elements) { - // nested source roots may be filtered out below the project root, + // nested source roots may be filtered out below the project root, // we need to find them to add them back in List missingElements = new ArrayList(); try { @@ -643,7 +649,7 @@ public class BaseCElementContentProvider implements ITreeContentProvider { } return filterNonCResources(members, cproject); } - + private Object[] filterNonCResources(Object[] objects, ICProject cproject) throws CModelException { ICElement[] binaries = null; ICElement[] archives = null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java index 8912250fd3b..a2972590882 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CActionFilter.java @@ -25,6 +25,7 @@ public class CActionFilter implements IActionFilter { public CActionFilter() { } + @Override public boolean testAttribute(Object target, String name, String value) { ICElement element = (ICElement) target; IResource resource = element.getResource(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java index f3c1983b1ba..c34d2a72a2e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementAdapterFactory.java @@ -31,33 +31,35 @@ import org.eclipse.cdt.core.model.ICElement; * Implements basic UI support for C elements. */ public class CElementAdapterFactory implements IAdapterFactory { - + private static Class[] PROPERTIES= new Class[] { IPropertySource.class, IResource.class, IWorkbenchAdapter.class, IPersistableElement.class, IDeferredWorkbenchAdapter.class, - IActionFilter.class + IActionFilter.class }; - + private static CWorkbenchAdapter fgCWorkbenchAdapter; private static CActionFilter fgCActionFilter; - + /** * @see CElementAdapterFactory#getAdapterList */ + @Override public Class[] getAdapterList() { return PROPERTIES; } /** * @see CElementAdapterFactory#getAdapter - */ + */ + @Override @SuppressWarnings({ "unchecked", "rawtypes" }) public Object getAdapter(Object element, Class key) { ICElement celem = (ICElement) element; - + if (IPropertySource.class.equals(key)) { return getPropertySource(celem); } else if (IResource.class.isAssignableFrom(key)) { @@ -74,12 +76,12 @@ public class CElementAdapterFactory implements IAdapterFactory { } else if (IActionFilter.class.equals(key)) { return getActionFilter(celem); } - return null; + return null; } private IPropertySource getPropertySource(ICElement celement) { if (celement instanceof IBinary) { - return new BinaryPropertySource((IBinary)celement); + return new BinaryPropertySource((IBinary)celement); } IResource res = celement.getResource(); if (res != null) { @@ -88,7 +90,7 @@ public class CElementAdapterFactory implements IAdapterFactory { } return new ResourcePropertySource(res); } - return new CElementPropertySource(celement); + return new CElementPropertySource(celement); } private IResource getResource(ICElement celement) { @@ -105,7 +107,7 @@ public class CElementAdapterFactory implements IAdapterFactory { } return fgCWorkbenchAdapter; } - + private IActionFilter getActionFilter(ICElement celement) { if (fgCActionFilter == null) { fgCActionFilter = new CActionFilter(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java index e69c13dadc8..c7bf15c4e12 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CElementPropertySource.java @@ -11,31 +11,32 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.jface.viewers.IBasicPropertyConstants; import org.eclipse.ui.views.properties.IPropertyDescriptor; import org.eclipse.ui.views.properties.IPropertySource; import org.eclipse.ui.views.properties.PropertyDescriptor; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.ui.CUIPlugin; + public class CElementPropertySource implements IPropertySource { - + private final static String LABEL= "CElementProperties.name"; //$NON-NLS-1$ - + private ICElement fCElement; - + // Property Descriptors static private IPropertyDescriptor[] fgPropertyDescriptors; - + static { // resource name String displayName= CUIPlugin.getResourceString(LABEL); PropertyDescriptor descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, displayName); descriptor.setAlwaysIncompatible(true); - + fgPropertyDescriptors= new IPropertyDescriptor[] { descriptor }; } - + public CElementPropertySource(ICElement elem) { fCElement= elem; } @@ -43,13 +44,15 @@ public class CElementPropertySource implements IPropertySource { /** * @see IPropertySource#getPropertyDescriptors */ + @Override public IPropertyDescriptor[] getPropertyDescriptors() { return fgPropertyDescriptors; } /** * @see IPropertySource#getPropertyValue - */ + */ + @Override public Object getPropertyValue(Object name) { if (name.equals(IBasicPropertyConstants.P_TEXT)) { return fCElement.getElementName(); @@ -59,27 +62,31 @@ public class CElementPropertySource implements IPropertySource { /** * @see IPropertySource#setPropertyValue - */ + */ + @Override public void setPropertyValue(Object name, Object value) { } /** * @see IPropertySource#getEditableValue - */ + */ + @Override public Object getEditableValue() { return null; } /** * @see IPropertySource#isPropertySet - */ + */ + @Override public boolean isPropertySet(Object property) { return false; } /** * @see IPropertySource#resetPropertyValue - */ + */ + @Override public void resetPropertyValue(Object property) { } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java index 192f5654142..15f803aed94 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPerspectiveFactory.java @@ -12,8 +12,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; -import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.search.ui.NewSearchUI; import org.eclipse.ui.IFolderLayout; import org.eclipse.ui.IPageLayout; @@ -21,8 +19,12 @@ import org.eclipse.ui.IPerspectiveFactory; import org.eclipse.ui.console.IConsoleConstants; import org.eclipse.ui.navigator.resources.ProjectExplorer; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.wizards.CWizardRegistry; + public class CPerspectiveFactory implements IPerspectiveFactory { - + /** * Constructs a new Default layout engine. */ @@ -33,34 +35,35 @@ public class CPerspectiveFactory implements IPerspectiveFactory { /** * @see IPerspectiveFactory#createInitialLayout */ + @Override public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); - + IFolderLayout folder1= layout.createFolder("topLeft", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$ folder1.addView(ProjectExplorer.VIEW_ID); folder1.addPlaceholder(CUIPlugin.CVIEW_ID); folder1.addPlaceholder(IPageLayout.ID_RES_NAV); folder1.addPlaceholder(IPageLayout.ID_BOOKMARKS); - + IFolderLayout folder2= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$ folder2.addView(IPageLayout.ID_PROBLEM_VIEW); folder2.addView(IPageLayout.ID_TASK_LIST); folder2.addView(IConsoleConstants.ID_CONSOLE_VIEW); folder2.addView(IPageLayout.ID_PROP_SHEET); - + IFolderLayout folder3= layout.createFolder("topRight", IPageLayout.RIGHT,(float)0.75, editorArea); //$NON-NLS-1$ folder3.addView(IPageLayout.ID_OUTLINE); layout.addActionSet(CUIPlugin.SEARCH_ACTION_SET_ID); layout.addActionSet(CUIPlugin.ID_CELEMENT_CREATION_ACTION_SET); layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET); - + // views - build console layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW); - + // views - searching layout.addShowViewShortcut(NewSearchUI.SEARCH_VIEW_ID); - + // views - standard workbench layout.addShowViewShortcut(IPageLayout.ID_OUTLINE); layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW); @@ -71,7 +74,7 @@ public class CPerspectiveFactory implements IPerspectiveFactory { addCWizardShortcuts(layout); } - + private void addCWizardShortcuts(IPageLayout layout) { // new actions - C project creation wizard String[] wizIDs = CWizardRegistry.getProjectWizardIDs(); @@ -93,6 +96,6 @@ public class CPerspectiveFactory implements IPerspectiveFactory { for (int i = 0; i < wizIDs.length; ++i) { layout.addNewWizardShortcut(wizIDs[i]); } - + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java index c9c3f244d39..ee355976529 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CProjectAdapterFactory.java @@ -28,6 +28,7 @@ public class CProjectAdapterFactory implements IAdapterFactory { /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) */ + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Object adaptableObject, Class adapterType) { if (IProject.class.equals(adapterType)) { @@ -39,6 +40,7 @@ public class CProjectAdapterFactory implements IAdapterFactory { /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() */ + @Override public Class[] getAdapterList() { return ADAPTERS; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java index 12e2cabba1a..5fecaccf09e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CWorkbenchAdapter.java @@ -12,14 +12,16 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.model.IWorkbenchAdapter; + import org.eclipse.cdt.core.model.CModelException; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.IParent; -import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CUIPlugin; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.ui.model.IWorkbenchAdapter; + +import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; /** * An implementation of the IWorkbenchAdapter for CElements. @@ -38,6 +40,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getChildren */ + @Override public Object[] getChildren(Object o) { if (o instanceof IParent) { try { @@ -55,6 +58,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getImageDescriptor */ + @Override public ImageDescriptor getImageDescriptor(Object element) { if (element instanceof ICElement) { return fImageProvider.getCImageDescriptor( @@ -67,6 +71,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getLabel */ + @Override public String getLabel(Object o) { if (o instanceof ICElement) { return fLabelProvider.getText(o); @@ -77,6 +82,7 @@ public class CWorkbenchAdapter implements IWorkbenchAdapter { /** * @see IWorkbenchAdapter#getParent */ + @Override public Object getParent(Object o) { if (o instanceof ICElement) { return ((ICElement) o).getParent(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java index 141534ced1a..a062100742a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/DeferredCWorkbenchAdapter.java @@ -10,13 +10,14 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.core.model.IParent; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.ui.progress.IDeferredWorkbenchAdapter; import org.eclipse.ui.progress.IElementCollector; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.core.model.IParent; + public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDeferredWorkbenchAdapter { private ICElement fCElement; @@ -28,11 +29,12 @@ public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDef /* * (non-Javadoc) - * + * * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#fetchDeferredChildren(java.lang.Object, * org.eclipse.jface.progress.IElementCollector, * org.eclipse.core.runtime.IProgressMonitor) */ + @Override public void fetchDeferredChildren(Object object, IElementCollector collector, IProgressMonitor monitor) { Object[] children = getChildren(object); if (monitor.isCanceled()) { @@ -44,18 +46,20 @@ public class DeferredCWorkbenchAdapter extends CWorkbenchAdapter implements IDef /* * (non-Javadoc) - * + * * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#isContainer() */ + @Override public boolean isContainer() { return fCElement instanceof IParent; } /* * (non-Javadoc) - * + * * @see org.eclipse.ui.progress.IDeferredWorkbenchAdapter#getRule(java.lang.Object) */ + @Override public ISchedulingRule getRule(final Object object) { return fCElement.getResource(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java index fe764f8e1c9..9a59059a3a6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ICThemeConstants.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 IBM Corporation and others. + * Copyright (c) 2007, 2011 IBM Corporation 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 @@ -40,4 +40,94 @@ public interface ICThemeConstants { */ public final String CODEASSIST_PARAMETERS_FOREGROUND= ID_PREFIX + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND; + /** + * A theme constant that holds the foreground color used for multi-line comments. + */ + public final String EDITOR_MULTI_LINE_COMMENT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR; + + /** + * A theme constant that holds the foreground color used for single-line comments. + */ + public final String EDITOR_SINGLE_LINE_COMMENT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR; + + /** + * A theme constant that holds the foreground color used for C/C++ keywords. + */ + public final String EDITOR_C_KEYWORD_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_KEYWORD_COLOR; + + /** + * A theme constant that holds the foreground color used for preprocessor directives. + */ + public final String EDITOR_PP_DIRECTIVE_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR; + + /** + * A theme constant that holds the foreground color used for preprocessor headers (includes). + */ + public final String EDITOR_PP_HEADER_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_PP_HEADER_COLOR; + + /** + * A theme constant that holds the foreground color used for preprocessor text. + */ + public final String EDITOR_PP_DEFAULT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_PP_DEFAULT_COLOR; + + /** + * A theme constant that holds the foreground color used for C/C++ built-in types. + */ + public final String EDITOR_C_BUILTIN_TYPE_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR; + + /** + * A theme constant that holds the foreground color used for string constants. + */ + public final String EDITOR_C_STRING_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_STRING_COLOR; + + /** + * A theme constant that holds the foreground color used for operators. + */ + public final String EDITOR_C_OPERATOR_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_OPERATOR_COLOR; + + /** + * A theme constant that holds the foreground color used for numbers. + */ + public final String EDITOR_C_NUMBER_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_NUMBER_COLOR; + + /** + * A theme constant that holds the foreground color used for braces. + */ + public final String EDITOR_C_BRACES_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_BRACES_COLOR; + + /** + * A theme constant that holds the foreground color used for C/C++ code. + */ + public final String EDITOR_C_DEFAULT_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_C_DEFAULT_COLOR; + + /** + * A theme constant that holds the foreground color used for assembly labels. + */ + public final String EDITOR_ASM_LABEL_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_ASM_LABEL_COLOR; + + /** + * A theme constant that holds the foreground color used for assembly directives. + */ + public final String EDITOR_ASM_DIRECTIVE_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR; + + /** + * A theme constant that holds the foreground color used for task tags. + */ + public final String EDITOR_TASK_TAG_COLOR= ID_PREFIX + PreferenceConstants.EDITOR_TASK_TAG_COLOR; + + /** + * A theme constant that holds the foreground color used for doxygen multi-line comments. + */ + public final String DOXYGEN_MULTI_LINE_COLOR= PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR; + + /** + * A theme constant that holds the foreground color used for doxygen single line comments. + */ + public final String DOXYGEN_SINGLE_LINE_COLOR= PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR; + + /** + * A theme constant that holds the foreground color used for doxygen tags. + */ + public final String DOXYGEN_TAG_COLOR= PreferenceConstants.DOXYGEN_TAG_COLOR; + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java index ea5364b97c4..3f287f0126b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/LineBackgroundPainter.java @@ -34,13 +34,13 @@ import org.eclipse.swt.graphics.Rectangle; /** * A painter for configurable background painting a range of text lines. - * Replicates also the functionality of the + * Replicates also the functionality of the * {@link org.eclipse.jface.text.CursorLinePainter} * because only one {@link LineBackgroundListener} is allowed * per {@link StyledText} widget. - * + * * @author anton.leherbauer@windriver.com - * + * * @since 4.0 */ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { @@ -89,7 +89,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Sets the color in which to draw the background of the given position type. - * + * * @param positionType the position type for which to specify the background color * @param color the color in which to draw the background of the given position type */ @@ -99,7 +99,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Sets the color in which to draw the background of the cursor line. - * + * * @param cursorLineColor the color in which to draw the background of the cursor line */ public void setCursorLineColor(Color cursorLineColor) { @@ -108,7 +108,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Sets the color in which to draw the background of untyped positions. - * + * * @param color the color in which to draw the background of untyped positions */ public void setDefaultColor(Color color) { @@ -117,7 +117,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Enable/disable cursor line highlighting. - * + * * @param enable */ public void enableCursorLine(boolean enable) { @@ -131,7 +131,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Set highlight positions. It is assumed that all positions * are up-to-date with respect to the text viewer document. - * + * * @param positions a list of Positions */ public void setHighlightPositions(List positions) { @@ -148,7 +148,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Add highlight positions. It is assumed that all positions * are up-to-date with respect to the text viewer document. - * + * * @param positions a list of Positions */ public void addHighlightPositions(List positions) { @@ -162,7 +162,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Remove highlight positions by identity. - * + * * @param positions a list of Positions */ public void removeHighlightPositions(List positions) { @@ -176,7 +176,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Replace given highlight positions in one step. - * + * * @param removePositions a list of Positions to remove * @param addPositions a list of Positions to add */ @@ -232,6 +232,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.jface.text.IPainter#dispose() */ + @Override public void dispose() { // no deactivate! fIsActive= false; @@ -252,10 +253,11 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { public boolean isDisposed() { return fTextViewer == null; } - + /* * @see org.eclipse.jface.text.IPainter#paint(int) */ + @Override public void paint(int reason) { IDocument document= fTextViewer.getDocument(); if (document == null) { @@ -365,7 +367,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /** * Trigger redraw of given text positions. - * + * * @param positions */ private void redrawPositions(List positions) { @@ -429,6 +431,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.jface.text.IPainter#deactivate(boolean) */ + @Override public void deactivate(boolean redraw) { if (fIsActive) { fIsActive= false; @@ -443,6 +446,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.jface.text.IPainter#setPositionManager(org.eclipse.jface.text.IPaintPositionManager) */ + @Override public void setPositionManager(IPaintPositionManager manager) { fPositionManager= manager; } @@ -485,6 +489,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { /* * @see org.eclipse.swt.custom.LineBackgroundListener#lineGetBackground(org.eclipse.swt.custom.LineBackgroundEvent) */ + @Override public void lineGetBackground(LineBackgroundEvent event) { if (fTextWidget != null) { Position match= findIncludingPosition(getDocumentOffset(event.lineOffset)); @@ -541,7 +546,7 @@ public class LineBackgroundPainter implements IPainter, LineBackgroundListener { IDocument document= fTextViewer.getDocument(); if (document != null) { int lineNumber= document.getLineOfOffset(getDocumentOffset(fTextWidget.getCaretOffset())); - + fCursorLine.isDeleted= false; fCursorLine.offset= document.getLineOffset(lineNumber); fCursorLine.length= 0; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java index 547ce717e01..8de110b288e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/PersistableCElementFactory.java @@ -27,7 +27,7 @@ import org.eclipse.ui.IPersistableElement; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICElement; -/** +/** * The PersistableCElementFactory is used to save and recreate an ICElement object. * As such, it implements the IPersistableElement interface for storage * and the IElementFactory interface for recreation. @@ -66,7 +66,8 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable /** * @see IElementFactory */ - public IAdaptable createElement(IMemento memento) { + @Override + public IAdaptable createElement(IMemento memento) { // Get the file name. String fileName = memento.getString(TAG_PATH); if (fileName == null) { @@ -84,7 +85,7 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable if (fCElement != null) { return fCElement; } - + final IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); Integer elementType= memento.getInteger(TAG_TYPE); if (elementType == null) { @@ -114,14 +115,16 @@ public class PersistableCElementFactory implements IElementFactory, IPersistable /** * @see IPersistableElement */ - public String getFactoryId() { + @Override + public String getFactoryId() { return FACTORY_ID; } /** * @see IPersistableElement */ - public void saveState(IMemento memento) { + @Override + public void saveState(IMemento memento) { if (fCElement.getResource() != null) { memento.putString(TAG_PATH, fCElement.getResource().getFullPath().toString()); memento.putInteger(TAG_TYPE, fCElement.getResource().getType()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java index 39049425b24..b2d80cd3231 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/ResourceAdapterFactory.java @@ -26,20 +26,22 @@ public class ResourceAdapterFactory implements IAdapterFactory { private static Class[] PROPERTIES= new Class[] { ICElement.class }; - + //private static CElementFactory celementFactory= new CElementFactory(); private static CoreModel celementFactory= CoreModel.getDefault(); /** * @see IAdapterFactory#getAdapterList - */ + */ + @Override public Class[] getAdapterList() { return PROPERTIES; } - + /** * @see IAdapterFactory#getAdapter */ + @Override @SuppressWarnings("rawtypes") public Object getAdapter(Object element, Class key) { if (ICElement.class.equals(key)) { @@ -60,5 +62,5 @@ public class ResourceAdapterFactory implements IAdapterFactory { //} } return null; - } + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java index bf4d34d50ac..fa5a437b9c7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/AbstractUpdateIndexAction.java @@ -8,7 +8,7 @@ * Contributors: * Markus Schorn - initial API and implementation * Anton Leherbauer (Wind River Systems) - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; @@ -34,14 +34,16 @@ import org.eclipse.cdt.ui.CUIPlugin; public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate { private ISelection fSelection; - + + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { } + @Override public void run(IAction action) { if (!(fSelection instanceof IStructuredSelection)) return; - + IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); Iterator i= cElements.iterator(); ArrayList tuSelection= new ArrayList(); @@ -52,7 +54,7 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate } } ICElement[] tuArray= tuSelection.toArray(new ICElement[tuSelection.size()]); - + try { CCorePlugin.getIndexManager().update(tuArray, getUpdateOptions()); } @@ -71,6 +73,7 @@ public abstract class AbstractUpdateIndexAction implements IObjectActionDelegate /** * @see IActionDelegate#selectionChanged(IAction, ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection = selection; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java index bb59cbe20ae..b68ebfdb6cf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2001, 2010 IBM Corporation and others. + * Copyright (c) 2001, 2011 IBM Corporation 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 @@ -91,6 +91,9 @@ public class ActionMessages extends NLS { public static String FormatAllAction_failedvalidateedit_message; public static String FormatAllAction_noundo_title; public static String FormatAllAction_noundo_message; + public static String CollapseAllAction_label; + public static String CollapseAllAction_tooltip; + public static String CollapseAllAction_description; static { // Initialize resource bundle. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties index c27f42bce76..44e4f33a4e5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ActionMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2010 IBM Corporation and others. +# Copyright (c) 2000, 2011 IBM Corporation 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 @@ -109,3 +109,7 @@ FormatAllAction_failedvalidateedit_title=Format FormatAllAction_failedvalidateedit_message=Problems while accessing selected files. FormatAllAction_noundo_title=Format FormatAllAction_noundo_message='Undo' is not supported by this operation. Do you want to continue? + +CollapseAllAction_label=Collapse All +CollapseAllAction_tooltip=Collapse All +CollapseAllAction_description=Collapse All diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java index 1b33aa414a5..d13b461c78d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CDTQuickMenuCreator.java @@ -11,20 +11,17 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Point; - import org.eclipse.core.commands.AbstractHandler; import org.eclipse.core.commands.ExecutionEvent; import org.eclipse.core.commands.ExecutionException; import org.eclipse.core.commands.IHandler; - import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.text.ITextViewerExtension5; import org.eclipse.jface.text.Region; import org.eclipse.jface.text.source.ISourceViewer; - +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.graphics.Point; import org.eclipse.ui.actions.QuickMenuCreator; import org.eclipse.cdt.internal.ui.editor.CEditor; @@ -33,7 +30,7 @@ import org.eclipse.cdt.internal.ui.text.CWordFinder; /** * C/C++ editor aware quick menu creator. In the given editor, the menu will be aligned with the word * at the current offset. - * + * * @since 5.2 */ public abstract class CDTQuickMenuCreator extends QuickMenuCreator { @@ -94,11 +91,12 @@ public abstract class CDTQuickMenuCreator extends QuickMenuCreator { /** * Returns a handler that can create and open the quick menu. - * + * * @return a handler that can create and open the quick menu */ public IHandler createHandler() { return new AbstractHandler() { + @Override public Object execute(ExecutionEvent event) throws ExecutionException { createMenu(); return null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java similarity index 60% rename from core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java rename to core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java index 8f06d23d398..42706c7ec3e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CollapseAllAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CollapseAllAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation 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 @@ -8,31 +8,38 @@ * Contributors: * IBM Corporation - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.internal.ui.cview; +package org.eclipse.cdt.internal.ui.actions; -import org.eclipse.cdt.internal.ui.ICHelpContextIds; -import org.eclipse.cdt.internal.ui.CPluginImages; import org.eclipse.jface.action.Action; +import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.ui.PlatformUI; +import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.cdt.internal.ui.ICHelpContextIds; + /** * Collapse all nodes. */ -class CollapseAllAction extends Action { +public class CollapseAllAction extends Action { - private CView cview; + private final TreeViewer fViewer; - CollapseAllAction(CView part) { - super(CViewMessages.CollapseAllAction_label); - setDescription(CViewMessages.CollapseAllAction_description); - setToolTipText(CViewMessages.CollapseAllAction_tooltip); + public CollapseAllAction(TreeViewer viewer) { + super(ActionMessages.CollapseAllAction_label); + setDescription(ActionMessages.CollapseAllAction_description); + setToolTipText(ActionMessages.CollapseAllAction_tooltip); CPluginImages.setImageDescriptors(this, CPluginImages.T_LCL, CPluginImages.IMG_MENU_COLLAPSE_ALL); - cview = part; + fViewer = viewer; PlatformUI.getWorkbench().getHelpSystem().setHelp(this, ICHelpContextIds.COLLAPSE_ALL_ACTION); } @Override public void run() { - cview.collapseAll(); + try { + fViewer.getControl().setRedraw(false); + fViewer.collapseAll(); + } finally { + fViewer.getControl().setRedraw(true); + } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java index 245816efe30..99d745db532 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/CreateParserLogAction.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; import java.io.File; @@ -98,7 +98,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { fProblems.add(problem); return PROCESS_SKIP; } - + @Override public int visit(IASTName name) { if (name instanceof ICPPASTQualifiedName) { @@ -117,6 +117,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { } private static final Comparator COMP_INSENSITIVE= new Comparator () { + @Override public int compare(String o1, String o2) { return o1.toUpperCase().compareTo(o2.toUpperCase()); } @@ -126,20 +127,23 @@ public class CreateParserLogAction implements IObjectActionDelegate { private IWorkbenchPartSite fSite; private boolean fWroteUnresolvedTitle; - + + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { fSite= targetPart.getSite(); } + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection = selection; } + @Override public void run(IAction action) { if (!(fSelection instanceof IStructuredSelection)) return; - - final String title= action.getText().replace("&", ""); + + final String title= action.getText().replace("&", ""); IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); Iterator i= cElements.iterator(); ArrayList tuSelection= new ArrayList(); @@ -155,36 +159,36 @@ public class CreateParserLogAction implements IObjectActionDelegate { } FileDialog dlg= new FileDialog(fSite.getShell(), SWT.SAVE); dlg.setText(title); - dlg.setFilterExtensions(new String[]{"*.log"}); + dlg.setFilterExtensions(new String[]{"*.log"}); String path= null; while(path == null) { path= dlg.open(); if (path == null) return; - File file= new File(path); + File file= new File(path); if (file.exists()) { if (!file.canWrite()) { - final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path); + final String msg= NLS.bind(ActionMessages.CreateParserLogAction_readOnlyFile, path); MessageDialog.openError(fSite.getShell(), title, msg); path= null; } else { - final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path); + final String msg = NLS.bind(ActionMessages.CreateParserLogAction_existingFile, path); if (!MessageDialog.openQuestion(fSite.getShell(), title, msg)) { path= null; } } } } - + try { PrintStream out= new PrintStream(path); try { boolean needsep= false; for (ITranslationUnit tu : tuArray) { if (needsep) { - out.println(); out.println(); + out.println(); out.println(); } createLog(out, tu, new NullProgressMonitor()); needsep= true; @@ -205,6 +209,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { CUIPlugin.log(e); } ASTProvider.getASTProvider().runOnAST(tu, ASTProvider.WAIT_IF_OPEN, pm, new ASTCache.ASTRunnable() { + @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { if (ast != null) return createLog(out, tu, lang, ast); @@ -243,11 +248,11 @@ public class CreateParserLogAction implements IObjectActionDelegate { final ExtendedScannerInfo scfg= new ExtendedScannerInfo(configureWith.getScannerInfo(true)); final MyVisitor visitor= new MyVisitor(); ast.accept(visitor); - - out.println("Project: " + projectName); - out.println("File: " + tu.getLocationURI()); - out.println("Language: " + lang.getName()); - out.println("Index Version: " + PDOM.versionString(PDOM.getDefaultVersion())); + + out.println("Project: " + projectName); + out.println("File: " + tu.getLocationURI()); + out.println("Language: " + lang.getName()); + out.println("Index Version: " + PDOM.versionString(PDOM.getDefaultVersion())); out.println("Build Configuration: " + getBuildConfig(cproject)); if (configureWith == tu) { out.println("Context: none"); @@ -255,7 +260,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println("Context: " + configureWith.getLocationURI()); out.println(INDENT + getLinkageName(ctxLinkage) + ", " + ctxSigMacros); } - + try { IIndexFile[] versions= index.getFiles(IndexLocationFactory.getIFL(tu)); out.println("Versions in Index: " + versions.length); @@ -271,7 +276,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { output(out, "Local Include Search Path (option -iquote):", scfg.getLocalIncludePath()); output(out, "Preincluded files (option -include):", scfg.getIncludeFiles()); output(out, "Preincluded macro files (option -imacros):", scfg.getMacroFiles()); - + HashSet reported= new HashSet(); output(out, "Macro definitions (option -D):", scfg.getDefinedSymbols(), reported); output(out, "Macro definitions (from language + headers in index):", ast.getBuiltinMacroDefinitions(), reported); @@ -306,13 +311,13 @@ public class CreateParserLogAction implements IObjectActionDelegate { ICProjectDescription prefs= prjDescMgr.getProjectDescription(cproject.getProject(), false); if (prefs != null) { ICConfigurationDescription cfg= prefs.getDefaultSettingConfiguration(); - if (cfg != null) + if (cfg != null) return cfg.getName(); } return "unknown"; } - private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, + private void outputUnresolvedIncludes(ICProject prj, IIndex index, PrintStream out, IASTPreprocessorIncludeStatement[] includeDirectives, int linkageID) throws CoreException { fWroteUnresolvedTitle= false; ASTFilePathResolver resolver= new ProjectIndexerInputAdapter(prj); @@ -328,11 +333,11 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } - private void outputUnresolvedIncludes(IIndex index, PrintStream out, + private void outputUnresolvedIncludes(IIndex index, PrintStream out, IIndexFileLocation ifl, IIndexFile ifile, Set handled) throws CoreException { if (ifile == null) { writeUnresolvedTitle(out); - out.println(INDENT + ifl.getURI() + " is not indexed"); + out.println(INDENT + ifl.getURI() + " is not indexed"); } else if (handled.add(ifile)) { IIndexInclude[] includes = ifile.getIncludes(); for (IIndexInclude inc : includes) { @@ -342,7 +347,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { outputUnresolvedIncludes(index, out, inc.getIncludesLocation(), next, handled); } else { writeUnresolvedTitle(out); - out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file " + + out.println(INDENT + "Unresolved inclusion: " + inc.getFullName() + " in file " + inc.getIncludedByLocation().getURI()); } } @@ -382,7 +387,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } } - + private void output(PrintStream out, String label, IASTPreprocessorMacroDefinition[] defs, HashSet reported) { if (defs.length > 0) { out.println(label); @@ -399,7 +404,7 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } } - + private void output(PrintStream out, String label, IASTProblem[] preprocessorProblems) { if (preprocessorProblems.length > 0) { out.println(label); @@ -409,14 +414,14 @@ public class CreateParserLogAction implements IObjectActionDelegate { out.println(); } } - + private void output(PrintStream out, String label, IProblemBinding[] list) { if (list.length > 0) { out.println(label); for (IProblemBinding problem : list) { String file= problem.getFileName(); int line = problem.getLineNumber(); - out.println(INDENT + problem.getMessage() + " in file " + file + ':' + line); + out.println(INDENT + problem.getMessage() + " in file " + file + ':' + line); } out.println(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java index 0f3322ca9b6..5694f23b76b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/DeleteResConfigsHandler.java @@ -58,14 +58,14 @@ import org.eclipse.cdt.ui.newui.AbstractPage; public class DeleteResConfigsHandler extends AbstractHandler { protected ArrayList objects; - private ArrayList outData; + private ArrayList outData; @Override public void setEnabled(Object context) { ISelection selection = getSelection(context); setEnabledFromSelection(selection); } - + protected ISelection getSelection(Object context) { Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof ISelection) { @@ -76,7 +76,7 @@ public class DeleteResConfigsHandler extends AbstractHandler { public void setEnabledFromSelection(ISelection selection) { objects = null; - + if ((selection != null) && !selection.isEmpty()) { // case for context menu Object[] obs = null; @@ -100,10 +100,10 @@ public class DeleteResConfigsHandler extends AbstractHandler { if (res != null) { IProject p = res.getProject(); if (!p.isOpen()) continue; - + if (!CoreModel.getDefault().isNewStyleProject(p)) continue; - + IPath path = res.getProjectRelativePath(); // getting description in read-only mode ICProjectDescription prjd = CoreModel.getDefault().getProjectDescription(p, false); @@ -121,7 +121,7 @@ public class DeleteResConfigsHandler extends AbstractHandler { } } } - } + } setBaseEnabled(objects != null); } @@ -141,19 +141,20 @@ public class DeleteResConfigsHandler extends AbstractHandler { return null; } + @Override public Object execute(ExecutionEvent event) throws ExecutionException { openDialog(); return null; } private void openDialog() { - if (objects == null || objects.size() == 0) return; + if (objects == null || objects.size() == 0) return; // create list of configurations to delete - + ListSelectionDialog dialog = new ListSelectionDialog( - CUIPlugin.getActiveWorkbenchShell(), - objects, - createSelectionDialogContentProvider(), + CUIPlugin.getActiveWorkbenchShell(), + objects, + createSelectionDialogContentProvider(), new LabelProvider() {}, ActionMessages.DeleteResConfigsAction_0); dialog.setTitle(ActionMessages.DeleteResConfigsAction_1); if (dialog.open() == Window.OK) { @@ -173,12 +174,12 @@ public class DeleteResConfigsHandler extends AbstractHandler { ICProjectDescription prjd; ICConfigurationDescription cfgd; ICResourceDescription rdesc; - + public ResCfgData(IResource res2, ICProjectDescription prjd2, ICConfigurationDescription cfgd2, ICResourceDescription rdesc2) { res = res2; prjd = prjd2; cfgd = cfgd2; rdesc = rdesc2; } - + // performs deletion public void delete() { try { @@ -191,16 +192,17 @@ public class DeleteResConfigsHandler extends AbstractHandler { return "[" + cfgd.getName() + "] for " + res.getName(); //$NON-NLS-1$ //$NON-NLS-2$ } } - - + + private IStructuredContentProvider createSelectionDialogContentProvider() { outData = null; - + return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { if (outData != null) return outData.toArray(); - + outData = new ArrayList(); List ls = (List)inputElement; Iterator it = ls.iterator(); @@ -220,16 +222,18 @@ public class DeleteResConfigsHandler extends AbstractHandler { if (cfgds != null) { for (ICConfigurationDescription cfgd : cfgds) { ICResourceDescription rd = cfgd.getResourceDescription(path, true); - if (rd != null) + if (rd != null) outData.add(new ResCfgData(res, prjd, cfgd, rd)); } } } return outData.toArray(); } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java index fe53bae4b8c..e9a85785539 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/ExcludeFromBuildHandler.java @@ -68,7 +68,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { ISelection selection = getSelection(context); setEnabledFromSelection(selection); } - + protected ISelection getSelection(Object context) { Object s = HandlerUtil.getVariable(context, ISources.ACTIVE_MENU_SELECTION_NAME); if (s instanceof ISelection) { @@ -81,7 +81,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { objects = null; cfgNames = null; boolean cfgsOK = true; - + if ((selection != null) && !selection.isEmpty()) { // case for context menu Object[] obs = null; @@ -97,7 +97,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { for (int i=0; i(); objects.add(res); if (cfgNames == null) { cfgNames = new ArrayList(cfgds.length); - for (int j=0; j it = objects.iterator(); while (it.hasNext()) { @@ -214,11 +215,11 @@ public class ExcludeFromBuildHandler extends AbstractHandler { } } ArrayList lst = new ArrayList(); - for (int i=0; i 0) dialog.setInitialElementSelections(lst); - + if (dialog.open() == Window.OK) { Object[] selected = dialog.getResult(); // may be empty Iterator it2 = objects.iterator(); @@ -243,7 +244,7 @@ public class ExcludeFromBuildHandler extends AbstractHandler { try { CoreModel.getDefault().setProjectDescription(p, prjd); } catch (CoreException e) { - CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); + CUIPlugin.logError(Messages.AbstractPage_11 + e.getLocalizedMessage()); } AbstractPage.updateViews(res); } @@ -252,10 +253,13 @@ public class ExcludeFromBuildHandler extends AbstractHandler { private IStructuredContentProvider createSelectionDialogContentProvider() { return new IStructuredContentProvider() { + @Override public Object[] getElements(Object inputElement) { return cfgNames.toArray(); } + @Override public void dispose() {} + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {} }; } - + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java index 87ec40c3f51..2bed740d9d4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/FoldingActionGroup.java @@ -30,7 +30,7 @@ import org.eclipse.cdt.internal.ui.editor.CEditor; /** * Groups the CDT folding actions. - * + * * @since 3.0 */ public class FoldingActionGroup extends ActionGroup { @@ -41,38 +41,39 @@ public class FoldingActionGroup extends ActionGroup { update(); } } - + private class FoldingAction extends PreferenceAction { FoldingAction(ResourceBundle bundle, String prefix) { super(bundle, prefix, IAction.AS_PUSH_BUTTON); } + @Override public void update() { setEnabled(FoldingActionGroup.this.isEnabled() && fViewer.isProjectionMode()); } - + } - + private ProjectionViewer fViewer; private IProjectionListener fProjectionListener; - + private TextOperationAction fToggle; private TextOperationAction fExpand; private TextOperationAction fCollapse; private TextOperationAction fExpandAll; - + // since 4.0 private TextOperationAction fCollapseAll; private PreferenceAction fRestoreDefaults; - + /** * Creates a new projection action group for editor. If the * supplied viewer is not an instance of ProjectionViewer, the * action group is disabled. - * + * * @param editor the text editor to operate on * @param viewer the viewer of the editor */ @@ -87,28 +88,30 @@ public class FoldingActionGroup extends ActionGroup { fProjectionListener= null; return; } - + fViewer= (ProjectionViewer) viewer; - + fProjectionListener= new IProjectionListener() { + @Override public void projectionEnabled() { update(); } + @Override public void projectionDisabled() { update(); } }; - + fViewer.addProjectionListener(fProjectionListener); - + fToggle= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); //$NON-NLS-1$ fToggle.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE); editor.setAction("FoldingToggle", fToggle); //$NON-NLS-1$ - + fExpandAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.ExpandAll.", editor, ProjectionViewer.EXPAND_ALL, true); //$NON-NLS-1$ fExpandAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND_ALL); editor.setAction("FoldingExpandAll", fExpandAll); //$NON-NLS-1$ - + fCollapseAll= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.CollapseAll.", editor, ProjectionViewer.COLLAPSE_ALL, true); //$NON-NLS-1$ fCollapseAll.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE_ALL); editor.setAction("FoldingCollapseAll", fCollapseAll); //$NON-NLS-1$ @@ -116,7 +119,7 @@ public class FoldingActionGroup extends ActionGroup { fExpand= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Expand.", editor, ProjectionViewer.EXPAND, true); //$NON-NLS-1$ fExpand.setActionDefinitionId(IFoldingCommandIds.FOLDING_EXPAND); editor.setAction("FoldingExpand", fExpand); //$NON-NLS-1$ - + fCollapse= new TextOperationAction(FoldingMessages.getResourceBundle(), "Projection.Collapse.", editor, ProjectionViewer.COLLAPSE, true); //$NON-NLS-1$ fCollapse.setActionDefinitionId(IFoldingCommandIds.FOLDING_COLLAPSE); editor.setAction("FoldingCollapse", fCollapse); //$NON-NLS-1$ @@ -133,19 +136,19 @@ public class FoldingActionGroup extends ActionGroup { fRestoreDefaults.setActionDefinitionId(IFoldingCommandIds.FOLDING_RESTORE); editor.setAction("FoldingRestore", fRestoreDefaults); //$NON-NLS-1$ } - + /** - * Returns true if the group is enabled. + * Returns true if the group is enabled. *
 	 * Invariant: isEnabled() <=> fViewer and all actions are != null.
 	 * 
- * + * * @return true if the group is enabled */ protected boolean isEnabled() { return fViewer != null; } - + /* * @see org.eclipse.ui.actions.ActionGroup#dispose() */ @@ -157,7 +160,7 @@ public class FoldingActionGroup extends ActionGroup { } super.dispose(); } - + /** * Updates the actions. */ @@ -172,10 +175,10 @@ public class FoldingActionGroup extends ActionGroup { fRestoreDefaults.update(); } } - + /** * Fills the menu with all folding actions. - * + * * @param manager the menu manager for the folding submenu */ public void fillMenu(IMenuManager manager) { @@ -189,7 +192,7 @@ public class FoldingActionGroup extends ActionGroup { manager.add(fRestoreDefaults); } } - + /* * @see org.eclipse.ui.actions.ActionGroup#updateActionBars() */ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java index a0419048dd5..99078e87d47 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/GotoNextBookmarkAction.java @@ -38,6 +38,7 @@ public class GotoNextBookmarkAction extends TextEditorAction { * Private class to handle comparison of markers using their line numbers. */ private class CompareMarker implements Comparator { + @Override public int compare(IMarker m1, IMarker m2) { int l1 = MarkerUtilities.getLineNumber(m1); int l2 = MarkerUtilities.getLineNumber(m2); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java index df58e6d0375..49ddef1832c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/IndentAction.java @@ -57,24 +57,24 @@ import org.eclipse.cdt.internal.ui.util.EditorUtility; * AST must be present, the indentation is computed using heuristics. The algorithm used is fast for * single lines, but does not store any information and therefore not so efficient for large line * ranges. - * + * * @see org.eclipse.cdt.internal.ui.text.CHeuristicScanner * @see org.eclipse.cdt.internal.ui.text.CIndenter */ public class IndentAction extends TextEditorAction { - + /** The caret offset after an indent operation. */ private int fCaretOffset; - + /** * Whether this is the action invoked by TAB. When true, indentation behaves * differently to accommodate normal TAB operation. */ private final boolean fIsTabAction; - + /** * Creates a new instance. - * + * * @param bundle the resource bundle * @param prefix the prefix to use for keys in bundle * @param editor the text editor @@ -84,7 +84,7 @@ public class IndentAction extends TextEditorAction { super(bundle, prefix, editor); fIsTabAction= isTabAction; } - + /* * @see org.eclipse.jface.action.Action#run() */ @@ -93,17 +93,17 @@ public class IndentAction extends TextEditorAction { // update has been called by the framework if (!isEnabled() || !validateEditorInputState()) return; - + ITextSelection selection= getSelection(); final IDocument document= getDocument(); - + if (document != null) { final int offset= selection.getOffset(); final int length= selection.getLength(); final Position end= new Position(offset + length); final int firstLine, nLines; fCaretOffset= -1; - + try { firstLine= document.getLineOfOffset(offset); // check for marginal (zero-length) lines @@ -115,13 +115,14 @@ public class IndentAction extends TextEditorAction { CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "", e)); //$NON-NLS-1$ return; } - + Runnable runnable= new Runnable() { + @Override public void run() { IRewriteTarget target= (IRewriteTarget)getTextEditor().getAdapter(IRewriteTarget.class); if (target != null) target.beginCompoundChange(); - + try { CHeuristicScanner scanner= new CHeuristicScanner(document); CIndenter indenter= new CIndenter(document, scanner, getCProject()); @@ -130,7 +131,7 @@ public class IndentAction extends TextEditorAction { for (int i= 0; i < nLines; i++) { hasChanged |= indentLine(document, firstLine + i, offset, indenter, scanner, multiLine); } - + // update caret position: move to new position when indenting just one line // keep selection when indenting multiple int newOffset, newLength; @@ -141,12 +142,12 @@ public class IndentAction extends TextEditorAction { newOffset= fCaretOffset; newLength= 0; } - + // always reset the selection if anything was replaced // but not when we had a single line non-tab invocation if (newOffset != -1 && (hasChanged || newOffset != offset || newLength != length)) selectAndReveal(newOffset, newLength); - + } catch (BadLocationException e) { // will only happen on concurrent modification CUIPlugin.log(new Status(IStatus.ERROR, CUIPlugin.getPluginId(), IStatus.OK, "ConcurrentModification in IndentAction", e)); //$NON-NLS-1$ @@ -157,7 +158,7 @@ public class IndentAction extends TextEditorAction { } } }; - + if (nLines > 50) { Display display= getTextEditor().getEditorSite().getWorkbenchWindow().getShell().getDisplay(); BusyIndicator.showWhile(display, runnable); @@ -166,10 +167,10 @@ public class IndentAction extends TextEditorAction { } } } - + /** * Selects the given range on the editor. - * + * * @param newOffset the selection offset * @param newLength the selection range */ @@ -190,7 +191,7 @@ public class IndentAction extends TextEditorAction { /** * Indents a single line using the heuristic scanner. Multiline comments are * indented as specified by the CCommentAutoIndentStrategy. - * + * * @param document the document * @param line the line to be indented * @param caret the caret position @@ -204,7 +205,7 @@ public class IndentAction extends TextEditorAction { IRegion currentLine= document.getLineInformation(line); int offset= currentLine.getOffset(); int wsStart= offset; // where we start searching for non-WS; after the "//" in single line comments - + String indent= null; if (offset < document.getLength()) { ITypedRegion partition= TextUtilities.getPartition(document, ICPartitions.C_PARTITIONING, offset, true); @@ -224,9 +225,9 @@ public class IndentAction extends TextEditorAction { int slashes= 2; while (slashes < max - 1 && document.get(offset + slashes, 2).equals("//")) //$NON-NLS-1$ slashes+= 2; - + wsStart= offset + slashes; - + StringBuilder computed= indenter.computeIndentation(offset); if (computed == null) computed= new StringBuilder(0); @@ -243,15 +244,15 @@ public class IndentAction extends TextEditorAction { } else { break; } - + computed.deleteCharAt(0); } - + indent= document.get(offset, wsStart - offset) + computed; } } } - + // standard C code indentation if (indent == null) { StringBuilder computed= indenter.computeIndentation(offset); @@ -260,7 +261,7 @@ public class IndentAction extends TextEditorAction { else indent= ""; //$NON-NLS-1$ } - + // change document: // get current white space int lineLength= currentLine.getLength(); @@ -273,7 +274,7 @@ public class IndentAction extends TextEditorAction { } int length= end - offset; String currentIndent= document.get(offset, length); - + // if we are right before the text start / line end, and already after the insertion point // then just shift to the right if (fIsTabAction && caret == end && whiteSpaceLength(currentIndent) >= whiteSpaceLength(indent)) { @@ -286,13 +287,13 @@ public class IndentAction extends TextEditorAction { fCaretOffset= offset + replacement.length(); return true; } - + // set the caret offset so it can be used when setting the selection if (caret >= offset && caret <= end) fCaretOffset= offset + indent.length(); else fCaretOffset= -1; - + // only change the document if it is a real change if (!indent.equals(currentIndent)) { document.replace(offset, length, indent); @@ -303,7 +304,7 @@ public class IndentAction extends TextEditorAction { /** * Strip trailing space characters. - * + * * @param indent * @return string with trailing spaces removed */ @@ -317,7 +318,7 @@ public class IndentAction extends TextEditorAction { /** * Computes and returns the indentation for a block comment line. - * + * * @param document the document * @param line the line in document * @param scanner the scanner @@ -328,10 +329,10 @@ public class IndentAction extends TextEditorAction { private String computeCommentIndent(IDocument document, int line, CHeuristicScanner scanner, ITypedRegion partition) throws BadLocationException { return IndentUtil.computeCommentIndent(document, line, scanner, partition); } - + /** * Computes and returns the indentation for a preprocessor line. - * + * * @param document the document * @param line the line in document * @param partition the comment partition @@ -341,11 +342,11 @@ public class IndentAction extends TextEditorAction { private String computePreprocessorIndent(IDocument document, int line, ITypedRegion partition) throws BadLocationException { return IndentUtil.computePreprocessorIndent(document, line, partition); } - + /** * Returns the size in characters of a string. All characters count one, tabs count the editor's * preference for the tab display - * + * * @param indent the string to be measured. * @return the size in characters of a string */ @@ -358,27 +359,27 @@ public class IndentAction extends TextEditorAction { /** * Returns whether spaces should be used exclusively for indentation, depending on the editor and * formatter preferences. - * + * * @return true if only spaces should be used */ private boolean useSpaces() { return CCorePlugin.SPACE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)); } - + /** * Returns whether mixed tabs/spaces should be used for indentation, depending on the editor and * formatter preferences. - * + * * @return true if tabs and spaces should be used */ private boolean useTabsAndSpaces() { return DefaultCodeFormatterConstants.MIXED.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR)); } - + /** * Returns the tab size used by the editor, which is deduced from the * formatter preferences. - * + * * @return the tab size as defined in the current formatter preferences */ private int getTabSize() { @@ -388,7 +389,7 @@ public class IndentAction extends TextEditorAction { /** * Returns the indent size used by the editor, which is deduced from the * formatter preferences. - * + * * @return the indent size as defined in the current formatter preferences */ private int getIndentSize() { @@ -397,25 +398,25 @@ public class IndentAction extends TextEditorAction { /** * Returns true if empty lines should be indented, false otherwise. - * + * * @return true if empty lines should be indented, false otherwise */ private boolean indentEmptyLines() { return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_EMPTY_LINES)); } - + /** * Returns true if line comments at column 0 should be indented inside, false otherwise. - * + * * @return true if line comments at column 0 should be indented inside, false otherwise. */ private boolean indentInsideLineComments() { return DefaultCodeFormatterConstants.TRUE.equals(getCoreFormatterOption(DefaultCodeFormatterConstants.FORMATTER_INDENT_INSIDE_LINE_COMMENTS)); } - + /** * Returns the possibly project-specific core preference defined under key. - * + * * @param key the key of the preference * @return the value of the preference */ @@ -429,7 +430,7 @@ public class IndentAction extends TextEditorAction { /** * Returns the possibly project-specific core preference defined under key, or * def if the value is not a integer. - * + * * @param key the key of the preference * @param def the default value * @return the value of the preference @@ -445,7 +446,7 @@ public class IndentAction extends TextEditorAction { /** * Returns the ICProject of the current editor input, or * null if it cannot be found. - * + * * @return the ICProject of the current editor input, or * null if it cannot be found */ @@ -453,13 +454,13 @@ public class IndentAction extends TextEditorAction { ITextEditor editor= getTextEditor(); if (editor == null) return null; - + return EditorUtility.getCProject(editor.getEditorInput()); } /** * Returns the editor's selection provider. - * + * * @return the editor's selection provider or null */ private ISelectionProvider getSelectionProvider() { @@ -469,14 +470,14 @@ public class IndentAction extends TextEditorAction { } return null; } - + /* * @see org.eclipse.ui.texteditor.IUpdate#update() */ @Override public void update() { super.update(); - + if (isEnabled()) { if (fIsTabAction) setEnabled(canModifyEditor() && isSmartMode() && isValidSelection()); @@ -484,29 +485,29 @@ public class IndentAction extends TextEditorAction { setEnabled(canModifyEditor() && !getSelection().isEmpty()); } } - + /** * Returns if the current selection is valid, i.e. whether it is empty and the caret in the * whitespace at the start of a line, or covers multiple lines. - * + * * @return true if the selection is valid for an indent operation */ private boolean isValidSelection() { ITextSelection selection= getSelection(); if (selection.isEmpty()) return false; - + int offset= selection.getOffset(); int length= selection.getLength(); - + IDocument document= getDocument(); if (document == null) return false; - + try { IRegion firstLine= document.getLineInformationOfOffset(offset); int lineOffset= firstLine.getOffset(); - + // either the selection has to be empty and the caret in the WS at the line start // or the selection has to extend over multiple lines if (length == 0) { @@ -516,28 +517,28 @@ public class IndentAction extends TextEditorAction { return false; // only enable for empty selections for now } catch (BadLocationException e) { } - + return false; } - + /** * Returns the smart preference state. - * + * * @return true if smart mode is on, false otherwise */ private boolean isSmartMode() { ITextEditor editor= getTextEditor(); - + if (editor instanceof ITextEditorExtension3) return ((ITextEditorExtension3) editor).getInsertMode() == ITextEditorExtension3.SMART_INSERT; - + return false; } - + /** * Returns the document currently displayed in the editor, or null if none can be * obtained. - * + * * @return the current document or null */ private IDocument getDocument() { @@ -547,15 +548,15 @@ public class IndentAction extends TextEditorAction { IEditorInput input= editor.getEditorInput(); if (provider != null && input != null) return provider.getDocument(input); - + } return null; } - + /** * Returns the selection on the editor or an invalid selection if none can be obtained. Returns * never null. - * + * * @return the current selection, never null */ private ITextSelection getSelection() { @@ -565,7 +566,7 @@ public class IndentAction extends TextEditorAction { if (selection instanceof ITextSelection) return (ITextSelection) selection; } - + // null object return TextSelection.emptySelection(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java index a9300c61b4e..232c32e1ecc 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/RebuildIndexAction.java @@ -7,7 +7,7 @@ * * Contributors: * Markus Schorn - initial API and implementation - *******************************************************************************/ + *******************************************************************************/ package org.eclipse.cdt.internal.ui.actions; @@ -27,9 +27,11 @@ public class RebuildIndexAction implements IObjectActionDelegate { private ISelection fSelection; + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { } - + + @Override public void run(IAction action) { IStructuredSelection cElements= SelectionConverter.convertSelectionToCElements(fSelection); for (Iterator i = cElements.iterator(); i.hasNext();) { @@ -39,10 +41,11 @@ public class RebuildIndexAction implements IObjectActionDelegate { } } } - + /** * @see IActionDelegate#selectionChanged(IAction, ISelection) */ + @Override public void selectionChanged(IAction action, ISelection selection) { fSelection= selection; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java index 087b44ef3e5..e8e78afb963 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithActionGroup.java @@ -15,10 +15,11 @@ import org.eclipse.jface.action.Action; import org.eclipse.jface.action.IMenuListener; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.MenuManager; +import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.text.ITextSelection; import org.eclipse.ui.actions.ActionGroup; + import org.eclipse.cdt.internal.ui.editor.CEditor; public class SurroundWithActionGroup extends ActionGroup { @@ -56,6 +57,7 @@ public class SurroundWithActionGroup extends ActionGroup { menu.appendToGroup(fGroup, subMenu); subMenu.add(new Action() {}); subMenu.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager manager) { manager.removeAll(); SurroundWithTemplateMenuAction.fillMenu(manager, fEditor); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java index 470af5a13fa..770375a7477 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/SurroundWithTemplateMenuAction.java @@ -15,24 +15,12 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.List; -import org.eclipse.swt.events.MenuAdapter; -import org.eclipse.swt.events.MenuEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.swt.widgets.MenuItem; -import org.eclipse.swt.widgets.Shell; - import org.eclipse.core.runtime.Assert; - import org.eclipse.jface.action.Action; import org.eclipse.jface.action.ActionContributionItem; import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionProvider; - import org.eclipse.jface.text.DocumentEvent; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IEditingSupport; @@ -44,7 +32,15 @@ import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.ITextViewerExtension; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2; - +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.swt.events.MenuAdapter; +import org.eclipse.swt.events.MenuEvent; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Menu; +import org.eclipse.swt.widgets.MenuItem; +import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IPartListener; import org.eclipse.ui.IPartService; import org.eclipse.ui.IWorkbenchPart; @@ -55,6 +51,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.ui.CUIPlugin; + import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.text.contentassist.CContentAssistInvocationContext; import org.eclipse.cdt.internal.ui.text.contentassist.TemplateCompletionProposalComputer; @@ -68,7 +65,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD private static final String TEMPLATE_GROUP= "templateGroup"; //$NON-NLS-1$ private static final String CONFIG_GROUP= "configGroup"; //$NON-NLS-1$ - + private static class ConfigureTemplatesAction extends Action { public ConfigureTemplatesAction() { @@ -103,19 +100,24 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD private IPartService fPartService; private IPartListener fPartListener= new IPartListener() { + @Override public void partActivated(IWorkbenchPart part) { } + @Override public void partBroughtToTop(IWorkbenchPart part) { } + @Override public void partClosed(IWorkbenchPart part) { } + @Override public void partDeactivated(IWorkbenchPart part) { disposeMenuItems(); } + @Override public void partOpened(IWorkbenchPart part) { } }; @@ -136,6 +138,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public Menu getMenu(Menu parent) { setMenu(new Menu(parent)); fillMenu(fMenu); @@ -146,6 +149,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public Menu getMenu(Control parent) { setMenu(new Menu(parent)); fillMenu(fMenu); @@ -170,6 +174,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void dispose() { if (fPartService != null) { fPartService.removePartListener(fPartListener); @@ -181,6 +186,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void init(IWorkbenchWindow window) { if (fPartService != null) { fPartService.removePartListener(fPartListener); @@ -199,6 +205,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void run(IAction action) { IWorkbenchPart activePart= CUIPlugin.getActivePage().getActivePart(); if (!(activePart instanceof CEditor)) @@ -217,6 +224,7 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD /** * {@inheritDoc} */ + @Override public void selectionChanged(IAction action, ISelection selection) { // Default do nothing } @@ -280,18 +288,18 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD ITextSelection textSelection= getTextSelection(editor); if (textSelection == null || textSelection.getLength() == 0) return null; - + ITranslationUnit tu= CUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editor.getEditorInput()); if (tu == null) return null; TemplateCompletionProposalComputer templateComputer = new TemplateCompletionProposalComputer(); CContentAssistInvocationContext context = new CContentAssistInvocationContext( editor.getViewer(), textSelection.getOffset(), editor, true, false ); - + List proposals= templateComputer.computeCompletionProposals(context, null); if (proposals == null || proposals.isEmpty()) return null; - + return getActionsFromProposals(proposals, context.getInvocationOffset(), editor.getViewer()); } @@ -344,10 +352,12 @@ public class SurroundWithTemplateMenuAction implements IWorkbenchWindowPulldownD IEditingSupportRegistry registry= null; IEditingSupport helper= new IEditingSupport() { + @Override public boolean isOriginator(DocumentEvent event, IRegion focus) { return focus.getOffset() <= offset && focus.getOffset() + focus.getLength() >= offset; } + @Override public boolean ownsFocusShell() { return false; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java index c7ac58952b9..3c5841e387f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/actions/WorkbenchRunnableAdapter.java @@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.actions; import java.lang.reflect.InvocationTargetException; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.internal.ui.CUIStatus; import org.eclipse.core.resources.IWorkspaceRunnable; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; @@ -23,27 +21,30 @@ import org.eclipse.core.runtime.OperationCanceledException; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.jobs.ISchedulingRule; import org.eclipse.core.runtime.jobs.Job; - import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.operation.IThreadListener; +import org.eclipse.cdt.core.model.CoreModel; + +import org.eclipse.cdt.internal.ui.CUIStatus; + /** * An IRunnableWithProgress that adapts and IWorkspaceRunnable - * so that is can be executed inside IRunnableContext. OperationCanceledException + * so that is can be executed inside IRunnableContext. OperationCanceledException * thrown by the adapted runnable are caught and re-thrown as a InterruptedException. */ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadListener { private IWorkspaceRunnable fWorkspaceRunnable; private ISchedulingRule fRule; private boolean fTransfer; - + /** * Runs a workspace runnable with the workspace lock. */ public WorkbenchRunnableAdapter(IWorkspaceRunnable runnable) { this(runnable, ResourcesPlugin.getWorkspace().getRoot()); } - + /** * Runs a workspace runnable with the given lock or null to run with no lock at all. */ @@ -51,11 +52,11 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL fWorkspaceRunnable= runnable; fRule= rule; } - + /** * Runs a workspace runnable with the given lock or null to run with no lock at * all. - * + * * @param runnable the runnable * @param rule the scheduling rule, or null * @param transfer true iff the rule is to be transfered to the modal context @@ -71,6 +72,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL return fRule; } + @Override public void threadChange(Thread thread) { if (fTransfer) Job.getJobManager().transferRule(fRule, thread); @@ -79,6 +81,7 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL /* * @see IRunnableWithProgress#run(IProgressMonitor) */ + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { try { CoreModel.run(fWorkspaceRunnable, fRule, monitor); @@ -88,9 +91,9 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL throw new InvocationTargetException(e); } } - + public void runAsUserJob(String name, final Object jobFamiliy) { - Job buildJob = new Job(name){ + Job buildJob = new Job(name){ /* (non-Javadoc) * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor) */ @@ -117,9 +120,9 @@ public class WorkbenchRunnableAdapter implements IRunnableWithProgress, IThreadL } }; buildJob.setRule(fRule); - buildJob.setUser(true); + buildJob.setUser(true); buildJob.schedule(); - + // TODO: should block until user pressed 'to background' } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java index e0093cf82ac..a4789d369b5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CallHierarchyUI.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.callhierarchy; import java.util.ArrayList; import java.util.Arrays; -import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.CoreException; @@ -38,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.IEnumerator; import org.eclipse.cdt.core.dom.ast.IFunction; +import org.eclipse.cdt.core.dom.ast.IScope; import org.eclipse.cdt.core.dom.ast.IVariable; import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding; import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression; @@ -325,7 +325,8 @@ public class CallHierarchyUI { if (binding instanceof IVariable) { try { - if (binding.getScope().getKind() == EScopeKind.eLocal) + final IScope scope = binding.getScope(); + if (scope != null && scope.getKind() == EScopeKind.eLocal) return false; } catch (DOMException e) { } @@ -382,8 +383,7 @@ public class CallHierarchyUI { */ static void clearHistory() { setHistoryEntries(new ICElement[0]); - for (Iterator iter= fLRUCallHierarchyViews.iterator(); iter.hasNext();) { - CHViewPart part= iter.next(); + for (CHViewPart part : fLRUCallHierarchyViews) { part.setInput(null); } } @@ -396,8 +396,7 @@ public class CallHierarchyUI { */ private static CHViewPart findLRUCallHierarchyViewPart(IWorkbenchPage page) { boolean viewFoundInPage= false; - for (Iterator iter= fLRUCallHierarchyViews.iterator(); iter.hasNext();) { - CHViewPart view= iter.next(); + for (CHViewPart view : fLRUCallHierarchyViews) { if (page.equals(view.getSite().getPage())) { if (!view.isPinned()) { return view; @@ -408,8 +407,7 @@ public class CallHierarchyUI { if (!viewFoundInPage) { // find unresolved views IViewReference[] viewReferences= page.getViewReferences(); - for (int i= 0; i < viewReferences.length; i++) { - IViewReference curr= viewReferences[i]; + for (IViewReference curr : viewReferences) { if (CUIPlugin.ID_CALL_HIERARCHY.equals(curr.getId()) && page.equals(curr.getPage())) { CHViewPart view= (CHViewPart)curr.getView(true); if (view != null && !view.isPinned()) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java index 099f7babe95..4b79c6a4bea 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 QNX Software Systems and others. + * Copyright (c) 2000, 2011 QNX Software Systems 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 @@ -929,12 +929,6 @@ public class CView extends ViewPart implements ISetSelectionTarget, IPropertyCha return null; } - public void collapseAll() { - viewer.getControl().setRedraw(false); - viewer.collapseToLevel(getViewPartInput(), AbstractTreeViewer.ALL_LEVELS); - viewer.getControl().setRedraw(true); - } - void restoreState(IMemento memento) { CoreModel factory = CoreModel.getDefault(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java index e646d874fb3..621c8535df9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation 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 @@ -25,9 +25,6 @@ public final class CViewMessages extends NLS { public static String BuildAction_label; public static String RebuildAction_label; public static String CleanAction_label; - public static String CollapseAllAction_label; - public static String CollapseAllAction_tooltip; - public static String CollapseAllAction_description; public static String CopyAction_title; public static String CopyAction_toolTip; public static String PasteAction_title; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties index 56993fc3e00..0b298856850 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/CViewMessages.properties @@ -1,5 +1,5 @@ ############################################################################### -# Copyright (c) 2000, 2009 IBM Corporation and others. +# Copyright (c) 2000, 2011 IBM Corporation 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 @@ -17,10 +17,6 @@ BuildAction_label=&Build Project RebuildAction_label=Rebuild Pro&ject CleanAction_label=Clean Project -CollapseAllAction_label=Collapse All -CollapseAllAction_tooltip=Collapse All -CollapseAllAction_description=Collapse All - CopyAction_title = &Copy CopyAction_toolTip = Copy diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java index fbc24891a47..a445f98388c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/cview/MainActionGroup.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation 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 @@ -45,6 +45,7 @@ import org.eclipse.cdt.ui.actions.OpenViewActionGroup; import org.eclipse.cdt.ui.refactoring.actions.CRefactoringActionGroup; import org.eclipse.cdt.internal.ui.IContextMenuConstants; +import org.eclipse.cdt.internal.ui.actions.CollapseAllAction; import org.eclipse.cdt.internal.ui.actions.SelectionConverter; import org.eclipse.cdt.internal.ui.editor.OpenIncludeAction; import org.eclipse.cdt.internal.ui.search.actions.SelectionSearchGroup; @@ -133,6 +134,7 @@ public class MainActionGroup extends CViewActionGroup { //sortByTypeAction = new SortViewAction(this, true); IPropertyChangeListener workingSetUpdater = new IPropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); @@ -158,7 +160,7 @@ public class MainActionGroup extends CViewActionGroup { importAction = new ImportResourcesAction(getCView().getSite().getWorkbenchWindow()); exportAction = new ExportResourcesAction(getCView().getSite().getWorkbenchWindow()); - collapseAllAction = new CollapseAllAction(getCView()); + collapseAllAction = new CollapseAllAction(getCView().getViewer()); toggleLinkingAction = new ToggleLinkingAction(getCView()); toggleLinkingAction.setImageDescriptor(getImageDescriptor("elcl16/synced.gif"));//$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java index 697a80ad0cc..e7640ba8e12 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/AbstractCModelOutlinePage.java @@ -21,6 +21,7 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.commands.ActionHandler; import org.eclipse.jface.text.ITextSelection; import org.eclipse.jface.util.LocalSelectionTransfer; import org.eclipse.jface.util.PropertyChangeEvent; @@ -46,6 +47,8 @@ import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; +import org.eclipse.ui.handlers.CollapseAllHandler; +import org.eclipse.ui.handlers.IHandlerService; import org.eclipse.ui.navigator.resources.ProjectExplorer; import org.eclipse.ui.part.IPageSite; import org.eclipse.ui.part.IShowInSource; @@ -71,6 +74,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.IContextMenuConstants; import org.eclipse.cdt.internal.ui.actions.AbstractToggleLinkingAction; import org.eclipse.cdt.internal.ui.actions.ActionMessages; +import org.eclipse.cdt.internal.ui.actions.CollapseAllAction; import org.eclipse.cdt.internal.ui.cview.SelectionTransferDragAdapter; import org.eclipse.cdt.internal.ui.cview.SelectionTransferDropAdapter; import org.eclipse.cdt.internal.ui.dnd.CDTViewerDragAdapter; @@ -294,6 +298,10 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent * @since 3.0 */ private ActionGroup fCustomFiltersActionGroup; + /** + * @since 5.4 + */ + private CollapseAllAction fCollapseAllAction; /** * Create a new outline page for the given editor. @@ -520,6 +528,9 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent fTreeViewer.setInput(fInput); PlatformUI.getWorkbench().getHelpSystem().setHelp(control, ICHelpContextIds.COUTLINE_VIEW); + + IHandlerService handlerService= (IHandlerService)site.getService(IHandlerService.class); + handlerService.activateHandler(CollapseAllHandler.COMMAND_ID, new ActionHandler(fCollapseAllAction)); } @Override @@ -582,6 +593,8 @@ public abstract class AbstractCModelOutlinePage extends Page implements IContent protected void registerActionBars(IActionBars actionBars) { IToolBarManager toolBarManager= actionBars.getToolBarManager(); + fCollapseAllAction = new CollapseAllAction(fTreeViewer); + toolBarManager.add(fCollapseAllAction); LexicalSortingAction action= new LexicalSortingAction(getTreeViewer()); toolBarManager.add(action); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java index a1cf6a2d9f5..d7691a06d7e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/CEditor.java @@ -254,6 +254,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#gotoMarker(org.eclipse.core.resources.IMarker) */ + @Override public void gotoMarker(IMarker marker) { if (fIsUpdatingMarkerViews) return; @@ -433,6 +434,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.link.LinkedModeUI$IExitPolicy#doExit(org.eclipse.jface.text.link.LinkedModeModel, org.eclipse.swt.events.VerifyEvent, int, int) */ + @Override public ExitFlags doExit(LinkedModeModel model, VerifyEvent event, int offset, int length) { if (fSize == fStack.size() && !isMasked(offset)) { if (event.character == fExitCharacter) { @@ -497,6 +499,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.IPositionUpdater#update(org.eclipse.jface.text.DocumentEvent) */ + @Override public void update(DocumentEvent event) { int eventOffset = event.getOffset(); int eventOldLength = event.getLength(); @@ -589,6 +592,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.swt.custom.VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent) */ + @Override public void verifyKey(VerifyEvent event) { // early pruning to slow down normal typing as little as possible @@ -746,6 +750,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.link.ILinkedModeListener#left(org.eclipse.jface.text.link.LinkedModeModel, int) */ + @Override public void left(LinkedModeModel environment, int flags) { final BracketLevel level = fBracketLevelStack.pop(); @@ -760,6 +765,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC IDocumentExtension extension = (IDocumentExtension) document; extension.registerPostNotificationReplace(null, new IDocumentExtension.IReplace() { + @Override public void perform(IDocument d, IDocumentListener owner) { if ((level.fFirstPosition.isDeleted || level.fFirstPosition.length == 0) && !level.fSecondPosition.isDeleted @@ -789,12 +795,14 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.link.ILinkedModeListener#suspend(org.eclipse.jface.text.link.LinkedModeModel) */ + @Override public void suspend(LinkedModeModel environment) { } /* * @see org.eclipse.jface.text.link.ILinkedModeListener#resume(org.eclipse.jface.text.link.LinkedModeModel, int) */ + @Override public void resume(LinkedModeModel environment, int flags) { } } @@ -809,6 +817,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /** * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ + @Override public void selectionChanged(SelectionChangedEvent event) { // XXX: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56161 CEditor.this.selectionChanged(); @@ -978,6 +987,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.ui.texteditor.IUpdate#update() */ + @Override public void update() { setEnabled(isEditorInputModifiable()); } @@ -1181,6 +1191,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.ui.texteditor.IUpdate#update() */ + @Override public void update() { setEnabled(isEditorInputModifiable()); } @@ -1225,6 +1236,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC private class IndexerPreferenceListener implements IPreferenceChangeListener { private IProject fProject; + @Override public void preferenceChange(PreferenceChangeEvent event) { if (IndexerPreferences.KEY_INDEX_ON_OPEN.equals(event.getKey())) { ICElement element= getInputCElement(); @@ -1398,7 +1410,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /** The translation unit that was added by the editor to index, or null. */ private ITranslationUnit fTuAddedToIndex; - private IndexerPreferenceListener fIndexerPreferenceListener; + private final IndexerPreferenceListener fIndexerPreferenceListener; private static final Set angularIntroducers = new HashSet(); static { @@ -1643,6 +1655,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC return getOutlinePage(); } else if (required == IShowInTargetList.class) { return new IShowInTargetList() { + @Override @SuppressWarnings("deprecation") public String[] getShowInTargetIds() { return new String[] { IPageLayout.ID_PROJECT_EXPLORER, IPageLayout.ID_OUTLINE, IPageLayout.ID_RES_NAV }; @@ -1656,6 +1669,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC } final ISelection selection= ce != null ? new StructuredSelection(ce) : null; return new IShowInSource() { + @Override public ShowInContext getShowInContext() { return new ShowInContext(getEditorInput(), selection); } @@ -1824,6 +1838,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC if (PreferenceConstants.SCALABILITY_RECONCILER.equals(property) || PreferenceConstants.SCALABILITY_SYNTAX_COLOR.equals(property)) { BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() { + @Override public void run() { setOutlinePageInput(fOutlinePage, getEditorInput()); asv.unconfigure(); @@ -1980,6 +1995,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC * React to changed selection in the outline view. * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ + @Override public void selectionChanged(SelectionChangedEvent event) { ISelection sel = event.getSelection(); if (sel instanceof IStructuredSelection) { @@ -2198,6 +2214,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC */ @Override public void dispose() { + fIndexerPreferenceListener.unregister(); updateIndexInclusion(null, true); ISourceViewer sourceViewer = getSourceViewer(); @@ -2578,6 +2595,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC // bug 291008 - register custom help listener final IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem(); parent.addHelpListener(new HelpListener() { + @Override public void helpRequested(HelpEvent e) { IContextProvider provider = (IContextProvider) CEditor.this.getAdapter(IContextProvider.class); if (provider != null) { @@ -2884,6 +2902,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$ fProjectionSupport.addSummarizableAnnotationType("org.eclipse.search.results"); //$NON-NLS-1$ fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() { + @Override public IInformationControl createInformationControl(Shell shell) { return new SourceViewerInformationControl(shell, false, getOrientation(), null); } @@ -3163,6 +3182,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#aboutToBeReconciled() * @since 4.0 */ + @Override public void aboutToBeReconciled() { fIsReconciling= true; @@ -3180,6 +3200,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC * @see org.eclipse.cdt.internal.ui.text.ICReconcilingListener#reconciled(IASTTranslationUnit, boolean, IProgressMonitor) * @since 4.0 */ + @Override public void reconciled(IASTTranslationUnit ast, boolean force, IProgressMonitor progressMonitor) { fIsReconciling= false; @@ -3417,6 +3438,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent) */ + @Override public void documentAboutToBeChanged(DocumentEvent event) { if (fOccurrencesAnnotationUpdaterJob != null) fOccurrencesAnnotationUpdaterJob.doCancel(); @@ -3425,12 +3447,14 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent) */ + @Override public void documentChanged(DocumentEvent event) { } /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ + @Override public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) { if (oldInput == null) return; @@ -3441,6 +3465,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC /* * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument) */ + @Override public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { if (newInput == null) return; @@ -3536,6 +3561,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC fMarkOccurrenceAnnotations= true; fPostSelectionListenerWithAST= new ISelectionListenerWithAST() { + @Override public void selectionChanged(IEditorPart part, ITextSelection selection, IASTTranslationUnit astRoot) { updateOccurrenceAnnotations(selection, astRoot); } @@ -3544,6 +3570,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC if (forceUpdate && getSelectionProvider() != null) { fForcedMarkOccurrencesSelection= getSelectionProvider().getSelection(); ASTProvider.getASTProvider().runOnAST(getInputCElement(), ASTProvider.WAIT_NO, getProgressMonitor(), new ASTRunnable() { + @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { updateOccurrenceAnnotations((ITextSelection) fForcedMarkOccurrencesSelection, ast); return Status.OK_STATUS; @@ -3733,6 +3760,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC ICElement inputCElement = getInputCElement(); if (provideAST && inputCElement instanceof ITranslationUnit) { ASTProvider.getASTProvider().runOnAST(inputCElement, ASTProvider.WAIT_ACTIVE_ONLY, getProgressMonitor(), new ASTRunnable() { + @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) throws CoreException { if (ast != null) fOverrideIndicatorManager.reconciled(ast, true, getProgressMonitor()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java index 0fb2e1632bb..570a59fd135 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlighting.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation 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 @@ -13,7 +13,11 @@ package org.eclipse.cdt.internal.ui.editor; +import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.PlatformUI; + +import org.eclipse.cdt.ui.CUIPlugin; /** * Semantic highlighting. @@ -28,11 +32,17 @@ public abstract class SemanticHighlighting { */ public abstract String getPreferenceKey(); + /** + * @return the default default text color + * @since 5.4 + */ + public abstract RGB getDefaultDefaultTextColor(); + /** * @return the default text color */ public RGB getDefaultTextColor() { - return new RGB(0, 0, 0); + return findRGB(getThemeColorKey(), getDefaultDefaultTextColor()); } /** @@ -93,4 +103,28 @@ public abstract class SemanticHighlighting { * @return true iff the semantic highlighting consumes the semantic token */ public abstract boolean consumes(SemanticToken token); + + private String getThemeColorKey() { + return CUIPlugin.PLUGIN_ID + "." + getPreferenceKey() + "Highlighting"; //$NON-NLS-1$//$NON-NLS-2$ + } + + /** + * Returns the RGB for the given key in the given color registry. + * + * @param key the key for the constant in the registry + * @param defaultRGB the default RGB if no entry is found + * @return RGB the RGB + * @since 5.4 + */ + private static RGB findRGB(String key, RGB defaultRGB) { + if (!PlatformUI.isWorkbenchRunning()) + return defaultRGB; + + ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); + RGB rgb= registry.getRGB(key); + if (rgb != null) + return rgb; + return defaultRGB; + } + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java index 8d872ecfa40..73f17530039 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/SemanticHighlightings.java @@ -64,7 +64,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator; /** * Semantic highlightings. * Derived from JDT. - * + * * @since 4.0 */ public class SemanticHighlightings { @@ -135,12 +135,12 @@ public class SemanticHighlightings { * A named preference part that controls the highlighting of classes. */ public static final String CLASS="class"; //$NON-NLS-1$ - + /** * A named preference part that controls the highlighting of enums. */ public static final String ENUM="enum"; //$NON-NLS-1$ - + /** * A named preference part that controls the highlighting of macro references. */ @@ -180,16 +180,16 @@ public class SemanticHighlightings { * A named preference part that controls the highlighting of external SDK. */ public static final String EXTERNAL_SDK="externalSDK"; //$NON-NLS-1$ - + /** * A named preference part that controls the highlighting of operators that have been overloaded. */ public static final String OVERLOADED_OPERATOR="overloadedOperator"; //$NON-NLS-1$ - + /** Init debugging mode */ private static final boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.cdt.ui/debug/SemanticHighlighting")); //$NON-NLS-1$//$NON-NLS-2$ - + /** * Semantic highlightings */ @@ -209,10 +209,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } @@ -245,7 +245,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_staticField; + return CEditorMessages.SemanticHighlighting_staticField; } /* @@ -282,10 +282,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } @@ -318,7 +318,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_field; + return CEditorMessages.SemanticHighlighting_field; } /* @@ -355,10 +355,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -391,7 +391,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_methodDeclaration; + return CEditorMessages.SemanticHighlighting_methodDeclaration; } /* @@ -454,10 +454,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -490,7 +490,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_staticMethodInvocation; + return CEditorMessages.SemanticHighlighting_staticMethodInvocation; } /* @@ -530,10 +530,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -566,7 +566,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_method; + return CEditorMessages.SemanticHighlighting_method; } /* @@ -606,10 +606,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -642,7 +642,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_functionDeclaration; + return CEditorMessages.SemanticHighlighting_functionDeclaration; } /* @@ -658,7 +658,7 @@ public class SemanticHighlightings { IASTName name= (IASTName)node; if (name.isDeclaration()) { IBinding binding= token.getBinding(); - if (binding instanceof IFunction + if (binding instanceof IFunction && !(binding instanceof ICPPMethod)) { return true; } else if (binding instanceof IProblemBinding) { @@ -700,10 +700,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -736,7 +736,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_function; + return CEditorMessages.SemanticHighlighting_function; } /* @@ -760,7 +760,7 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for local variable declarations. */ @@ -775,10 +775,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(128, 0, 0); } @@ -811,7 +811,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_localVariableDeclaration; + return CEditorMessages.SemanticHighlighting_localVariableDeclaration; } /* @@ -835,7 +835,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } + } } } } @@ -858,10 +858,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -894,7 +894,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_localVariable; + return CEditorMessages.SemanticHighlighting_localVariable; } /* @@ -918,7 +918,7 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } + } } } } @@ -956,10 +956,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -992,7 +992,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_globalVariable; + return CEditorMessages.SemanticHighlighting_globalVariable; } /* @@ -1019,12 +1019,12 @@ public class SemanticHighlightings { } } catch (DOMException exc) { CUIPlugin.log(exc); - } + } } } return false; } - + } /** @@ -1041,10 +1041,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } @@ -1077,7 +1077,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_parameterVariable; + return CEditorMessages.SemanticHighlighting_parameterVariable; } /* @@ -1107,10 +1107,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(100, 70, 50); } @@ -1143,7 +1143,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_templateParameter; + return CEditorMessages.SemanticHighlighting_templateParameter; } /* @@ -1161,7 +1161,7 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for classes. */ @@ -1176,10 +1176,10 @@ public class SemanticHighlightings { } /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 80, 50); } @@ -1212,7 +1212,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_classes; + return CEditorMessages.SemanticHighlighting_classes; } /* @@ -1238,7 +1238,7 @@ public class SemanticHighlightings { * Semantic highlighting for enums. */ private static final class EnumHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1246,15 +1246,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return ENUM; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(100, 70, 50); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1262,7 +1262,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1270,7 +1270,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1278,15 +1278,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_enums; + return CEditorMessages.SemanticHighlighting_enums; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1302,12 +1302,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for macro references. */ private static final class MacroReferenceHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1315,15 +1315,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return MACRO_REFERENCE; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1331,7 +1331,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1339,7 +1339,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1347,15 +1347,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_macroSubstitution; + return CEditorMessages.SemanticHighlighting_macroSubstitution; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1371,12 +1371,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for macro definitions. */ private static final class MacroDefinitionHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1384,15 +1384,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return MACRO_DEFINITION; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1400,7 +1400,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1408,7 +1408,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1416,15 +1416,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_macroDefintion; + return CEditorMessages.SemanticHighlighting_macroDefintion; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1440,12 +1440,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for typedefs. */ private static final class TypedefHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1453,15 +1453,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return TYPEDEF; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 80, 50); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1469,7 +1469,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1477,7 +1477,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1485,15 +1485,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_typeDef; + return CEditorMessages.SemanticHighlighting_typeDef; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1513,12 +1513,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for namespaces. */ private static final class NamespaceHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1526,15 +1526,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return NAMESPACE; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1542,7 +1542,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1550,7 +1550,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1558,15 +1558,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_namespace; + return CEditorMessages.SemanticHighlighting_namespace; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1579,12 +1579,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for labels. */ private static final class LabelHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1592,15 +1592,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return LABEL; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return RGB_BLACK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1608,7 +1608,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1616,7 +1616,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1624,15 +1624,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_label; + return CEditorMessages.SemanticHighlighting_label; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1645,12 +1645,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for enumerators. */ private static final class EnumeratorHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1658,15 +1658,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return ENUMERATOR; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(0, 0, 192); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1674,7 +1674,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isItalicByDefault() */ @@ -1682,7 +1682,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1690,15 +1690,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_enumerator; + return CEditorMessages.SemanticHighlighting_enumerator; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1718,12 +1718,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for problems. */ private static final class ProblemHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1731,15 +1731,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return PROBLEM; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(224, 0, 0); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1747,7 +1747,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() */ @@ -1763,7 +1763,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1771,15 +1771,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_problem; + return CEditorMessages.SemanticHighlighting_problem; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1796,12 +1796,12 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for external SDK references. */ private static final class ExternalSDKHighlighting extends SemanticHighlighting { - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getPreferenceKey() */ @@ -1809,15 +1809,15 @@ public class SemanticHighlightings { public String getPreferenceKey() { return EXTERNAL_SDK; } - + /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(100, 40, 128); } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextStyleBold() */ @@ -1825,7 +1825,7 @@ public class SemanticHighlightings { public boolean isBoldByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isStrikethroughByDefault() */ @@ -1841,7 +1841,7 @@ public class SemanticHighlightings { public boolean isItalicByDefault() { return false; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#isEnabledByDefault() */ @@ -1849,15 +1849,15 @@ public class SemanticHighlightings { public boolean isEnabledByDefault() { return true; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDisplayName() */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_externalSDK; + return CEditorMessages.SemanticHighlighting_externalSDK; } - + /* * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#consumes(org.eclipse.cdt.internal.ui.editor.SemanticToken) */ @@ -1910,7 +1910,7 @@ public class SemanticHighlightings { return false; } } - + /** * Semantic highlighting for functions. */ @@ -1924,7 +1924,7 @@ public class SemanticHighlightings { return OVERLOADED_OPERATOR; } - + @Override public boolean requiresImplicitNames() { return true; @@ -1932,10 +1932,10 @@ public class SemanticHighlightings { /* - * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultTextColor() + * @see org.eclipse.cdt.internal.ui.editor.SemanticHighlighting#getDefaultDefaultTextColor() */ @Override - public RGB getDefaultTextColor() { + public RGB getDefaultDefaultTextColor() { return new RGB(200, 100, 0); // orange } @@ -1968,7 +1968,7 @@ public class SemanticHighlightings { */ @Override public String getDisplayName() { - return CEditorMessages.SemanticHighlighting_overloadedOperators; + return CEditorMessages.SemanticHighlighting_overloadedOperators; } /* @@ -1999,7 +1999,7 @@ public class SemanticHighlightings { return false; } } - + /** * A named preference that controls the given semantic highlighting's color. * diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java new file mode 100644 index 00000000000..b2d9ddc8df2 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/filters/AnonymousStructFilter.java @@ -0,0 +1,37 @@ +/******************************************************************************* + * Copyright (c) 2011, 2011 Andrew Gvozdev 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: + * Andrew Gvozdev - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.filters; + +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerFilter; + +import org.eclipse.cdt.internal.core.model.CElement; +import org.eclipse.cdt.internal.core.model.Enumeration; +import org.eclipse.cdt.internal.core.model.Structure; + +/** + * Filters out anonymous structs and enums. + */ +public class AnonymousStructFilter extends ViewerFilter { + /** + * Returns the result of this filter, when applied to the + * given inputs. + * + * @return Returns true if element should be included in filtered set + */ + @Override + public boolean select(Viewer viewer, Object parent, Object element) { + if (element instanceof Structure || element instanceof Enumeration) { + return !((CElement) element).getElementName().isEmpty(); + } + return true; + } +} \ No newline at end of file diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index baa9ca350c1..f394643dff9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2010 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation 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 @@ -66,7 +66,6 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.ui.text.IColorManager; -import org.eclipse.cdt.ui.text.doctools.doxygen.DoxygenHelper; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; import org.eclipse.cdt.internal.ui.editor.SemanticHighlighting; @@ -206,6 +205,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object) */ + @Override public Color getBackground(Object element) { return null; } @@ -213,6 +213,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object) */ + @Override public Color getForeground(Object element) { if (element instanceof SemanticHighlightingColorListItem) { if (!getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED)) { @@ -231,6 +232,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ + @Override public Object[] getElements(Object inputElement) { return new String[] {fCodeCategory, fAssemblyCategory, fCommentsCategory, fPreprocessorCategory, fDoxygenCategory}; } @@ -238,15 +240,18 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { /* * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ + @Override public void dispose() { } /* * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object) */ + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } + @Override public Object[] getChildren(Object parentElement) { if (parentElement instanceof String) { String entry= (String) parentElement; @@ -264,6 +269,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { return new Object[0]; } + @Override public Object getParent(Object element) { if (element instanceof String) return null; @@ -279,6 +285,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { return fCommentsCategory; } + @Override public boolean hasChildren(Object element) { return element instanceof String; } @@ -313,9 +320,9 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { { PreferencesMessages.CEditorColoringConfigurationBlock_ppHeaders, PreferenceConstants.EDITOR_PP_HEADER_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_asmLabels, PreferenceConstants.EDITOR_ASM_LABEL_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_asmDirectives, PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR }, - { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized, DoxygenHelper.DOXYGEN_TAG_RECOGNIZED }, - { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment, DoxygenHelper.DOXYGEN_SINGLE_TOKEN }, - { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment, DoxygenHelper.DOXYGEN_MULTI_TOKEN }, + { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenTagRecognized, PreferenceConstants.DOXYGEN_TAG_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenSingleLineComment, PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR }, + { PreferencesMessages.CEditorColoringConfigurationBlock_DoxygenMultiLineComment, PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_keywords, PreferenceConstants.EDITOR_C_KEYWORD_COLOR }, // { PreferencesMessages.CEditorColoringConfigurationBlock_returnKeyword, PreferenceConstants.EDITOR_C_KEYWORD_RETURN_COLOR }, { PreferencesMessages.CEditorColoringConfigurationBlock_builtInTypes, PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR }, @@ -432,6 +439,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { * @param parent the parent composite * @return the control for the preference page */ + @Override public Control createControl(Composite parent) { initializeDialogUnits(parent); return createSyntaxPage(parent); @@ -698,15 +706,18 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { previewer.setLayoutData(gd); fListViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { handleSyntaxColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); @@ -714,9 +725,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fBoldCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getBoldKey(), fBoldCheckBox.getSelection()); @@ -724,18 +737,22 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fItalicCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getItalicKey(), fItalicCheckBox.getSelection()); } }); fStrikethroughCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection()); @@ -743,9 +760,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fUnderlineCheckBox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); getPreferenceStore().setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection()); @@ -753,9 +772,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fEnableCheckbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); if (item instanceof SemanticHighlightingColorListItem) { @@ -775,9 +796,11 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { }); fEnableSemanticHighlightingCheckbox.addSelectionListener(new SelectionListener() { + @Override public void widgetDefaultSelected(SelectionEvent e) { // do nothing } + @Override public void widgetSelected(SelectionEvent e) { fListViewer.refresh(true); HighlightingColorListItem item= getHighlightingColorListItem(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index 104a1c69dfa..cab1a4f022d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2010 IBM Corporation and others. + * Copyright (c) 2005, 2011 IBM Corporation 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 @@ -29,6 +29,7 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Event; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; @@ -45,6 +46,7 @@ import org.eclipse.cdt.utils.ui.controls.ControlFactory; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.editor.CEditor; import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; +import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl; import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; @@ -329,7 +331,10 @@ public class CEditorPreferencePage extends AbstractPreferencePage { */ private void initializeDefaultColors() { if (getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) { - RGB rgb= fAppearanceColorList.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); + Display display= fAppearanceColorList.getDisplay(); + RGB rgb= SourceViewerInformationControl.getVisibleBackgroundColor(display); + if (rgb == null) + rgb= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB(); PreferenceConverter.setValue(getPreferenceStore(), PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR, rgb); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java index 29cc0c8ed41..59892a5926f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeExceptionHandler.java @@ -54,10 +54,12 @@ public class ChangeExceptionHandler { public NotCancelableProgressMonitor(IProgressMonitor monitor) { super(monitor); } + @Override public void setCanceled(boolean b) { // ignore set cancel } + @Override public boolean isCanceled() { return false; @@ -142,6 +144,7 @@ public class ChangeExceptionHandler { private void performUndo(final Change undo) { IWorkspaceRunnable runnable= new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { monitor.beginTask("", 11); //$NON-NLS-1$ try { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java index 3e5ea98cbde..04ef64201b5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/ChangeTreeSet.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -21,11 +21,11 @@ import org.eclipse.cdt.ui.refactoring.CTextFileChange; /** * @author Emanuel Graf - * */ public class ChangeTreeSet { private static final class ChangePositionComparator implements Comparator { + @Override public int compare(CTextFileChange o1, CTextFileChange o2) { if(o1.getFile().equals(o2.getFile())){ return o2.getEdit().getOffset() - o1.getEdit().getOffset(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java index ae56eb1905d..4cdc4fae9f6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/IndexToASTNameHelper.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Institute for Software - initial API and implementation + * Institute for Software - initial API and implementation *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring; @@ -28,7 +28,6 @@ import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.parser.util.CharArrayUtils; public class IndexToASTNameHelper { - public static List findNamesIn(IASTTranslationUnit tu, IBinding binding, IIndex index) { BindingToAstNameMatcher visitor = new BindingToAstNameMatcher(binding, index); tu.accept(visitor); @@ -69,7 +68,6 @@ public class IndexToASTNameHelper { } class IndexNameToAstNameMatcher extends ASTVisitor { - private IASTName result; private IBinding bindingToFind; private char[] charNameToFind; @@ -104,8 +102,10 @@ class IndexNameToAstNameMatcher extends ASTVisitor { private boolean matchesIndexName(IASTName candidate) { IASTFileLocation candidateLocation = candidate.getFileLocation(); - return locationToFind.getNodeOffset() == candidateLocation.getNodeOffset() && locationToFind.getNodeLength() == candidateLocation.getNodeLength() - && locationToFind.getFileName().equals(candidateLocation.getFileName()) && CharArrayUtils.equals(candidate.getLookupKey(), charNameToFind); + return locationToFind.getNodeOffset() == candidateLocation.getNodeOffset() && + locationToFind.getNodeLength() == candidateLocation.getNodeLength() && + locationToFind.getFileName().equals(candidateLocation.getFileName()) && + CharArrayUtils.equals(candidate.getLookupKey(), charNameToFind); } public IASTName getMatch() { @@ -114,7 +114,6 @@ class IndexNameToAstNameMatcher extends ASTVisitor { } class BindingToAstNameMatcher extends ASTVisitor { - private List results = new ArrayList(); private IBinding bindingToFind; private char[] toFindName; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java index 1b56aa359fb..8ae223e3f23 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringASTCache.java @@ -125,6 +125,7 @@ public class RefactoringASTCache implements IDisposable { /** * @see IDisposable#dispose() */ + @Override public void dispose() { Assert.isTrue(!fDisposed, "RefactoringASTCache.dispose() called more than once"); //$NON-NLS-1$ fDisposed = true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java index 545b93a4522..8a44bd356ac 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringExecutionHelper.java @@ -69,6 +69,7 @@ public class RefactoringExecutionHelper { this.fCancelable = cancelable; } + @Override public void run(IProgressMonitor pm) throws CoreException { try { pm.beginTask("", fForked && !fForkChangeExecution ? 7 : 11); //$NON-NLS-1$ @@ -80,6 +81,7 @@ public class RefactoringExecutionHelper { final boolean[] canceled= { false }; if (fForked) { fParent.getDisplay().syncExec(new Runnable() { + @Override public void run() { canceled[0]= showStatusDialog(status); } @@ -185,6 +187,7 @@ public class RefactoringExecutionHelper { try { try { Runnable r= new Runnable() { + @Override public void run() { manager.beginRule(rule, null); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java index fd07b0801f4..eee5e1beb3c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/RefactoringSaveHelper.java @@ -130,6 +130,7 @@ public class RefactoringSaveHelper { return false; } else { IRunnableWithProgress runnable= new IRunnableWithProgress() { + @Override public void run(IProgressMonitor pm) throws InterruptedException { int count= dirtyEditors.length; pm.beginTask("", count); //$NON-NLS-1$ diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java new file mode 100644 index 00000000000..45beb6d1d3c --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorDescriptor.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2011 Google, Inc 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: + * Sergey Prigogin (Google) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; + +import com.ibm.icu.text.Collator; + +import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; + +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName; + +public class AccessorDescriptor implements Comparable { + public enum AccessorKind { + GETTER, + SETTER; + } + + private static final Collator collator = Collator.getInstance(); + + private final AccessorKind kind; + private final String accessorName; + private final IASTName fieldName; + private AccessorFactory accessorFactory; + private IASTSimpleDeclaration accessorDeclaration; + private IASTSimpleDeclaration existingAccessorDeclaration; + private IASTFunctionDefinition existingAccessorDefinition; + + public AccessorDescriptor(AccessorKind kind, String accessorName, FieldDescriptor fieldDescriptor) { + GetterSetterContext context = fieldDescriptor.getContext(); + this.kind = kind; + this.accessorName = accessorName; + this.fieldName = fieldDescriptor.getFieldName(); + if (accessorName != null) { + this.accessorFactory = AccessorFactory.createFactory(kind, fieldName, + fieldDescriptor.getFieldDeclaration(), accessorName); + this.accessorDeclaration = accessorFactory.createDeclaration(); + + for (IASTFunctionDefinition currentDefinition : context.existingFunctionDefinitions) { + if (currentDefinition.getDeclarator().getName().toString().equals(accessorName)) { + existingAccessorDefinition = currentDefinition; + } + } + for (IASTSimpleDeclaration currentDeclaration : context.existingFunctionDeclarations) { + if (GetterSetterContext.getDeclarationName(currentDeclaration).toString().equals(accessorName)) { + existingAccessorDeclaration = currentDeclaration; + } + } + } + } + + boolean canBeGenerated() { + return accessorName != null && existingAccessorDeclaration == null && existingAccessorDefinition == null; + } + + public AccessorKind getKind() { + return kind; + } + + public IASTName getFieldName() { + return fieldName; + } + + @Override + public int compareTo(AccessorDescriptor other) { + int c = collator.compare(fieldName.toString(), other.fieldName.toString()); + if (c != 0) + return c; + return kind.ordinal() - other.kind.ordinal(); + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof AccessorDescriptor)) + return false; + AccessorDescriptor other = (AccessorDescriptor) obj; + return fieldName == other.fieldName && kind == other.kind; + } + + @Override + public String toString() { + return accessorName; + } + + public IASTSimpleDeclaration getAccessorDeclaration() { + return accessorDeclaration; + } + + public IASTFunctionDefinition getAccessorDefinition(boolean qualifedName) { + ICPPASTQualifiedName qname; + if (qualifedName) { + qname = getClassName(); + } else { + qname = null; + } + + return accessorFactory.createDefinition(qname); + } + + private ICPPASTQualifiedName getClassName() { + IASTNode node = fieldName.getParent(); + while (!(node instanceof IASTCompositeTypeSpecifier)) { + node = node.getParent(); + } + IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) node; + + CPPASTQualifiedName qname = new CPPASTQualifiedName(); + qname.addName(comp.getName().copy(CopyStyle.withLocations)); + return qname; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java new file mode 100644 index 00000000000..9ee966e281a --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/AccessorFactory.java @@ -0,0 +1,277 @@ +/******************************************************************************* + * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik + * Rapperswil, University of applied sciences 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: + * Institute for Software - initial API and implementation + * Sergey Prigogin (Google) + *******************************************************************************/ +package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; + +import java.util.Arrays; + +import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; +import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle; +import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; +import org.eclipse.cdt.core.dom.rewrite.TypeHelper; +import org.eclipse.cdt.core.parser.Keywords; + +import org.eclipse.cdt.internal.core.dom.parser.c.CASTDeclarator; +import org.eclipse.cdt.internal.core.dom.parser.c.CASTPointer; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReferenceOperator; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier; +import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration; +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; + +import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind; + +public abstract class AccessorFactory { + protected final IASTName fieldName; + protected final IASTSimpleDeclaration fieldDeclaration; + protected final String accessorName; + protected boolean passByReference; + + public static AccessorFactory createFactory(AccessorKind kind, IASTName fieldName, + IASTSimpleDeclaration fieldDeclaration, String accessorName) { + if (kind == AccessorKind.GETTER) { + return new GetterFactory(fieldName, fieldDeclaration, accessorName); + } else { + return new SetterFactory(fieldName, fieldDeclaration, accessorName); + } + } + + protected AccessorFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, + String accessorName) { + this.fieldName = fieldName; + this.fieldDeclaration = fieldDeclaration; + this.accessorName = accessorName; + IType type = CPPVisitor.createType(fieldDeclaration.getDeclSpecifier()); + passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclaration.getTranslationUnit()); + } + + /** + * Creates an accessor declaration. + */ + public abstract IASTSimpleDeclaration createDeclaration(); + + /** + * Creates an accessor definition. + * + * @param className qualified name of the class containing the accessor + */ + public abstract IASTFunctionDefinition createDefinition(ICPPASTQualifiedName className); + + protected IASTDeclSpecifier getParamOrReturnDeclSpecifier() { + IASTDeclSpecifier declSpec = fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations); + if (passByReference || fieldDeclaration.getDeclarators()[0] instanceof IASTArrayDeclarator) { + declSpec.setConst(true); + } + return declSpec; + } + + private static class GetterFactory extends AccessorFactory { + GetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, String getterName) { + super(fieldName, fieldDeclaration, getterName); + } + + @Override + public IASTSimpleDeclaration createDeclaration() { + IASTSimpleDeclaration getter = new CPPASTSimpleDeclaration(); + getter.setDeclSpecifier(getParamOrReturnDeclSpecifier()); + getter.addDeclarator(getGetterDeclarator(null)); + return getter; + } + + @Override + public IASTFunctionDefinition createDefinition(ICPPASTQualifiedName className) { + IASTFunctionDefinition getter = new CPPASTFunctionDefinition(); + + getter.setDeclSpecifier(getParamOrReturnDeclSpecifier()); + IASTDeclarator getterDeclarator = getGetterDeclarator(className); + // IASTFunctionDefinition expects the outermost IASTFunctionDeclarator in declarator hierarchy + while (!(getterDeclarator instanceof IASTFunctionDeclarator)) { + getterDeclarator = getterDeclarator.getNestedDeclarator(); + } + getter.setDeclarator((IASTFunctionDeclarator) getterDeclarator); + getter.setBody(getGetterBody()); + return getter; + } + + private CPPASTCompoundStatement getGetterBody() { + CPPASTCompoundStatement compound = new CPPASTCompoundStatement(); + CPPASTReturnStatement returnStatement = new CPPASTReturnStatement(); + CPPASTIdExpression idExpr = new CPPASTIdExpression(); + CPPASTName returnVal = new CPPASTName(); + returnVal.setName(fieldName.toCharArray()); + idExpr.setName(returnVal); + returnStatement.setReturnValue(idExpr); + compound.addStatement(returnStatement); + return compound; + } + + private IASTDeclarator getGetterDeclarator(ICPPASTQualifiedName qualifiedName) { + CPPASTName getterName = new CPPASTName(); + getterName.setName(accessorName.toCharArray()); + + // Copy declarator hierarchy + IASTDeclarator topDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations); + + if (topDeclarator instanceof IASTArrayDeclarator) { + boolean isCpp = topDeclarator instanceof ICPPASTArrayDeclarator; + IASTDeclarator decl = isCpp ? new CPPASTDeclarator() : new CASTDeclarator(); + decl.setName(topDeclarator.getName()); + decl.setNestedDeclarator(topDeclarator.getNestedDeclarator()); + decl.addPointerOperator(isCpp ? new CPPASTPointer() : new CASTPointer()); + for (IASTPointerOperator pointer : topDeclarator.getPointerOperators()) { + decl.addPointerOperator(pointer); + } + topDeclarator = decl; + } + // Find the innermost declarator in hierarchy + IASTDeclarator innermost = topDeclarator; + while (innermost.getNestedDeclarator() != null) { + innermost = innermost.getNestedDeclarator(); + } + + // Create a new innermost function declarator based on the field declarator + CPPASTFunctionDeclarator functionDeclarator = new CPPASTFunctionDeclarator(); + functionDeclarator.setConst(true); + if (qualifiedName != null) { + qualifiedName.addName(getterName); + functionDeclarator.setName(qualifiedName); + } else { + functionDeclarator.setName(getterName); + } + for (IASTPointerOperator pointer : innermost.getPointerOperators()){ + functionDeclarator.addPointerOperator(pointer.copy(CopyStyle.withLocations)); + } + if (passByReference) { + functionDeclarator.addPointerOperator(new CPPASTReferenceOperator(false)); + } + + // Replace the innermost with functionDeclarator and return the whole declarator tree + if (innermost == topDeclarator) { + // No tree + return functionDeclarator; + } else { + IASTDeclarator parent = (IASTDeclarator) innermost.getParent(); + parent.setNestedDeclarator(functionDeclarator); + return topDeclarator; + } + } + } + + private static class SetterFactory extends AccessorFactory { + SetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, String setterName) { + super(fieldName, fieldDeclaration, setterName); + } + + @Override + public IASTSimpleDeclaration createDeclaration() { + IASTSimpleDeclaration setter = new CPPASTSimpleDeclaration(); + setter.setDeclSpecifier(getVoidDeclSpec()); + setter.addDeclarator(getSetterDeclarator(null)); + return setter; + } + + @Override + public IASTFunctionDefinition createDefinition(ICPPASTQualifiedName className) { + IASTFunctionDefinition setter = new CPPASTFunctionDefinition(); + setter.setDeclSpecifier(getVoidDeclSpec()); + setter.setDeclarator(getSetterDeclarator(className)); + setter.setBody(getSetterBody()); + return setter; + } + + private CPPASTCompoundStatement getSetterBody() { + CPPASTCompoundStatement compound = new CPPASTCompoundStatement(); + CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement(); + CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression(); + IASTDeclarator innerDeclarator = fieldDeclaration.getDeclarators()[0]; + while (innerDeclarator.getNestedDeclarator() != null) { + innerDeclarator = innerDeclarator.getNestedDeclarator(); + } + IASTName fieldName = innerDeclarator.getName(); + CPPASTName parameterName = getSetterParameterName(); + if (Arrays.equals(fieldName.getSimpleID(), parameterName.getSimpleID())) { + CPPASTFieldReference fieldRef = new CPPASTFieldReference(); + CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression(); + litExpr.setValue(Keywords.cTHIS); + fieldRef.setFieldOwner(litExpr); + fieldRef.setIsPointerDereference(true); + fieldRef.setFieldName(fieldName.copy(CopyStyle.withLocations)); + binExpr.setOperand1(fieldRef); + } else { + CPPASTIdExpression idExpr = new CPPASTIdExpression(fieldName.copy(CopyStyle.withLocations)); + binExpr.setOperand1(idExpr); + } + binExpr.setOperator(IASTBinaryExpression.op_assign); + CPPASTIdExpression idExpr = new CPPASTIdExpression(parameterName); + binExpr.setOperand2(idExpr); + exprStmt.setExpression(binExpr); + compound.addStatement(exprStmt); + return compound; + } + + private CPPASTFunctionDeclarator getSetterDeclarator(ICPPASTQualifiedName qualifiedName) { + CPPASTName setterName = new CPPASTName(); + setterName.setName(accessorName.toCharArray()); + CPPASTFunctionDeclarator declarator = new CPPASTFunctionDeclarator(); + if (qualifiedName != null) { + qualifiedName.addName(setterName); + declarator.setName(qualifiedName); + } else { + declarator.setName(setterName); + } + CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration(); + IASTDeclarator parameterDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations); + parameterDeclarator.setName(getSetterParameterName()); + if (passByReference) { + parameterDeclarator.addPointerOperator(new CPPASTReferenceOperator(false)); + } + parameterDeclaration.setDeclarator(parameterDeclarator); + parameterDeclaration.setDeclSpecifier(getParamOrReturnDeclSpecifier()); + declarator.addParameterDeclaration(parameterDeclaration.copy(CopyStyle.withLocations)); + return declarator; + } + + private CPPASTName getSetterParameterName() { + String parameterName = GetterSetterNameGenerator.generateSetterParameterName(fieldName); + return new CPPASTName(parameterName.toCharArray()); + } + + private static CPPASTSimpleDeclSpecifier getVoidDeclSpec() { + CPPASTSimpleDeclSpecifier declSpecifier = new CPPASTSimpleDeclSpecifier(); + declSpecifier.setType(IASTSimpleDeclSpecifier.t_void); + return declSpecifier; + } + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java new file mode 100644 index 00000000000..c627a0eee34 --- /dev/null +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/FieldDescriptor.java @@ -0,0 +1,121 @@ +package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; +import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; +import org.eclipse.cdt.core.dom.ast.IArrayType; +import org.eclipse.cdt.core.dom.ast.IBinding; +import org.eclipse.cdt.core.dom.ast.IPointerType; +import org.eclipse.cdt.core.dom.ast.IQualifierType; +import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; +import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; + +import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; + +import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind; + +class FieldDescriptor { + private final IASTName fieldName; + private final IASTSimpleDeclaration fieldDeclaration; + private final AccessorDescriptor getter; + private final AccessorDescriptor setter; + private final AccessorDescriptor[] childNodes; + private final GetterSetterContext context; + + FieldDescriptor(IASTSimpleDeclaration fieldDeclaration, GetterSetterContext context) { + this.fieldName = GetterSetterContext.getDeclarationName(fieldDeclaration); + this.fieldDeclaration = fieldDeclaration; + this.context = context; + Set namesToAvoid = getNamesToAvoid(); + String name = GetterSetterNameGenerator.generateGetterName(fieldName, namesToAvoid); + this.getter = new AccessorDescriptor(AccessorKind.GETTER, name, this); + name = GetterSetterNameGenerator.generateSetterName(fieldName, namesToAvoid); + if (!isAssignable(fieldDeclaration)) + name = null; + this.setter = new AccessorDescriptor(AccessorKind.SETTER, name, this); + + List children = new ArrayList(2); + if (getter.canBeGenerated()) { + children.add(getter); + } + if (setter.canBeGenerated()) { + children.add(setter); + } + childNodes = children.toArray(new AccessorDescriptor[children.size()]); + } + + private Set getNamesToAvoid() { + Set namesToAvoid = new HashSet(); + // Add field names. + for (IASTSimpleDeclaration fieldDeclaration : context.existingFields) { + namesToAvoid.add(String.valueOf(GetterSetterContext.getDeclarationName(fieldDeclaration).getSimpleID())); + } + // Add constructor name. + if (!context.existingFields.isEmpty()) { + IASTNode node = context.existingFields.get(0).getParent(); + while (!(node instanceof IASTCompositeTypeSpecifier)) { + node = node.getParent(); + } + IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) node; + namesToAvoid.add(String.valueOf(comp.getName().getLastName().getSimpleID())); + } + return namesToAvoid; + } + + private static boolean isAssignable(IASTSimpleDeclaration declaration) { + IASTName name = GetterSetterContext.getDeclarationName(declaration); + IBinding binding = name.resolveBinding(); + if (!(binding instanceof ICPPField)) + return false; + ICPPField field = (ICPPField) binding; + IType type = field.getType(); + type = SemanticUtil.getNestedType(type, SemanticUtil.TDEF); + if (type instanceof IArrayType || type instanceof ICPPReferenceType) + return false; + if (type instanceof IPointerType && ((IPointerType) type).isConst()) + return false; + if (type instanceof IQualifierType && ((IQualifierType) type).isConst()) + return false; + return true; + } + + @Override + public String toString() { + return fieldName.toString(); + } + + AccessorDescriptor[] getChildNodes() { + return childNodes; + } + + boolean missingGetterOrSetter() { + return getter.canBeGenerated() || setter.canBeGenerated(); + } + + public GetterSetterContext getContext() { + return context; + } + + public IASTName getFieldName() { + return fieldName; + } + + public IASTSimpleDeclaration getFieldDeclaration() { + return fieldDeclaration; + } + + public AccessorDescriptor getGetter() { + return getter; + } + + public AccessorDescriptor getSetter() { + return setter; + } +} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java index 4c00941a4e2..857a1dff291 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersInputPage.java @@ -11,9 +11,6 @@ *******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; -import java.util.Set; -import java.util.SortedSet; - import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener; import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent; @@ -36,8 +33,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.internal.ui.preferences.NameStylePreferencePage; -import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterContext.FieldWrapper; -import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.AccessorKind; +import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind; public class GenerateGettersAndSettersInputPage extends UserInputWizardPage implements IPreferenceChangeListener { private GetterSetterContext context; @@ -45,7 +41,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl private GetterSetterLabelProvider labelProvider; public GenerateGettersAndSettersInputPage(GetterSetterContext context) { - super(Messages.GettersAndSetters_Name); + super(Messages.GenerateGettersAndSettersInputPage_Name); this.context = context; IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID); // We are listening for changes in the Name Style preferences @@ -54,20 +50,19 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl @Override public void createControl(Composite parent) { + setTitle(Messages.GenerateGettersAndSettersInputPage_Name); + setMessage(Messages.GenerateGettersAndSettersInputPage_Header); + Composite comp = new Composite(parent, SWT.NONE); - - setTitle(Messages.GettersAndSetters_Name); - setMessage(Messages.GenerateGettersAndSettersInputPage_header); - comp.setLayout(new GridLayout(2, false)); createTree(comp); GridData gd = new GridData(GridData.FILL_BOTH); variableSelectionView.getTree().setLayoutData(gd); - Composite btComp = createButtonComposite(comp); + Composite buttonContainer = createButtonComposite(comp); gd = new GridData(); gd.verticalAlignment = SWT.TOP; - btComp.setLayoutData(gd); + buttonContainer.setLayoutData(gd); final Button definitionSeparate = new Button(comp, SWT.CHECK); definitionSeparate.setText(Messages.GenerateGettersAndSettersInputPage_SeparateDefinition); @@ -89,7 +84,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl @Override public void widgetSelected(SelectionEvent e) { String id = NameStylePreferencePage.PREF_ID; - PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String [] { id }, null).open(); + PreferencesUtil.createPreferenceDialogOn(getShell(), id, new String[] { id }, null).open(); } }); link.setToolTipText(Messages.GenerateGettersAndSettersInputPage_LinkTooltip); @@ -109,21 +104,14 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl Button selectAll = new Button(btComp, SWT.PUSH); selectAll.setText(Messages.GenerateGettersAndSettersInputPage_SelectAll); - selectAll.addSelectionListener(new SelectionAdapter(){ + selectAll.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Object[] items = context.getElements(null); - SortedSet checkedFunctions = context.selectedFunctions; for (Object treeItem : items) { variableSelectionView.setChecked(treeItem, true); - Object[] childs = context.getChildren(treeItem); - for(Object currentElement : childs){ - if (currentElement instanceof GetterSetterInsertEditProvider) { - GetterSetterInsertEditProvider editProvider = (GetterSetterInsertEditProvider) currentElement; - checkedFunctions.add(editProvider); - } - } } + updateSelectedFunctions(); } }); @@ -132,11 +120,10 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl deselectAll.addSelectionListener(new SelectionAdapter(){ @Override public void widgetSelected(SelectionEvent e) { - Object[] items = context.getElements(null); - for (Object treeItem : items) { + for (Object treeItem : context.getElements(null)) { variableSelectionView.setChecked(treeItem, false); } - context.selectedFunctions.clear(); + updateSelectedFunctions(); } }); @@ -145,7 +132,7 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl selectGetter.addSelectionListener(new SelectionAdapter(){ @Override public void widgetSelected(SelectionEvent e) { - selectMethods(AccessorKind.GETTER); + selectAccessors(AccessorKind.GETTER); } }); @@ -154,31 +141,29 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl selectSetter.addSelectionListener(new SelectionAdapter(){ @Override public void widgetSelected(SelectionEvent e) { - selectMethods(AccessorKind.SETTER); + selectAccessors(AccessorKind.SETTER); } }); return btComp; } - private void selectMethods(AccessorKind type) { - Object[] items = context.getElements(null); - Set checked = context.selectedFunctions; - for (Object treeItem : items) { - if (treeItem instanceof FieldWrapper) { - FieldWrapper field = (FieldWrapper) treeItem; - Object[] funtions = context.getChildren(field); - for (Object funct : funtions) { - if (funct instanceof GetterSetterInsertEditProvider) { - GetterSetterInsertEditProvider getSet = (GetterSetterInsertEditProvider) funct; - if (getSet.getType() == type) { - checked.add(getSet); - variableSelectionView.setChecked(getSet, true); + private void selectAccessors(AccessorKind kind) { + for (Object treeItem : context.getElements(null)) { + if (treeItem instanceof FieldDescriptor) { + FieldDescriptor field = (FieldDescriptor) treeItem; + Object[] children = context.getChildren(field); + for (Object child : children) { + if (child instanceof AccessorDescriptor) { + AccessorDescriptor accessor = (AccessorDescriptor) child; + if (accessor.getKind() == kind) { + variableSelectionView.setChecked(accessor, true); } } } } } + updateSelectedFunctions(); } private void createTree(Composite comp) { @@ -188,38 +173,38 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl variableSelectionView.setLabelProvider(labelProvider); variableSelectionView.setAutoExpandLevel(3); - variableSelectionView.setInput(""); //$NON-NLS-1$ + variableSelectionView.setInput(context); if (context.selectedName != null) { String rawSignature = context.selectedName.getRawSignature(); for (Object obj : variableSelectionView.getVisibleExpandedElements()) { - if (obj instanceof FieldWrapper) { + if (obj instanceof FieldDescriptor) { if (obj.toString().contains(rawSignature)) { variableSelectionView.setSubtreeChecked(obj, true); } } } } - Set checkedFunctions = context.selectedFunctions; - for (Object currentElement : variableSelectionView.getCheckedElements()) { - if (currentElement instanceof GetterSetterInsertEditProvider) { - GetterSetterInsertEditProvider editProvider = (GetterSetterInsertEditProvider) currentElement; - checkedFunctions.add(editProvider); - } - } + + updateSelectedFunctions(); + variableSelectionView.addCheckStateListener(new ICheckStateListener() { @Override public void checkStateChanged(CheckStateChangedEvent event) { - Set checkedFunctions = context.selectedFunctions; - for (Object currentElement : variableSelectionView.getCheckedElements()) { - if (currentElement instanceof GetterSetterInsertEditProvider) { - GetterSetterInsertEditProvider editProvider = (GetterSetterInsertEditProvider) currentElement; - checkedFunctions.add(editProvider); - } - } + updateSelectedFunctions(); } }); } + private void updateSelectedFunctions() { + context.selectedAccessors.clear(); + for (Object element : variableSelectionView.getCheckedElements()) { + if (element instanceof AccessorDescriptor) { + context.selectedAccessors.add((AccessorDescriptor) element); + } + } + setPageComplete(!context.selectedAccessors.isEmpty()); + } + @Override public void preferenceChange(PreferenceChangeEvent event) { if (variableSelectionView.getTree().isDisposed()) { @@ -227,8 +212,19 @@ public class GenerateGettersAndSettersInputPage extends UserInputWizardPage impl } if (GetterSetterNameGenerator.getGenerateGetterSettersPreferenceKeys().contains(event.getKey())) { - context.refresh(); + context.recreateFieldDescriptors(); variableSelectionView.refresh(); + variableSelectionView.setInput(context); // Set input to trigger node expansion. + for (Object element : context.selectedAccessors) { + variableSelectionView.setChecked(element, true); + } } } + + @Override + public void dispose() { + IEclipsePreferences node = InstanceScope.INSTANCE.getNode(CUIPlugin.PLUGIN_ID); + node.removePreferenceChangeListener(this); + super.dispose(); + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java index a613276f522..7f6d0c36d2b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GenerateGettersAndSettersRefactoring.java @@ -159,7 +159,7 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 { if (compositeTypeSpecifier != null) { findDeclarations(compositeTypeSpecifier); } else { - initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoCassDefFound); + initStatus.addFatalError(Messages.GenerateGettersAndSettersRefactoring_NoClassDefFound); } } @@ -230,17 +230,17 @@ public class GenerateGettersAndSettersRefactoring extends CRefactoring2 { throws CoreException, OperationCanceledException { List getterAndSetters = new ArrayList(); List definitions = new ArrayList(); - for (GetterSetterInsertEditProvider currentProvider : context.selectedFunctions) { + for (AccessorDescriptor accessor : context.selectedAccessors) { if (context.isDefinitionSeparate()) { - getterAndSetters.add(currentProvider.getFunctionDeclaration()); - IASTFunctionDefinition functionDefinition = currentProvider.getFunctionDefinition(true); + getterAndSetters.add(accessor.getAccessorDeclaration()); + IASTFunctionDefinition functionDefinition = accessor.getAccessorDefinition(true); // Standalone definitions in a header file have to be declared inline. if (definitionInsertLocation.getTranslationUnit().isHeaderUnit()) { functionDefinition.getDeclSpecifier().setInline(true); } definitions.add(functionDefinition); } else { - getterAndSetters.add(currentProvider.getFunctionDefinition(false)); + getterAndSetters.add(accessor.getAccessorDefinition(false)); } } if (context.isDefinitionSeparate()) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java index 09697a87b08..e915b736b81 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterContext.java @@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; import java.util.ArrayList; +import java.util.List; import java.util.SortedSet; import java.util.TreeSet; @@ -23,54 +24,24 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; -import org.eclipse.cdt.core.dom.ast.IArrayType; -import org.eclipse.cdt.core.dom.ast.IBinding; -import org.eclipse.cdt.core.dom.ast.IPointerType; -import org.eclipse.cdt.core.dom.ast.IQualifierType; -import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPField; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil; - -import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.GetterSetterInsertEditProvider.AccessorKind; +import org.eclipse.cdt.internal.ui.refactoring.gettersandsetters.AccessorDescriptor.AccessorKind; public class GetterSetterContext implements ITreeContentProvider { - public ArrayList existingFields = new ArrayList(); - public ArrayList existingFunctionDefinitions = new ArrayList(); - public ArrayList existingFunctionDeclarations = new ArrayList(); - public SortedSet selectedFunctions = new TreeSet(); - public IASTName selectedName; - private ArrayList wrappedFields; + final List existingFields = new ArrayList(); + final List existingFunctionDefinitions = new ArrayList(); + final List existingFunctionDeclarations = new ArrayList(); + final SortedSet selectedAccessors = new TreeSet(); + IASTName selectedName; + private List fieldDescriptors; private boolean definitionSeparate; + private static final Object[] NO_CHILDREN = {}; @Override public Object[] getChildren(Object parentElement) { - ArrayList children = new ArrayList(); - if (parentElement instanceof FieldWrapper) { - FieldWrapper wrapper = (FieldWrapper) parentElement; - - if (wrapper.getChildNodes().isEmpty()) { - if (!wrapper.getter.exists()) { - wrapper.childNodes.add(createGetterInserter(wrapper.field)); - } - if (!wrapper.setter.exists() && isAssignable(wrapper.field)) { - wrapper.childNodes.add(createSetterInserter(wrapper.field)); - } - } - children = wrapper.getChildNodes(); - } - return children.toArray(); - } - - public GetterSetterInsertEditProvider createGetterInserter(IASTSimpleDeclaration simpleDeclaration) { - IASTName fieldName = getDeclarationName(simpleDeclaration); - return new GetterSetterInsertEditProvider(fieldName, simpleDeclaration, AccessorKind.GETTER); - } - - public GetterSetterInsertEditProvider createSetterInserter(IASTSimpleDeclaration simpleDeclaration) { - IASTName fieldName = getDeclarationName(simpleDeclaration); - return new GetterSetterInsertEditProvider(fieldName, simpleDeclaration, AccessorKind.SETTER); + if (!(parentElement instanceof FieldDescriptor)) + return NO_CHILDREN; + return ((FieldDescriptor) parentElement).getChildNodes(); } @Override @@ -80,31 +51,18 @@ public class GetterSetterContext implements ITreeContentProvider { @Override public boolean hasChildren(Object element) { - if (element instanceof FieldWrapper) { - FieldWrapper wrapper = (FieldWrapper) element; - return wrapper.missingGetterOrSetter(); + if (element instanceof FieldDescriptor) { + FieldDescriptor descriptor = (FieldDescriptor) element; + return descriptor.missingGetterOrSetter(); } return false; } @Override public Object[] getElements(Object inputElement) { - return getWrappedFields().toArray(); + return getFieldDescriptors().toArray(); } - public void refresh() { - // We only recreate the function declarations instead of recreating - // GetterSetterInsertEditProviders. That way, selectedFunctions is still valid. - // Also, the objects inside the TreeViewer are still the same, which is convenient because - // that way we don't need to save then restore the collapsed/expanded+checked/unchecked - // state of the TreeViewer. - for (FieldWrapper wrapper : wrappedFields) { - for (GetterSetterInsertEditProvider provider : wrapper.childNodes) { - provider.createFunctionDeclaration(); - } - } - } - @Override public void dispose() { } @@ -112,7 +70,35 @@ public class GetterSetterContext implements ITreeContentProvider { @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } - + + public void recreateFieldDescriptors() { + // Delete field descriptors so that they are recreated by the next getFieldDescriptors call. + fieldDescriptors = null; + SortedSet oldSelected = new TreeSet(selectedAccessors); + selectedAccessors.clear(); + for (FieldDescriptor descriptor : getFieldDescriptors()) { + for (AccessorDescriptor accessor : descriptor.getChildNodes()) { + if (oldSelected.contains(accessor)) { + selectedAccessors.add(accessor); + } + } + } + } + + public void selectAccessorForField(String name, AccessorKind kind) { + for (FieldDescriptor descriptor : getFieldDescriptors()) { + if (name.equals(String.valueOf(descriptor.getFieldName().getSimpleID()))) { + for (Object child : descriptor.getChildNodes()) { + AccessorDescriptor accessor = (AccessorDescriptor) child; + if (accessor.getKind() == kind) { + selectedAccessors.add(accessor); + break; + } + } + } + } + } + public boolean isDefinitionSeparate() { return definitionSeparate; } @@ -121,105 +107,24 @@ public class GetterSetterContext implements ITreeContentProvider { this.definitionSeparate = definitionSeparate; } - private ArrayList getWrappedFields() { - if (wrappedFields == null) { - wrappedFields = new ArrayList(); + private List getFieldDescriptors() { + if (fieldDescriptors == null) { + fieldDescriptors = new ArrayList(); for (IASTSimpleDeclaration field : existingFields) { - FieldWrapper wrapper = new FieldWrapper(); - wrapper.field = field; - wrapper.getter = getGetterForField(field); - wrapper.setter = getSetterForField(field); - if (wrapper.missingGetterOrSetter()) { - wrappedFields.add(wrapper); + FieldDescriptor descriptor = new FieldDescriptor(field, this); + if (descriptor.missingGetterOrSetter()) { + fieldDescriptors.add(descriptor); } } } - return wrappedFields; + return fieldDescriptors; } - private FunctionWrapper getGetterForField(IASTSimpleDeclaration currentField) { - FunctionWrapper wrapper = new FunctionWrapper(); - String name = GetterSetterNameGenerator.generateGetterName(getDeclarationName(currentField)); - setFunctionToWrapper(wrapper, name); - return wrapper; - } - - private FunctionWrapper getSetterForField(IASTSimpleDeclaration field) { - FunctionWrapper wrapper = new FunctionWrapper(); - String name = GetterSetterNameGenerator.generateSetterName(getDeclarationName(field)); - setFunctionToWrapper(wrapper, name); - return wrapper; - } - - private static IASTName getDeclarationName(IASTSimpleDeclaration declaration) { + static IASTName getDeclarationName(IASTSimpleDeclaration declaration) { IASTDeclarator declarator = declaration.getDeclarators()[0]; while (declarator.getNestedDeclarator() != null) { declarator = declarator.getNestedDeclarator(); } return declarator.getName(); } - - private static boolean isAssignable(IASTSimpleDeclaration declaration) { - IASTName name = getDeclarationName(declaration); - IBinding binding = name.resolveBinding(); - if (!(binding instanceof ICPPField)) - return false; - ICPPField field = (ICPPField) binding; - IType type = field.getType(); - type = SemanticUtil.getNestedType(type, SemanticUtil.TDEF); - if (type instanceof IArrayType || type instanceof ICPPReferenceType) - return false; - if (type instanceof IPointerType && ((IPointerType) type).isConst()) - return false; - if (type instanceof IQualifierType && ((IQualifierType) type).isConst()) - return false; - return true; - } - - private void setFunctionToWrapper(FunctionWrapper wrapper, String accessorName) { - for (IASTFunctionDefinition currentDefinition : existingFunctionDefinitions) { - if (currentDefinition.getDeclarator().getName().toString().equals(accessorName)) { - wrapper.functionDefinition = currentDefinition; - } - } - - for (IASTSimpleDeclaration currentDeclaration : existingFunctionDeclarations) { - if (getDeclarationName(currentDeclaration).toString().equals(accessorName)) { - wrapper.functionDeclaration = currentDeclaration; - } - } - } - - protected class FieldWrapper { - protected IASTSimpleDeclaration field; - protected FunctionWrapper getter; - protected FunctionWrapper setter; - protected ArrayList childNodes = new ArrayList(2); - - @Override - public String toString() { - IASTDeclarator declarator = field.getDeclarators()[0]; - while (declarator.getNestedDeclarator() != null) { - declarator = declarator.getNestedDeclarator(); - } - return declarator.getName().toString(); - } - - public ArrayList getChildNodes() { - return childNodes; - } - - public boolean missingGetterOrSetter() { - return !getter.exists() || !setter.exists(); - } - } - - protected class FunctionWrapper { - protected IASTSimpleDeclaration functionDeclaration; - protected IASTFunctionDefinition functionDefinition; - - public boolean exists() { - return functionDeclaration != null || functionDefinition != null; - } - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterFactory.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterFactory.java deleted file mode 100644 index 070d7c2d1f9..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterFactory.java +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - * Sergey Prigogin (Google) - *******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; - -import java.util.Arrays; - -import org.eclipse.cdt.core.dom.ast.IASTArrayDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTBinaryExpression; -import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle; -import org.eclipse.cdt.core.dom.ast.IASTPointerOperator; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; -import org.eclipse.cdt.core.dom.ast.IType; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; -import org.eclipse.cdt.core.dom.rewrite.TypeHelper; -import org.eclipse.cdt.core.parser.Keywords; - -import org.eclipse.cdt.internal.core.dom.parser.c.CASTDeclarator; -import org.eclipse.cdt.internal.core.dom.parser.c.CASTPointer; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTCompoundStatement; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTDeclarator; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTExpressionStatement; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFieldReference; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDeclarator; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTFunctionDefinition; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLiteralExpression; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTParameterDeclaration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTPointer; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReferenceOperator; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTReturnStatement; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclSpecifier; -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSimpleDeclaration; -import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; - -public class GetterSetterFactory { - private final IASTName fieldName; - private final IASTSimpleDeclaration fieldDeclaration; - private boolean passByReference; - - public GetterSetterFactory(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration) { - this.fieldName = fieldName; - this.fieldDeclaration = fieldDeclaration; - IType type = CPPVisitor.createType(fieldDeclaration.getDeclSpecifier()); - passByReference = TypeHelper.shouldBePassedByReference(type, fieldDeclaration.getTranslationUnit()); - } - - public IASTFunctionDefinition createGetterDefinition(ICPPASTQualifiedName qualifiedName) { - IASTFunctionDefinition getter = new CPPASTFunctionDefinition(); - - getter.setDeclSpecifier(getParamOrReturnDeclSpecifier()); - IASTDeclarator getterDeclarator = getGetterDeclarator(qualifiedName); - // IASTFunctionDefinition expects the outermost IASTFunctionDeclarator in declarator hierarchy - while (!(getterDeclarator instanceof IASTFunctionDeclarator)) { - getterDeclarator = getterDeclarator.getNestedDeclarator(); - } - getter.setDeclarator((IASTFunctionDeclarator) getterDeclarator); - getter.setBody(getGetterBody()); - return getter; - } - - private CPPASTCompoundStatement getGetterBody() { - CPPASTCompoundStatement compound = new CPPASTCompoundStatement(); - CPPASTReturnStatement returnStatement = new CPPASTReturnStatement(); - CPPASTIdExpression idExpr = new CPPASTIdExpression(); - CPPASTName returnVal = new CPPASTName(); - returnVal.setName(fieldName.toCharArray()); - idExpr.setName(returnVal); - returnStatement.setReturnValue(idExpr); - compound.addStatement(returnStatement); - return compound; - } - - private IASTDeclarator getGetterDeclarator(ICPPASTQualifiedName qualifiedName) { - CPPASTName getterName = new CPPASTName(); - getterName.setName(GetterSetterNameGenerator.generateGetterName(fieldName).toCharArray()); - - // Copy declarator hierarchy - IASTDeclarator topDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations); - - if (topDeclarator instanceof IASTArrayDeclarator) { - boolean isCpp = topDeclarator instanceof ICPPASTArrayDeclarator; - IASTDeclarator decl = isCpp ? new CPPASTDeclarator() : new CASTDeclarator(); - decl.setName(topDeclarator.getName()); - decl.setNestedDeclarator(topDeclarator.getNestedDeclarator()); - decl.addPointerOperator(isCpp ? new CPPASTPointer() : new CASTPointer()); - for (IASTPointerOperator pointer : topDeclarator.getPointerOperators()) { - decl.addPointerOperator(pointer); - } - topDeclarator = decl; - } - // Find the innermost declarator in hierarchy - IASTDeclarator innermost = topDeclarator; - while (innermost.getNestedDeclarator() != null) { - innermost = innermost.getNestedDeclarator(); - } - - // Create a new innermost function declarator based on the field declarator - CPPASTFunctionDeclarator functionDeclarator = new CPPASTFunctionDeclarator(); - functionDeclarator.setConst(true); - if (qualifiedName != null) { - qualifiedName.addName(getterName); - functionDeclarator.setName(qualifiedName); - } else { - functionDeclarator.setName(getterName); - } - for (IASTPointerOperator pointer : innermost.getPointerOperators()){ - functionDeclarator.addPointerOperator(pointer.copy(CopyStyle.withLocations)); - } - if (passByReference) { - functionDeclarator.addPointerOperator(new CPPASTReferenceOperator(false)); - } - - // Replace the innermost with functionDeclarator and return the whole declarator tree - if (innermost == topDeclarator) { - // No tree - return functionDeclarator; - } else { - IASTDeclarator parent = (IASTDeclarator) innermost.getParent(); - parent.setNestedDeclarator(functionDeclarator); - return topDeclarator; - } - } - - public IASTFunctionDefinition createSetterDefinition(ICPPASTQualifiedName qualifiedName) { - IASTFunctionDefinition setter = new CPPASTFunctionDefinition(); - setter.setDeclSpecifier(getVoidDeclSpec()); - setter.setDeclarator(getSetterDeclarator(qualifiedName)); - setter.setBody(getSetterBody()); - return setter; - } - - private CPPASTCompoundStatement getSetterBody() { - CPPASTCompoundStatement compound = new CPPASTCompoundStatement(); - CPPASTExpressionStatement exprStmt = new CPPASTExpressionStatement(); - CPPASTBinaryExpression binExpr = new CPPASTBinaryExpression(); - IASTDeclarator innerDeclarator = fieldDeclaration.getDeclarators()[0]; - while (innerDeclarator.getNestedDeclarator() != null) { - innerDeclarator = innerDeclarator.getNestedDeclarator(); - } - IASTName fieldName = innerDeclarator.getName(); - CPPASTName parameterName = getSetterParameterName(); - if (Arrays.equals(fieldName.getSimpleID(), parameterName.getSimpleID())) { - CPPASTFieldReference fieldRef = new CPPASTFieldReference(); - CPPASTLiteralExpression litExpr = new CPPASTLiteralExpression(); - litExpr.setValue(Keywords.cTHIS); - fieldRef.setFieldOwner(litExpr); - fieldRef.setIsPointerDereference(true); - fieldRef.setFieldName(fieldName.copy(CopyStyle.withLocations)); - binExpr.setOperand1(fieldRef); - } else { - CPPASTIdExpression idExpr = new CPPASTIdExpression(fieldName.copy(CopyStyle.withLocations)); - binExpr.setOperand1(idExpr); - } - binExpr.setOperator(IASTBinaryExpression.op_assign); - CPPASTIdExpression idExpr = new CPPASTIdExpression(parameterName); - binExpr.setOperand2(idExpr); - exprStmt.setExpression(binExpr); - compound.addStatement(exprStmt); - return compound; - } - - private CPPASTFunctionDeclarator getSetterDeclarator(ICPPASTQualifiedName qualifiedName) { - CPPASTName setterName = new CPPASTName(); - setterName.setName(GetterSetterNameGenerator.generateSetterName(fieldName).toCharArray()); - CPPASTFunctionDeclarator declarator = new CPPASTFunctionDeclarator(); - if (qualifiedName != null) { - qualifiedName.addName(setterName); - declarator.setName(qualifiedName); - } else { - declarator.setName(setterName); - } - CPPASTParameterDeclaration parameterDeclaration = new CPPASTParameterDeclaration(); - IASTDeclarator parameterDeclarator = fieldDeclaration.getDeclarators()[0].copy(CopyStyle.withLocations); - parameterDeclarator.setName(getSetterParameterName()); - if (passByReference) { - parameterDeclarator.addPointerOperator(new CPPASTReferenceOperator(false)); - } - parameterDeclaration.setDeclarator(parameterDeclarator); - parameterDeclaration.setDeclSpecifier(getParamOrReturnDeclSpecifier()); - declarator.addParameterDeclaration(parameterDeclaration.copy(CopyStyle.withLocations)); - return declarator; - } - - private CPPASTName getSetterParameterName() { - String parameterName = GetterSetterNameGenerator.generateSetterParameterName(fieldName); - return new CPPASTName(parameterName.toCharArray()); - } - - private static CPPASTSimpleDeclSpecifier getVoidDeclSpec() { - CPPASTSimpleDeclSpecifier declSpecifier = new CPPASTSimpleDeclSpecifier(); - declSpecifier.setType(IASTSimpleDeclSpecifier.t_void); - return declSpecifier; - } - - public IASTSimpleDeclaration createGetterDeclaration() { - IASTSimpleDeclaration getter = new CPPASTSimpleDeclaration(); - getter.setDeclSpecifier(getParamOrReturnDeclSpecifier()); - getter.addDeclarator(getGetterDeclarator(null)); - return getter; - } - - private IASTDeclSpecifier getParamOrReturnDeclSpecifier() { - IASTDeclSpecifier declSpec = fieldDeclaration.getDeclSpecifier().copy(CopyStyle.withLocations); - if (passByReference || fieldDeclaration.getDeclarators()[0] instanceof IASTArrayDeclarator) { - declSpec.setConst(true); - } - return declSpec; - } - - public IASTSimpleDeclaration createSetterDeclaration() { - IASTSimpleDeclaration setter = new CPPASTSimpleDeclaration(); - setter.setDeclSpecifier(getVoidDeclSpec()); - setter.addDeclarator(getSetterDeclarator(null)); - return setter; - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java deleted file mode 100644 index 0956d700277..00000000000 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterInsertEditProvider.java +++ /dev/null @@ -1,110 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik - * Rapperswil, University of applied sciences 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: - * Institute for Software - initial API and implementation - * Sergey Prigogin (Google) - *******************************************************************************/ -package org.eclipse.cdt.internal.ui.refactoring.gettersandsetters; - -import org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; -import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition; -import org.eclipse.cdt.core.dom.ast.IASTName; -import org.eclipse.cdt.core.dom.ast.IASTNode; -import org.eclipse.cdt.core.dom.ast.IASTNode.CopyStyle; -import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration; -import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName; - -import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTQualifiedName; - -public class GetterSetterInsertEditProvider implements Comparable { - public enum AccessorKind { - GETTER, - SETTER; - } - - private IASTSimpleDeclaration functionDeclaration; - private AccessorKind kind; - private IASTSimpleDeclaration fieldDeclaration; - private GetterSetterFactory getterSetterFactory; - - public GetterSetterInsertEditProvider(IASTName fieldName, IASTSimpleDeclaration fieldDeclaration, - AccessorKind kind) { - this.kind = kind; - this.fieldDeclaration = fieldDeclaration; - this.getterSetterFactory = new GetterSetterFactory(fieldName, fieldDeclaration); - - createFunctionDeclaration(); - } - - public void createFunctionDeclaration() { - switch (this.kind) { - case GETTER: - this.functionDeclaration = getterSetterFactory.createGetterDeclaration(); - break; - case SETTER: - this.functionDeclaration = getterSetterFactory.createSetterDeclaration(); - break; - } - } - - @Override - public String toString() { - IASTDeclarator declarator = functionDeclaration.getDeclarators()[0]; - while (declarator.getNestedDeclarator() != null) { - declarator = declarator.getNestedDeclarator(); - } - return declarator.getName().toString(); - } - - public IASTFunctionDefinition getFunctionDefinition(boolean qualifedName) { - IASTFunctionDefinition definition = null; - ICPPASTQualifiedName qname; - if (qualifedName) { - qname = getClassName(); - } else { - qname = null; - } - - switch (kind) { - case GETTER: - definition = getterSetterFactory.createGetterDefinition(qname); - break; - case SETTER: - definition = getterSetterFactory.createSetterDefinition(qname); - break; - } - return definition; - } - - private ICPPASTQualifiedName getClassName() { - IASTNode node = fieldDeclaration.getParent(); - while (!(node instanceof IASTCompositeTypeSpecifier)) { - node = node.getParent(); - } - IASTCompositeTypeSpecifier comp = (IASTCompositeTypeSpecifier) node; - - CPPASTQualifiedName qname = new CPPASTQualifiedName(); - qname.addName(comp.getName().copy(CopyStyle.withLocations)); - return qname; - } - - public IASTSimpleDeclaration getFunctionDeclaration() { - return functionDeclaration; - } - - public AccessorKind getType() { - return kind; - } - - @Override - public int compareTo(GetterSetterInsertEditProvider o) { - return toString().compareTo(o.toString()); - } -} diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java index 927579fa0eb..a5ba6dcb1d5 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterLabelProvider.java @@ -22,10 +22,9 @@ import org.eclipse.cdt.internal.ui.viewsupport.CElementImageProvider; * @author Emanuel Graf IFS */ public class GetterSetterLabelProvider extends LabelProvider { - @Override public Image getImage(Object element) { - if (element instanceof GetterSetterInsertEditProvider) { + if (element instanceof AccessorDescriptor) { return CElementImageProvider.getMethodImageDescriptor(ASTAccessVisibility.PUBLIC).createImage(); } return null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java index 229fe842b5f..f13586f9af9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/GetterSetterNameGenerator.java @@ -16,11 +16,12 @@ import java.util.Set; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.IPreferencesService; - +import org.eclipse.cdt.core.CConventions; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IBasicType; import org.eclipse.cdt.core.dom.ast.IType; +import org.eclipse.cdt.core.dom.ast.gnu.cpp.GPPLanguage; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; @@ -29,11 +30,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor; import org.eclipse.cdt.internal.ui.util.NameComposer; public class GetterSetterNameGenerator { - - // Do not instantiate. - private GetterSetterNameGenerator() { - } - private static Set generateGetterSettersPreferenceKeys = new HashSet(); static { generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION); @@ -51,18 +47,30 @@ public class GetterSetterNameGenerator { generateGetterSettersPreferenceKeys.add(PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX); } + // Do not instantiate. + private GetterSetterNameGenerator() { + } + public static Set getGenerateGetterSettersPreferenceKeys() { return generateGetterSettersPreferenceKeys; } - - public static String generateGetterName(IASTName fieldName) { + + /** + * Generates getter name for a given field name. + * + * @param fieldName the name of the field + * @param namesToAvoid the set of names to avoid + * @return the generated getter name, or null if a valid name could not be + * generated. + */ + public static String generateGetterName(IASTName fieldName, Set namesToAvoid) { IPreferencesService preferences = Platform.getPreferencesService(); int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_GETTER_CAPITALIZATION, PreferenceConstants.NAME_STYLE_CAPITALIZATION_CAMEL_CASE, null); String wordDelimiter = preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_GETTER_WORD_DELIMITER, "", null); //$NON-NLS-1$ - String prefix = isBooleanDecaratorName(fieldName) ? + String prefix = isBooleanDeclaratorName(fieldName) ? preferences.getString(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_GETTER_PREFIX_FOR_BOOLEAN, "is", null) : //$NON-NLS-1$ preferences.getString(CUIPlugin.PLUGIN_ID, @@ -71,10 +79,11 @@ public class GetterSetterNameGenerator { PreferenceConstants.NAME_STYLE_GETTER_SUFFIX, "", null); //$NON-NLS-1$ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix); String name = NameComposer.trimFieldName(fieldName.toString()); - return composer.compose(name); + name = composer.compose(name); + return adjustName(name, namesToAvoid); } - private static boolean isBooleanDecaratorName(IASTName name) { + private static boolean isBooleanDeclaratorName(IASTName name) { if (IASTDeclarator.DECLARATOR_NAME.equals(name.getPropertyInParent())) { IASTDeclarator declarator = (IASTDeclarator) name.getParent(); IType type = CPPVisitor.createType(declarator); @@ -85,7 +94,15 @@ public class GetterSetterNameGenerator { return false; } - public static String generateSetterName(IASTName fieldName) { + /** + * Generates setter name for a given field name. + * + * @param fieldName the name of the field + * @param namesToAvoid the set of names to avoid + * @return the generated setter name, or null if a valid name could not be + * generated. + */ + public static String generateSetterName(IASTName fieldName, Set namesToAvoid) { IPreferencesService preferences = Platform.getPreferencesService(); int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_SETTER_CAPITALIZATION, @@ -98,10 +115,11 @@ public class GetterSetterNameGenerator { PreferenceConstants.NAME_STYLE_SETTER_SUFFIX, "", null); //$NON-NLS-1$ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix); String name = NameComposer.trimFieldName(fieldName.toString()); - return composer.compose(name); + name = composer.compose(name); + return adjustName(name, namesToAvoid); } - public static String generateSetterParameterName(IASTName fieldName) { + public static String generateSetterParameterName(IASTName fieldName){ IPreferencesService preferences = Platform.getPreferencesService(); int capitalization = preferences.getInt(CUIPlugin.PLUGIN_ID, PreferenceConstants.NAME_STYLE_VARIABLE_CAPITALIZATION, @@ -114,6 +132,28 @@ public class GetterSetterNameGenerator { PreferenceConstants.NAME_STYLE_VARIABLE_SUFFIX, "", null); //$NON-NLS-1$ NameComposer composer = new NameComposer(capitalization, wordDelimiter, prefix, suffix); String name = NameComposer.trimFieldName(fieldName.toString()); - return composer.compose(name); + name = composer.compose(name); + if (!CConventions.validateIdentifier(name, GPPLanguage.getDefault()).isOK()) + name = '_' + name; + return name; + } + + /** + * Checks is the given name is valid and, if not, tries to adjust it by adding a numeric suffix + * to it. + * + * @param name the name to check and, possibly, adjust + * @param namesToAvoid the set of names to avoid + * @return the adjusted name, or null if a valid name could not be generated. + */ + private static String adjustName(String name, Set namesToAvoid) { + String originalName = name; + for (int i = 1; i < 100; i++) { + if (!namesToAvoid.contains(name) && CConventions.validateIdentifier(name, GPPLanguage.getDefault()).isOK()) { + return name; + } + name = originalName + i; + } + return null; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java index be3a7e838e7..f6cac1f695d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.java @@ -15,17 +15,17 @@ import org.eclipse.osgi.util.NLS; public final class Messages extends NLS { public static String GenerateGettersAndSettersInputPage_DeselectAll; - public static String GenerateGettersAndSettersInputPage_header; + public static String GenerateGettersAndSettersInputPage_Header; + public static String GenerateGettersAndSettersInputPage_LinkDescription; + public static String GenerateGettersAndSettersInputPage_LinkTooltip; + public static String GenerateGettersAndSettersInputPage_Name; public static String GenerateGettersAndSettersInputPage_SeparateDefinition; public static String GenerateGettersAndSettersInputPage_SelectAll; public static String GenerateGettersAndSettersInputPage_SelectGetters; public static String GenerateGettersAndSettersInputPage_SelectSetters; - public static String GenerateGettersAndSettersInputPage_LinkDescription; - public static String GenerateGettersAndSettersInputPage_LinkTooltip; - public static String GenerateGettersAndSettersRefactoring_NoCassDefFound; + public static String GenerateGettersAndSettersRefactoring_NoClassDefFound; public static String GenerateGettersAndSettersRefactoring_NoFields; public static String GenerateGettersAndSettersRefactoring_NoImplFile; - public static String GettersAndSetters_Name; static { NLS.initializeMessages(Messages.class.getName(), Messages.class); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties index e4ca8314022..f57203d0fe7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/gettersandsetters/Messages.properties @@ -9,15 +9,15 @@ # Contributors: # Institute for Software - initial API and implementation ############################################################################### -GettersAndSetters_Name=Generate getters and setters GenerateGettersAndSettersInputPage_DeselectAll=Deselect All -GenerateGettersAndSettersInputPage_header=Select getters and setters to create: +GenerateGettersAndSettersInputPage_Header=Select getters and setters to create: +GenerateGettersAndSettersInputPage_LinkDescription=The names of getters and setters may be configured on the Name Style preference page. +GenerateGettersAndSettersInputPage_LinkTooltip=Show the name style preferences. +GenerateGettersAndSettersInputPage_Name=Generate getters and setters GenerateGettersAndSettersInputPage_SeparateDefinition=Definition separate from declaration GenerateGettersAndSettersInputPage_SelectAll=Select All GenerateGettersAndSettersInputPage_SelectGetters=Select Getters GenerateGettersAndSettersInputPage_SelectSetters=Select Setters -GenerateGettersAndSettersInputPage_LinkDescription=The names of getters and setters may be configured on the Name Style preference page. -GenerateGettersAndSettersInputPage_LinkTooltip=Show the name style preferences. -GenerateGettersAndSettersRefactoring_NoCassDefFound=No class definition found +GenerateGettersAndSettersRefactoring_NoClassDefFound=No class definition found GenerateGettersAndSettersRefactoring_NoFields=The class does not contain any fields. GenerateGettersAndSettersRefactoring_NoImplFile=No implementation file found. Inserting definition into the header file. diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java index 4c5afdbf40f..6d1da8aa5b6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/ASTManager.java @@ -805,6 +805,7 @@ public class ASTManager implements IDisposable { /** * @see IDisposable#dispose() */ + @Override public void dispose() { Assert.isTrue(!fDisposed, "ASTManager.dispose() called more than once"); //$NON-NLS-1$ fDisposed = true; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java index 7caeed00aee..40733e1d3ab 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRefactoringMatchStore.java @@ -6,7 +6,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Markus Schorn - initial API and implementation + * Markus Schorn - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.rename; @@ -25,7 +25,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; - public class CRefactoringMatchStore { private Map fFileToPathMap= new HashMap(); private Map> fPathToMatches= new HashMap>(); @@ -33,7 +32,8 @@ public class CRefactoringMatchStore { public CRefactoringMatchStore() { fOffsetComparator= new Comparator() { - public int compare(CRefactoringMatch o1, CRefactoringMatch o2) { + @Override + public int compare(CRefactoringMatch o1, CRefactoringMatch o2) { return o1.getOffset() - o2.getOffset(); } }; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java index f88b03f1f1e..2b22bf24ecf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameProcessorDelegate.java @@ -323,7 +323,8 @@ public abstract class CRenameProcessorDelegate { return null; } Collections.sort(fMatches, new Comparator() { - public int compare(CRefactoringMatch m1, CRefactoringMatch m2) { + @Override + public int compare(CRefactoringMatch m1, CRefactoringMatch m2) { IFile f1= m1.getFile(); IFile f2= m2.getFile(); int cmp= f1.getName().compareTo(f2.getName()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java index 4ff71ad86af..d5ef17064ac 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/CRenameRefactoringInputPage.java @@ -73,8 +73,8 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { return (fOptions & options) == options; } - // overrider - public void createControl(Composite parent) { + @Override + public void createControl(Composite parent) { CRenameProcessor processor= getRenameProcessor(); fSearchString= processor.getArgument().getName(); fOptions= processor.getAvailableOptions(); @@ -226,7 +226,7 @@ public class CRenameRefactoringInputPage extends UserInputWizardPage { private void hookSelectionListeners() { fNewName.addModifyListener(new ModifyListener() { - + @Override public void modifyText(ModifyEvent e) { onKeyReleaseInNameField(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java index 9b9fa478ea1..b06421c6c07 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameInformationPopup.java @@ -9,7 +9,6 @@ * IBM Corporation - initial API and implementation * Sergey Prigogin (Google) *******************************************************************************/ - package org.eclipse.cdt.internal.ui.refactoring.rename; import org.eclipse.osgi.util.NLS; @@ -93,7 +92,8 @@ import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenKeeperExtension { - private class PopupVisibilityManager implements IPartListener2, ControlListener, MouseListener, KeyListener, ITextListener, IViewportListener { + private class PopupVisibilityManager implements IPartListener2, ControlListener, MouseListener, + KeyListener, ITextListener, IViewportListener { public void start() { fEditor.getSite().getWorkbenchWindow().getPartService().addPartListener(this); @@ -106,6 +106,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK viewer.addTextListener(this); viewer.addViewportListener(this); fPopup.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent e) { fEditor.getSite().getWorkbenchWindow().getPartService().removePartListener(PopupVisibilityManager.this); if (!textWidget.isDisposed()) { @@ -129,6 +130,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK }); } + @Override public void partActivated(IWorkbenchPartReference partRef) { IWorkbenchPart fPart= fEditor.getEditorSite().getPart(); if (partRef.getPart(false) == fPart) { @@ -136,12 +138,15 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK } } + @Override public void partBroughtToTop(IWorkbenchPartReference partRef) { } + @Override public void partClosed(IWorkbenchPartReference partRef) { } + @Override public void partDeactivated(IWorkbenchPartReference partRef) { IWorkbenchPart fPart= fEditor.getEditorSite().getPart(); if (fPopup != null && !fPopup.isDisposed() && partRef.getPart(false) == fPart) { @@ -149,47 +154,59 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK } } + @Override public void partHidden(IWorkbenchPartReference partRef) { } + @Override public void partInputChanged(IWorkbenchPartReference partRef) { } + @Override public void partOpened(IWorkbenchPartReference partRef) { } + @Override public void partVisible(IWorkbenchPartReference partRef) { } + @Override public void controlMoved(ControlEvent e) { updatePopupLocation(true); updateVisibility(); //only for hiding outside editor area } + @Override public void controlResized(ControlEvent e) { updatePopupLocation(true); updateVisibility(); //only for hiding outside editor area } + @Override public void mouseDoubleClick(MouseEvent e) { } + @Override public void mouseDown(MouseEvent e) { } + @Override public void mouseUp(MouseEvent e) { updatePopupLocation(false); updateVisibility(); } + @Override public void keyPressed(KeyEvent e) { updatePopupLocation(false); updateVisibility(); } + @Override public void keyReleased(KeyEvent e) { } + @Override public void textChanged(TextEvent event) { if (!event.getViewerRedrawState()) return; @@ -197,6 +214,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK updateVisibility(); //only for hiding outside editor area } + @Override public void viewportChanged(int verticalOffset) { updatePopupLocation(true); updateVisibility(); //only for hiding outside editor area @@ -309,7 +327,8 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK final Shell editorShell= fEditor.getSite().getShell(); display.asyncExec(new Runnable() { - // post to UI thread since editor shell only gets activated after popup has lost focus + // Post to UI thread since editor shell only gets activated after popup has lost focus + @Override public void run() { Shell activeShell= display.getActiveShell(); if (activeShell != editorShell) { @@ -322,6 +341,7 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK if (!MAC) { // carbon and cocoa draw their own border... fPopup.addPaintListener(new PaintListener() { + @Override public void paintControl(PaintEvent pe) { pe.gc.drawPolygon(getPolygon(true)); } @@ -722,9 +742,12 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK fMenuManager.setRemoveAllWhenShown(true); fMenuManager.addMenuListener(new IMenuListener2() { + @Override public void menuAboutToHide(IMenuManager manager) { fIsMenuUp= false; } + + @Override public void menuAboutToShow(IMenuManager manager) { boolean canRefactor= !fRenameLinkedMode.isOriginalName(); @@ -840,14 +863,17 @@ public class RenameInformationPopup implements IWidgetTokenKeeper, IWidgetTokenK fEditor.getSite().getShell().setActive(); } + @Override public boolean requestWidgetToken(IWidgetTokenOwner owner) { return false; } + @Override public boolean requestWidgetToken(IWidgetTokenOwner owner, int priority) { return false; } + @Override public boolean setFocus(IWidgetTokenOwner owner) { if (fToolBar != null && !fToolBar.isDisposed()) showMenu(fToolBar); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java index dfb2d6e86ae..0559998b204 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameLinkedMode.java @@ -83,6 +83,7 @@ import org.eclipse.cdt.internal.ui.text.correction.proposals.LinkedNamesAssistPr public class RenameLinkedMode { private class FocusEditingSupport implements IEditingSupport { + @Override public boolean ownsFocusShell() { if (fInfoPopup == null) return false; @@ -97,12 +98,14 @@ public class RenameLinkedMode { return false; } + @Override public boolean isOriginator(DocumentEvent event, IRegion subjectRegion) { return false; //leave on external modification outside positions } } private class EditorSynchronizer implements ILinkedModeListener { + @Override public void left(LinkedModeModel model, int flags) { linkedModeLeft(); if ((flags & ILinkedModeListener.UPDATE_CARET) != 0) { @@ -110,9 +113,11 @@ public class RenameLinkedMode { } } + @Override public void resume(LinkedModeModel model, int flags) { } + @Override public void suspend(LinkedModeModel model) { } } @@ -194,7 +199,7 @@ public class RenameLinkedMode { ASTProvider.getASTProvider().runOnAST(fEditor.getInputCElement(), ASTProvider.WAIT_ACTIVE_ONLY, new NullProgressMonitor(), new ASTRunnable() { - + @Override public IStatus runOnAST(ILanguage lang, IASTTranslationUnit astRoot) throws CoreException { if (astRoot == null) return Status.CANCEL_STATUS; @@ -225,7 +230,7 @@ public class RenameLinkedMode { // Sort the locations starting with the one @ offset. Arrays.sort(fLocations, new Comparator() { - + @Override public int compare(IRegion n1, IRegion n2) { return rank(n1) - rank(n2); } @@ -384,6 +389,7 @@ public class RenameLinkedMode { try { if (!fOriginalName.equals(newName)) { fEditor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (viewer instanceof ITextViewerExtension6) { IUndoManager undoManager= ((ITextViewerExtension6) viewer).getUndoManager(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java index f54d36a7df5..df251517fbe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/RenameSupport.java @@ -200,7 +200,11 @@ public class RenameSupport { processor.getSaveMode())) { return DialogResult.OK; } - return dialogSkipped[0] ? DialogResult.SKIPPED : DialogResult.CANCELED; + if (dialogSkipped[0]) { + // If the dialog was not shown, it is our responsibility to close it. + wizard.getContainer().getShell().close(); + return DialogResult.SKIPPED; + } } finally { processor.unlockIndex(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java index 6c32f9ece07..ff05f281ea7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/rename/TextSearchWrapper.java @@ -313,7 +313,8 @@ public class TextSearchWrapper { } final static Comparator COMPARE_FIRST_INTEGER= new Comparator() { - public int compare(int[] o1, int[] o2) { + @Override + public int compare(int[] o1, int[] o2) { return (o1)[0] - (o2)[0]; } }; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java index 36d091d4cde..0e8480badae 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFileCreator.java @@ -6,8 +6,8 @@ * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * - * Contributors: - * Martin Schwab & Thomas Kallenberg - initial API and implementation + * Contributors: + * Martin Schwab & Thomas Kallenberg - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.togglefunction; @@ -29,7 +29,6 @@ import org.eclipse.cdt.internal.ui.refactoring.Container; import org.eclipse.cdt.internal.ui.refactoring.CreateFileChange; public class ToggleFileCreator { - private static final String EMPTY_STRING = ""; //$NON-NLS-1$ private static final String H = ".h"; //$NON-NLS-1$ private ToggleRefactoringContext context; @@ -71,7 +70,7 @@ public class ToggleFileCreator { CreateFileChange change; String filename = getNewFileName(); try { - change = new CreateFileChange(filename, new Path(getPath()+filename), + change = new CreateFileChange(filename, new Path(getPath() + filename), EMPTY_STRING, context.getSelectionFile().getCharset()); change.perform(new NullProgressMonitor()); } catch (CoreException e) { @@ -85,6 +84,7 @@ public class ToggleFileCreator { } final Container answer = new Container(); Runnable r = new Runnable() { + @Override public void run() { Shell shell = CUIPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell(); String functionname; @@ -103,7 +103,7 @@ public class ToggleFileCreator { } public String getIncludeStatement() { - return "#include \"" + ToggleNodeHelper.getFilenameWithoutExtension(getNewFileName()) + ".h\""; //$NON-NLS-1$//$NON-NLS-2$ + return "#include \"" + ToggleNodeHelper.getFilenameWithoutExtension(getNewFileName()) + ".h\"\n"; //$NON-NLS-1$//$NON-NLS-2$ } private String getNewFileName() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java index 36eba0e5d17..701396beaaa 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/togglefunction/ToggleFromInHeaderToImplementationStrategy.java @@ -7,7 +7,7 @@ * http://www.eclipse.org/legal/epl-v10.html * * Contributors: - * Martin Schwab & Thomas Kallenberg - initial API and implementation + * Martin Schwab & Thomas Kallenberg - initial API and implementation ******************************************************************************/ package org.eclipse.cdt.internal.ui.refactoring.togglefunction; @@ -57,7 +57,6 @@ import org.eclipse.cdt.internal.ui.refactoring.Container; import org.eclipse.cdt.internal.ui.refactoring.ModificationCollector; public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefactoringStrategy { - private IASTTranslationUnit impl_unit; private ToggleRefactoringContext context; private TextEditGroup infoText; @@ -68,16 +67,16 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact this.context = context; } + @Override public void run(ModificationCollector collector) { - if(!newFileCheck()) { + if (!newFileCheck()) { return; } // newFileCheck(); ICPPASTFunctionDefinition newDefinition = getNewDefinition(); if (context.getDeclaration() != null) { removeDefinitionFromHeader(collector); - } - else { + } else { replaceDefinitionWithDeclaration(collector); } @@ -97,8 +96,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact implRewrite = implRewrite.insertBefore(impl_unit.getTranslationUnit(), null, insertionParent, infoText); } - } - else { + } else { insertionParent = impl_unit.getTranslationUnit(); } @@ -115,25 +113,6 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact private void copyCommentsToNewFile(ICPPASTFunctionDefinition newDefinition, final ASTRewrite newRewriter, final ASTRewrite oldRewriter) { newDefinition.accept(new ASTVisitor(true) { - - private void copy(IASTNode node) { - copyComments(node, newRewriter, oldRewriter, CommentPosition.leading); - copyComments(node, newRewriter, oldRewriter, CommentPosition.trailing); - copyComments(node, newRewriter, oldRewriter, CommentPosition.freestanding); - } - - private void copyComments(IASTNode node, ASTRewrite newRewriter, ASTRewrite oldRewriter, - CommentPosition pos) { - if (node.getNodeLocations().length > 0 && node.getNodeLocations()[0] instanceof IASTCopyLocation) { - IASTCopyLocation copyLoc = (IASTCopyLocation) node.getNodeLocations()[0]; - List comments = oldRewriter.getComments(copyLoc.getOriginalNode(), pos); - for (IASTComment comment : comments) { - newRewriter.addComment(node, comment, pos); - } - } - - } - @Override public int visit(IASTName name) { copy(name); @@ -241,20 +220,36 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact copy(designator); return super.visit(designator); } + + private void copy(IASTNode node) { + copyComments(node, newRewriter, oldRewriter, CommentPosition.leading); + copyComments(node, newRewriter, oldRewriter, CommentPosition.trailing); + copyComments(node, newRewriter, oldRewriter, CommentPosition.freestanding); + } + + private void copyComments(IASTNode node, ASTRewrite newRewriter, ASTRewrite oldRewriter, + CommentPosition pos) { + if (node.getNodeLocations().length > 0 && node.getNodeLocations()[0] instanceof IASTCopyLocation) { + IASTCopyLocation copyLoc = (IASTCopyLocation) node.getNodeLocations()[0]; + List comments = oldRewriter.getComments(copyLoc.getOriginalNode(), pos); + for (IASTComment comment : comments) { + newRewriter.addComment(node, comment, pos); + } + } + } }); - } private boolean newFileCheck() { impl_unit = context.getTUForSiblingFile(); - if (this.impl_unit == null) { + if (impl_unit == null) { ToggleFileCreator filecreator = new ToggleFileCreator(context, ".cpp"); //$NON-NLS-1$ if (filecreator.askUserForFileCreation(context)) { filecreator.createNewFile(); impl_unit = filecreator.loadTranslationUnit(); includenode = new ASTLiteralNode(filecreator.getIncludeStatement()); return true; - }else { + } else { return false; } } @@ -269,8 +264,7 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact return ToggleNodeHelper.getAncestorOfType(toquery, ICPPASTNamespaceDefinition.class); } - private IASTNode findInsertionPoint(IASTNode insertionParent, - IASTTranslationUnit unit) { + private IASTNode findInsertionPoint(IASTNode insertionParent, IASTTranslationUnit unit) { IASTFunctionDeclarator declarator = context.getDeclaration(); if (unit == null) { unit = context.getDefinitionUnit(); @@ -283,34 +277,33 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact return insertion_point; } - private void restoreLeadingComments( - ICPPASTFunctionDefinition newDefinition, ASTRewrite newRewriter, ModificationCollector collector) { + private void restoreLeadingComments(ICPPASTFunctionDefinition newDefinition, + ASTRewrite newRewriter, ModificationCollector collector) { ASTRewrite rw = collector.rewriterForTranslationUnit(context.getDefinitionUnit()); Listcomments = rw.getComments(context.getDefinition(), CommentPosition.leading); - if(comments != null) { + if (comments != null) { for (IASTComment comment : comments) { newRewriter.addComment(newDefinition, comment, CommentPosition.leading); - if(context.getDeclaration() != null) { + if (context.getDeclaration() != null) { rw.remove(comment, infoText); } } } } - private void replaceDefinitionWithDeclaration( - ModificationCollector collector) { - IASTSimpleDeclaration newdeclarator = - ToggleNodeHelper.createDeclarationFromDefinition(context.getDefinition()); + private void replaceDefinitionWithDeclaration(ModificationCollector collector) { + IASTSimpleDeclaration newdeclarator = + ToggleNodeHelper.createDeclarationFromDefinition(context.getDefinition()); ASTRewrite rewrite = collector.rewriterForTranslationUnit(context.getDefinitionUnit()); rewrite.replace(context.getDefinition(), newdeclarator, infoText); } private ICPPASTFunctionDefinition getNewDefinition() { ICPPASTFunctionDefinition newDefinition = - ToggleNodeHelper.createFunctionSignatureWithEmptyBody( - context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations), context - .getDefinition().getDeclarator().copy(CopyStyle.withLocations), context - .getDefinition().copy(CopyStyle.withLocations)); + ToggleNodeHelper.createFunctionSignatureWithEmptyBody( + context.getDefinition().getDeclSpecifier().copy(CopyStyle.withLocations), + context.getDefinition().getDeclarator().copy(CopyStyle.withLocations), + context.getDefinition().copy(CopyStyle.withLocations)); newDefinition.getDeclSpecifier().setInline(false); newDefinition.setBody(context.getDefinition().getBody().copy(CopyStyle.withLocations)); if (newDefinition instanceof ICPPASTFunctionWithTryBlock) { @@ -328,8 +321,8 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact if (parent instanceof ICPPASTNamespaceDefinition) { ICPPASTNamespaceDefinition ns = (ICPPASTNamespaceDefinition) parent; if (new_definition.getDeclarator().getName() instanceof ICPPASTQualifiedName) { - ICPPASTQualifiedName qname = - (ICPPASTQualifiedName) new_definition.getDeclarator().getName(); + ICPPASTQualifiedName qname = + (ICPPASTQualifiedName) new_definition.getDeclarator().getName(); ICPPASTQualifiedName qname_new = new CPPASTQualifiedName(); boolean start = false; for(IASTName partname: qname.getNames()) { @@ -346,11 +339,9 @@ public class ToggleFromInHeaderToImplementationStrategy implements IToggleRefact } } - private CPPASTNamespaceDefinition createNamespace( - ICPPASTNamespaceDefinition parent_namespace) { + private CPPASTNamespaceDefinition createNamespace(ICPPASTNamespaceDefinition parent_namespace) { CPPASTNamespaceDefinition insertionParent = new CPPASTNamespaceDefinition( -parent_namespace.getName() - .copy(CopyStyle.withLocations)); + parent_namespace.getName().copy(CopyStyle.withLocations)); insertionParent.setParent(impl_unit); return insertionParent; } @@ -363,19 +354,19 @@ parent_namespace.getName() private IASTNode searchNamespaceInImplementation(final IASTName name) { final Container result = new Container(); - this.impl_unit.accept( -new ASTVisitor() { - { - shouldVisitNamespaces = true; - } - @Override - public int visit(ICPPASTNamespaceDefinition namespaceDefinition) { - if (name.toString().equals(namespaceDefinition.getName().toString())) { - result.setObject(namespaceDefinition); - return PROCESS_ABORT; - } - return super.visit(namespaceDefinition); - } + this.impl_unit.accept(new ASTVisitor() { + { + shouldVisitNamespaces = true; + } + + @Override + public int visit(ICPPASTNamespaceDefinition namespaceDefinition) { + if (name.toString().equals(namespaceDefinition.getName().toString())) { + result.setObject(namespaceDefinition); + return PROCESS_ABORT; + } + return super.visit(namespaceDefinition); + } }); return result.getObject(); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java index 8f6a5510801..9f7b0c141f8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractCompareViewerInformationControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. 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 @@ -44,6 +44,8 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl; + /** * Abstract class for "quick" compare views in light-weight controls. * @@ -75,7 +77,7 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips private ICompareInput fCompareInput; private Color fBackgroundColor; - private boolean fIsSystemBackgroundColor; + private boolean fIsSystemBackgroundColor = true; private Label fTitleLabel; @@ -106,7 +108,13 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips } private void initializeColors() { - RGB bgRGB= getHoverBackgroundColorRGB(); + IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); + RGB bgRGB; + if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) { + bgRGB= SourceViewerInformationControl.getVisibleBackgroundColor(getShell().getDisplay()); + } else { + bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); + } if (bgRGB != null) { fBackgroundColor= new Color(getShell().getDisplay(), bgRGB); fIsSystemBackgroundColor= false; @@ -116,13 +124,6 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips } } - private RGB getHoverBackgroundColorRGB() { - IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT) - ? null - : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); - } - @Override protected void createContent(Composite parent) { initializeColors(); @@ -207,6 +208,10 @@ public abstract class AbstractCompareViewerInformationControl extends org.eclips return false; } + protected Color getBackgroundColor() { + return fBackgroundColor; + } + @Override public void setInformation(String content) { } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java index 5a379c0bddf..6004d9889e1 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/AbstractSourceViewerInformationControl.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2011 Wind River Systems, Inc. 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 @@ -41,6 +41,7 @@ import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; +import org.eclipse.cdt.internal.ui.text.c.hover.SourceViewerInformationControl; /** * Abstract class for "quick" source views in light-weight controls. @@ -50,15 +51,10 @@ import org.eclipse.cdt.internal.ui.editor.CSourceViewer; public abstract class AbstractSourceViewerInformationControl extends org.eclipse.jface.text.AbstractInformationControl implements IInformationControlExtension2, DisposeListener { private ISourceViewer fSourceViewer; - private Color fBackgroundColor; - - private boolean fIsSystemBackgroundColor; - + private boolean fIsSystemBackgroundColor = true; private Font fTextFont; - private StyledText fText; - private Label fTitleLabel; /** @@ -95,7 +91,13 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse } private void initializeColors() { - RGB bgRGB= getHoverBackgroundColorRGB(); + IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); + RGB bgRGB; + if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) { + bgRGB= SourceViewerInformationControl.getVisibleBackgroundColor(getShell().getDisplay()); + } else { + bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); + } if (bgRGB != null) { fBackgroundColor= new Color(getShell().getDisplay(), bgRGB); fIsSystemBackgroundColor= false; @@ -105,13 +107,6 @@ public abstract class AbstractSourceViewerInformationControl extends org.eclipse } } - private RGB getHoverBackgroundColorRGB() { - IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT) - ? null - : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); - } - @Override public void createContent(Composite parent) { Composite content= new Composite(parent, SWT.NONE); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java index 608cd2e30b4..0eb4ff3ebe7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/CMacroExpansionExplorationControl.java @@ -262,8 +262,7 @@ public class CMacroExpansionExplorationControl extends AbstractCompareViewerInfo GridData gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH); gd.heightHint= fMacroText.getLineHeight() * 2; fMacroText.setLayoutData(gd); - fMacroText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND)); - + final Document doc= new Document(); CUIPlugin.getDefault().getTextTools().setupCDocument(doc); sourceViewer.setDocument(doc); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java index 23d155cd8fd..b1ef9f28f54 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/c/hover/SourceViewerInformationControl.java @@ -1,13 +1,13 @@ /******************************************************************************* - * Copyright (c) 2002, 2008 QNX Software Systems and others. + * Copyright (c) 2002, 2011 QNX Software Systems 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: - * QNX Software Systems - Initial API and implementation - * Anton Leherbauer (Wind River Systems) + * QNX Software Systems - Initial API and implementation + * Anton Leherbauer (Wind River Systems) *******************************************************************************/ package org.eclipse.cdt.internal.ui.text.c.hover; @@ -46,9 +46,12 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; +import org.eclipse.ui.texteditor.AbstractTextEditor; +import org.eclipse.cdt.ui.CDTUITools; import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; +import org.eclipse.cdt.ui.text.ICColorConstants; import org.eclipse.cdt.ui.text.ICPartitions; import org.eclipse.cdt.internal.ui.editor.CSourceViewer; @@ -88,6 +91,10 @@ public class SourceViewerInformationControl implements IInformationControl, IInf * @since 3.0 */ private Font fStatusTextFont; + /** + * The color of the optional status text label or null if none. + */ + private Color fStatusTextForegroundColor; /** * The width size constraint. * @since 4.0 @@ -198,16 +205,49 @@ public class SourceViewerInformationControl implements IInformationControl, IInf GridData gd2= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING); fStatusField.setLayoutData(gd2); - // Regarding the color see bug 41128 - fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW)); + RGB defaultColor= CDTUITools.getColorManager().getColor(ICColorConstants.C_DEFAULT).getRGB(); + fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(fBackgroundColor.getRGB(), defaultColor, 0.56f)); + fStatusField.setForeground(fStatusTextForegroundColor); fStatusField.setBackground(fBackgroundColor); } addDisposeListener(this); } + /** + * Returns an RGB that lies between the given foreground and background + * colors using the given mixing factor. A factor of 1.0 will produce a + * color equal to fg, while a factor of 0.0 will produce one + * equal to bg. + * @param bg the background color + * @param fg the foreground color + * @param factor the mixing factor, must be in [0, 1] + * + * @return the interpolated color + */ + @SuppressWarnings("null") + private static RGB blend(RGB bg, RGB fg, float factor) { + // copy of org.eclipse.jface.internal.text.revisions.Colors#blend(..) + Assert.isLegal(bg != null); + Assert.isLegal(fg != null); + Assert.isLegal(factor >= 0f && factor <= 1f); + + float complement= 1f - factor; + return new RGB( + (int) (complement * bg.red + factor * fg.red), + (int) (complement * bg.green + factor * fg.green), + (int) (complement * bg.blue + factor * fg.blue) + ); + } + private void initializeColors() { - RGB bgRGB= getHoverBackgroundColorRGB(); + IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); + RGB bgRGB; + if (store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT)) { + bgRGB= getVisibleBackgroundColor(fShell.getDisplay()); + } else { + bgRGB= PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); + } if (bgRGB != null) { fBackgroundColor= new Color(fShell.getDisplay(), bgRGB); fIsSystemBackgroundColor= false; @@ -217,11 +257,29 @@ public class SourceViewerInformationControl implements IInformationControl, IInf } } - private RGB getHoverBackgroundColorRGB() { - IPreferenceStore store= CUIPlugin.getDefault().getPreferenceStore(); - return store.getBoolean(PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT) - ? null - : PreferenceConverter.getColor(store, PreferenceConstants.EDITOR_SOURCE_HOVER_BACKGROUND_COLOR); + /** + * Returns null if {@link SWT#COLOR_INFO_BACKGROUND} is visibly distinct from the + * default source text color. Otherwise, returns the editor background color. + * + * @param display the display + * @return an RGB or null + */ + public static RGB getVisibleBackgroundColor(Display display) { + float[] infoBgHSB= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND).getRGB().getHSB(); + + Color defaultColor= CDTUITools.getColorManager().getColor(ICColorConstants.C_DEFAULT); + RGB defaultRGB= defaultColor != null ? defaultColor.getRGB() : new RGB(255, 255, 255); + float[] defaultHSB= defaultRGB.getHSB(); + + if (Math.abs(infoBgHSB[2] - defaultHSB[2]) < 0.5f) { + // workaround for dark tooltip background color, see https://bugs.eclipse.org/365051 + IPreferenceStore preferenceStore= CUIPlugin.getDefault().getCombinedPreferenceStore(); + boolean useDefault= preferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT); + if (useDefault) + return display.getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB(); + return PreferenceConverter.getColor(preferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); + } + return null; } /** @@ -274,6 +332,10 @@ public class SourceViewerInformationControl implements IInformationControl, IInf if (fStatusTextFont != null && !fStatusTextFont.isDisposed()) fStatusTextFont.dispose(); + if (fStatusTextForegroundColor != null && !fStatusTextForegroundColor.isDisposed()) + fStatusTextForegroundColor.dispose(); + + fStatusTextForegroundColor= null; fStatusTextFont= null; fTextFont= null; fShell= null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java index f8e2cdc9137..3915d9cbc8f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPlugin.java @@ -48,6 +48,8 @@ import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.source.ISharedTextColors; import org.eclipse.jface.text.templates.ContextTypeRegistry; import org.eclipse.jface.text.templates.persistence.TemplateStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; @@ -56,6 +58,7 @@ import org.eclipse.ui.IEditorReference; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.PlatformUI; import org.eclipse.ui.editors.text.EditorsUI; import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry; import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; @@ -64,6 +67,7 @@ import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.preferences.ScopedPreferenceStore; import org.eclipse.ui.texteditor.ChainedPreferenceStore; import org.eclipse.ui.texteditor.ConfigurationElementSorter; +import org.eclipse.ui.themes.IThemeManager; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; @@ -118,11 +122,11 @@ public class CUIPlugin extends AbstractUIPlugin { public static final String C_PROBLEMMARKER = PLUGIN_CORE_ID + ".problem"; //$NON-NLS-1$ public static final String ID_COMMENT_OWNER= PLUGIN_ID+".DocCommentOwner"; //$NON-NLS-1$ - + public static final String ID_INCLUDE_BROWSER= PLUGIN_ID + ".includeBrowser"; //$NON-NLS-1$ public static final String ID_CALL_HIERARCHY= PLUGIN_ID + ".callHierarchy"; //$NON-NLS-1$ public static final String ID_TYPE_HIERARCHY = PLUGIN_ID + ".typeHierarchy"; //$NON-NLS-1$ - + public static final String C_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCWizard"; //$NON-NLS-1$ public static final String CPP_PROJECT_WIZARD_ID = PLUGIN_ID + ".wizards.StdCCWizard"; //$NON-NLS-1$ @@ -130,7 +134,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** @deprecated This wizard category has been merged with the {@link #CWIZARD_CATEGORY_ID c wizard category} */ @Deprecated public final static String CCWIZARD_CATEGORY_ID = "org.eclipse.cdt.ui.newCCWizards"; //$NON-NLS-1$ - + public static final String SEARCH_ACTION_SET_ID = PLUGIN_ID + ".SearchActionSet"; //$NON-NLS-1$ public static final String BUILDER_ID = PLUGIN_CORE_ID + ".cbuilder"; //$NON-NLS-1$ @@ -142,22 +146,22 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The id of the C perspective * (value "org.eclipse.cdt.ui.CPerspective"). - */ + */ public static final String ID_CPERSPECTIVE = PLUGIN_ID + ".CPerspective"; //$NON-NLS-1$ /** * The id of the C hierarchy perspective * (value "org.eclipse.cdt.ui.CHierarchyPerspective"). - * + * * @deprecated This perspective no longer exists. - */ + */ @Deprecated public static final String ID_CHIERARCHY_PERSPECTIVE = PLUGIN_ID + ".CHierarchyPerspective"; //$NON-NLS-1$ /** * The id of the C Browsing Perspective * (value "org.eclipse.cdt.ui.CBrowsingPerspective"). - * + * * @since 2.0 * @deprecated This perspective no longer exists. */ @@ -167,7 +171,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Projects view * (value "org.eclipse.cdt.ui.ProjectsView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -178,7 +182,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Namespaces view * (value "org.eclipse.cdt.ui.NamespacesView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -189,7 +193,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Types view * (value "org.eclipse.cdt.ui.TypesView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -200,7 +204,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The view part id of the C Browsing Members view * (value "org.eclipse.cdt.ui.MembersView"). - * + * * @since 2.0 * @deprecated This view no longer exists. * @noreference This field is not intended to be referenced by clients. @@ -209,7 +213,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static String ID_MEMBERS_VIEW = PLUGIN_ID + ".MembersView"; //$NON-NLS-1$ /** - * The key to store customized templates. + * The key to store customized templates. * @since 3.0 */ private static final String CUSTOM_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.templates.custom"; //$NON-NLS-1$ @@ -217,20 +221,20 @@ public class CUIPlugin extends AbstractUIPlugin { /** * The id of the C Element Creation action set * (value "org.eclipse.cdt.ui.CElementCreationActionSet"). - * + * * @since 2.0 */ public static final String ID_CELEMENT_CREATION_ACTION_SET= "org.eclipse.cdt.ui.CElementCreationActionSet"; //$NON-NLS-1$ - + /** * The id of the scope used by all the CDT views * (value "org.eclipse.cdt.ui.scope"). * @since 4.0 */ public static final String CVIEWS_SCOPE = "org.eclipse.cdt.ui.cViewScope"; //$NON-NLS-1$ - + /** - * The key to store customized code templates. + * The key to store customized code templates. * @since 5.0 */ private static final String CODE_TEMPLATES_KEY= "org.eclipse.cdt.ui.text.custom_code_templates"; //$NON-NLS-1$ @@ -253,11 +257,11 @@ public class CUIPlugin extends AbstractUIPlugin { public synchronized IBufferFactory getBufferFactory() { return ((WorkingCopyManager) getWorkingCopyManager()).getBufferFactory(); } - + public static IWorkingCopy[] getSharedWorkingCopies() { return getDefault().getWorkingCopyManager().getSharedWorkingCopies(); } - + public static String getResourceString(String key) { try { return fgResourceBundle.getString(key); @@ -271,7 +275,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } - + public static String getFormattedString(String key, String arg) { return MessageFormat.format(getResourceString(key), new Object[] {arg}); } @@ -283,7 +287,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static ResourceBundle getResourceBundle() { return fgResourceBundle; } - + public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } @@ -319,7 +323,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static void log(IStatus status) { getDefault().getLog().log(status); } - + /** * @noreference This method is not intended to be referenced by clients. */ @@ -342,7 +346,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static void errorDialog(Shell shell, String title, String message, IStatus s, boolean logError) { if (logError) log(s); - + // if the 'message' resource string and the IStatus' message are the same, // don't show both in the dialog if (s != null && message.equals(s.getMessage())) { @@ -358,7 +362,7 @@ public class CUIPlugin extends AbstractUIPlugin { public static void errorDialog(Shell shell, String title, String message, Throwable t, boolean logError) { if (logError) log(message, t); - + IStatus status; if (t instanceof CoreException) { status = ((CoreException) t).getStatus(); @@ -368,7 +372,7 @@ public class CUIPlugin extends AbstractUIPlugin { message = null; } } else { - status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "Internal Error: ", t); //$NON-NLS-1$ + status = new Status(IStatus.ERROR, CUIPlugin.PLUGIN_ID, -1, "Internal Error: ", t); //$NON-NLS-1$ } ErrorDialog.openError(shell, title, message, status); } @@ -405,14 +409,14 @@ public class CUIPlugin extends AbstractUIPlugin { private ResourceAdapterFactory fResourceAdapterFactory; private CElementAdapterFactory fCElementAdapterFactory; - /** - * The template context type registry for the C editor. + /** + * The template context type registry for the C editor. * @since 3.0 */ private ContributionContextTypeRegistry fContextTypeRegistry; /** - * The template store for the C editor. + * The template store for the C editor. * @since 3.0 */ private TemplateStore fTemplateStore; @@ -423,28 +427,34 @@ public class CUIPlugin extends AbstractUIPlugin { */ private ASTProvider fASTProvider; - /** - * The code template context type registry for the C editor. + /** + * The code template context type registry for the C editor. * @since 5.0 */ private ContextTypeRegistry fCodeTemplateContextTypeRegistry; - + /** - * The code template store for the C editor. + * The code template store for the C editor. * @since 5.0 */ private TemplateStore fCodeTemplateStore; + /** + * Theme listener. + * @since 5.4 + */ + private IPropertyChangeListener fThemeListener; + public CUIPlugin() { fgCPlugin = this; fDocumentProvider = null; - fTextTools = null; + fTextTools = null; fBuildConsoleManagers = new HashMap(); } - + /** * Returns the used document provider. - * + * * @noreference This method is not intended to be referenced by clients. */ public synchronized CDocumentProvider getDocumentProvider() { @@ -453,7 +463,7 @@ public class CUIPlugin extends AbstractUIPlugin { } return fDocumentProvider; } - + /** * Returns the working copy manager * @return IWorkingCopyManager @@ -487,11 +497,11 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Obtain a console manager with the given id. If a manager has not been created yet, * it is created and its console created and activated. - * + * * @param name - console name. * @param contextId - console id matching context id in the Console view dropdown. * @return console manager. - * + * * Note that this method is rather internal and should not be referenced by clients. * To create a build console, use {@link CCorePlugin#getBuildConsole(String, String, URL)} */ @@ -502,7 +512,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Obtain a console manager with the given id. If a manager has not been created yet, * it is created and its console created and activated with the given attributes. - * + * * @param name - console name. * @param contextId - console id matching context id in the Console view dropdown. * Can't be {@code null}. @@ -510,7 +520,7 @@ public class CUIPlugin extends AbstractUIPlugin { * view. The url is expected to point to an image in eclipse OSGi bundle. * {@code iconUrl} can be null, in that case the default image is used. * @return console manager. - * + * * @noreference This method is not intended to be referenced by clients. */ public IBuildConsoleManager getConsoleManager(String name, String contextId, URL iconUrl) { @@ -531,6 +541,7 @@ public class CUIPlugin extends AbstractUIPlugin { public void startGlobalConsole() { GlobalBuildConsoleManager.startGlobalConsole(); } + /* * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) */ @@ -540,22 +551,34 @@ public class CUIPlugin extends AbstractUIPlugin { //Set debug tracing options configurePluginDebugOptions(); - + registerAdapters(); IWorkingCopyProvider workingCopyProvider = new IWorkingCopyProvider() { + @Override public IWorkingCopy[] getWorkingCopies() { return CUIPlugin.getSharedWorkingCopies(); } }; CCorePlugin.getDefault().getDOM().setWorkingCopyProvider(workingCopyProvider); - - // init ast provider - getASTProvider(); + + if (PlatformUI.isWorkbenchRunning()) { + // Initialize AST provider + getASTProvider(); + + fThemeListener= new IPropertyChangeListener() { + @Override + public void propertyChange(PropertyChangeEvent event) { + if (IThemeManager.CHANGE_CURRENT_THEME.equals(event.getProperty())) + CUIPreferenceInitializer.setThemeBasedPreferences(PreferenceConstants.getPreferenceStore(), true); + } + }; + PlatformUI.getWorkbench().getThemeManager().addPropertyChangeListener(fThemeListener); + } CDTContextActivator.getInstance().install(); - + DocCommentOwnerManager.getInstance().addListener(new EditorReopener()); ASTRewriteAnalyzer.setCTextFileChangeFactory(new CTextFileChangeFactory()); - + // A workaround for black console bug 320723. BuildConsolePreferencePage.initDefaults(getPreferenceStore()); //initialize ContentAssistMatcherPreference @@ -612,7 +635,7 @@ public class CUIPlugin extends AbstractUIPlugin { } fBuildConsoleManagers.clear(); } - + GlobalBuildConsoleManager.stop(); unregisterAdapters(); @@ -621,14 +644,19 @@ public class CUIPlugin extends AbstractUIPlugin { fWorkingCopyManager.shutdown(); fWorkingCopyManager= null; } - + if (fDocumentProvider != null) { fDocumentProvider.shutdown(); fDocumentProvider= null; } - + ContentAssistPreference.shutdown(); + if (fThemeListener != null) { + PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(fThemeListener); + fThemeListener= null; + } + // Do this last. super.stop(context); } @@ -656,7 +684,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the problem marker manager. - * + * * @noreference This method is not intended to be referenced by clients. */ public ProblemMarkerManager getProblemMarkerManager() { @@ -673,14 +701,14 @@ public class CUIPlugin extends AbstractUIPlugin { manager.registerAdapters(fResourceAdapterFactory, IResource.class); manager.registerAdapters(fCElementAdapterFactory, ICElement.class); } - + private void unregisterAdapters() { IAdapterManager manager = Platform.getAdapterManager(); manager.unregisterAdapters(fResourceAdapterFactory); manager.unregisterAdapters(fCElementAdapterFactory); } - /** + /** * @deprecated Use {@link EditorsUI#getSharedTextColors()} instead. * @noreference This method is not intended to be referenced by clients. */ @@ -688,7 +716,7 @@ public class CUIPlugin extends AbstractUIPlugin { public ISharedTextColors getSharedTextColors() { return EditorsUI.getSharedTextColors(); } - + public void configurePluginDebugOptions() { if (isDebugging()) { String option = Platform.getDebugOption(CONTENTASSIST); @@ -699,17 +727,17 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns a combined preference store, this store is read-only. - * + * * @return the combined preference store - * + * * @since 3.0 */ public IPreferenceStore getCombinedPreferenceStore() { if (fCombinedPreferenceStore == null) { - fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { - getPreferenceStore(), - getCorePreferenceStore(), - EditorsUI.getPreferenceStore() + fCombinedPreferenceStore= new ChainedPreferenceStore(new IPreferenceStore[] { + getPreferenceStore(), + getCorePreferenceStore(), + EditorsUI.getPreferenceStore() }); } return fCombinedPreferenceStore; @@ -744,11 +772,11 @@ public class CUIPlugin extends AbstractUIPlugin { } /** - * Returns an array of all editors that have an unsaved content. If the identical content is + * Returns an array of all editors that have an unsaved content. If the identical content is * presented in more than one editor, only one of those editor parts is part of the result. - * + * * @return an array of all dirty editor parts. - */ + */ public static IEditorPart[] getDirtyEditors() { Set inputs= new HashSet(); List result= new ArrayList(0); @@ -770,7 +798,7 @@ public class CUIPlugin extends AbstractUIPlugin { return result.toArray(new IEditorPart[result.size()]); } /** - * Returns an array of all instanciated editors. + * Returns an array of all instanciated editors. */ public static IEditorPart[] getInstanciatedEditors() { List result= new ArrayList(0); @@ -800,8 +828,8 @@ public class CUIPlugin extends AbstractUIPlugin { if (display == null) { display= Display.getDefault(); } - return display; - } + return display; + } /** * Creates the CUIplugin standard groups in a context menu. @@ -826,9 +854,9 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns all C editor text hovers contributed to the workbench. - * + * * @return an array of CEditorTextHoverDescriptor - * + * * @noreference This method is not intended to be referenced by clients. */ public CEditorTextHoverDescriptor[] getCEditorTextHoverDescriptors() { @@ -844,7 +872,7 @@ public class CUIPlugin extends AbstractUIPlugin { } }; sorter.sort(fCEditorTextHoverDescriptors); - + // The Problem hover has to be the first and the Annotation hover has to be the last one in the CDT UI's hover list int length= fCEditorTextHoverDescriptors.length; int first= -1; @@ -861,7 +889,7 @@ public class CUIPlugin extends AbstractUIPlugin { } if (first == -1) first= i; - + if (fCEditorTextHoverDescriptors[i].getId().equals("org.eclipse.cdt.ui.AnnotationHover")) { //$NON-NLS-1$ annotationHoverIndex= i; continue; @@ -871,9 +899,9 @@ public class CUIPlugin extends AbstractUIPlugin { continue; } } - + CEditorTextHoverDescriptor hoverDescriptor= null; - + if (first > -1 && problemHoverIndex > -1 && problemHoverIndex > first) { // move problem hover to beginning hoverDescriptor= fCEditorTextHoverDescriptors[problemHoverIndex]; @@ -884,7 +912,7 @@ public class CUIPlugin extends AbstractUIPlugin { if (annotationHoverIndex >= first && annotationHoverIndex < problemHoverIndex) annotationHoverIndex++; } - + if (annotationHoverIndex > -1 && annotationHoverIndex < last) { // move annotation hover to end hoverDescriptor= fCEditorTextHoverDescriptors[annotationHoverIndex]; @@ -903,11 +931,11 @@ public class CUIPlugin extends AbstractUIPlugin { } break; } - + } } return fCEditorTextHoverDescriptors; - } + } /** * Resets the C editor text hovers contributed to the workbench. @@ -915,7 +943,7 @@ public class CUIPlugin extends AbstractUIPlugin { * This will force a rebuild of the descriptors the next time * a client asks for them. *

- * + * */ public void resetCEditorTextHoverDescriptors() { fCEditorTextHoverDescriptors= null; @@ -924,9 +952,9 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the registry of the extensions to the org.eclipse.cdt.ui.foldingStructureProviders * extension point. - * + * * @return the registry of contributed ICFoldingStructureProvider - * + * * @noreference This method is not intended to be referenced by clients. * @since 3.0 */ @@ -938,7 +966,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the template context type registry for the C plugin. - * + * * @return the template context type registry for the C plugin * @since 3.0 */ @@ -954,7 +982,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the template store for the C editor templates. - * + * * @return the template store for the C editor templates * @since 3.0 */ @@ -973,7 +1001,7 @@ public class CUIPlugin extends AbstractUIPlugin { /** * Returns the template context type registry for the code generation * templates. - * + * * @return the template context type registry for the code generation * templates * @since 5.0 @@ -981,17 +1009,17 @@ public class CUIPlugin extends AbstractUIPlugin { public ContextTypeRegistry getCodeTemplateContextRegistry() { if (fCodeTemplateContextTypeRegistry == null) { fCodeTemplateContextTypeRegistry= new ContributionContextTypeRegistry("org.eclipse.cdt.ui.codeTemplates"); //$NON-NLS-1$ - + CodeTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry); FileTemplateContextType.registerContextTypes(fCodeTemplateContextTypeRegistry); } return fCodeTemplateContextTypeRegistry; } - + /** * Returns the template store for the code generation templates. - * + * * @return the template store for the code generation templates * @since 5.0 */ @@ -1005,30 +1033,30 @@ public class CUIPlugin extends AbstractUIPlugin { } catch (IOException e) { log(e); } - + fCodeTemplateStore.startListeningForPreferenceChanges(); } - + return fCodeTemplateStore; } - + /** * Returns the AST provider. - * + * * @return the AST provider - * + * * @noreference This method is not intended to be referenced by clients. * @since 4.0 */ public synchronized ASTProvider getASTProvider() { if (fASTProvider == null) fASTProvider= new ASTProvider(); - + return fASTProvider; } - + /** - * Answers the Shell associated with the active workbench, or + * Answers the Shell associated with the active workbench, or * one of the windows associated with the workbench. */ public Shell getShell() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java index 60d6458e5d8..4188e1b9407 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/CUIPreferenceInitializer.java @@ -1,15 +1,26 @@ /******************************************************************************* - * Copyright (c) 2003, 2009 IBM Corporation and others. + * Copyright (c) 2003, 2011 IBM Corporation 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: * QNX Software Systems - Initial implementation *******************************************************************************/ package org.eclipse.cdt.ui; +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.resource.ColorRegistry; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.editors.text.EditorsUI; +import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; +import org.eclipse.ui.texteditor.AbstractTextEditor; + +import org.eclipse.cdt.internal.ui.ICThemeConstants; import org.eclipse.cdt.internal.ui.cview.CView; import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; import org.eclipse.cdt.internal.ui.preferences.BuildConsolePreferencePage; @@ -18,19 +29,13 @@ import org.eclipse.cdt.internal.ui.preferences.CPluginPreferencePage; import org.eclipse.cdt.internal.ui.preferences.CodeAssistPreferencePage; import org.eclipse.cdt.internal.ui.preferences.WorkInProgressPreferencePage; -import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.editors.text.EditorsUI; -import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; -import org.eclipse.ui.texteditor.AbstractTextEditor; - /** * This class implements the setting of the CUI initial preference store settings. - * + * * @noextend This class is not intended to be subclassed by clients. */ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { - + /* (non-Javadoc) * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ @@ -46,7 +51,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { CodeAssistPreferencePage.initDefaults(store); SemanticHighlightings.initDefaults(store); WorkInProgressPreferencePage.initDefaults(store); - + // We need to do this remove any keys that might have been // in the CUIPlugin store prior to the move of the CEditor setting // All of those settings are now in the workbench "All TextEditor" preference Page. @@ -63,7 +68,7 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR); - store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); + store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER); @@ -72,10 +77,10 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN); - + store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET); - + store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR); @@ -88,4 +93,145 @@ public class CUIPreferenceInitializer extends AbstractPreferenceInitializer { store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE); store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SMART_HOME_END); } + + static void setThemeBasedPreferences(IPreferenceStore store, boolean fireEvent) { + ColorRegistry registry= null; + if (PlatformUI.isWorkbenchRunning()) + registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); + + setDefault( + store, + PreferenceConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_TASK_TAG_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_KEYWORD_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_BUILTIN_TYPE_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_STRING_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_STRING_COLOR, new RGB(42, 0, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_DEFAULT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_OPERATOR_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_BRACES_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_C_NUMBER_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_PP_DIRECTIVE_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_PP_DIRECTIVE_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_PP_HEADER_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_PP_HEADER_COLOR, new RGB(42, 0, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_PP_DEFAULT_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_PP_DEFAULT_COLOR, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_ASM_LABEL_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_ASM_LABEL_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.EDITOR_ASM_DIRECTIVE_COLOR, + findRGB(registry, ICThemeConstants.EDITOR_ASM_DIRECTIVE_COLOR, new RGB(127, 0, 85)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(255, 255, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255)), fireEvent); + setDefault( + store, + PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, + findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0)), fireEvent); + setDefault( + store, + PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR, + findRGB(registry, ICThemeConstants.DOXYGEN_MULTI_LINE_COLOR, new RGB(63, 95, 191)), fireEvent); + setDefault( + store, + PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR, + findRGB(registry, ICThemeConstants.DOXYGEN_SINGLE_LINE_COLOR, new RGB(63, 95, 191)), fireEvent); + setDefault( + store, + PreferenceConstants.DOXYGEN_TAG_COLOR, + findRGB(registry, ICThemeConstants.DOXYGEN_TAG_COLOR, new RGB(127, 159, 191)), fireEvent); + } + + /** + * Sets the default value and fires a property + * change event if necessary. + * + * @param store the preference store + * @param key the preference key + * @param newValue the new value + * @param fireEvent false if no event should be fired + * @since 5.4 + */ + private static void setDefault(IPreferenceStore store, String key, RGB newValue, boolean fireEvent) { + if (!fireEvent) { + PreferenceConverter.setDefault(store, key, newValue); + return; + } + + RGB oldValue= null; + if (store.isDefault(key)) + oldValue= PreferenceConverter.getDefaultColor(store, key); + + PreferenceConverter.setDefault(store, key, newValue); + + if (oldValue != null && !oldValue.equals(newValue)) + store.firePropertyChangeEvent(key, oldValue, newValue); + } + + /** + * Returns the RGB for the given key in the given color registry. + * + * @param registry the color registry + * @param key the key for the constant in the registry + * @param defaultRGB the default RGB if no entry is found + * @return RGB the RGB + * @since 5.4 + */ + private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { + if (registry == null) + return defaultRGB; + + RGB rgb= registry.getRGB(key); + if (rgb != null) + return rgb; + + return defaultRGB; + } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java index 724fb2f7d36..a979aa5cb8e 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/PreferenceConstants.java @@ -23,17 +23,12 @@ import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.InstanceScope; import org.eclipse.jface.action.Action; import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.jface.resource.ColorRegistry; import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.RGB; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.text.ICColorConstants; -import org.eclipse.cdt.internal.ui.ICThemeConstants; import org.eclipse.cdt.internal.ui.preferences.formatter.FormatterProfileManager; import org.eclipse.cdt.internal.ui.text.spelling.SpellCheckEngine; @@ -554,6 +549,45 @@ public class PreferenceConstants { */ public final static String EDITOR_ASM_DIRECTIVE_ITALIC= ICColorConstants.ASM_DIRECTIVE + EDITOR_ITALIC_SUFFIX; + /** + * A named preference that holds the color used to render doxygen tags. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 5.4 + */ + public static final String DOXYGEN_TAG_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$ + + /** + * A named preference that holds the color used to render doxygen single line comments. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 5.4 + */ + public static final String DOXYGEN_SINGLE_LINE_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$ + + /** + * A named preference that holds the color used to render doxygen multi-line comments. + *

+ * Value is of type String. A RGB color value encoded as a string + * using class PreferenceConverter + *

+ * + * @see org.eclipse.jface.resource.StringConverter + * @see org.eclipse.jface.preference.PreferenceConverter + * @since 5.4 + */ + public static final String DOXYGEN_MULTI_LINE_COLOR= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$ + /** * The symbolic font name for the C/C++ editor text font * (value "org.eclipse.cdt.ui.editors.textfont"). @@ -1859,8 +1893,6 @@ public class PreferenceConstants { * @param store the preference store to be initialized */ public static void initializeDefaultValues(IPreferenceStore store) { - ColorRegistry registry= PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry(); - store.setDefault(PreferenceConstants.EDITOR_CORRECTION_INDICATION, false); store.setDefault(PreferenceConstants.EDITOR_SHOW_SEGMENTS, false); store.setDefault(PreferenceConstants.PREF_SHOW_CU_CHILDREN, true); @@ -1875,64 +1907,49 @@ public class PreferenceConstants { store.setDefault(EDITOR_SOURCE_HOVER_BACKGROUND_COLOR_SYSTEM_DEFAULT, true); - // Coloring - PreferenceConverter.setDefault(store, EDITOR_MULTI_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); + // Syntax highlighting store.setDefault(EDITOR_MULTI_LINE_COMMENT_BOLD, false); store.setDefault(EDITOR_MULTI_LINE_COMMENT_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_SINGLE_LINE_COMMENT_COLOR, new RGB(63, 127, 95)); store.setDefault(EDITOR_SINGLE_LINE_COMMENT_BOLD, false); store.setDefault(EDITOR_SINGLE_LINE_COMMENT_ITALIC, false); - PreferenceConverter.setDefault(store, PreferenceConstants.EDITOR_TASK_TAG_COLOR, new RGB(127, 159, 191)); - store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_BOLD, true); - store.setDefault(PreferenceConstants.EDITOR_TASK_TAG_ITALIC, false); + store.setDefault(EDITOR_TASK_TAG_BOLD, true); + store.setDefault(EDITOR_TASK_TAG_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_KEYWORD_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_C_KEYWORD_BOLD, true); store.setDefault(EDITOR_C_KEYWORD_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_BUILTIN_TYPE_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_C_BUILTIN_TYPE_BOLD, true); store.setDefault(EDITOR_C_BUILTIN_TYPE_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_STRING_COLOR, new RGB(42, 0, 255)); store.setDefault(EDITOR_C_STRING_BOLD, false); store.setDefault(EDITOR_C_STRING_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_DEFAULT_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_DEFAULT_BOLD, false); store.setDefault(EDITOR_C_DEFAULT_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_OPERATOR_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_OPERATOR_BOLD, false); store.setDefault(EDITOR_C_OPERATOR_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_BRACES_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_BRACES_BOLD, false); store.setDefault(EDITOR_C_BRACES_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_C_NUMBER_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_C_NUMBER_BOLD, false); store.setDefault(EDITOR_C_NUMBER_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_PP_DIRECTIVE_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_PP_DIRECTIVE_BOLD, true); store.setDefault(EDITOR_PP_DIRECTIVE_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_PP_HEADER_COLOR, new RGB(42, 0, 255)); store.setDefault(EDITOR_PP_HEADER_BOLD, false); store.setDefault(EDITOR_PP_HEADER_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_PP_DEFAULT_COLOR, new RGB(0, 0, 0)); store.setDefault(EDITOR_PP_DEFAULT_BOLD, false); store.setDefault(EDITOR_PP_DEFAULT_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_ASM_LABEL_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_ASM_LABEL_BOLD, true); store.setDefault(EDITOR_ASM_LABEL_ITALIC, false); - PreferenceConverter.setDefault(store, EDITOR_ASM_DIRECTIVE_COLOR, new RGB(127, 0, 85)); store.setDefault(EDITOR_ASM_DIRECTIVE_BOLD, true); store.setDefault(EDITOR_ASM_DIRECTIVE_ITALIC, false); @@ -1972,23 +1989,6 @@ public class PreferenceConstants { store.setDefault(PreferenceConstants.CODEASSIST_PROPOSALS_TIMEOUT, 5000); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_BACKGROUND, new RGB(255, 255, 255))); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PROPOSALS_FOREGROUND, new RGB(0, 0, 0))); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PARAMETERS_BACKGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_BACKGROUND, new RGB(255, 255, 255))); - setDefaultAndFireEvent( - store, - PreferenceConstants.CODEASSIST_PARAMETERS_FOREGROUND, - findRGB(registry, ICThemeConstants.CODEASSIST_PARAMETERS_FOREGROUND, new RGB(0, 0, 0))); - // Refactoring. store.setDefault(PreferenceConstants.REFACTOR_SAVE_ALL_EDITORS, false); store.setDefault(PreferenceConstants.REFACTOR_LIGHTWEIGHT, true); @@ -2081,6 +2081,9 @@ public class PreferenceConstants { store.setDefault(NAME_STYLE_CPP_TEST_PREFIX, ""); //$NON-NLS-1$ store.setDefault(NAME_STYLE_CPP_TEST_SUFFIX, "_test.cpp"); //$NON-NLS-1$ store.setDefault(NAME_STYLE_CPP_TEST_WORD_DELIMITER, ""); //$NON-NLS-1$ + + // Colors that are set by the current theme + CUIPreferenceInitializer.setThemeBasedPreferences(store, false); } /** @@ -2149,39 +2152,4 @@ public class PreferenceConstants { return getPreferenceNode(key, project).getBoolean(key, defaultValue); } - /** - * Sets the default value and fires a property - * change event if necessary. - * - * @param store the preference store - * @param key the preference key - * @param newValue the new value - * @since 5.0 - */ - private static void setDefaultAndFireEvent(IPreferenceStore store, String key, RGB newValue) { - RGB oldValue= null; - if (store.isDefault(key)) - oldValue= PreferenceConverter.getDefaultColor(store, key); - - PreferenceConverter.setDefault(store, key, newValue); - - if (oldValue != null && !oldValue.equals(newValue)) - store.firePropertyChangeEvent(key, oldValue, newValue); - } - - /** - * Returns the RGB for the given key in the given color registry. - * - * @param registry the color registry - * @param key the key for the constant in the registry - * @param defaultRGB the default RGB if no entry is found - * @return RGB the RGB - * @since 5.0 - */ - private static RGB findRGB(ColorRegistry registry, String key, RGB defaultRGB) { - RGB rgb= registry.getRGB(key); - if (rgb != null) - return rgb; - return defaultRGB; - } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java index 1ae0336cb9b..dd089fa34ed 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/text/doctools/doxygen/DoxygenHelper.java @@ -1,12 +1,12 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 Symbian Software Systems and others. + * Copyright (c) 2008, 2011 Symbian Software Systems 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: - * Andrew Ferguson (Symbian) - Initial implementation + * Andrew Ferguson (Symbian) - Initial implementation *******************************************************************************/ package org.eclipse.cdt.ui.text.doctools.doxygen; import java.io.BufferedReader; @@ -20,42 +20,53 @@ import org.eclipse.core.runtime.FileLocator; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceConverter; -import org.eclipse.swt.graphics.RGB; - import org.eclipse.cdt.ui.CUIPlugin; +import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.doctools.generic.GenericDocTag; /** * Makes available information for Doxygen support. - * + * * @since 5.0 * @noextend This class is not intended to be subclassed by clients. */ public class DoxygenHelper extends AbstractPreferenceInitializer { private static final IPath TAGS_CSV= new Path("doxygenTags.csv"); //$NON-NLS-1$ private static GenericDocTag[] fTags; - - public static final String DOXYGEN_TAG_RECOGNIZED= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.recognizedTag"; //$NON-NLS-1$ - public static final String DOXYGEN_SINGLE_TOKEN= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.single"; //$NON-NLS-1$ - public static final String DOXYGEN_MULTI_TOKEN= "org.eclipse.cdt.internal.ui.text.doctools.doxygen.multi"; //$NON-NLS-1$ - + + /** + * @deprecated Use {@link PreferenceConstants#DOXYGEN_TAG_COLOR} instead. + */ + @Deprecated + public static final String DOXYGEN_TAG_RECOGNIZED= PreferenceConstants.DOXYGEN_TAG_COLOR; + /** + * @deprecated Use {@link PreferenceConstants#DOXYGEN_SINGLE_LINE_COLOR} instead. + */ + @Deprecated + public static final String DOXYGEN_SINGLE_TOKEN= PreferenceConstants.DOXYGEN_SINGLE_LINE_COLOR; + /** + * @deprecated Use {@link PreferenceConstants#DOXYGEN_MULTI_LINE_COLOR} instead. + */ + @Deprecated + public static final String DOXYGEN_MULTI_TOKEN= PreferenceConstants.DOXYGEN_MULTI_LINE_COLOR; + /** * @return The tags which are understood by default by the doxygen tool. */ public static GenericDocTag[] getDoxygenTags() { if(fTags==null) { + InputStream is = null; try { List temp= new ArrayList(); - InputStream is= FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false); + is= FileLocator.openStream(CUIPlugin.getDefault().getBundle(), TAGS_CSV, false); BufferedReader br= new BufferedReader(new InputStreamReader(is)); - StringBuffer content= new StringBuffer(); + StringBuilder content= new StringBuilder(2000); for(String line= br.readLine(); line!=null; line= br.readLine()) { - content.append(line+"\n"); //$NON-NLS-1$ + content.append(line).append('\n'); } - String[] values= (content.toString()+"dummy-for-split").split("(\\s)*,(\\s)*"); //$NON-NLS-1$ //$NON-NLS-2$ - + content.append("dummy-for-split"); //$NON-NLS-1$ + String[] values= content.toString().split("(\\s)*,(\\s)*"); //$NON-NLS-1$ + for(int i=0; i+1 + diff --git a/debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd b/debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd new file mode 100644 index 00000000000..5a8315aaaa8 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/schema/disassemblyRulerColumns.exsd @@ -0,0 +1,269 @@ + + + + + + + + + Ruler column contributions are line based information areas that are normally shown in the vertical ruler area of the disassembly. + + + + + + + + + + + + + + + + + a fully qualified identifier of the target extension point + + + + + + + an optional identifier of the extension instance + + + + + + + an optional name of the extension instance + + + + + + + + + + + + + + + + The specification of a ruler column contribution. + + + + + + + + + + + + + + the unique id of this column + + + + + + + an optional name of the column, may be used in the user interface (e.g. in preference pages) + + + + + + + + + + an optional icon for the column. May be used in the user interface, for example on preference pages. + + + + + + + + + + the class implementing the column; must implement <code>org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn</code> + + + + + + + + + + the default enablement state of this column + + + + + + + controls whether toggling the visibility of this column operates on all targeted disassembly parts, or only the active disassembly part. If true, the ruler is added to all applicable parts when the user enables the column; if false, the ruler is only added to the active disassembly part. + + + + + + + whether to include a "Show/Hide" menu entry for this column in the ruler context menu + + + + + + + + + + Describes a disassembly part that the column is contributed to. + + + + + + + the part id of the target disassembly part + + + + + + + + + + + + + Describes a disassembly part class that the column is contributed to. Subclasses of the specified class are also targeted by this colum contribution. + + + + + + + the fully qualified name of a class implementing IWorkbenchPart. The class does not need to be instantiatable. + + + + + + + + + + + + + Describes the placement of this ruler column relative to other contributed columns. A column may request to be placed <em>before</em> or <em>after</em> other known columns (identified by their <tt>id</tt>). Columns that would end up at the same position are ordered by <em>gravity</em> (see below). If the ordering is contradicting or no ordering can be found that fulfills all placement requests, some placement requirements are dropped until the placement can be achieved. If a column does not fully specify its placement it will be placed at an arbitrary but consistent location. + + + + + + + + + + + + + a float number between 0.0 and 1.0 that tells how close the column wants to be to the editor, where 0.0 means as far away as possible and 1.0 means as close as possible. After all <i>before</i> and <i>after</i> constraints are evaluated, columns that would end up at the same position are ordered by their <i>gravity</i> value. + + + + + + + + + + Requests placement before another column. The meaning of <i>before</i> is similar to the SWT.LEAD flag: In left-to-right environments, <i>before</i> means <i>to the left of</i>, in right-to-left environments, it means <i>to the right of</i>. + + + + + + + the id of another <tt>rulerColumns</tt> contribution + + + + + + + + + + + + + Requests placement after another column. The meaning of <i>after</i> is similar to the SWT.TRAIL flag: In left-to-right environments, <i>after</i> means <i>to the right of</i>, in right-to-left environments, it means <i>to the left of</i>. + + + + + + + the id of another <tt>rulerColumns</tt> contribution + + + + + + + + + + + + + + + 7.2 + + + + + + + + + The extension point is supported by the <tt>org.eclipse.cdt.debug.ui.disassembly.rulers</tt> package. <code>RulerColumnRegistry</code> gives access to all contributions, which in turn are described by <code>RulerColumnDescriptor</code> instances. + + + + + + + + + + All ruler column contributions must implement <code>org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn</code>. Many contributors will find the supplied <code>org.eclipse.cdt.debug.ui.disassembly.rulers.AbstractContributedRulerColumn</code> useful which serves as super class for contributed ruler columns. Others might start off <code>org.eclipse.jface.text.source.AbstractRulerColumn</code> which takes over most painting and scrolling aspects of a line based column and can be extended at various granularity levels. Those subclassing the latter class will have to implement <code>org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn</code> on their own by using <code>org.eclipse.cdt.debug.ui.disassembly.rulers.AbstractContributedRulerColumn</code> as template. + + + + + + + + + Copyright (c) 2006, 20011 IBM Corporation and others.<br> +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 <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a> + + + + diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java new file mode 100644 index 00000000000..68f71ebed2f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/preferences/StringSetSerializer.java @@ -0,0 +1,56 @@ +/******************************************************************************* + * Copyright (c) 2006, 2008 IBM Corporation 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: + * IBM Corporation - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.internal.ui.preferences; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.StringTokenizer; + +import org.eclipse.core.runtime.Assert; + +public final class StringSetSerializer { + private static final String DELIM= "\0"; //$NON-NLS-1$ + private StringSetSerializer() { + } + + public static String serialize(Set strings) { + Assert.isLegal(strings != null); + @SuppressWarnings("null") + StringBuffer buf= new StringBuffer(strings.size() * 20); + for (Iterator it= strings.iterator(); it.hasNext();) { + buf.append(it.next()); + if (it.hasNext()) + buf.append(DELIM); + } + return buf.toString(); + } + + public static Set deserialize(String serialized) { + Assert.isLegal(serialized != null); + Set marked= new HashSet(); + StringTokenizer tok= new StringTokenizer(serialized, DELIM); + while (tok.hasMoreTokens()) + marked.add(tok.nextToken()); + return marked; + } + + public static String[] getDifference(String oldValue, String newValue) { + Set oldSet= deserialize(oldValue); + Set newSet= deserialize(newValue); + Set intersection= new HashSet(oldSet); + intersection.retainAll(newSet); + oldSet.removeAll(intersection); + newSet.removeAll(intersection); + oldSet.addAll(newSet); + return oldSet.toArray(new String[oldSet.size()]); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java new file mode 100644 index 00000000000..a46aaf45a49 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/AbstractContributedRulerColumn.java @@ -0,0 +1,66 @@ +/******************************************************************************* + * Copyright (c) 2006, 2011 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.IConfigurationElement; + +import org.eclipse.ui.IWorkbenchPart; + + +/** + * Helper class for contributions to the + * org.eclipse.cdt.debug.ui.disassemblyRulerColumns extension point. + *

+ * Subclasses must have a zero-argument constructor so that they can be created by + * {@link IConfigurationElement#createExecutableExtension(String)}.

+ * + * @since 7.2 + */ +public abstract class AbstractContributedRulerColumn implements IContributedRulerColumn { + /** The contribution descriptor. */ + private RulerColumnDescriptor fDescriptor; + /** The target disassembly part. */ + private IWorkbenchPart fDisassembly; + + @Override + public final RulerColumnDescriptor getDescriptor() { + return fDescriptor; + } + + @Override + public final void setDescriptor(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + Assert.isTrue(fDescriptor == null); + fDescriptor= descriptor; + } + + @Override + public final void setDisassemblyPart(IWorkbenchPart disassembly) { + Assert.isLegal(disassembly != null); + Assert.isTrue(fDisassembly == null); + fDisassembly= disassembly; + } + + @Override + public final IWorkbenchPart getDisassemblyPart() { + return fDisassembly; + } + + @Override + public void columnCreated() { + } + + @Override + public void columnRemoved() { + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java new file mode 100644 index 00000000000..ea21e15a4b7 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IColumnSupport.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2007, 2011 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + + +/** + * Provides support to modify and query the visibility of + * ruler columns and test whether a ruler column is supported. + *

+ * This interface must not be implemented by clients. + *

+ * + * @since 7.2 + * @noimplement This interface is not intended to be implemented by clients. + * @noextend This interface is not intended to be extended by clients. + */ +public interface IColumnSupport { + + /** + * Returns true if the column described by descriptor is + * currently showing, false if not. + * + * @param descriptor the column descriptor + * @return true if the specified column is currently visible + */ + boolean isColumnVisible(RulerColumnDescriptor descriptor); + + /** + * Attempts to set the visibility of the column described by descriptor. Nothing + * happens if the visibility is already as requested, or if the column is not supported by the + * editor. + * + * @param descriptor the column descriptor + * @param visible true to show the column, false to hide it + */ + void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible); + + /** + * Returns true if the column described by descriptor is + * supported by the receiver's editor, false if id is not the + * identifier of a known column contribution, if the column does not target the editor, or if + * the editor does not support contributed columns. + * + * @param descriptor the column descriptor + * @return true if the specified column is supported + */ + boolean isColumnSupported(RulerColumnDescriptor descriptor); + + /** + * Removes and disposes all currently visible ruler columns. + */ + void dispose(); +} \ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java new file mode 100644 index 00000000000..4c2e7c616ba --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/IContributedRulerColumn.java @@ -0,0 +1,99 @@ +/******************************************************************************* + * Copyright (c) 2006, 2011 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + + +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.jface.text.source.IVerticalRulerColumn; +import org.eclipse.ui.IWorkbenchPart; + + +/** + * Interface that has to be implemented by contributions to the + * org.eclipse.cdt.debug.ui.disassembly.rulerColumns extension point. + *

+ * Implementors must have a zero-argument constructor so that they can be created + * by {@link IConfigurationElement#createExecutableExtension(String)}.

+ * + * @since 7.2 + */ +public interface IContributedRulerColumn extends IVerticalRulerColumn { + + /** + * Returns the extension point descriptor of this ruler. + * + * @return descriptor the extension point descriptor of this ruler or null if called before {@link #columnCreated()} + */ + RulerColumnDescriptor getDescriptor(); + + /** + * Sets the extension point descriptor of this ruler. + *

+ * This method will be called by the framework and must not + * be called by clients.

+ * + * @param descriptor the extension point descriptor + */ + void setDescriptor(RulerColumnDescriptor descriptor); + + /** + * Sets the disassembly part (called right after the extension was instantiated). + *

+ * This method will be called by the framework and must not + * be called by clients.

+ * + * @param disassembly the disassembly part targeted by this ruler instance + */ + void setDisassemblyPart(IWorkbenchPart disassembly); + + /** + * Returns the disassembly part targeted by this ruler instance. + * + * @return the disassembly part targeted by this ruler instance or null if called before {@link #columnCreated()} + */ + IWorkbenchPart getDisassemblyPart(); + + /** + * Hook method called after a column has been instantiated, but before it is + * added to a {@link org.eclipse.jface.text.source.CompositeRuler} and before + * {@linkplain org.eclipse.jface.text.source.IVerticalRulerColumn#createControl(org.eclipse.jface.text.source.CompositeRuler, org.eclipse.swt.widgets.Composite) createControl} + * is called. + *

+ * This happens when + *

    + *
  • the column is set visible by the user or programmatically
  • + *
  • the disassembly part is created, if this ruler targets the disassembly part and is enabled by default
  • + *
  • the disassembly part input changes and the column now targets the new disassembly part contents.
  • + *

+ */ + void columnCreated(); + + /** + * Hook method called after a column has been removed from the {@link org.eclipse.jface.text.source.CompositeRuler}. + *

+ * This happens when + *

    + *
  • the column is hidden by the user or programmatically
  • + *
  • the disassembly part is closed
  • + *
  • the disassembly part input changes and the column no longer targets the disassembly part + * contents.
  • + *
+ *

+ *

+ * The column will not be used after this method has been called. A new + * column will be instantiated if the same column type should be shown for + * the same disassembly part. + *

+ */ + void columnRemoved(); + +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java new file mode 100644 index 00000000000..48dfaef455f --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnDescriptor.java @@ -0,0 +1,309 @@ +/******************************************************************************* + * Copyright (c) 2005, 2011 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.net.URL; + +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.content.IContentType; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.IWorkbenchPart; +import org.eclipse.ui.IWorkbenchPartSite; +import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacement; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnTarget; + + +/** + * The description of an extension to the + * org.eclipse.ui.workbench.texteditor.rulerColumns extension point. Instances are + * immutable. Instances can be obtained from a {@link RulerColumnRegistry}. + * + * @since 7.2 + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class RulerColumnDescriptor { + /** The extension schema name of the class attribute. */ + private static final String CLASS= "class"; //$NON-NLS-1$ + /** The extension schema name of the id attribute. */ + private static final String ID= "id"; //$NON-NLS-1$ + /** The extension schema name of the optional name attribute. */ + private static final String NAME= "name"; //$NON-NLS-1$ + /** The extension schema name of the optional enabled attribute. */ + private static final String ENABLED= "enabled"; //$NON-NLS-1$ + /** The extension schema name of the optional icon attribute. */ + private static final String ICON= "icon"; //$NON-NLS-1$ + /** The extension schema name of the optional global attribute. */ + private static final String GLOBAL= "global"; //$NON-NLS-1$ + /** The extension schema name of the optional menu inclusion attribute. */ + private static final String INCLUDE_IN_MENU= "includeInMenu"; //$NON-NLS-1$ + /** The extension schema name of the targetEditor element. */ + private static final String TARGET_ID= "targetId"; //$NON-NLS-1$ + /** The extension schema name of the targetClass element. */ + private static final String TARGET_CLASS= "targetClass"; //$NON-NLS-1$ + /** The extension schema name of the placement element. */ + private static final String PLACEMENT= "placement"; //$NON-NLS-1$ + + /** The identifier of the extension. */ + private final String fId; + /** The name of the extension, equal to the id if no name is given. */ + private final String fName; + /** The icon descriptor. */ + private final ImageDescriptor fIcon; + /** The configuration element of this extension. */ + private final IConfigurationElement fElement; + /** The target specification of the ruler column contribution. */ + private final RulerColumnTarget fTarget; + /** The placement specification of the ruler column contribution. */ + private final RulerColumnPlacement fRulerColumnPlacement; + /** The default enablement setting of the ruler column contribution. */ + private final boolean fDefaultEnablement; + /** The global setting of the ruler column contribution. */ + private final boolean fIsGlobal; + /** The menu inclusion setting of the ruler column contribution. */ + private final boolean fIncludeInMenu; + + /** + * Creates a new descriptor. + * + * @param element the configuration element to read + * @param registry the computer registry creating this descriptor + * @throws InvalidRegistryObjectException if the configuration element is no longer valid + * @throws CoreException if the configuration element does not conform to the extension point spec + */ + RulerColumnDescriptor(IConfigurationElement element, RulerColumnRegistry registry) throws InvalidRegistryObjectException, CoreException { + Assert.isLegal(registry != null); + Assert.isLegal(element != null); + fElement= element; + + ExtensionPointHelper helper= new ExtensionPointHelper(element); + + fId= helper.getNonNullAttribute(ID); + fName= helper.getDefaultAttribute(NAME, fId); + helper.getNonNullAttribute(CLASS); // just check validity + URL iconURL= helper.getDefaultResourceURL(ICON, null); + fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL); + fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true); + fIsGlobal= helper.getDefaultAttribute(GLOBAL, true); + fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true); + + @SuppressWarnings("null") + IConfigurationElement[] targetEditors= element.getChildren(TARGET_ID); + IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS); + + RulerColumnTarget combined= null; + for (int i= 0; i < targetEditors.length; i++) { + IConfigurationElement targetEditor= targetEditors[i]; + RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor).getNonNullAttribute(ID)); + combined= RulerColumnTarget.createOrTarget(combined, target); + } + for (int i= 0; i < targetClasses.length; i++) { + IConfigurationElement targetClass= targetClasses[i]; + RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass).getNonNullAttribute(CLASS)); + combined= RulerColumnTarget.createOrTarget(combined, target); + } + fTarget= combined; + + IConfigurationElement[] placements= element.getChildren(PLACEMENT); + switch (placements.length) { + case 0: + fRulerColumnPlacement= new RulerColumnPlacement(); + break; + case 1: + fRulerColumnPlacement= new RulerColumnPlacement(placements[0]); + break; + default: + helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg); + fRulerColumnPlacement= null; // dummy + break; + } + + Assert.isTrue(fTarget != null); + Assert.isTrue(fRulerColumnPlacement != null); + } + + /** + * Returns the identifier of the described extension. + * + * @return the identifier of the described extension + */ + public String getId() { + return fId; + } + + /** + * Returns the name of the described extension. + * + * @return the name of the described extension + */ + public String getName() { + return fName; + } + + /** + * Returns the image descriptor of the described extension, null if it does not + * have an image. + * + * @return the image descriptor of the described extension or null for no image + */ + public ImageDescriptor getIcon() { + return fIcon; + } + + RulerColumnTarget getTarget() { + return fTarget; + } + + RulerColumnPlacement getPlacement() { + return fRulerColumnPlacement; + } + + /** + * Returns the default enablement of the described extension. Editors that support this + * contribution should typically enable the column by default. + * + * @return the default enablement of the described extension + */ + public boolean getDefaultEnablement() { + return fDefaultEnablement; + } + + /** + * Returns the global property of the described extension. Changing the visibility of a column + * with the global property set to true should typically affect all matching + * editors. Changing the visibility of a column with the global property set to + * false should only affect the current disassembly part. + * + * @return the global property of the described extension + */ + public boolean isGlobal() { + return fIsGlobal; + } + + /** + * Returns the menu inclusion property of the described extension. A toggle menu entry should be + * inluded in the ruler context menu for columns with this property set to true. + * + * @return the menu inclusion property of the described extension + */ + public boolean isIncludedInMenu() { + return fIncludeInMenu; + } + + /** + * Returns true if this contribution matches the passed disassembly part , false if not. + * + * @param disassembly the disassembly part to check + * @return true if this contribution targets the passed disassembly part + */ + public boolean matchesPart(IWorkbenchPart disassembly) { + Assert.isLegal(disassembly != null); + RulerColumnTarget target= getTarget(); + + @SuppressWarnings("null") + IWorkbenchPartSite site= disassembly.getSite(); + if (site != null && target.matchesEditorId(site.getId())) + return true; + + if (target.matchesClass(disassembly.getClass())) + return true; + + IContentType contentType= getContentType(disassembly); + return contentType != null && target.matchesContentType(contentType); + + } + + /** + * Creates a {@link IContributedRulerColumn} instance as described by the receiver. This may load the contributing plug-in. + * + * @param disassembly the disassembly part that loads the contributed column + * @return the instantiated column + * @throws CoreException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} + * @throws InvalidRegistryObjectException as thrown by {@link IConfigurationElement#createExecutableExtension(String)} + */ + public IContributedRulerColumn createColumn(IWorkbenchPart disassembly) throws CoreException, InvalidRegistryObjectException { + Assert.isLegal(disassembly != null); + IContributedRulerColumn column= (IContributedRulerColumn)fElement.createExecutableExtension(CLASS); + column.setDescriptor(this); + column.setDisassemblyPart(disassembly); + column.columnCreated(); + return column; + } + + /* + * @see java.lang.Object#toString() + * @since 3.3 + */ + @Override + public String toString() { + return "RulerColumnDescriptor[name=" + getName() + "]"; //$NON-NLS-1$ //$NON-NLS-2$ + } + + IConfigurationElement getConfigurationElement() { + return fElement; + } + + /* + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + final int prime= 31; + int result= 1; + result= prime * result + ((fId == null) ? 0 : fId.hashCode()); + return result; + } + + /* + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final RulerColumnDescriptor other= (RulerColumnDescriptor) obj; + if (fId == null) { + if (other.fId != null) + return false; + } else if (!fId.equals(other.fId)) + return false; + return true; + } + + /** + * Returns the content type of the disassembly part's input, null if the disassembly part input or + * the document provider is null or the content type cannot be determined. + * + * @param disassembly part the disassembly part to get the content type from + * @return the content type of the disassembly part's input, null if it cannot be + * determined + */ + private IContentType getContentType(IWorkbenchPart disassembly) { + return null; + } + + String getContributor() { + try { + return fElement.getContributor().getName(); + } catch (InvalidRegistryObjectException e) { + return "unknown"; //$NON-NLS-1$ + } + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java new file mode 100644 index 00000000000..b924ec41782 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnPreferenceAdapter.java @@ -0,0 +1,89 @@ +/******************************************************************************* + * Copyright (c) 2006, 201 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.util.Set; + +import org.eclipse.cdt.debug.internal.ui.preferences.StringSetSerializer; +import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Manages the preferences for ruler contributions stored in a preference store. + * + * @since 7.2 + */ +public final class RulerColumnPreferenceAdapter { + private final IPreferenceStore fStore; + private final String fKey; + + /** + * Creates a new preference adapter that will read and write under the specified key in the + * given preference store. + * + * @param store the preference store + * @param key the key + */ + public RulerColumnPreferenceAdapter(IPreferenceStore store, String key) { + Assert.isLegal(store != null); + Assert.isLegal(key != null); + fStore= store; + fKey= key; + } + + /** + * Returns the enablement state of the given ruler contribution. + * + * @param descriptor a ruler contribution descriptor + * @return true if the ruler is enabled, false otherwise + */ + @SuppressWarnings("null") + public boolean isEnabled(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + String preference= fStore.getString(fKey); + return StringSetSerializer.deserialize(preference).contains(descriptor.getId()) ^ descriptor.getDefaultEnablement(); + } + + /** + * Sets the enablement state of the given ruler contribution. + * + * @param descriptor a ruler contribution descriptor + * @param enabled true to enable the contribution, false to + * disable it + */ + public void setEnabled(RulerColumnDescriptor descriptor, boolean enabled) { + Assert.isLegal(descriptor != null); + @SuppressWarnings("null") + String id= descriptor.getId(); + String preference= fStore.getString(fKey); + Set marked= StringSetSerializer.deserialize(preference); + boolean shouldMark= enabled ^ descriptor.getDefaultEnablement(); + boolean isMarked= marked.contains(id); + if (isMarked != shouldMark) { + if (shouldMark) + marked.add(id); + else + marked.remove(id); + fStore.setValue(fKey, StringSetSerializer.serialize(marked)); + } + } + + /** + * Toggles the enablement state of given the ruler contribution. + * + * @param descriptor a ruler contribution descriptor + */ + public void toggle(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + setEnabled(descriptor, !isEnabled(descriptor)); + } +} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java new file mode 100644 index 00000000000..024d07e97b0 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/disassembly/rulers/RulerColumnRegistry.java @@ -0,0 +1,294 @@ +/******************************************************************************* + * Copyright (c) 2000, 2011 IBM Corporation 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: + * IBM Corporation - initial API and implementation + * Wind River Systems, Inc. - adapted for for disassembly parts + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.disassembly.rulers; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.ListIterator; +import java.util.Map; +import java.util.Set; + +import org.eclipse.cdt.debug.ui.CDebugUIPlugin; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.InvalidRegistryObjectException; +import org.eclipse.core.runtime.Platform; +import org.eclipse.core.runtime.Status; +import org.eclipse.ui.internal.texteditor.TextEditorPlugin; +import org.eclipse.ui.internal.texteditor.rulers.DAG; +import org.eclipse.ui.internal.texteditor.rulers.ExtensionPointHelper; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnMessages; +import org.eclipse.ui.internal.texteditor.rulers.RulerColumnPlacementConstraint; +import org.eclipse.ui.texteditor.ConfigurationElementSorter; + +import com.ibm.icu.text.MessageFormat; + + +/** + * A registry for all extensions to the + * rulerColumns extension point. + * + * @since 7.2 + * @noinstantiate This class is not intended to be instantiated by clients. + */ +public final class RulerColumnRegistry { + + private static final String EXTENSION_POINT= "disassemblyRulerColumns"; //$NON-NLS-1$ + private static final String QUALIFIED_EXTENSION_POINT= CDebugUIPlugin.PLUGIN_ID + '.' + EXTENSION_POINT; + + /** The singleton instance. */ + private static RulerColumnRegistry fgSingleton= null; + + /** + * Returns the default computer registry. + * + * @return the singleton instance + */ + public static synchronized RulerColumnRegistry getDefault() { + if (fgSingleton == null) { + fgSingleton= new RulerColumnRegistry(); + } + + return fgSingleton; + } + + /** + * All descriptors (element type: + * {@link RulerColumnDescriptor}). + */ + private List fDescriptors= null; + /** + * All descriptors by id (element type: {@link RulerColumnDescriptor}). + */ + private Map fDescriptorMap= null; + + /** + * true if this registry has been loaded. + */ + private boolean fLoaded= false; + + /** + * Creates a new instance. + */ + RulerColumnRegistry() { + } + + /** + * Returns the list of {@link RulerColumnDescriptor}s describing all extensions to the + * rulerColumns extension point. The list's iterator traverses the descriptors in + * the ordering implied by the placement specifications of the contributions. + *

+ * The returned list is unmodifiable and guaranteed to never change. Note that the set of + * descriptors may change over time due to dynamic plug-in removal or addition. + *

+ * + * @return the sorted list of extensions to the rulerColumns extension point + * (element type: {@link RulerColumnDescriptor}) + */ + public List getColumnDescriptors() { + ensureExtensionPointRead(); + return fDescriptors; + } + + /** + * Returns the {@link RulerColumnDescriptor} with the given identity, null if no + * such descriptor exists. + * + * @param id the identity of the ruler contribution as given in the extension point xml. + * @return the {@link RulerColumnDescriptor} with the given identity, null if no + * such descriptor exists + */ + public RulerColumnDescriptor getColumnDescriptor(String id) { + Assert.isLegal(id != null); + ensureExtensionPointRead(); + return fDescriptorMap.get(id); + } + + /** + * Ensures that the extensions are read and stored in + * fDescriptorsByPartition. + */ + private void ensureExtensionPointRead() { + boolean reload; + synchronized (this) { + reload= !fLoaded; + fLoaded= true; + } + if (reload) + reload(); + } + + /** + * Reloads the extensions to the extension point. + *

+ * This method can be called more than once in order to reload from + * a changed extension registry. + *

+ */ + public void reload() { + IExtensionRegistry registry= Platform.getExtensionRegistry(); + List elements= new ArrayList(Arrays.asList(registry.getConfigurationElementsFor(CDebugUIPlugin.PLUGIN_ID, EXTENSION_POINT))); + + List descriptors= new ArrayList(); + Map descriptorMap= new HashMap(); + + for (Iterator iter= elements.iterator(); iter.hasNext();) { + IConfigurationElement element= iter.next(); + try { + RulerColumnDescriptor desc= new RulerColumnDescriptor(element, this); + String id= desc.getId(); + if (descriptorMap.containsKey(id)) { + noteDuplicateId(desc); + continue; + } + + descriptors.add(desc); + descriptorMap.put(id, desc); + } catch (InvalidRegistryObjectException x) { + /* + * Element is not valid any longer as the contributing plug-in was unloaded or for + * some other reason. Do not include the extension in the list and inform the user + * about it. + */ + noteInvalidExtension(element, x); + } catch (CoreException x) { + warnUser(x.getStatus()); + } + } + + sort(descriptors); + + synchronized (this) { + fDescriptors= Collections.unmodifiableList(descriptors); + fDescriptorMap= Collections.unmodifiableMap(descriptorMap); + } + } + + /** + * Sorts the column contributions. + * + * @param descriptors the descriptors to sort + */ + @SuppressWarnings("unchecked") + private void sort(List descriptors) { + /* + * Topological sort of the DAG defined by the plug-in dependencies + * 1. TopoSort descriptors by plug-in dependency + * 2. Insert into Directed Acyclic Graph + * 3. TopoSort DAG: pick the source with the lowest gravity and remove from DAG + */ + ConfigurationElementSorter sorter= new ConfigurationElementSorter() { + @Override + public IConfigurationElement getConfigurationElement(Object object) { + return ((RulerColumnDescriptor) object).getConfigurationElement(); + } + }; + RulerColumnDescriptor[] array= new RulerColumnDescriptor[descriptors.size()]; + descriptors.toArray(array); + sorter.sort(array); + + Map descriptorsById= new HashMap(); + for (RulerColumnDescriptor desc : array) { + descriptorsById.put(desc.getId(), desc); + } + + DAG dag= new DAG(); + for (RulerColumnDescriptor desc : array) { + dag.addVertex(desc); + + Set before= desc.getPlacement().getConstraints(); + for (Iterator it= before.iterator(); it.hasNext();) { + RulerColumnPlacementConstraint constraint= (RulerColumnPlacementConstraint) it.next(); + String id= constraint.getId(); + RulerColumnDescriptor target= descriptorsById.get(id); + if (target == null) { + noteUnknownTarget(desc, id); + } else { + boolean success; + if (constraint.isBefore()) + success= dag.addEdge(desc, target); + else + success= dag.addEdge(target, desc); + if (!success) + noteCycle(desc, target); + } + } + } + + Comparator gravityComp= new Comparator() { + @Override + public int compare(RulerColumnDescriptor o1, RulerColumnDescriptor o2) { + float diff= o1.getPlacement().getGravity() - o2.getPlacement().getGravity(); + if (diff == 0) + return 0; + if (diff < 0) + return -1; + return 1; + } + }; + + /* Topological sort - always select the source with the least gravity */ + Set toProcess= dag.getSources(); + int index= 0; + while (!toProcess.isEmpty()) { + RulerColumnDescriptor next= Collections.min(toProcess, gravityComp); + array[index]= next; + index++; + dag.removeVertex(next); + toProcess= dag.getSources(); + } + Assert.isTrue(index == array.length); + + ListIterator it= descriptors.listIterator(); + for (int i= 0; i < index; i++) { + it.next(); + it.set(array[i]); + } + } + + private void noteInvalidExtension(IConfigurationElement element, InvalidRegistryObjectException x) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_invalid_msg, new Object[] {ExtensionPointHelper.findId(element)}); + warnUser(message, x); + } + + private void noteUnknownTarget(RulerColumnDescriptor desc, String referencedId) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_unresolved_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, referencedId, desc.getName(), desc.getContributor()}); + warnUser(message, null); + } + + private void noteCycle(RulerColumnDescriptor desc, RulerColumnDescriptor target) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_cyclic_placement_msg, new Object[] {QUALIFIED_EXTENSION_POINT, target.getName(), desc.getName(), desc.getContributor()}); + warnUser(message, null); + } + + private void noteDuplicateId(RulerColumnDescriptor desc) { + String message= MessageFormat.format(RulerColumnMessages.RulerColumnRegistry_duplicate_id_msg, new Object[] {QUALIFIED_EXTENSION_POINT, desc.getId(), desc.getContributor()}); + warnUser(message, null); + } + + private void warnUser(String message, Exception exception) { + IStatus status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, exception); + warnUser(status); + } + + private void warnUser(IStatus status) { + TextEditorPlugin.getDefault().getLog().log(status); + } +} diff --git a/doc/org.eclipse.cdt.doc.isv/reference/.gitignore b/doc/org.eclipse.cdt.doc.isv/reference/.gitignore new file mode 100644 index 00000000000..e340d794a36 --- /dev/null +++ b/doc/org.eclipse.cdt.doc.isv/reference/.gitignore @@ -0,0 +1 @@ +/extension-points diff --git a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_outlineview.htm b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_outlineview.htm index 83c089da869..99a663ecc10 100644 --- a/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_outlineview.htm +++ b/doc/org.eclipse.cdt.doc.user/concepts/cdt_c_outlineview.htm @@ -72,27 +72,35 @@ items:

Icons

-

- - - - - - - - - - - - - - - - - - - - +

IconDescription
Hide Fields ButtonHide Fields
Hide Static Members ButtonHide Static Members
Hide Non Public Members ButtonHide Non-Public Members
Sort ButtonSort
+ + + + + + + + + + + + + + + + + + + + + + + + + + + +
IconDescription
Collapse All IconCollapse All
Sort items alphabetically IconSort items alphabetically
Hide Fields IconHide Fields
Hide Static Members IconHide Static Members
Hide Non-Public Members IconHide Non-Public Members
Hide Inactive Elements IconHide Inactive Elements

For more information about the Eclipse workbench, see Workbench User Guide > Tasks > Upgrading Eclipse.

diff --git a/doc/org.eclipse.cdt.doc.user/images/outlineView.png b/doc/org.eclipse.cdt.doc.user/images/outlineView.png index 3f9a9704f51..6a2c58c667b 100644 Binary files a/doc/org.eclipse.cdt.doc.user/images/outlineView.png and b/doc/org.eclipse.cdt.doc.user/images/outlineView.png differ diff --git a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_outline_view.htm b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_outline_view.htm index d70f7f370dd..84b5413056d 100644 --- a/doc/org.eclipse.cdt.doc.user/reference/cdt_u_outline_view.htm +++ b/doc/org.eclipse.cdt.doc.user/reference/cdt_u_outline_view.htm @@ -27,6 +27,14 @@ open in the editor area, by listing the structural elements.

Icon Description + + Collapse All Icon + Collapse All + + + Sort items alphabetically Icon + Sort items alphabetically + Hide Fields Icon Hide Fields @@ -40,8 +48,8 @@ open in the editor area, by listing the structural elements.

Hide Non-Public Members - Sort items alphabetically Icon - Sort items alphabetically + Hide Inactive Elements Icon + Hide Inactive Elements @@ -65,7 +73,7 @@ open in the editor area, by listing the structural elements.

- Namespace icon + Namespace icon Namespace diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java index 24fe859fdc7..da17bba5f5c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbAdapterFactory.java @@ -202,6 +202,7 @@ public class GdbAdapterFactory fDebugModelProvider = new IDebugModelProvider() { // @see org.eclipse.debug.core.model.IDebugModelProvider#getModelIdentifiers() + @Override public String[] getModelIdentifiers() { return new String[] { GdbLaunchDelegate.GDB_DEBUG_MODEL_ID, ICBreakpoint.C_BREAKPOINTS_DEBUG_MODEL_ID }; } @@ -329,6 +330,7 @@ public class GdbAdapterFactory * This method only actually returns adapters for the launch object. */ @SuppressWarnings("rawtypes") + @Override public Object getAdapter(Object adaptableObject, Class adapterType) { if (!(adaptableObject instanceof GdbLaunch)) return null; @@ -379,6 +381,7 @@ public class GdbAdapterFactory } @SuppressWarnings("rawtypes") + @Override public Class[] getAdapterList() { return new Class[] { IElementContentProvider.class, IModelProxyFactory.class, ISuspendTrigger.class, @@ -386,6 +389,7 @@ public class GdbAdapterFactory }; } + @Override public void launchesRemoved(ILaunch[] launches) { // Dispose the set of adapters for a launch only after the launch is // removed. @@ -396,12 +400,15 @@ public class GdbAdapterFactory } } + @Override public void launchesTerminated(ILaunch[] launches) { } + @Override public void launchesAdded(ILaunch[] launches) { } + @Override public void launchesChanged(ILaunch[] launches) { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java index 94967cc6088..bec41e415cb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbPinProvider.java @@ -61,9 +61,11 @@ public class GdbPinProvider implements IPinProvider { GdbPinElementColorDescriptor(int color) { fColor = color; } + @Override public int getOverlayColor() { return fColor; } + @Override public ImageDescriptor getToolbarIconDescriptor() { return null; } @@ -89,6 +91,7 @@ public class GdbPinProvider implements IPinProvider { fSession = session; session.getExecutor().execute(new Runnable() { + @Override public void run() { fSession.addServiceEventListener(GdbPinProvider.this, null); } @@ -101,6 +104,7 @@ public class GdbPinProvider implements IPinProvider { public void dispose() { try { fSession.getExecutor().execute(new Runnable() { + @Override public void run() { fSession.removeServiceEventListener(GdbPinProvider.this); } @@ -190,6 +194,7 @@ public class GdbPinProvider implements IPinProvider { * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#isPinnable(org.eclipse.ui.IWorkbenchPart, java.lang.Object) */ + @Override public boolean isPinnable(IWorkbenchPart part, Object debugContext) { if (debugContext instanceof IAdaptable) { return ((IAdaptable) debugContext).getAdapter(IDMContext.class) != null; @@ -201,6 +206,7 @@ public class GdbPinProvider implements IPinProvider { * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#pin(org.eclipse.ui.IWorkbenchPart, java.lang.Object, org.eclipse.cdt.debug.ui.IPinModelListener) */ + @Override public IPinElementHandle pin(IWorkbenchPart part, Object debugContext, IPinModelListener listener) { Object pinContext = debugContext; String label = ""; //$NON-NLS-1$ @@ -242,6 +248,7 @@ public class GdbPinProvider implements IPinProvider { * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#unpin(org.eclipse.ui.IWorkbenchPart, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle) */ + @Override public void unpin(IWorkbenchPart part, IPinElementHandle handle) { // remove the handle from the cache gsPinnedHandles.remove(handle); @@ -260,6 +267,7 @@ public class GdbPinProvider implements IPinProvider { * (non-Javadoc) * @see org.eclipse.cdt.debug.ui.IPinProvider#isPinnedTo(java.lang.Object, org.eclipse.cdt.debug.ui.IPinProvider.IPinElementHandle) */ + @Override public boolean isPinnedTo(Object debugContext, IPinElementHandle handle) { Object handleDebugContext = handle.getDebugContext(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java index 97fdfd168e0..21c199e2a11 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/GdbSuspendTrigger.java @@ -39,7 +39,8 @@ public class GdbSuspendTrigger extends DsfSuspendTrigger { protected void getLaunchTopContainers(final DataRequestMonitor rm) { try { getSession().getExecutor().execute(new DsfRunnable() { - public void run() { + @Override + public void run() { IProcesses processService = getServicesTracker().getService(IProcesses.class); ICommandControlService controlService = getServicesTracker().getService(ICommandControlService.class); if (processService == null || controlService == null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java index 784fde439a9..81cba62accb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ConnectActionDelegate.java @@ -27,6 +27,7 @@ public class ConnectActionDelegate extends AbstractVMProviderActionDelegate { /* * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) */ + @Override public void run(IAction action) { if (action.isEnabled()) { // disable the action so it cannot be run again until an event or diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java index f233aa6b6cf..4850e0781d1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/DsfTerminateCommand.java @@ -42,6 +42,7 @@ public class DsfTerminateCommand implements ITerminateHandler { } // Run control may not be avilable after a connection is terminated and shut down. + @Override public void canExecute(final IEnabledStateRequest request) { if (request.getElements().length != 1 || !(request.getElements()[0] instanceof IDMVMContext) ) @@ -64,6 +65,7 @@ public class DsfTerminateCommand implements ITerminateHandler { try { fExecutor.execute( new DsfRunnable() { + @Override public void run() { // Get the processes service and the exec context. IProcesses procService = fTracker.getService(IProcesses.class); @@ -88,6 +90,7 @@ public class DsfTerminateCommand implements ITerminateHandler { } } + @Override public boolean execute(final IDebugCommandRequest request) { if (request.getElements().length != 1 || !(request.getElements()[0] instanceof IDMVMContext)) { @@ -106,6 +109,7 @@ public class DsfTerminateCommand implements ITerminateHandler { try { fExecutor.execute(new DsfRunnable() { + @Override public void run() { IProcesses procService = fTracker.getService(IProcesses.class); if (procService != null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java index 84842f340c6..c74fc317d74 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/FetchMoreChildrenAction.java @@ -38,6 +38,7 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate private ISelection selection; + @Override public void run(IAction action) { IncompleteChildrenVMC incompleteChildrenVmc = getIncompleteChildrenVMC(); @@ -53,6 +54,7 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent(exprCtx, path); final AbstractVMProvider vmProvider = (AbstractVMProvider) getVMProvider(); vmProvider.getExecutor().execute(new DsfRunnable() { + @Override public void run() { vmProvider.handleEvent(fetchMoreChildrenEvent); } @@ -89,6 +91,7 @@ public class FetchMoreChildrenAction extends AbstractVMProviderActionDelegate getAction().setEnabled(enabled); } + @Override public void setActivePart(IAction action, IWorkbenchPart targetPart) { if (targetPart instanceof IViewPart) { init((IViewPart) targetPart); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java index ff72cce4a54..04ca9d980ee 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbConnectCommand.java @@ -84,6 +84,7 @@ public class GdbConnectCommand implements IConnect { fTracker.dispose(); } + @Override public boolean canConnect() { Query canConnectQuery = new Query() { @Override @@ -210,6 +211,7 @@ public class GdbConnectCommand implements IConnect { final String finalBinaryPath = binaryPath; fExecutor.execute(new DsfRunnable() { + @Override public void run() { IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); @@ -239,6 +241,7 @@ public class GdbConnectCommand implements IConnect { } } + @Override public void connect(RequestMonitor requestMonitor) { // Create a fake rm to avoid null pointer exceptions @@ -255,6 +258,7 @@ public class GdbConnectCommand implements IConnect { // thread to prompt the user for the process to choose. // This is why we simply use a DsfRunnable. fExecutor.execute(new DsfRunnable() { + @Override public void run() { final IProcesses procService = fTracker.getService(IProcesses.class); ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java index c2c406f4742..93c56084d43 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbDisconnectCommand.java @@ -37,6 +37,7 @@ public class GdbDisconnectCommand implements IDisconnectHandler { fTracker.dispose(); } + @Override public void canExecute(final IEnabledStateRequest request) { if (request.getElements().length != 1) { request.setEnabled(false); @@ -67,6 +68,7 @@ public class GdbDisconnectCommand implements IDisconnectHandler { }); } + @Override public boolean execute(final IDebugCommandRequest request) { if (request.getElements().length != 1) { request.done(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java index 6619bdb0534..e2e05301f60 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/GdbRestartCommand.java @@ -45,6 +45,7 @@ public class GdbRestartCommand implements IRestartHandler { fTracker.dispose(); } + @Override public void canExecute(final IEnabledStateRequest request) { if (request.getElements().length != 1) { request.setEnabled(false); @@ -75,6 +76,7 @@ public class GdbRestartCommand implements IRestartHandler { }); } + @Override public boolean execute(final IDebugCommandRequest request) { if (request.getElements().length != 1) { request.done(); @@ -92,6 +94,7 @@ public class GdbRestartCommand implements IRestartHandler { fExecutor.submit(new DsfRunnable() { @SuppressWarnings("unchecked") + @Override public void run() { IGDBProcesses procService = fTracker.getService(IGDBProcesses.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java index 8ec9b08b961..6b763246435 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ProcessInfo.java @@ -32,18 +32,22 @@ class ProcessInfo implements IProcessExtendedInfo, Comparable { this.ownerId = owner; } + @Override public String getName() { return name; } + @Override public int getPid() { return pid; } + @Override public String[] getCores() { return cores; } + @Override public String getOwner() { return ownerId; } @@ -52,6 +56,7 @@ class ProcessInfo implements IProcessExtendedInfo, Comparable { * Sort by name, then by pid. * No need to sort any further since pids are unique. */ + @Override public int compareTo(ProcessInfo other) { int nameCompare = getName().compareTo(other.getName()); if (nameCompare != 0) return nameCompare; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java index 1067991189c..7b913d3aaff 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/actions/ReverseDebuggingPropertyTester.java @@ -31,6 +31,7 @@ public class ReverseDebuggingPropertyTester extends PropertyTester { private static final String ENABLED = "isReverseDebuggingEnabled"; //$NON-NLS-1$ + @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (ENABLED.equals(property)) { if (receiver instanceof IDMVMContext) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java index 3c166416bbd..acfa8557ac2 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GDBTracepointPropertyPage.java @@ -356,6 +356,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#getElement() */ + @Override public IAdaptable getElement() { return fElement; } @@ -363,6 +364,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPropertyPage#setElement(org.eclipse.core.runtime.IAdaptable) */ + @Override public void setElement(IAdaptable element) { fElement = element; } @@ -380,6 +382,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme /** * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { changedProperties.add(event.getProperty()); } @@ -392,6 +395,7 @@ public class GDBTracepointPropertyPage extends FieldEditorPreferencePage impleme protected void setBreakpointProperties(final List changedProperties) { IWorkspaceRunnable wr = new IWorkspaceRunnable() { + @Override public void run( IProgressMonitor monitor ) throws CoreException { ICTracepoint tracepoint = getTracepoint(); Iterator changed = changedProperties.iterator(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java index 8fb3b63a6ba..2e1681fa829 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/GdbThreadFilterEditor.java @@ -72,6 +72,7 @@ public class GdbThreadFilterEditor { * * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent) */ + @Override public void checkStateChanged(CheckStateChangedEvent event) { Object element = event.getElement(); if (element instanceof IContainerDMContext) { @@ -140,6 +141,7 @@ public class GdbThreadFilterEditor { * * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object) */ + @Override public Object[] getChildren(Object parent) { if (parent instanceof IContainerDMContext) { return syncGetThreads((IContainerDMContext) parent); @@ -165,6 +167,7 @@ public class GdbThreadFilterEditor { * * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object) */ + @Override public Object getParent(Object element) { if (element instanceof IContainerDMContext) { return DebugPlugin.getDefault().getLaunchManager(); @@ -180,6 +183,7 @@ public class GdbThreadFilterEditor { * * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object) */ + @Override public boolean hasChildren(Object element) { return getChildren(element).length > 0; } @@ -189,6 +193,7 @@ public class GdbThreadFilterEditor { * * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) */ + @Override public Object[] getElements(Object inputElement) { return getChildren(inputElement); } @@ -198,6 +203,7 @@ public class GdbThreadFilterEditor { * * @see org.eclipse.jface.viewers.IContentProvider#dispose() */ + @Override public void dispose() { } @@ -207,6 +213,7 @@ public class GdbThreadFilterEditor { * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, * java.lang.Object, java.lang.Object) */ + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java index 3032a3e0aab..72409bfe4ce 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/breakpoints/ToggleTracepointsTargetFactory.java @@ -53,6 +53,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF public ToggleTracepointsTargetFactory() { } + @Override public IToggleBreakpointsTarget createToggleTarget(String targetID) { if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { return fgDisassemblyToggleTracepointsTarget; @@ -60,10 +61,12 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF return null; } + @Override public String getDefaultToggleTarget(IWorkbenchPart part, ISelection selection) { return null; } + @Override public String getToggleTargetDescription(String targetID) { if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { return Messages.ToggleTracepointsTargetFactory_description; @@ -71,6 +74,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF return null; } + @Override public String getToggleTargetName(String targetID) { if (TOGGLE_C_TRACEPOINT_TARGET_ID.equals(targetID)) { return Messages.ToggleTracepointsTargetFactory_name; @@ -78,6 +82,7 @@ public class ToggleTracepointsTargetFactory implements IToggleBreakpointsTargetF return null; } + @Override public Set getToggleTargets(IWorkbenchPart part, ISelection selection) { if (part instanceof IDisassemblyPart) { return TOGGLE_TARGET_IDS_ALL; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java index 18e5c270aae..dd236ed83d0 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbReverseToggleCommand.java @@ -149,10 +149,12 @@ public class GdbReverseToggleCommand extends AbstractDebugCommand implements IRe return true; } + @Override public boolean toggleNeedsUpdating() { return true; } + @Override public boolean isReverseToggled(Object context) { IDMContext dmc; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java index d534bf15f68..e4d62a8483a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/commands/GdbSaveTraceDataCommand.java @@ -69,6 +69,7 @@ public class GdbSaveTraceDataCommand extends AbstractDebugCommand implements ISa final String[] fileName = new String[1]; PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() { + @Override public void run() { fileName[0] = promptForFileName(); }; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java index fd04e971f10..a35f1e86ac6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsolePageParticipant.java @@ -45,6 +45,7 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo private IPageBookViewPage fPage; private IConsoleView fView; + @Override public void init(IPageBookViewPage page, IConsole console) { fPage = page; fConsole = console; @@ -98,10 +99,12 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo } @SuppressWarnings("rawtypes") + @Override public Object getAdapter(Class adapter) { return null; } + @Override public void dispose() { if (isConsoleInferior(fConsole) || isConsoleGdbCli(fConsole)) { DebugUITools.getDebugContextManager().getContextService(fPage.getSite().getWorkbenchWindow()).removeDebugContextListener(this); @@ -109,9 +112,11 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo fConsole = null; } + @Override public void activated() { } + @Override public void deactivated() { } @@ -186,6 +191,7 @@ public class ConsolePageParticipant implements IConsolePageParticipant, IDebugCo /* (non-Javadoc) * @see org.eclipse.debug.internal.ui.contexts.provisional.IDebugContextListener#contextEvent(org.eclipse.debug.internal.ui.contexts.provisional.DebugContextEvent) */ + @Override public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) > 0) { IProcess consoleProcess = getConsoleProcess(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleSaveAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleSaveAction.java index 30fd14e5850..2b161752e06 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleSaveAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/ConsoleSaveAction.java @@ -48,6 +48,7 @@ public class ConsoleSaveAction extends Action{ } Runnable saveJob = new Runnable() { + @Override public void run() { saveContent(fileName); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java index 2f873307d37..6193a8a7dfd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsole.java @@ -70,6 +70,7 @@ public class TracingConsole extends IOConsole { protected void init() { super.init(); fSession.getExecutor().submit(new DsfRunnable() { + @Override public void run() { fSession.addServiceEventListener(TracingConsole.this, null); } @@ -84,6 +85,7 @@ public class TracingConsole extends IOConsole { } try { fSession.getExecutor().submit(new DsfRunnable() { + @Override public void run() { fSession.removeServiceEventListener(TracingConsole.this); } @@ -99,6 +101,7 @@ public class TracingConsole extends IOConsole { private void setStreamInService() { try { fSession.getExecutor().submit(new DsfRunnable() { + @Override public void run() { DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), fSession.getId()); IGDBControl control = tracker.getService(IGDBControl.class); @@ -146,6 +149,7 @@ public class TracingConsole extends IOConsole { String name = getName(); if (!name.equals(newName)) { Runnable r = new Runnable() { + @Override public void run() { setName(newName); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java index 84176be6cb0..6a6d4c5a72b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/console/TracingConsoleManager.java @@ -108,21 +108,25 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang } } + @Override public void launchesAdded(ILaunch[] launches) { for (ILaunch launch : launches) { addConsole(launch); } } + @Override public void launchesChanged(ILaunch[] launches) { } + @Override public void launchesRemoved(ILaunch[] launches) { for (ILaunch launch : launches) { removeConsole(launch); } } + @Override public void launchesTerminated(ILaunch[] launches) { for (ILaunch launch : launches) { // Since we already had a console, don't get rid of it @@ -131,6 +135,7 @@ public class TracingConsoleManager implements ILaunchesListener2, IPropertyChang } } + @Override public void propertyChange(PropertyChangeEvent event) { if (event.getProperty().equals(IGdbDebugPreferenceConstants.PREF_TRACES_ENABLE)) { fTracingEnabled = (Boolean)event.getNewValue(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java index 9eeeca46aac..bb653b04059 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CArgumentsTab.java @@ -68,6 +68,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { Font font = parent.getFont(); Composite comp = new Composite(parent, SWT.NONE); @@ -111,6 +112,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { fPrgmArgumentsText.setLayoutData(gd); fPrgmArgumentsText.setFont(font); fPrgmArgumentsText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { updateLaunchConfigurationDialog(); } @@ -187,6 +189,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, (String) null); config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String) null); @@ -195,6 +198,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void initializeFrom(ILaunchConfiguration configuration) { try { fPrgmArgumentsText.setText(configuration.getAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, "")); //$NON-NLS-1$ @@ -209,6 +213,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute( ICDTLaunchConfigurationConstants.ATTR_PROGRAM_ARGUMENTS, @@ -239,6 +244,7 @@ public class CArgumentsTab extends CLaunchConfigurationTab { /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ + @Override public String getName() { return LaunchMessages.getString("CArgumentsTab.Arguments"); //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java index 41625aee268..b5dfc7a551b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CDebuggerTab.java @@ -91,6 +91,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { private Composite fContents; private IContentChangeListener fContentListener = new IContentChangeListener() { + @Override public void contentChanged() { contentsChanged(); } @@ -116,6 +117,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { return TAB_ID; } + @Override public void createControl(Composite parent) { fContainer = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL); fContainer.setLayoutData(new GridData(GridData.FILL_BOTH)); @@ -162,6 +164,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } } + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { setLaunchConfigurationWorkingCopy(config); ICDebuggerPage dynamicTab = getDynamicTab(); @@ -199,6 +202,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } } + @Override public void initializeFrom(ILaunchConfiguration config) { setInitializing(true); @@ -217,6 +221,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { setInitializing(false); } + @Override public void performApply(ILaunchConfigurationWorkingCopy config) { if (getDebuggerId() != null) { config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, getDebuggerId()); @@ -322,6 +327,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { gridData.widthHint = 100; fStopInMainSymbol.setLayoutData(gridData); fStopInMainSymbol.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { update(); } @@ -536,6 +542,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { return LaunchImages.get(LaunchImages.IMG_VIEW_DEBUGGER_TAB); } + @Override public String getName() { return LaunchMessages.getString("AbstractCDebuggerTab.Debugger"); //$NON-NLS-1$ } @@ -551,6 +558,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { fDCombo = new Combo(comboComp, SWT.READ_ONLY | SWT.DROP_DOWN); fDCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); fDCombo.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { if (!isInitializing()) { setInitializeDefault(true); @@ -558,6 +566,7 @@ public class CDebuggerTab extends CLaunchConfigurationTab { } } + @Override public void widgetDefaultSelected(SelectionEvent e) { } }); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java index cc979aa15f4..93a56874be6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CMainTab.java @@ -107,6 +107,7 @@ public class CMainTab extends CAbstractMainTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); setControl(comp); @@ -149,6 +150,7 @@ public class CMainTab extends CAbstractMainTab { gd = new GridData(GridData.FILL_HORIZONTAL); fProgText.setLayoutData(gd); fProgText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { updateLaunchConfigurationDialog(); } @@ -208,6 +210,7 @@ public class CMainTab extends CAbstractMainTab { gd = new GridData(GridData.FILL_HORIZONTAL); fCoreText.setLayoutData(gd); fCoreText.addModifyListener(new ModifyListener() { + @Override public void modifyText(ModifyEvent evt) { updateLaunchConfigurationDialog(); } @@ -237,11 +240,13 @@ public class CMainTab extends CAbstractMainTab { }); fCoreTypeCombo.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { updateCoreFileLabel(); updateLaunchConfigurationDialog(); } + @Override public void widgetDefaultSelected(SelectionEvent e) { } }); @@ -268,6 +273,7 @@ public class CMainTab extends CAbstractMainTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void initializeFrom(ILaunchConfiguration config) { filterPlatform = getPlatform(config); updateProjectFromConfig(config); @@ -500,6 +506,7 @@ public class CMainTab extends CAbstractMainTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { // We set empty attributes for project & program so that when one config is // compared to another, the existence of empty attributes doesn't cause and @@ -592,6 +599,7 @@ public class CMainTab extends CAbstractMainTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ + @Override public String getName() { return LaunchMessages.getString("CMainTab.Main"); //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java index c41e9c114cd..6d00780f285 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/CoreFilePrompter.java @@ -34,6 +34,7 @@ public class CoreFilePrompter implements IStatusHandler { * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, * java.lang.Object) */ + @Override public Object handleStatus(IStatus status, Object params) throws CoreException { final Shell shell = GdbUIPlugin.getShell(); if (shell == null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java index ab539f4bf2b..fd7ddaf98ac 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GDBSolibBlock.java @@ -54,6 +54,7 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC fAutoSolib = autoSolib; } + @Override public void createControl( Composite parent ) { Composite subComp = ControlFactory.createCompositeEx( parent, 1, GridData.FILL_HORIZONTAL ); ((GridLayout)subComp.getLayout()).makeColumnsEqualWidth = false; @@ -89,6 +90,7 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC fControl = subComp; } + @Override public void initializeFrom( ILaunchConfiguration configuration ) { if ( fSolibSearchPathBlock != null ) fSolibSearchPathBlock.initializeFrom( configuration ); @@ -104,6 +106,7 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC } } + @Override public void performApply( ILaunchConfigurationWorkingCopy configuration ) { if ( fSolibSearchPathBlock != null ) fSolibSearchPathBlock.performApply( configuration ); @@ -121,6 +124,7 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC } } + @Override public void setDefaults( ILaunchConfigurationWorkingCopy configuration ) { if ( fSolibSearchPathBlock != null ) fSolibSearchPathBlock.setDefaults( configuration ); @@ -131,6 +135,7 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC protected void updateButtons() { } + @Override public void dispose() { deleteObservers(); if ( fSolibSearchPathBlock != null ) { @@ -140,6 +145,7 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC } } + @Override public void update( Observable o, Object arg ) { changed(); } @@ -161,10 +167,12 @@ public class GDBSolibBlock extends Observable implements IMILaunchConfigurationC } } + @Override public Control getControl() { return fControl; } + @Override public boolean isValid( ILaunchConfiguration launchConfig ) { // TODO Auto-generated method stub return false; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java index 912e35bfedf..71b206e1fbf 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbCoreDebuggerPage.java @@ -53,6 +53,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ private IMILaunchConfigurationComponent fSolibBlock; private boolean fIsInitializing = false; + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); @@ -64,6 +65,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ setControl(parent); } + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); String defaultGdbCommand = preferenceStore.getString(IGdbDebugPreferenceConstants.PREF_DEFAULT_GDB_COMMAND); @@ -88,6 +90,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ return valid; } + @Override public void initializeFrom(ILaunchConfiguration configuration) { setInitializing(true); IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); @@ -114,6 +117,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ setInitializing(false); } + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, fGDBCommandText.getText().trim()); @@ -124,6 +128,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ fSolibBlock.performApply(configuration); } + @Override public String getName() { return LaunchUIMessages.getString("GDBDebuggerPage.tab_name"); //$NON-NLS-1$ } @@ -149,6 +154,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ * * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ + @Override public void update(Observable o, Object arg) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -181,7 +187,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ label.setLayoutData(gd); fGDBCommandText = ControlFactory.createTextField(subComp, SWT.SINGLE | SWT.BORDER); fGDBCommandText.addModifyListener(new ModifyListener() { - + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -218,7 +224,7 @@ public class GdbCoreDebuggerPage extends AbstractCDebuggerPage implements Observ gd = new GridData(GridData.FILL_HORIZONTAL); fGDBInitText.setLayoutData(gd); fGDBInitText.addModifyListener(new ModifyListener() { - + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java index f4f91de6799..64193d74e70 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/GdbDebuggerPage.java @@ -68,6 +68,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { private IMILaunchConfigurationComponent fSolibBlock; private boolean fIsInitializing = false; + @Override public void createControl(Composite parent) { Composite comp = new Composite(parent, SWT.NONE); comp.setLayout(new GridLayout()); @@ -79,6 +80,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { setControl(parent); } + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, @@ -130,6 +132,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { } } + @Override public void initializeFrom(ILaunchConfiguration configuration) { setInitializing(true); IPreferenceStore preferenceStore = GdbUIPlugin.getDefault().getPreferenceStore(); @@ -194,6 +197,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { return IGDBLaunchConfigurationConstants.DEBUGGER_TRACEPOINT_MODE_DEFAULT; } + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUG_NAME, fGDBCommandText.getText().trim()); @@ -217,6 +221,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fSolibBlock.performApply(configuration); } + @Override public String getName() { return LaunchUIMessages.getString("GDBDebuggerPage.tab_name"); //$NON-NLS-1$ } @@ -242,6 +247,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { * * @see java.util.Observer#update(java.util.Observable, java.lang.Object) */ + @Override public void update(Observable o, Object arg) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -274,7 +280,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { label.setLayoutData(gd); fGDBCommandText = ControlFactory.createTextField(subComp, SWT.SINGLE | SWT.BORDER); fGDBCommandText.addModifyListener(new ModifyListener() { - + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -311,7 +317,7 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { gd = new GridData(GridData.FILL_HORIZONTAL); fGDBInitText.setLayoutData(gd); fGDBInitText.addModifyListener(new ModifyListener() { - + @Override public void modifyText(ModifyEvent evt) { if (!isInitializing()) updateLaunchConfigurationDialog(); @@ -378,10 +384,12 @@ public class GdbDebuggerPage extends AbstractCDebuggerPage implements Observer { fTracepointModeCombo.add(TP_AUTOMATIC); fTracepointModeCombo.addSelectionListener(new SelectionListener() { + @Override public void widgetSelected(SelectionEvent e) { updateLaunchConfigurationDialog(); } + @Override public void widgetDefaultSelected(SelectionEvent e) { } }); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java index e2010daf80a..19a46e5335b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompter.java @@ -48,6 +48,7 @@ public class ProcessPrompter implements IStatusHandler { * @see org.eclipse.debug.core.IStatusHandler#handleStatus(org.eclipse.core.runtime.IStatus, * java.lang.Object) */ + @Override public Object handleStatus(IStatus status, Object info) throws CoreException { Shell shell = GdbUIPlugin.getShell(); if (shell == null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java index 93bf4fcf314..92f6ee216bd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/ProcessPrompterDialog.java @@ -103,6 +103,7 @@ public class ProcessPrompterDialog extends TwoPaneElementSelector { // Now add a listener to prevent selection list.addListener(SWT.EraseItem, new Listener() { + @Override public void handleEvent(Event event) { if ((event.detail & SWT.SELECTED) != 0) { event.detail &= ~SWT.SELECTED; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java index f67d15f0068..6f87f5ca9a3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/SolibSearchPathBlock.java @@ -269,6 +269,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { fShell = parent.getShell(); Composite comp = ControlFactory.createCompositeEx(parent, 2, GridData.FILL_BOTH); @@ -287,6 +288,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void initializeFrom(ILaunchConfiguration configuration) { IProject project = null; try { @@ -340,6 +342,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(IGDBLaunchConfigurationConstants.ATTR_DEBUGGER_SOLIB_PATH, Collections.EMPTY_LIST); } @@ -347,6 +350,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { if (fDirList != null) { @@ -410,6 +414,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#dispose() */ + @Override public void dispose() { deleteObservers(); } @@ -417,6 +422,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#getControl() */ + @Override public Control getControl() { return fControl; } @@ -424,6 +430,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu /* (non-Javadoc) * @see org.eclipse.cdt.debug.mi.internal.ui.IMILaunchConfigurationComponent#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public boolean isValid(ILaunchConfiguration launchConfig) { // TODO Auto-generated method stub return false; @@ -459,31 +466,31 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu final HashSet libs = new HashSet(10); if (generateLibraryList(dirList.toArray(new IPath[dirList.size()]), libs)) { ITreeContentProvider cp = new ITreeContentProvider() { - + @Override public Object[] getChildren(Object parentElement) { return getElements(parentElement); } - + @Override public Object getParent(Object element) { if (libs.contains(element)) return libs; return null; } - + @Override public boolean hasChildren(Object element) { return false; } - + @Override public Object[] getElements(Object inputElement) { if (inputElement instanceof Set) { return ((Set)inputElement).toArray(); } return new Object[0]; } - + @Override public void dispose() { } - + @Override public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { } }; @@ -517,6 +524,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu boolean result = true; IRunnableWithProgress runnable = new IRunnableWithProgress() { + @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { for (int i = 0; i < paths.length; ++i) { @@ -614,6 +622,7 @@ public class SolibSearchPathBlock extends Observable implements IMILaunchConfigu return (name.indexOf(".so.") >= 0); //$NON-NLS-1$ } + @Override public void dialogFieldChanged(DialogField field) { setChanged(); notifyObservers(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java index 076fd9366e4..77adc2ef96e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/launching/WorkingDirectoryBlock.java @@ -71,6 +71,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { */ private class WidgetListener extends SelectionAdapter implements ModifyListener { + @Override public void modifyText(ModifyEvent e) { updateLaunchConfigurationDialog(); } @@ -97,6 +98,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ + @Override public void createControl(Composite parent) { Font font = parent.getFont(); @@ -305,6 +307,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void setDefaults(ILaunchConfigurationWorkingCopy config) { // config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, // (String)null); @@ -315,6 +318,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ + @Override public void initializeFrom(ILaunchConfiguration configuration) { setLaunchConfiguration(configuration); try { @@ -338,6 +342,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ + @Override public void performApply(ILaunchConfigurationWorkingCopy configuration) { String wd = null; if (!isDefaultWorkingDirectory()) { @@ -364,6 +369,7 @@ public class WorkingDirectoryBlock extends CLaunchConfigurationTab { * * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ + @Override public String getName() { return LaunchUIMessages.getString("WorkingDirectoryBlock.Working_Directory_8"); //$NON-NLS-1$ } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java index 6993e02e459..7277956d3f1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/preferences/GdbDebugPreferencePage.java @@ -65,6 +65,7 @@ public class GdbDebugPreferencePage extends FieldEditorPreferencePage implements setDescription(MessagesForPreferences.GdbDebugPreferencePage_description); } + @Override public void init(IWorkbench workbench) { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java index bdfdae2e855..1f6201c7d01 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/CollectActionPage.java @@ -51,13 +51,16 @@ public class CollectActionPage extends PlatformObject implements IBreakpointActi return fCollectAction; } + @Override public void actionDialogCanceled() { } + @Override public void actionDialogOK() { fCollectAction.setCollectString(fCollectString.getText()); } + @Override public Composite createComposite(IBreakpointAction action, Composite composite, int style) { fCollectAction = (CollectAction) action; return createCollectActionComposite(composite, style); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java index b80b0ca2b97..ba13780f301 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/EvaluateActionPage.java @@ -52,13 +52,16 @@ public class EvaluateActionPage extends PlatformObject implements IBreakpointAct return fEvalAction; } + @Override public void actionDialogCanceled() { } + @Override public void actionDialogOK() { fEvalAction.setEvalString(fEvalString.getText()); } + @Override public Composite createComposite(IBreakpointAction action, Composite composite, int style) { fEvalAction = (EvaluateAction) action; return createEvaluateActionComposite(composite, style); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java index 1532ac64f1a..77918114f1d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/TracepointActionsPreferencePage.java @@ -61,6 +61,7 @@ public class TracepointActionsPreferencePage extends PreferencePage implements I } + @Override public void init(IWorkbench workbench) { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java index abc47339bac..e3c7f0ea1c6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepointactions/WhileSteppingActionPage.java @@ -125,9 +125,11 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi return fWhileSteppingAction; } + @Override public void actionDialogCanceled() { } + @Override public void actionDialogOK() { // Make sure we are dealing with an int int count = 1; @@ -141,6 +143,7 @@ public class WhileSteppingActionPage extends PlatformObject implements IBreakpoi fWhileSteppingAction.setSubActionsContent(actionsList.getActionNames()); } + @Override public Composite createComposite(IBreakpointAction action, Composite composite, int style) { fWhileSteppingAction = (WhileSteppingAction)action; return createWhileSteppingActionComposite(composite, style); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java index 1e6a127eb14..d7b0714f36b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceControlView.java @@ -124,6 +124,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde @Override public void run() { asyncExec(new Runnable() { + @Override public void run() { exitVisualizationMode(); updateActionEnablement(); @@ -152,6 +153,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde super.init(site); site.getPage().addSelectionListener(IDebugUIConstants.ID_DEBUG_VIEW, fDebugViewListener = new ISelectionListener() { + @Override public void selectionChanged(IWorkbenchPart part, ISelection selection) { updateDebugContext(); }}); @@ -221,6 +223,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde if (ctx != null) { getSession().getExecutor().execute( new DsfRunnable() { + @Override public void run() { final IGDBTraceControl traceControl = getService(IGDBTraceControl.class); if (traceControl != null) { @@ -247,6 +250,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde final String finalStatus = traceStatus; asyncExec(new Runnable() { + @Override public void run() { fStatusText.setText(finalStatus); updateActionEnablement(); @@ -257,6 +261,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde fTracingSupported = false; asyncExec(new Runnable() { + @Override public void run() { fStatusText.setText(EMPTY_STRING); updateActionEnablement(); @@ -287,6 +292,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde getSession().getExecutor().execute( new DsfRunnable() { + @Override public void run() { final IGDBTraceControl traceControl = getService(IGDBTraceControl.class); if (traceControl != null) { @@ -316,6 +322,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde try { final DsfSession session = getSession(); session.getExecutor().execute(new DsfRunnable() { + @Override public void run() { session.removeServiceEventListener(TraceControlView.this); } @@ -336,6 +343,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde try { final DsfSession session = getSession(); session.getExecutor().execute(new DsfRunnable() { + @Override public void run() { session.removeServiceEventListener(TraceControlView.this); } @@ -363,6 +371,7 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde try { final DsfSession session = getSession(); session.getExecutor().execute(new DsfRunnable() { + @Override public void run() { session.addServiceEventListener(TraceControlView.this, null); } @@ -395,9 +404,11 @@ public class TraceControlView extends ViewPart implements IViewPart, SessionEnde } } + @Override public void sessionEnded(DsfSession session) { if (session.getId().equals(fDebugSessionId)) { asyncExec(new Runnable() { + @Override public void run() { setDebugContext(null); }}); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java index 8df6738368a..e414bcafc99 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/tracepoints/TraceVarDetailsDialog.java @@ -168,6 +168,7 @@ public final class TraceVarDetailsDialog extends Dialog { warningTextLabel = new Label(createButtonComposite, SWT.NONE); warningTextLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); parent.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent e) { if (warningImage != null) warningImage.dispose(); @@ -177,9 +178,11 @@ public final class TraceVarDetailsDialog extends Dialog { // When the user goes into either input field, then pressing return // should try to create the command FocusListener clearWarningFocusListener = new FocusListener() { + @Override public void focusGained(FocusEvent e) { getShell().setDefaultButton(createButton); } + @Override public void focusLost(FocusEvent e) { } }; @@ -189,6 +192,7 @@ public final class TraceVarDetailsDialog extends Dialog { // When the user modifies any entry in the input, we should clear any warning ModifyListener clearWarningListener = new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { setWarningVisible(false); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java index 424438918f6..2deb784576c 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbExpressionVMProvider.java @@ -70,6 +70,7 @@ public class GdbExpressionVMProvider extends ExpressionVMProvider { } fPreferencesListener = new IPropertyChangeListener() { + @Override public void propertyChange(final PropertyChangeEvent event) { handlePropertyChanged(store, event); }}; @@ -190,6 +191,7 @@ public class GdbExpressionVMProvider extends ExpressionVMProvider { final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent( exprCtx, path); getExecutor().execute(new DsfRunnable() { + @Override public void run() { handleEvent(fetchMoreChildrenEvent, rm); } @@ -225,6 +227,7 @@ public class GdbExpressionVMProvider extends ExpressionVMProvider { } getExecutor().execute(new DsfRunnable() { + @Override public void run() { handleEvent(event); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java index 934a304ac01..2d6eaf50e24 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMNode.java @@ -108,10 +108,12 @@ public class GdbVariableVMNode extends VariableVMNode { /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#getSize() */ + @Override public void getSize(final ICWatchpointTarget.GetSizeRequest request) { final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class); if (exprDmc != null) { getSession().getExecutor().execute(new Runnable() { + @Override public void run() { final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); if (expressionService != null) { @@ -144,6 +146,7 @@ public class GdbVariableVMNode extends VariableVMNode { /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.IWatchpointTarget#canCreateWatchpoint(org.eclipse.cdt.debug.internal.core.IWatchpointTarget.CanCreateWatchpointRequest) */ + @Override public void canSetWatchpoint(final ICWatchpointTarget.CanCreateWatchpointRequest request) { // If the expression is an l-value, then we say it supports a // watchpoint. The logic here is basically the same as what's in @@ -152,6 +155,7 @@ public class GdbVariableVMNode extends VariableVMNode { final IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(getDMContext(), IExpressionDMContext.class); if (exprDmc != null) { getSession().getExecutor().execute(new Runnable() { + @Override public void run() { final IExpressions expressionService = getServicesTracker().getService(IExpressions.class); if (expressionService != null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java index 7832b053c30..a3a89ceb64e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/GdbVariableVMProvider.java @@ -62,6 +62,7 @@ public class GdbVariableVMProvider extends VariableVMProvider { } fPreferencesListener = new IPropertyChangeListener() { + @Override public void propertyChange(final PropertyChangeEvent event) { handlePropertyChanged(store, event); }}; @@ -127,6 +128,7 @@ public class GdbVariableVMProvider extends VariableVMProvider { final FetchMoreChildrenEvent fetchMoreChildrenEvent = new FetchMoreChildrenEvent( exprCtx, path); getExecutor().execute(new DsfRunnable() { + @Override public void run() { handleEvent(fetchMoreChildrenEvent, rm); } @@ -162,6 +164,7 @@ public class GdbVariableVMProvider extends VariableVMProvider { } getExecutor().execute(new DsfRunnable() { + @Override public void run() { handleEvent(event); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java index 9c63633e01f..b6b20dc5618 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/breakpoints/GdbBreakpointVMProvider.java @@ -104,6 +104,7 @@ public class GdbBreakpointVMProvider extends BreakpointVMProvider { try { fSession.getExecutor().execute(new DsfRunnable() { + @Override public void run() { IBreakpointsExtension bpService = fServicesTracker.getService(IBreakpointsExtension.class); if (bpService == null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java index 9834ccc58a4..ccbde94b82d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/commands/RetargetDebugContextCommand.java @@ -59,6 +59,7 @@ abstract public class RetargetDebugContextCommand extends AbstractHandler implem update(); } + @Override public Object execute(ExecutionEvent event) throws ExecutionException { fCommandId = event.getCommand().getId(); @@ -137,6 +138,7 @@ abstract public class RetargetDebugContextCommand extends AbstractHandler implem fTargetAdapter = null; } + @Override public void debugContextChanged(DebugContextEvent event) { fDebugContext = event.getContext(); update(); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java index 76233d36347..b727c78a20d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ContainerVMNode.java @@ -328,6 +328,7 @@ public class ContainerVMNode extends AbstractContainerVMNode */ private final String MEMENTO_NAME = "CONTAINER_MEMENTO_NAME"; //$NON-NLS-1$ + @Override public void compareElements(IElementCompareRequest[] requests) { for (final IElementCompareRequest request : requests) { @@ -347,6 +348,7 @@ public class ContainerVMNode extends AbstractContainerVMNode if (procDmc != null) { try { getSession().getExecutor().execute(new DsfRunnable() { + @Override public void run() { final IProcesses processService = getServicesTracker().getService(IProcesses.class); if (processService != null) { @@ -384,6 +386,7 @@ public class ContainerVMNode extends AbstractContainerVMNode * (non-Javadoc) * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) */ + @Override public void encodeElements(IElementMementoRequest[] requests) { for (final IElementMementoRequest request : requests) { @@ -401,6 +404,7 @@ public class ContainerVMNode extends AbstractContainerVMNode if (procDmc != null) { try { getSession().getExecutor().execute(new DsfRunnable() { + @Override public void run() { final IProcesses processService = getServicesTracker().getService(IProcesses.class); if (processService != null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java index f7f32928ce8..16a0d1d0f57 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/LaunchVMProvider.java @@ -144,6 +144,7 @@ public class LaunchVMProvider extends AbstractLaunchVMProvider super.refresh(); try { getSession().getExecutor().execute(new DsfRunnable() { + @Override public void run() { DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), getSession().getId()); IProcesses processesService = tracker.getService(IProcesses.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java index 4b56d0dee91..03887ccf20b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.ui/src/org/eclipse/cdt/dsf/gdb/internal/ui/viewmodel/launch/ThreadVMNode.java @@ -287,6 +287,7 @@ public class ThreadVMNode extends AbstractThreadVMNode /* * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#compareElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest[]) */ + @Override public void compareElements(IElementCompareRequest[] requests) { for ( IElementCompareRequest request : requests ) { @@ -314,6 +315,7 @@ public class ThreadVMNode extends AbstractThreadVMNode /* * @see org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider#encodeElements(org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest[]) */ + @Override public void encodeElements(IElementMementoRequest[] requests) { for ( IElementMementoRequest request : requests ) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/breakpoints/CBreakpointGdbThreadsFilterExtension.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/breakpoints/CBreakpointGdbThreadsFilterExtension.java index 74d59bb728d..a9c4e41f203 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/breakpoints/CBreakpointGdbThreadsFilterExtension.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/breakpoints/CBreakpointGdbThreadsFilterExtension.java @@ -34,12 +34,14 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpointExtension#initialize(org.eclipse.cdt.debug.core.model.ICBreakpoint) */ + @Override public void initialize(ICBreakpoint breakpoint) { } /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getTargetFilters() */ + @Override public IContainerDMContext[] getTargetFilters() throws CoreException { Set set = fFilteredThreadsByTarget.keySet(); return set.toArray( new IContainerDMContext[set.size()] ); @@ -48,6 +50,7 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#getThreadFilters(org.eclipse.cdt.debug.core.model.ICDebugTarget) */ + @Override public IExecutionDMContext[] getThreadFilters( IContainerDMContext target ) throws CoreException { Set set = fFilteredThreadsByTarget.get( target ); return ( set != null ) ? set.toArray( new IExecutionDMContext[set.size()] ) : null; @@ -56,6 +59,7 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#removeTargetFilter(org.eclipse.cdt.debug.core.model.ICDebugTarget) */ + @Override public void removeTargetFilter( IContainerDMContext target ) throws CoreException { if ( fFilteredThreadsByTarget.containsKey( target ) ) { fFilteredThreadsByTarget.remove( target ); @@ -65,6 +69,7 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#removeThreadFilters(org.eclipse.cdt.debug.core.model.ICThread[]) */ + @Override public void removeThreadFilters( IExecutionDMContext[] threads ) throws CoreException { if ( threads != null && threads.length > 0 ) { IContainerDMContext target = DMContexts.getAncestorOfType(threads[0], IContainerDMContext.class); @@ -83,6 +88,7 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setTargetFilter(org.eclipse.cdt.debug.core.model.ICDebugTarget) */ + @Override public void setTargetFilter( IContainerDMContext target ) throws CoreException { fFilteredThreadsByTarget.put( target, null ); } @@ -90,6 +96,7 @@ public class CBreakpointGdbThreadsFilterExtension implements IDsfBreakpointExten /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.ICBreakpoint#setThreadFilters(org.eclipse.cdt.debug.core.model.ICThread[]) */ + @Override public void setThreadFilters( IExecutionDMContext[] threads ) throws CoreException { if ( threads != null && threads.length > 0 ) { IContainerDMContext target = DMContexts.getAncestorOfType(threads[0], IContainerDMContext.class); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java index 7f19800fbd9..802e89834ec 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlock.java @@ -70,6 +70,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IMemorySpaces.IMemorySpaceDMContext#getMemorySpaceId() */ + @Override public String getMemorySpaceId() { return fMemorySpaceId; } @@ -245,6 +246,7 @@ public class GdbMemoryBlock extends DsfMemoryBlock implements IMemorySpaceAwareM /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.model.provisional.IMemorySpaceAwareMemoryBlock#getMemorySpaceID() */ + @Override public String getMemorySpaceID() { return fMemorySpaceID; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java index 1081e67f2f7..61184df3544 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/memory/GdbMemoryBlockRetrieval.java @@ -106,6 +106,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval#getExtendedMemoryBlock(java.lang.String, java.lang.Object, java.lang.String) */ + @Override public IMemorySpaceAwareMemoryBlock getMemoryBlock(String expression, Object context, String memorySpaceID) throws DebugException { // Drill for the actual DMC IMemoryDMContext memoryDmc = null; @@ -185,6 +186,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements * implementation of * @see org.eclipse.cdt.debug.internal.core.model.provisional.IMemorySpaceManagement#getMemorySpaces(Object context) */ + @Override public void getMemorySpaces(final Object context, final GetMemorySpacesRequest request) { Query query = new Query() { @Override @@ -227,6 +229,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval#encodeAddress(java.lang.String, java.lang.String) */ + @Override public String encodeAddress(String expression, String memorySpaceID) { String result = null; IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService(); @@ -244,13 +247,16 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval#decodeAddress(java.lang.String) */ + @Override public DecodeResult decodeAddress(String str) throws CoreException { IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService(); if (service != null) { final IMemorySpaces.DecodeResult result = service.decodeAddress(str); if (result != null) { // service can return null to tell use to use default decoding return new DecodeResult() { + @Override public String getMemorySpaceId() { return result.getMemorySpaceId(); } + @Override public String getExpression() { return result.getExpression(); } }; } @@ -265,7 +271,9 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements final String memorySpaceID = str.substring(0, index); final String expression = (index < str.length()-1) ? str.substring(index+1) : ""; //$NON-NLS-1$ return new DecodeResult() { + @Override public String getMemorySpaceId() { return memorySpaceID; } + @Override public String getExpression() { return expression; } }; @@ -365,6 +373,7 @@ public class GdbMemoryBlockRetrieval extends DsfMemoryBlockRetrieval implements /* (non-Javadoc) * @see org.eclipse.cdt.debug.core.model.provisional.IMemorySpaceAwareMemoryBlockRetrieval#creatingBlockRequiresMemorySpaceID() */ + @Override public boolean creatingBlockRequiresMemorySpaceID() { IMemorySpaces service = (IMemorySpaces)fMemorySpaceServiceTracker.getService(); if (service != null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/AbstractTracepointAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/AbstractTracepointAction.java index 9f6f25e13be..82f7450db10 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/AbstractTracepointAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/AbstractTracepointAction.java @@ -25,6 +25,7 @@ public abstract class AbstractTracepointAction extends AbstractBreakpointAction /** * Tracepoint commands, by default, are not executed in Eclipse, but are executed by the backend. */ + @Override public IStatus execute(IBreakpoint breakpoint, IAdaptable context, IProgressMonitor monitor) { return new Status(IStatus.OK, GdbPlugin.PLUGIN_ID, null); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java index ee082704b51..b69eba9985a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/CollectAction.java @@ -37,6 +37,7 @@ public class CollectAction extends AbstractTracepointAction { private String fCollectString = ""; //$NON-NLS-1$ + @Override public String getDefaultName() { return MessagesForTracepointActions.TracepointActions_Untitled_Collect; } @@ -49,10 +50,12 @@ public class CollectAction extends AbstractTracepointAction { fCollectString = str; } + @Override public String getIdentifier() { return COLLECT_ACTION_ID; } + @Override public String getMemento() { String collectData = new String(""); //$NON-NLS-1$ @@ -86,14 +89,17 @@ public class CollectAction extends AbstractTracepointAction { return collectData; } + @Override public String getSummary() { return MessageFormat.format(MessagesForTracepointActions.TracepointActions_Collect_text, new Object[] { fCollectString }); } + @Override public String getTypeName() { return MessagesForTracepointActions.TracepointActions_Collect_Name; } + @Override public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java index 0d51805c130..da8a8a7574a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/EvaluateAction.java @@ -36,6 +36,7 @@ public class EvaluateAction extends AbstractTracepointAction { private String fEvalString = ""; //$NON-NLS-1$ + @Override public String getDefaultName() { return MessagesForTracepointActions.TracepointActions_Untitled_Evaluate; } @@ -48,10 +49,12 @@ public class EvaluateAction extends AbstractTracepointAction { fEvalString = str; } + @Override public String getIdentifier() { return EVALUATE_ACTION_ID; } + @Override public String getMemento() { String collectData = new String(""); //$NON-NLS-1$ @@ -85,14 +88,17 @@ public class EvaluateAction extends AbstractTracepointAction { return collectData; } + @Override public String getSummary() { return MessageFormat.format(MessagesForTracepointActions.TracepointActions_Evaluate_text, new Object[] { fEvalString }); } + @Override public String getTypeName() { return MessagesForTracepointActions.TracepointActions_Evaluate_Name; } + @Override public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java index bfbb96713b2..8c509cd5267 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/internal/tracepointactions/WhileSteppingAction.java @@ -42,6 +42,7 @@ public class WhileSteppingAction extends AbstractTracepointAction { // The number of steps this while-stepping command will occur private int fStepCount = 1; + @Override public String getDefaultName() { return MessagesForTracepointActions.TracepointActions_Untitled_WhileStepping; } @@ -84,10 +85,12 @@ public class WhileSteppingAction extends AbstractTracepointAction { fStepCount = count; } + @Override public String getIdentifier() { return WHILE_STEPPING_ACTION_ID; } + @Override public String getMemento() { String collectData = new String(""); //$NON-NLS-1$ @@ -122,14 +125,17 @@ public class WhileSteppingAction extends AbstractTracepointAction { return collectData; } + @Override public String getSummary() { return MessageFormat.format(MessagesForTracepointActions.TracepointActions_WhileStepping_text, new Object[] { fStepCount, fSubActionContent }); } + @Override public String getTypeName() { return MessagesForTracepointActions.TracepointActions_WhileStepping_Name; } + @Override public void initializeFromMemento(String data) { Element root = null; DocumentBuilder parser; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java index 9ab997480a6..92ee9fb219d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence.java @@ -11,6 +11,7 @@ * IBM Corporation * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) * Sergey Prigogin (Google) + * Marc Khouzam (Ericsson) - No longer call method to check non-stop for GDB < 7.0 (Bug 365471) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.launching; @@ -79,7 +80,6 @@ public class FinalLaunchSequence extends ReflectionSequence { "stepSetBreakpointPending", //$NON-NLS-1$ "stepEnablePrettyPrinting", //$NON-NLS-1$ "stepSourceGDBInitFile", //$NON-NLS-1$ - "stepSetNonStop", //$NON-NLS-1$ "stepSetAutoLoadSharedLibrarySymbols", //$NON-NLS-1$ "stepSetSharedLibraryPaths", //$NON-NLS-1$ @@ -251,6 +251,9 @@ public class FinalLaunchSequence extends ReflectionSequence { * Enable non-stop mode if requested. * @since 4.0 */ + // Keep this method in this class for backwards-compatibility, although + // it is called only by sub-classes. + // It could be moved to FinalLaunchSequence_7_0, otherwise. @Execute public void stepSetNonStop(final RequestMonitor requestMonitor) { boolean isNonStop = CDebugUtils.getAttribute( @@ -280,7 +283,17 @@ public class FinalLaunchSequence extends ReflectionSequence { } }); } else { - requestMonitor.done(); + // Explicitly set target-async to off for all-stop mode. + fCommandControl.queueCommand( + fCommandFactory.createMIGDBSetTargetAsync(fCommandControl.getContext(), false), + new DataRequestMonitor(getExecutor(), requestMonitor) { + @Override + protected void handleError() { + // We should only be calling this for GDB >= 7.0, + // but just in case, accept errors for older GDBs + requestMonitor.done(); + } + }); } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java new file mode 100644 index 00000000000..19f2d875f8d --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_0.java @@ -0,0 +1,62 @@ +/******************************************************************************* + * Copyright (c) 2011 Ericsson 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: + * Marc Khouzam (Ericsson) - initial API and implementation (Bug 365471) + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.launching; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.concurrent.RequestMonitorWithProgress; +import org.eclipse.cdt.dsf.service.DsfSession; + +/** + * Subclass for GDB >= 7.0. + * This class currently sets non-stop mode, or makes + * sure target-async is off for all-stop. + * + * @since 4.1 + */ +public class FinalLaunchSequence_7_0 extends FinalLaunchSequence { + + public FinalLaunchSequence_7_0(DsfSession session, Map attributes, RequestMonitorWithProgress rm) { + super(session, attributes, rm); + } + + @Override + protected String[] getExecutionOrder(String group) { + if (GROUP_TOP_LEVEL.equals(group)) { + // Initialize the list with the base class' steps + // We need to create a list that we can modify, which is why we create our own ArrayList. + List orderList = new ArrayList(Arrays.asList(super.getExecutionOrder(GROUP_TOP_LEVEL))); + + // Now insert our steps right after the initialization of the base class. + orderList.add(orderList.indexOf("stepInitializeFinalLaunchSequence") + 1, "stepInitializeFinalLaunchSequence_7_0"); //$NON-NLS-1$ //$NON-NLS-2$ + + // Note that stepSetNonStop is defined in the base class for backwards-compatibility + orderList.add(orderList.indexOf("stepSourceGDBInitFile") + 1, "stepSetNonStop"); //$NON-NLS-1$ //$NON-NLS-2$ + + return orderList.toArray(new String[orderList.size()]); + } + + return null; + } + + /** + * Initialize the members of the FinalLaunchSequence_7_0 class. + * This step is mandatory for the rest of the sequence to complete. + */ + @Execute + public void stepInitializeFinalLaunchSequence_7_0(RequestMonitor rm) { + rm.done(); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_2.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_2.java index ae5cdd7ad35..f5b1683c5a3 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_2.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/FinalLaunchSequence_7_2.java @@ -7,6 +7,7 @@ * * Contributors: * Ericsson - initial API and implementation + * Marc Khouzam (Ericsson) - Use new FinalLaunchSequence_7_0 as base class (Bug 365471) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.launching; @@ -34,7 +35,7 @@ import org.eclipse.core.runtime.Status; * * @since 4.0 */ -public class FinalLaunchSequence_7_2 extends FinalLaunchSequence { +public class FinalLaunchSequence_7_2 extends FinalLaunchSequence_7_0 { private IGDBControl fGdbControl; private DsfSession fSession; @@ -56,7 +57,7 @@ public class FinalLaunchSequence_7_2 extends FinalLaunchSequence { List orderList = new ArrayList(Arrays.asList(super.getExecutionOrder(GROUP_TOP_LEVEL))); // Now insert our steps right after the initialization of the base class. - orderList.add(orderList.indexOf("stepInitializeFinalLaunchSequence") + 1, "stepInitializeFinalLaunchSequence_7_2"); //$NON-NLS-1$ //$NON-NLS-2$ + orderList.add(orderList.indexOf("stepInitializeFinalLaunchSequence_7_0") + 1, "stepInitializeFinalLaunchSequence_7_2"); //$NON-NLS-1$ //$NON-NLS-2$ orderList.add(orderList.indexOf("stepSetBreakpointPending") + 1, "stepDetachOnFork"); //$NON-NLS-1$ //$NON-NLS-2$ return orderList.toArray(new String[orderList.size()]); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java index 699795ae7e6..c12d53cf518 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/GdbLaunch.java @@ -103,6 +103,7 @@ public class GdbLaunch extends DsfLaunch fSession.registerModelAdapter(ILaunch.class, this); Runnable initRunnable = new DsfRunnable() { + @Override public void run() { fTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fSession.getId()); fSession.addServiceEventListener(GdbLaunch.this, null); @@ -128,6 +129,7 @@ public class GdbLaunch extends DsfLaunch // Create a memory retrieval and register it with the session try { fExecutor.submit( new Callable() { + @Override public Object call() throws CoreException { ICommandControlService commandControl = fTracker.getService(ICommandControlService.class); IMIProcesses procService = fTracker.getService(IMIProcesses.class); @@ -160,6 +162,7 @@ public class GdbLaunch extends DsfLaunch // Add the CLI process object to the launch. AbstractCLIProcess cliProc = getDsfExecutor().submit( new Callable() { + @Override public AbstractCLIProcess call() throws CoreException { IGDBControl gdb = fTracker.getService(IGDBControl.class); if (gdb != null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java index 59bb8d964b8..7f7a1256583 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/launching/ShutdownSequence.java @@ -93,6 +93,7 @@ public class ShutdownSequence extends Sequence { } Collections.sort( services, new Comparator() { + @Override public int compare( IDsfService o1, IDsfService o2 ) { return o2.getStartupNumber() - o1.getStartupNumber(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java index 8af2b962ee4..5eaccda0f6e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/GdbDebugServicesFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2011 Ericsson and others. + * Copyright (c) 2008, 2012 Ericsson 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 @@ -9,6 +9,7 @@ * Ericsson - initial API and implementation * Nokia - create and use backend service. * Onur Akdemir (TUBITAK BILGEM-ITI) - Multi-process debugging (Bug 237306) + * Marc Khouzam (Ericsson) - Support for GDB 7.4 (Bug 367788) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.service; @@ -29,6 +30,7 @@ import org.eclipse.cdt.dsf.gdb.service.command.CommandFactory_6_8; import org.eclipse.cdt.dsf.gdb.service.command.GDBControl; import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_0; import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_2; +import org.eclipse.cdt.dsf.gdb.service.command.GDBControl_7_4; import org.eclipse.cdt.dsf.mi.service.CSourceLookup; import org.eclipse.cdt.dsf.mi.service.IMIBackend; import org.eclipse.cdt.dsf.mi.service.MIBreakpoints; @@ -55,7 +57,11 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { public static final String GDB_7_2_VERSION = "7.2"; //$NON-NLS-1$ /** @since 4.1 */ public static final String GDB_7_2_1_VERSION = "7.2.1"; //$NON-NLS-1$ - + + // Keep private until GDB 7.4 is released and we can change the constant + // to its proper value of 7.4 + private static final String GDB_7_4_VERSION = "7.3.50"; //$NON-NLS-1$ + private final String fVersion; public GdbDebugServicesFactory(String version) { @@ -112,6 +118,9 @@ public class GdbDebugServicesFactory extends AbstractDsfDebugServicesFactory { } protected ICommandControl createCommandControl(DsfSession session, ILaunchConfiguration config) { + if (GDB_7_4_VERSION.compareTo(fVersion) <= 0) { + return new GDBControl_7_4(session, config, new CommandFactory_6_8()); + } if (GDB_7_2_VERSION.compareTo(fVersion) <= 0) { return new GDBControl_7_2(session, config, new CommandFactory_6_8()); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java index 09c8cced6c4..ebbcf745d65 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_0.java @@ -11,6 +11,7 @@ * Ericsson - New version for 7_0 * Vladimir Prus (CodeSourcery) - Support for -data-read-memory-bytes (bug 322658) * Jens Elmenthaler (Verigy) - Added Full GDB pretty-printing support (bug 302121) + * Marc Khouzam (Ericsson) - Call new FinalLaunchSequence_7_0 (Bug 365471) *******************************************************************************/ package org.eclipse.cdt.dsf.gdb.service.command; @@ -38,7 +39,7 @@ import org.eclipse.cdt.dsf.datamodel.AbstractDMEvent; import org.eclipse.cdt.dsf.debug.service.command.ICommandControl; import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService; import org.eclipse.cdt.dsf.gdb.internal.GdbPlugin; -import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence; +import org.eclipse.cdt.dsf.gdb.launching.FinalLaunchSequence_7_0; import org.eclipse.cdt.dsf.gdb.service.IGDBBackend; import org.eclipse.cdt.dsf.gdb.service.IGDBTraceControl.ITraceRecordSelectedChangedDMEvent; import org.eclipse.cdt.dsf.mi.service.IMIBackend; @@ -170,6 +171,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { } + @Override public String getId() { return fMIBackend.getId(); } @@ -179,10 +181,12 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { return fControlDmc; } + @Override public ICommandControlDMContext getContext() { return fControlDmc; } + @Override public void terminate(final RequestMonitor rm) { if (fTerminated) { rm.done(); @@ -204,6 +208,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { // runnable will kill the task. final Future forceQuitTask = getExecutor().schedule( new DsfRunnable() { + @Override public void run() { fMIBackend.destroy(); rm.done(); @@ -246,6 +251,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { }); } + @Override public AbstractCLIProcess getCLIProcess() { return fCLIProcess; } @@ -253,11 +259,13 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { /** * @since 2.0 */ + @Override public void setTracingStream(OutputStream tracingStream) { setMITracingStream(tracingStream); } /** @since 3.0 */ + @Override public void setEnvironment(Properties props, boolean clear, RequestMonitor rm) { int count = 0; CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), rm); @@ -285,6 +293,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { /** * @since 4.0 */ + @Override @SuppressWarnings("unchecked") public void completeInitialization(final RequestMonitor rm) { // We take the attributes from the launchConfiguration @@ -321,10 +330,11 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { * @since 4.0 */ protected Sequence getCompleteInitializationSequence(Map attributes, RequestMonitorWithProgress rm) { - return new FinalLaunchSequence(getSession(), attributes, rm); + return new FinalLaunchSequence_7_0(getSession(), attributes, rm); } /**@since 4.0 */ + @Override public List getFeatures() { return fFeatures; } @@ -468,9 +478,8 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { /** * @since 4.0 */ - public void enablePrettyPrintingForMIVariableObjects( - final RequestMonitor rm) { - + @Override + public void enablePrettyPrintingForMIVariableObjects(RequestMonitor rm) { queueCommand( getCommandFactory().createMIEnablePrettyPrinting(fControlDmc), new DataRequestMonitor(getExecutor(), rm)); @@ -479,6 +488,7 @@ public class GDBControl_7_0 extends AbstractMIControl implements IGDBControl { /** * @since 4.0 */ + @Override public void setPrintPythonErrors(boolean enabled, RequestMonitor rm) { String subCommand = "set python print-stack " + (enabled ? "on" : "off"); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_4.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_4.java new file mode 100644 index 00000000000..16fcb5317fd --- /dev/null +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/gdb/service/command/GDBControl_7_4.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2012 Ericsson 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: + * Marc Khouzam (Ericsson) - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.gdb.service.command; + +import org.eclipse.cdt.dsf.concurrent.RequestMonitor; +import org.eclipse.cdt.dsf.mi.service.command.CommandFactory; +import org.eclipse.cdt.dsf.service.DsfSession; +import org.eclipse.debug.core.ILaunchConfiguration; + +/** + * With GDB 7.4, the command 'maintenance set python print-stack' is not supported. + * The new command "set python print-stack none|full|message" has replaced it, with + * the default being 'message'. With this new default + * @since 4.1 + */ +public class GDBControl_7_4 extends GDBControl_7_2 implements IGDBControl { + public GDBControl_7_4(DsfSession session, ILaunchConfiguration config, CommandFactory factory) { + super(session, config, factory); + setUseThreadGroupOptions(true); + } + + @Override + public void setPrintPythonErrors(boolean enabled, RequestMonitor rm) { + // With GDB 7.4, the command 'maintenance set python print-stack' is not supported. + // The new command "set python print-stack none|full|message" has replaced it, with + // the default being 'message'. This new default is good enough for us, so no + // need to do anything anymore. + // Bug 367788 + rm.done(); + } +} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java index b93975d2c57..5afc35c68dd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/CSourceLookup.java @@ -148,6 +148,7 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup { super.shutdown(requestMonitor); } + @Override public void getDebuggerPath(ISourceLookupDMContext sourceLookupCtx, Object source, final DataRequestMonitor rm) { if (!(source instanceof String)) { // In future if needed other elements such as URIs could be supported. @@ -179,6 +180,7 @@ public class CSourceLookup extends AbstractDsfService implements ISourceLookup { }.schedule(); } + @Override public void getSource(ISourceLookupDMContext sourceLookupCtx, final String debuggerPath, final DataRequestMonitor rm) { if (!fDirectors.containsKey(sourceLookupCtx)) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java index afe3b74f9fa..e9e311cfc34 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointDMData.java @@ -218,6 +218,7 @@ public class MIBreakpointDMData implements IBreakpointDMData { // IBreakpointDMData /////////////////////////////////////////////////////////////////////////// + @Override public String getBreakpointType() { return (String) fProperties.get(MIBreakpoints.BREAKPOINT_TYPE); } @@ -226,36 +227,44 @@ public class MIBreakpointDMData implements IBreakpointDMData { return fBreakpoint.getNumber(); } + @Override public IAddress[] getAddresses() { IAddress[] addresses = new IAddress[1]; addresses[0] = new Addr64(fBreakpoint.getAddress()); return addresses; } + @Override public String getCondition() { return fBreakpoint.getCondition(); } + @Override public String getExpression() { return fBreakpoint.getExpression(); } + @Override public String getFileName() { return fBreakpoint.getFile(); } + @Override public String getFunctionName() { return fBreakpoint.getFunction(); } + @Override public int getIgnoreCount() { return fBreakpoint.getIgnoreCount(); } + @Override public int getLineNumber() { return fBreakpoint.getLine(); } + @Override public boolean isEnabled() { return fBreakpoint.isEnabled(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java index c449af45af7..345b35b49dd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpoints.java @@ -188,6 +188,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I super(DMContexts.getAncestorOfType(bp, IBreakpointsTargetDMContext.class)); fEventBreakpoints = new IBreakpointDMContext[] { bp }; } + @Override public IBreakpointDMContext[] getBreakpoints() { return fEventBreakpoints; } @@ -383,6 +384,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#getBreakpoints(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getBreakpoints(final IBreakpointsTargetDMContext context, final DataRequestMonitor drm) { // Validate the context @@ -430,6 +432,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#getBreakpointDMData(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IDsfBreakpointDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getBreakpointDMData(IBreakpointDMContext dmc, DataRequestMonitor drm) { // Validate the breakpoint context @@ -479,6 +482,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#insertBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointsTargetDMContext, java.util.Map, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void insertBreakpoint(IBreakpointsTargetDMContext context, Map attributes, DataRequestMonitor drm) { // Validate the context @@ -524,6 +528,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I /** * @since 3.0 */ + @Override public void getExecutionContextBreakpoints(IExecutionDMContext ctx, DataRequestMonitor rm) { IBreakpointDMContext[] bps = fBreakpointHitMap.get(ctx); if (bps == null && ctx instanceof IContainerDMContext) { @@ -866,6 +871,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#removeBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void removeBreakpoint(final IBreakpointDMContext dmc, final RequestMonitor finalRm) { // Validate the breakpoint context @@ -940,6 +946,7 @@ public class MIBreakpoints extends AbstractDsfService implements IBreakpoints, I /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IBreakpoints#updateBreakpoint(org.eclipse.cdt.dsf.debug.service.IBreakpoints.IBreakpointDMContext, java.util.Map, org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void updateBreakpoint(IBreakpointDMContext dmc, Map properties, RequestMonitor rm) { // Validate the breakpoint context diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java index 211992419e0..d9f92ccf869 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIBreakpointsManager.java @@ -365,7 +365,8 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo protected IStatus run(IProgressMonitor monitor) { // Submit the runnable to plant the breakpoints on dispatch thread. getExecutor().submit(new Runnable() { - public void run() { + @Override + public void run() { installInitialBreakpoints(dmc, rm); } }); @@ -399,7 +400,6 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(fDebugModelId); for (IBreakpoint breakpoint : breakpoints) { if (supportsBreakpoint(breakpoint)) { - @SuppressWarnings("unchecked") Map attributes = breakpoint.getMarker().getAttributes(); attributes.put(ATTR_DEBUGGER_PATH, NULL_STRING); attributes.put(ATTR_THREAD_FILTER, extractThreads(dmc, (ICBreakpoint) breakpoint)); @@ -1108,6 +1108,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo /* (non-Javadoc) * @see org.eclipse.debug.core.IBreakpointManagerListener#breakpointManagerEnablementChanged(boolean) */ + @Override public void breakpointManagerEnablementChanged(boolean enabled) { // Only modify enabled breakpoints @@ -1136,15 +1137,16 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo * @see org.eclipse.debug.core.IBreakpointListener#breakpointAdded(org.eclipse.debug.core.model.IBreakpoint) */ @ThreadSafe + @Override public void breakpointAdded(final IBreakpoint breakpoint) { if (supportsBreakpoint(breakpoint)) { try { // Retrieve the breakpoint attributes - @SuppressWarnings("unchecked") final Map attrs = breakpoint.getMarker().getAttributes(); getExecutor().execute(new DsfRunnable() { + @Override public void run() { final CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), null) { @Override @@ -1199,13 +1201,13 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo /* (non-Javadoc) * @see org.eclipse.debug.core.IBreakpointListener#breakpointChanged(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta) */ + @Override public void breakpointChanged(final IBreakpoint breakpoint, final IMarkerDelta delta) { if (supportsBreakpoint(breakpoint)) { try { // Retrieve the breakpoint attributes - @SuppressWarnings("unchecked") final Map attrs = breakpoint.getMarker().getAttributes(); // Tracepoints are not affected by "skip-all" if (!(breakpoint instanceof ICTracepoint) && !fBreakpointManager.isEnabled()) { @@ -1214,6 +1216,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo // Modify the breakpoint in all the target contexts getExecutor().execute( new DsfRunnable() { + @Override public void run() { // If the breakpoint is currently being updated, queue the request and exit @@ -1269,11 +1272,13 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo /* (non-Javadoc) * @see org.eclipse.debug.core.IBreakpointListener#breakpointRemoved(org.eclipse.debug.core.model.IBreakpoint, org.eclipse.core.resources.IMarkerDelta) */ + @Override public void breakpointRemoved(final IBreakpoint breakpoint, IMarkerDelta delta) { if (supportsBreakpoint(breakpoint)) { try { getExecutor().execute(new DsfRunnable() { + @Override public void run() { CountingRequestMonitor countingRm = new CountingRequestMonitor(getExecutor(), null) { @Override @@ -1448,6 +1453,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo private void clearBreakpointStatus(final ICBreakpoint[] bps, final IBreakpointsTargetDMContext ctx) { IWorkspaceRunnable wr = new IWorkspaceRunnable() { + @Override public void run(IProgressMonitor monitor) throws CoreException { // For every platform breakpoint that has at least one target breakpoint installed // we must decrement the install count, for every target breakpoint. diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIDisassembly.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIDisassembly.java index 3486217ddde..bdbd630da8b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIDisassembly.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIDisassembly.java @@ -97,6 +97,7 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly { /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IDisassembly#getInstructions(org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext, java.math.BigInteger, java.math.BigInteger, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getInstructions(IDisassemblyDMContext context, BigInteger startAddress, BigInteger endAddress, final DataRequestMonitor drm) @@ -125,6 +126,7 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly { /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IDisassembly#getInstructions(org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext, java.lang.String, int, int, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getInstructions(IDisassemblyDMContext context, String filename, int linenum, int lines, final DataRequestMonitor drm) { @@ -150,6 +152,7 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly { /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IDisassembly#getMixedInstructions(org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext, java.math.BigInteger, java.math.BigInteger, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getMixedInstructions(IDisassemblyDMContext context, BigInteger startAddress, BigInteger endAddress, final DataRequestMonitor drm) @@ -178,6 +181,7 @@ public class MIDisassembly extends AbstractDsfService implements IDisassembly { /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IDisassembly#getMixedInstructions(org.eclipse.cdt.dsf.debug.service.IDisassembly.IDisassemblyDMContext, java.lang.String, int, int, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getMixedInstructions(IDisassemblyDMContext context, String filename, int linenum, int lines, final DataRequestMonitor drm) diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java index e0a567f4fdc..9f978a8a274 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIExpressions.java @@ -349,6 +349,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, /** * @return The full expression string represented by this ExpressionDMC */ + @Override public String getExpression() { return exprInfo.getFullExpr(); } @@ -407,6 +408,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, return baseToString() + ".invalid_expr[" + expression + "]"; //$NON-NLS-1$ //$NON-NLS-2$ } + @Override public String getExpression() { return expression; } @@ -437,7 +439,9 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, } } + @Override public IAddress getAddress() { return fAddr; } + @Override public int getSize() { return fSize; } @Override @@ -468,14 +472,17 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, */ protected class InvalidDMAddress implements IExpressionDMLocation { + @Override public IAddress getAddress() { return IExpressions.IExpressionDMLocation.INVALID_ADDRESS; } + @Override public int getSize() { return 0; } + @Override public String getLocation() { return ""; //$NON-NLS-1$ } @@ -525,22 +532,27 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, fBasicType = basicType; } + @Override public BasicType getBasicType() { return fBasicType; } + @Override public String getEncoding() { return null; } + @Override public Map getEnumerations() { return new HashMap(); } + @Override public String getName() { return relativeExpression; } + @Override public IRegisterDMContext getRegister() { return null; } @@ -550,10 +562,12 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, return null; } + @Override public String getTypeId() { return null; } + @Override public String getTypeName() { return exprType; } @@ -586,6 +600,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, /** * @since 4.0 */ + @Override public boolean hasChildren() { return numChildrenHint > 0; } @@ -739,6 +754,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, /** * Create an expression context with the same full and relative expression */ + @Override public IExpressionDMContext createExpression(IDMContext ctx, String expression) { return createExpression(ctx, expression, expression); } @@ -797,6 +813,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * of an expression in a specific format. */ + @Override public FormattedValueDMContext getFormattedValueContext( IFormattedDataDMContext dmc, String formatId) { return new FormattedValueDMContext(this, dmc, formatId); @@ -813,6 +830,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * */ + @Override public void getAvailableFormats(IFormattedDataDMContext dmc, final DataRequestMonitor rm) { rm.setData(FORMATS_SUPPORTED); @@ -828,6 +846,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The data request monitor that will contain the requested data */ + @Override public void getExpressionData( final IExpressionDMContext dmc, final DataRequestMonitor rm) @@ -892,6 +911,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The data request monitor that will contain the requested data */ + @Override public void getExpressionAddressData( IExpressionDMContext dmc, final DataRequestMonitor rm) { @@ -961,6 +981,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The data request monitor that will contain the requested data */ + @Override public void getFormattedExpressionValue( final FormattedValueDMContext dmc, final DataRequestMonitor rm) @@ -1025,6 +1046,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IExpressions#getBaseExpressions(org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getBaseExpressions(IExpressionDMContext exprContext, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, @@ -1041,6 +1063,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The data request monitor that will contain the requested data */ + @Override public void getSubExpressions(final IExpressionDMContext dmc, final DataRequestMonitor rm) { @@ -1085,6 +1108,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The data request monitor that will contain the requested data */ + @Override public void getSubExpressions(final IExpressionDMContext exprCtx, final int startIndex, final int length, final DataRequestMonitor rm) { @@ -1131,6 +1155,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, /** * @since 4.0 */ + @Override public void safeToAskForAllSubExpressions(IExpressionDMContext dmc, final DataRequestMonitor rm) { if (dmc instanceof MIExpressionDMC) { @@ -1157,6 +1182,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, /** * @since 4.0 */ + @Override public void getSubExpressionCount(IExpressionDMContext dmc, final int numChildLimit, final DataRequestMonitor rm) { @@ -1188,6 +1214,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The data request monitor that will contain the requested data */ + @Override public void getSubExpressionCount(IExpressionDMContext dmc, final DataRequestMonitor rm) { @@ -1202,6 +1229,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm Data Request monitor containing True if this expression's value can be edited. False otherwise. */ + @Override public void canWriteExpression(IExpressionDMContext dmc, final DataRequestMonitor rm) { if (dmc instanceof MIExpressionDMC) { fExpressionCache.execute( @@ -1236,6 +1264,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @param rm * The request monitor that will indicate the completion of the operation */ + @Override public void writeExpression(final IExpressionDMContext dmc, String expressionValue, String formatId, final RequestMonitor rm) { @@ -1305,6 +1334,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * {@inheritDoc} * @since 1.1 */ + @Override public void flushCache(IDMContext context) { fExpressionCache.reset(context); // We must also mark all variable objects as out-of-date @@ -1331,6 +1361,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext#getCastInfo() */ + @Override public CastInfo getCastInfo() { return fCastInfo; } @@ -1364,6 +1395,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @see org.eclipse.cdt.dsf.debug.service.IExpressions2#createCastedExpression(org.eclipse.cdt.dsf.datamodel.IDMContext, java.lang.String, org.eclipse.cdt.dsf.debug.service.IExpressions2.ICastedExpressionDMContext) */ /** @since 3.0 */ + @Override public ICastedExpressionDMContext createCastedExpression(IExpressionDMContext exprDMC, CastInfo castInfo) { if (exprDMC instanceof MIExpressionDMC && castInfo != null) { String castType = castInfo.getTypeString(); @@ -1400,6 +1432,7 @@ public class MIExpressions extends AbstractDsfService implements IMIExpressions, * @see org.eclipse.cdt.dsf.debug.service.IExpressions3#getExpressionDataExtension(org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ /** @since 4.0 */ + @Override public void getExpressionDataExtension(IExpressionDMContext dmc, final DataRequestMonitor rm) { getExpressionData(dmc, new DataRequestMonitor(getExecutor(), rm) { @Override diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java index 8263718d4ee..4aa41ceff4a 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIMemory.java @@ -75,6 +75,7 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer fAddresses = addresses; } + @Override public IAddress[] getAddresses() { return fAddresses; } @@ -199,6 +200,7 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IMemory#getMemory(org.eclipse.cdt.dsf.datamodel.IDMContext, org.eclipse.cdt.core.IAddress, long, int, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getMemory(IMemoryDMContext memoryDMC, IAddress address, long offset, int word_size, int count, DataRequestMonitor drm) { @@ -231,6 +233,7 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IMemory#setMemory(org.eclipse.cdt.dsf.datamodel.IDMContext, org.eclipse.cdt.core.IAddress, long, int, byte[], org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void setMemory(IMemoryDMContext memoryDMC, IAddress address, long offset, int word_size, int count, byte[] buffer, RequestMonitor rm) { @@ -270,6 +273,7 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer /* (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IMemory#fillMemory(org.eclipse.cdt.dsf.datamodel.IDMContext, org.eclipse.cdt.core.IAddress, long, int, byte[], org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void fillMemory(IMemoryDMContext memoryDMC, IAddress address, long offset, int word_size, int count, byte[] pattern, RequestMonitor rm) { @@ -994,6 +998,7 @@ public class MIMemory extends AbstractDsfService implements IMemory, ICachingSer * {@inheritDoc} * @since 1.1 */ + @Override public void flushCache(IDMContext context) { fCommandCache.reset(context); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java index 177f9873ba9..15089ec276f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIModules.java @@ -121,30 +121,37 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS fIsSymbolsRead = isSymsRead; } + @Override public String getFile() { return fFile; } + @Override public String getName() { return fFile; } + @Override public long getTimeStamp() { return 0; } - public String getBaseAddress() { + @Override + public String getBaseAddress() { return fFromAddress; } + @Override public String getToAddress() { return fToAddress; } + @Override public boolean isSymbolsLoaded() { return fIsSymbolsRead; } + @Override public long getSize() { long result = 0; if(getBaseAddress() == null || getToAddress() == null) @@ -158,6 +165,7 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS } + @Override public void getModules(final ISymbolDMContext symCtx, final DataRequestMonitor rm) { if(symCtx != null){ fModulesCache.execute(fCommandFactory.createCLIInfoSharedLibrary(symCtx), @@ -186,6 +194,7 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS return modules; } + @Override public void getModuleData(final IModuleDMContext dmc, final DataRequestMonitor rm) { assert dmc != null; if (dmc instanceof ModuleDMContext) { @@ -213,11 +222,13 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS } + @Override public void calcAddressInfo(ISymbolDMContext symCtx, String file, int line, int col, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Functionality not supported", null)); //$NON-NLS-1$ rm.done(); } + @Override public void calcLineInfo(ISymbolDMContext symCtx, IAddress address, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Functionality not supported", null)); //$NON-NLS-1$ rm.done(); @@ -227,6 +238,7 @@ public class MIModules extends AbstractDsfService implements IModules, ICachingS * {@inheritDoc} * @since 1.1 */ + @Override public void flushCache(IDMContext context) { fModulesCache.reset(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIProcesses.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIProcesses.java index 0d3cdbac54c..250782a5027 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIProcesses.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIProcesses.java @@ -107,6 +107,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa * Returns the GDB/MI thread identifier of this context. * @return */ + @Override public int getThreadId(){ try { return Integer.parseInt(fThreadId); @@ -162,6 +163,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa /** * Returns the GDB/MI thread group identifier of this context. */ + @Override public String getGroupId(){ return fId; } @Override @@ -249,6 +251,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa fId = id; } + @Override public String getProcId() { return fId; } @Override @@ -302,8 +305,11 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa fId = id; } + @Override public String getId() { return fId; } + @Override public String getName() { return fName; } + @Override public boolean isDebuggerAttached() { return true; } @@ -423,36 +429,43 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa return GdbPlugin.getBundleContext(); } + @Override public IThreadDMContext createThreadContext(IProcessDMContext processDmc, String threadId) { return new MIThreadDMC(getSession().getId(), processDmc, threadId); } + @Override public IProcessDMContext createProcessContext(ICommandControlDMContext controlDmc, String pid) { return new MIProcessDMC(getSession().getId(), controlDmc, pid); } + @Override public IMIExecutionDMContext createExecutionContext(IContainerDMContext containerDmc, IThreadDMContext threadDmc, String threadId) { return new MIExecutionDMC(getSession().getId(), containerDmc, threadDmc, threadId); } + @Override public IMIContainerDMContext createContainerContext(IProcessDMContext processDmc, String groupId) { return new MIContainerDMC(getSession().getId(), processDmc, groupId); } + @Override public IMIContainerDMContext createContainerContextFromThreadId(ICommandControlDMContext controlDmc, String threadId) { return createContainerContextFromGroupId(controlDmc, UNIQUE_GROUP_ID); } /** @since 4.0 */ + @Override public IMIContainerDMContext createContainerContextFromGroupId(ICommandControlDMContext controlDmc, String groupId) { IProcessDMContext processDmc = createProcessContext(controlDmc, UNKNOWN_PROCESS_ID); return createContainerContext(processDmc, groupId); } + @Override public void getExecutionData(IThreadDMContext dmc, final DataRequestMonitor rm) { if (dmc instanceof MIProcessDMC) { rm.setData(new MIThreadDMData("", ((MIProcessDMC)dmc).getProcId())); //$NON-NLS-1$ @@ -495,6 +508,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa } } + @Override public void getDebuggingContext(IThreadDMContext dmc, DataRequestMonitor rm) { if (dmc instanceof MIProcessDMC) { MIProcessDMC procDmc = (MIProcessDMC)dmc; @@ -511,11 +525,13 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa rm.done(); } + @Override public void isDebuggerAttachSupported(IDMContext dmc, DataRequestMonitor rm) { rm.setData(false); rm.done(); } + @Override public void attachDebuggerToProcess(final IProcessDMContext procCtx, final DataRequestMonitor rm) { if (procCtx instanceof IMIProcessDMContext) { @@ -539,11 +555,13 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa } } + @Override public void canDetachDebuggerFromProcess(IDMContext dmc, DataRequestMonitor rm) { rm.setData(false); rm.done(); } + @Override public void detachDebuggerFromProcess(final IDMContext dmc, final RequestMonitor rm) { ICommandControlDMContext controlDmc = DMContexts.getAncestorOfType(dmc, ICommandControlDMContext.class); @@ -574,16 +592,19 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa } } + @Override public void canTerminate(IThreadDMContext thread, DataRequestMonitor rm) { rm.setData(true); rm.done(); } + @Override public void isDebugNewProcessSupported(IDMContext dmc, DataRequestMonitor rm) { rm.setData(false); rm.done(); } + @Override public void debugNewProcess(IDMContext dmc, String file, Map attributes, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, @@ -591,6 +612,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa rm.done(); } + @Override public void getProcessesBeingDebugged(IDMContext dmc, final DataRequestMonitor rm) { final IMIContainerDMContext containerDmc = DMContexts.getAncestorOfType(dmc, IMIContainerDMContext.class); if (containerDmc != null) { @@ -636,16 +658,20 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa } } + @Override public void getRunningProcesses(IDMContext dmc, final DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ rm.done(); } + @Override public void isRunNewProcessSupported(IDMContext dmc, DataRequestMonitor rm) { rm.setData(false); rm.done(); } + + @Override public void runNewProcess(IDMContext dmc, String file, Map attributes, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, @@ -653,6 +679,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa rm.done(); } + @Override public void terminate(IThreadDMContext thread, RequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Not supported", null)); //$NON-NLS-1$ @@ -716,6 +743,7 @@ public class MIProcesses extends AbstractDsfService implements IMIProcesses, ICa fContainerCommandCache.reset(); } + @Override public void flushCache(IDMContext context) { fContainerCommandCache.reset(context); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRegisters.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRegisters.java index d808baf1c86..2931117ad58 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRegisters.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRegisters.java @@ -136,6 +136,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach fRegisterDmc = registerDMC; } + @Override public IRegisterDMContext getDMContext() { return fRegisterDmc; } @@ -221,6 +222,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach public boolean isValid() { return true; } + @Override public void getFormattedExpressionValue(FormattedValueDMContext dmc, DataRequestMonitor rm) { if (dmc.getParents().length == 1 && dmc.getParents()[0] instanceof MIRegisterDMC) { getRegisterDataValue( (MIRegisterDMC) dmc.getParents()[0], dmc.getFormatID(), rm); @@ -230,13 +232,16 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach } } + @Override public void getRegisterGroupData(IRegisterGroupDMContext regGroupDmc, DataRequestMonitor rm) { /** * For the GDB GDBMI implementation there is only on group. The GPR and FPU registers are grouped into * one set. We are going to hard wire this set as the "General Registers". */ class RegisterGroupData implements IRegisterGroupDMData { + @Override public String getName() { return "General Registers"; } //$NON-NLS-1$ + @Override public String getDescription() { return "General Purpose and FPU Register Group"; } //$NON-NLS-1$ } @@ -244,6 +249,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach rm.done(); } + @Override public void getBitFieldData(IBitFieldDMContext dmc, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Bit fields not yet supported", null)); //$NON-NLS-1$ rm.done(); @@ -254,6 +260,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * this group as a single list we maintain within this service. So we * need to search this list to see if we have a current value. */ + @Override public void getRegisterData(IRegisterDMContext regDmc , final DataRequestMonitor rm) { if (regDmc instanceof MIRegisterDMC) { final MIRegisterDMC miRegDmc = (MIRegisterDMC)regDmc; @@ -362,15 +369,24 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach fIsFloat = isFloat; } + @Override public boolean isReadable() { return true; } + @Override public boolean isReadOnce() { return false; } + @Override public boolean isWriteable() { return true; } + @Override public boolean isWriteOnce() { return false; } + @Override public boolean hasSideEffects() { return false; } + @Override public boolean isVolatile() { return true; } + @Override public boolean isFloat() { return fIsFloat; } + @Override public String getName() { return fRegName; } + @Override public String getDescription() { return fRegDesc; } } @@ -443,6 +459,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#getRegisterGroups(org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext, org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getRegisterGroups(IDMContext ctx, DataRequestMonitor rm ) { IContainerDMContext contDmc = DMContexts.getAncestorOfType(ctx, IContainerDMContext.class); if (contDmc == null) { @@ -464,6 +481,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#getRegisters(org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterGroupDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getRegisters(final IDMContext dmc, final DataRequestMonitor rm) { final MIRegisterGroupDMC groupDmc = DMContexts.getAncestorOfType(dmc, MIRegisterGroupDMC.class); if ( groupDmc == null ) { @@ -513,6 +531,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#getBitFields(org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getBitFields( IDMContext regDmc , DataRequestMonitor rm ) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "BitField not supported", null)); //$NON-NLS-1$ rm.done(); @@ -522,6 +541,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#writeRegister(org.eclipse.cdt.dsf.debug.service.IRegisters.IRegisterDMContext, java.lang.String, java.lang.String, org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void writeRegister(IRegisterDMContext regCtx, final String regValue, final String formatId, final RequestMonitor rm) { MIRegisterGroupDMC grpDmc = DMContexts.getAncestorOfType(regCtx, MIRegisterGroupDMC.class); if ( grpDmc == null ) { @@ -569,6 +589,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#writeBitField(org.eclipse.cdt.dsf.debug.service.IRegisters.IBitFieldDMContext, java.lang.String, java.lang.String, org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void writeBitField(IBitFieldDMContext bitFieldCtx, String bitFieldValue, String formatId, RequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Writing bit field not supported", null)); //$NON-NLS-1$ rm.done(); @@ -578,6 +599,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#writeBitField(org.eclipse.cdt.dsf.debug.service.IRegisters.IBitFieldDMContext, org.eclipse.cdt.dsf.debug.service.IRegisters.IMnemonic, org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public void writeBitField(IBitFieldDMContext bitFieldCtx, IMnemonic mnemonic, RequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Writing bit field not supported", null)); //$NON-NLS-1$ rm.done(); @@ -587,6 +609,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IFormattedValues#getAvailableFormats(org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void getAvailableFormats(IFormattedDataDMContext dmc, DataRequestMonitor rm) { rm.setData(new String[] { HEX_FORMAT, DECIMAL_FORMAT, OCTAL_FORMAT, BINARY_FORMAT, NATURAL_FORMAT }); @@ -597,6 +620,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IFormattedValues#getFormattedValueContext(org.eclipse.cdt.dsf.debug.service.IFormattedValues.IFormattedDataDMContext, java.lang.String) */ + @Override public FormattedValueDMContext getFormattedValueContext(IFormattedDataDMContext dmc, String formatId) { if ( dmc instanceof MIRegisterDMC ) { MIRegisterDMC regDmc = (MIRegisterDMC) dmc; @@ -609,6 +633,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#findRegisterGroup(org.eclipse.cdt.dsf.datamodel.IDMContext, java.lang.String, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void findRegisterGroup(IDMContext ctx, String name, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Finding a Register Group context not supported", null)); //$NON-NLS-1$ rm.done(); @@ -618,6 +643,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#findRegister(org.eclipse.cdt.dsf.datamodel.IDMContext, java.lang.String, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void findRegister(IDMContext ctx, String name, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Finding a Register context not supported", null)); //$NON-NLS-1$ rm.done(); @@ -627,6 +653,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * (non-Javadoc) * @see org.eclipse.cdt.dsf.debug.service.IRegisters#findBitField(org.eclipse.cdt.dsf.datamodel.IDMContext, java.lang.String, org.eclipse.cdt.dsf.concurrent.DataRequestMonitor) */ + @Override public void findBitField(IDMContext ctx, String name, DataRequestMonitor rm) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, NOT_SUPPORTED, "Finding a Register Group context not supported", null)); //$NON-NLS-1$ rm.done(); @@ -636,6 +663,7 @@ public class MIRegisters extends AbstractDsfService implements IRegisters, ICach * {@inheritDoc} * @since 1.1 */ + @Override public void flushCache(IDMContext context) { fRegisterNameCache.reset(context); fRegisterValueCache.reset(context); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java index 00d00abe18b..eb6a5a66ba9 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIRunControl.java @@ -120,6 +120,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I * Returns the GDB/MI thread identifier of this context. * @return */ + @Override public int getThreadId(){ return fThreadId; } @@ -144,7 +145,9 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I fReason = reason; fDetails = details; } + @Override public StateChangeReason getStateChangeReason() { return fReason; } + @Override public String getDetails() { return fDetails; } } @@ -167,6 +170,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I fMIInfo = miInfo; } + @Override public T getMIEvent() { return fMIInfo; } } @@ -181,6 +185,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I super(ctx, miInfo); } + @Override public StateChangeReason getReason() { if (getMIEvent() instanceof MICatchpointHitEvent) { // must precede MIBreakpointHitEvent return StateChangeReason.EVENT_BREAKPOINT; @@ -244,6 +249,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I fBreakpoints = new IBreakpointDMContext[] { bpCtx }; } + @Override public IBreakpointDMContext[] getBreakpoints() { return fBreakpoints; } @@ -261,6 +267,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I ? new IExecutionDMContext[] { triggeringDmc } : new IExecutionDMContext[0]; } + @Override public IExecutionDMContext[] getTriggeringContexts() { return triggeringDmcs; } @@ -282,6 +289,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I fBreakpoints = new IBreakpointDMContext[] { bpCtx }; } + @Override public IBreakpointDMContext[] getBreakpoints() { return fBreakpoints; } @@ -295,6 +303,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I super(ctx, miInfo); } + @Override public StateChangeReason getReason() { switch(getMIEvent().getType()) { case MIRunningEvent.CONTINUE: @@ -327,6 +336,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I ? new IExecutionDMContext[] { triggeringDmc } : new IExecutionDMContext[0]; } + @Override public IExecutionDMContext[] getTriggeringContexts() { return triggeringDmcs; } @@ -655,6 +665,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /////////////////////////////////////////////////////////////////////////// // IRunControl + @Override public void canResume(IExecutionDMContext context, DataRequestMonitor rm) { rm.setData(doCanResume(context)); rm.done(); @@ -665,6 +676,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I return !fTerminated && isSuspended(context) && !fResumePending; } + @Override public void canSuspend(IExecutionDMContext context, DataRequestMonitor rm) { rm.setData(doCanSuspend(context)); rm.done(); @@ -674,14 +686,17 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I return !fTerminated && !isSuspended(context); } + @Override public boolean isSuspended(IExecutionDMContext context) { return !fTerminated && fSuspended; } + @Override public boolean isStepping(IExecutionDMContext context) { return !fTerminated && fStepping; } + @Override public void resume(final IExecutionDMContext context, final RequestMonitor rm) { assert context != null; @@ -723,6 +738,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } } + @Override public void suspend(IExecutionDMContext context, final RequestMonitor rm){ assert context != null; @@ -747,6 +763,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } } + @Override public void canStep(IExecutionDMContext context, StepType stepType, DataRequestMonitor rm) { if (context instanceof IContainerDMContext) { rm.setData(false); @@ -756,6 +773,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I canResume(context, rm); } + @Override public void step(final IExecutionDMContext context, StepType stepType, final RequestMonitor rm) { assert context != null; @@ -826,6 +844,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } + @Override public void getExecutionContexts(final IContainerDMContext containerDmc, final DataRequestMonitor rm) { fMICommandCache.execute( fCommandFactory.createMIThreadListIds(containerDmc), @@ -856,6 +875,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } } + @Override public void getExecutionData(IExecutionDMContext dmc, DataRequestMonitor rm){ if (dmc instanceof IContainerDMContext) { rm.setData( new ExecutionData(fStateChangeReason, fStateChangeDetails) ); @@ -1123,6 +1143,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void executeWithTargetAvailable(IDMContext ctx, final Sequence.Step[] steps, final RequestMonitor rm) { if (!fOngoingOperation) { // We are the first operation of this kind currently requested @@ -1362,6 +1383,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I * {@inheritDoc} * @since 1.1 */ + @Override public void flushCache(IDMContext context) { fMICommandCache.reset(context); } @@ -1397,6 +1419,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void canRunToLine(IExecutionDMContext context, String sourceFile, int lineNumber, DataRequestMonitor rm) { canResume(context, rm); @@ -1408,6 +1431,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void runToLine(IExecutionDMContext context, String sourceFile, int lineNumber, boolean skipBreakpoints, RequestMonitor rm) { @@ -1423,6 +1447,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void canRunToAddress(IExecutionDMContext context, IAddress address, DataRequestMonitor rm) { canResume(context, rm); @@ -1434,6 +1459,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void runToAddress(IExecutionDMContext context, IAddress address, boolean skipBreakpoints, RequestMonitor rm) { runToLocation(context, "*0x" + address.toString(16), skipBreakpoints, rm); //$NON-NLS-1$ @@ -1445,6 +1471,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void canMoveToLine(IExecutionDMContext context, String sourceFile, int lineNumber, boolean resume, DataRequestMonitor rm) { canResume(context, rm); @@ -1456,6 +1483,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void moveToLine(IExecutionDMContext context, String sourceFile, int lineNumber, boolean resume, RequestMonitor rm) { IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); @@ -1489,6 +1517,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void canMoveToAddress(IExecutionDMContext context, IAddress address, boolean resume, DataRequestMonitor rm) { canResume(context, rm); @@ -1500,6 +1529,7 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I /** * @since 3.0 */ + @Override public void moveToAddress(IExecutionDMContext context, IAddress address, boolean resume, RequestMonitor rm) { IMIExecutionDMContext threadExecDmc = DMContexts.getAncestorOfType(context, IMIExecutionDMContext.class); @@ -1527,11 +1557,13 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I } /** @since 4.0 */ + @Override public IRunMode getRunMode() { return MIRunMode.ALL_STOP; } /** @since 4.0 */ + @Override public boolean isTargetAcceptingCommands() { // For all-stop mode: // 1- if GDB is not terminated and diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java index df9861beb76..c37fbc247eb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIStack.java @@ -70,6 +70,7 @@ public class MIStack extends AbstractDsfService fLevel = level; } + @Override public int getLevel() { return fLevel; } @Override @@ -244,10 +245,12 @@ public class MIStack extends AbstractDsfService return new MIFrameDMC(getSession().getId(), execDmc, level); } + @Override public void getFrames(final IDMContext ctx, final DataRequestMonitor rm) { getFrames(ctx, 0, ALL_FRAMES, rm); } + @Override public void getFrames(final IDMContext ctx, final int startIndex, final int endIndex, final DataRequestMonitor rm) { if (startIndex < 0 || endIndex > 0 && endIndex < startIndex) { @@ -304,6 +307,7 @@ public class MIStack extends AbstractDsfService }); } + @Override public void getTopFrame(final IDMContext ctx, final DataRequestMonitor rm) { final IMIExecutionDMContext execDmc = DMContexts.getAncestorOfType(ctx, IMIExecutionDMContext.class); if (execDmc == null) { @@ -357,6 +361,7 @@ public class MIStack extends AbstractDsfService + @Override public void getFrameData(final IFrameDMContext frameDmc, final DataRequestMonitor rm) { if (!(frameDmc instanceof MIFrameDMC)) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context type " + frameDmc, null)); //$NON-NLS-1$ @@ -381,6 +386,7 @@ public class MIStack extends AbstractDsfService { abstract protected MIFrame getMIFrame(); + @Override public IAddress getAddress() { String addr = getMIFrame().getAddress(); if (addr == null || addr.length() == 0) { @@ -396,11 +402,16 @@ public class MIStack extends AbstractDsfService } } + @Override public int getColumn() { return 0; } + @Override public String getFile() { return getMIFrame().getFile(); } + @Override public int getLine() { return getMIFrame().getLine(); } + @Override public String getFunction() { return getMIFrame().getFunction(); } + @Override public String getModule() { return ""; }//$NON-NLS-1$ @Override @@ -494,6 +505,7 @@ public class MIStack extends AbstractDsfService }); } + @Override public void getArguments(final IFrameDMContext frameDmc, final DataRequestMonitor rm) { final IMIExecutionDMContext execDmc = DMContexts.getAncestorOfType(frameDmc, IMIExecutionDMContext.class); if (execDmc == null) { @@ -578,6 +590,7 @@ public class MIStack extends AbstractDsfService }); } + @Override public void getVariableData(IVariableDMContext variableDmc, final DataRequestMonitor rm) { if (!(variableDmc instanceof MIVariableDMC)) { rm.setStatus(new Status(IStatus.ERROR, GdbPlugin.PLUGIN_ID, INVALID_HANDLE, "Invalid context type " + variableDmc, null)); //$NON-NLS-1$ @@ -610,7 +623,9 @@ public class MIStack extends AbstractDsfService VariableData(MIArg arg){ dsfMIArg = arg; } + @Override public String getName() { return dsfMIArg.getName(); } + @Override public String getValue() { return dsfMIArg.getValue(); } @Override public String toString() { return dsfMIArg.toString(); } @@ -753,6 +768,7 @@ public class MIStack extends AbstractDsfService } + @Override public void getLocals(final IFrameDMContext frameDmc, final DataRequestMonitor rm) { final List localsList = new ArrayList(); @@ -811,6 +827,7 @@ public class MIStack extends AbstractDsfService }); } + @Override public void getStackDepth(final IDMContext dmc, final int maxDepth, final DataRequestMonitor rm) { final IMIExecutionDMContext execDmc = DMContexts.getAncestorOfType(dmc, IMIExecutionDMContext.class); if (execDmc != null) { @@ -939,6 +956,7 @@ public class MIStack extends AbstractDsfService * {@inheritDoc} * @since 1.1 */ + @Override public void flushCache(IDMContext context) { fMICommandCache.reset(context); fStackDepthCache.clear(context); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java index c248ac05a7b..1636f919ede 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/MIVariableManager.java @@ -2752,9 +2752,11 @@ public class MIVariableManager implements ICommandControl { }); } + @Override public ICommandToken queueCommand(final ICommand command, DataRequestMonitor rm) { final ICommandToken token = new ICommandToken() { + @Override public ICommand getCommand() { return command; } @@ -2939,6 +2941,7 @@ public class MIVariableManager implements ICommandControl { * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#removeCommand(org.eclipse.cdt.dsf.mi.service.command.commands.ICommand) */ + @Override public void removeCommand(ICommandToken token) { // It is impossible to remove a command from the MIVariableManager. // This should never be called, if we did things right. @@ -2955,9 +2958,13 @@ public class MIVariableManager implements ICommandControl { * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#cancelCommand(org.eclipse.cdt.dsf.mi.service.command.commands.ICommand) */ + @Override public void addCommandListener(ICommandListener processor) { fCommandProcessors.add(processor); } + @Override public void removeCommandListener(ICommandListener processor) { fCommandProcessors.remove(processor); } + @Override public void addEventListener(IEventListener processor) {} + @Override public void removeEventListener(IEventListener processor) {} diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/BreakpointActionAdapter.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/BreakpointActionAdapter.java index 8404758b4c5..aa2861b5eb5 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/BreakpointActionAdapter.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/BreakpointActionAdapter.java @@ -34,6 +34,7 @@ public class BreakpointActionAdapter implements IAdaptable { } @SuppressWarnings("rawtypes") + @Override public Object getAdapter(Class adapter) { if (adapter.equals(ILogActionEnabler.class)) { return new MILogActionEnabler(fExecutor, fServiceTracker, fContext); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MILogActionEnabler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MILogActionEnabler.java index e2845d0e9ba..c5e37bbd070 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MILogActionEnabler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MILogActionEnabler.java @@ -42,6 +42,7 @@ public class MILogActionEnabler implements ILogActionEnabler { fContext = DMContexts.getAncestorOfType(context, IBreakpointsTargetDMContext.class); } + @Override public String evaluateExpression(final String expression) throws Exception { // Use a Query to synchronize the call Query query = new Query() { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MIResumeActionEnabler.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MIResumeActionEnabler.java index 1f994ce9382..6ab835df48b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MIResumeActionEnabler.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/breakpoint/actions/MIResumeActionEnabler.java @@ -35,8 +35,10 @@ public class MIResumeActionEnabler implements IResumeActionEnabler { fContext = (IExecutionDMContext) context; } + @Override public void resume() throws Exception { fExecutor.execute(new DsfRunnable() { + @Override public void run() { final IRunControl runControlService = fServiceTracker.getService(IRunControl.class); if (runControlService != null) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java index 5661ac2e293..4ee7f8922cb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractCLIProcess.java @@ -205,6 +205,7 @@ public abstract class AbstractCLIProcess extends Process } + @Override public void eventReceived(Object output) { if (fSuppressConsoleOutputCounter > 0) return; for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) { @@ -250,10 +251,12 @@ public abstract class AbstractCLIProcess extends Process } } + @Override public void commandQueued(ICommandToken token) { // Ignore } + @Override public void commandSent(ICommandToken token) { // Bug 285170 // Don't reset the fPrompt here, in case we are @@ -340,10 +343,12 @@ public abstract class AbstractCLIProcess extends Process return false; } + @Override public void commandRemoved(ICommandToken token) { // Ignore } + @Override public void commandDone(ICommandToken token, ICommandResult result) { // Whenever we get a command that is completed, we know we must be in the primary prompt fPrompt = PromptType.IN_PRIMARY_PROMPT; @@ -405,7 +410,7 @@ public abstract class AbstractCLIProcess extends Process final String bufString = buf.toString().trim(); buf.setLength(0); try { - fSession.getExecutor().execute(new DsfRunnable() { public void run() { + fSession.getExecutor().execute(new DsfRunnable() { @Override public void run() { try { post(bufString); } catch (IOException e) { @@ -445,7 +450,7 @@ public abstract class AbstractCLIProcess extends Process cmd = new ProcessCLICommand(getCommandControlService().getContext(), str); } final ICommand finalCmd = cmd; - fSession.getExecutor().execute(new DsfRunnable() { public void run() { + fSession.getExecutor().execute(new DsfRunnable() { @Override public void run() { if (isDisposed()) return; // Do not wait around for the answer. getCommandControlService().queueCommand(finalCmd, null); diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java index 33bb3e2fe39..e9cb3781732 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/AbstractMIControl.java @@ -199,6 +199,7 @@ public abstract class AbstractMIControl extends AbstractDsfService /** * @since 3.0 */ + @Override public CommandFactory getCommandFactory() { return fCommandFactory; } @@ -291,6 +292,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * @see org.eclipse.cdt.dsf.debug.service.command.ICommandControl#addCommand(org.eclipse.cdt.dsf.debug.service.command.ICommand, org.eclipse.cdt.dsf.concurrent.RequestMonitor) */ + @Override public ICommandToken queueCommand(final ICommand command, DataRequestMonitor rm) { // Cast the command to MI Command type. This will cause a cast exception to be @@ -323,6 +325,7 @@ public abstract class AbstractMIControl extends AbstractDsfService // In a separate dispatch cycle. This allows command listeners // to respond to the command queued event. getExecutor().execute(new DsfRunnable() { + @Override public void run() { processNextQueuedCommand(); } @@ -396,6 +399,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#removeCommand(org.eclipse.cdt.dsf.mi.service.command.commands.ICommand) */ + @Override public void removeCommand(ICommandToken token) { synchronized(fCommandQueue) { @@ -406,6 +410,7 @@ public abstract class AbstractMIControl extends AbstractDsfService final CommandHandle finalHandle = handle; getExecutor().execute(new DsfRunnable() { + @Override public void run() { processCommandRemoved(finalHandle); } @@ -423,6 +428,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#addCommandListener(org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl.ICommandListener) */ + @Override public void addCommandListener(ICommandListener processor) { fCommandProcessors.add(processor); } /* @@ -430,6 +436,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#removeCommandListener(org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl.ICommandListener) */ + @Override public void removeCommandListener(ICommandListener processor) { fCommandProcessors.remove(processor); } /* @@ -438,6 +445,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#addEventListener(org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl.IEventListener) */ + @Override public void addEventListener(IEventListener processor) { fEventProcessors.add(processor); } /* @@ -446,6 +454,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * (non-Javadoc) * @see org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl#removeEventListener(org.eclipse.cdt.dsf.mi.service.command.IDebuggerControl.IEventListener) */ + @Override public void removeEventListener(IEventListener processor) { fEventProcessors.remove(processor); } abstract public MIControlDMContext getControlDMContext(); @@ -453,6 +462,7 @@ public abstract class AbstractMIControl extends AbstractDsfService /** * @since 1.1 */ + @Override public boolean isActive() { return !fStoppedCommandProcessing; } @@ -525,6 +535,7 @@ public abstract class AbstractMIControl extends AbstractDsfService fTokenId = -1; // Only initialize to a real value when needed } + @Override public MICommand getCommand() { return fCommand; } public DataRequestMonitor getRequestMonitor() { return fRequestMonitor; } // This method allows us to generate the token Id when we area actually going to use @@ -891,6 +902,7 @@ public abstract class AbstractMIControl extends AbstractDsfService */ final ICommandResult finalResult = result; getExecutor().execute(new DsfRunnable() { + @Override public void run() { /* * Complete the specific command. @@ -918,6 +930,7 @@ public abstract class AbstractMIControl extends AbstractDsfService */ final ICommandResult finalResult = result; getExecutor().execute(new DsfRunnable() { + @Override public void run() { processCommandDone(commandHandle, finalResult); } @@ -937,6 +950,7 @@ public abstract class AbstractMIControl extends AbstractDsfService final MIOutput response = new MIOutput(rr, new MIOOBRecord[0]); getExecutor().execute(new DsfRunnable() { + @Override public void run() { processEvent(response); } @@ -979,6 +993,7 @@ public abstract class AbstractMIControl extends AbstractDsfService * be done on the DSF thread for integrity. */ getExecutor().execute(new DsfRunnable() { + @Override public void run() { processEvent(response); } @@ -990,6 +1005,7 @@ public abstract class AbstractMIControl extends AbstractDsfService } getExecutor().execute(new DsfRunnable() { + @Override public void run() { processNextQueuedCommand(); } @@ -1030,6 +1046,7 @@ public abstract class AbstractMIControl extends AbstractDsfService final MIOOBRecord oob = fMiParser.parseMIOOBRecord("&"+line+"\n"); //$NON-NLS-1$//$NON-NLS-2$ final MIOutput response = new MIOutput(oob, new MIStreamRecord[0]); getExecutor().execute(new DsfRunnable() { + @Override public void run() { processEvent(response); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java index c7185e882e1..2d245d25eb1 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor.java @@ -81,6 +81,7 @@ public class CLIEventProcessor fServicesTracker.dispose(); } + @Override public void commandSent(ICommandToken token) { if (token.getCommand() instanceof CLICommand) { processStateChanges( (CLICommand)token.getCommand() ); @@ -90,6 +91,7 @@ public class CLIEventProcessor } } + @Override public void commandDone(ICommandToken token, ICommandResult result) { if (token.getCommand() instanceof CLICommand) { processSettingChanges( (CLICommand)token.getCommand() ); @@ -99,14 +101,17 @@ public class CLIEventProcessor } } + @Override public void commandQueued(ICommandToken token) { // No action } + @Override public void commandRemoved(ICommandToken token) { // No action } + @Override public void eventReceived(Object output) { for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) { if (oobr instanceof MIConsoleStreamOutput) { diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java index 85765af7b75..bcafe71276b 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/CLIEventProcessor_7_0.java @@ -44,13 +44,11 @@ public class CLIEventProcessor_7_0 implements ICommandListener, IEventListener { private final ICommandControlService fCommandControl; - private final ICommandControlDMContext fControlDmc; private final DsfServicesTracker fServicesTracker; public CLIEventProcessor_7_0(ICommandControlService connection, ICommandControlDMContext controlDmc) { fCommandControl = connection; - fControlDmc = controlDmc; fServicesTracker = new DsfServicesTracker(GdbPlugin.getBundleContext(), fCommandControl.getSession().getId()); fCommandControl.addCommandListener(this); fCommandControl.addEventListener(this); @@ -62,6 +60,7 @@ public class CLIEventProcessor_7_0 fServicesTracker.dispose(); } + @Override public void commandSent(ICommandToken token) { if (token.getCommand() instanceof CLICommand) { processStateChanges( (CLICommand)token.getCommand() ); @@ -71,6 +70,7 @@ public class CLIEventProcessor_7_0 } } + @Override public void commandDone(ICommandToken token, ICommandResult result) { if (token.getCommand() instanceof CLICommand) { processSettingChanges( (CLICommand)token.getCommand() ); @@ -80,14 +80,17 @@ public class CLIEventProcessor_7_0 } } + @Override public void commandQueued(ICommandToken token) { // No action } + @Override public void commandRemoved(ICommandToken token) { // No action } + @Override public void eventReceived(Object output) { } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIBackendCLIProcess.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIBackendCLIProcess.java index e28c5ca8611..8f19d8eb8e6 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIBackendCLIProcess.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIBackendCLIProcess.java @@ -132,6 +132,7 @@ public class MIBackendCLIProcess extends AbstractCLIProcess { } try { getSession().getExecutor().submit(new Callable() { + @Override public Object call() throws Exception { if (fMIBackend.getState() != IMIBackend.State.TERMINATED) { throw new IllegalThreadStateException("Backend Process has not exited"); //$NON-NLS-1$ @@ -153,7 +154,7 @@ public class MIBackendCLIProcess extends AbstractCLIProcess { @Override public void destroy() { try { - getSession().getExecutor().execute(new DsfRunnable() { public void run() { + getSession().getExecutor().execute(new DsfRunnable() { @Override public void run() { if (!DsfSession.isSessionActive(getSession().getId())) return; if (isDisposed()) return; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIControlDMContext.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIControlDMContext.java index 3ec9afafa25..e923cc754a8 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIControlDMContext.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIControlDMContext.java @@ -53,6 +53,7 @@ public class MIControlDMContext extends AbstractDMContext /** * @since 1.1 */ + @Override public String getCommandControlId() { return fCommandControlId; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIInferiorProcess.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIInferiorProcess.java index 7a128a82818..57c4a6c0433 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIInferiorProcess.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIInferiorProcess.java @@ -315,6 +315,7 @@ public class MIInferiorProcess extends Process public void destroy() { try { fSession.getExecutor().execute(new DsfRunnable() { + @Override public void run() { doDestroy(); } @@ -374,6 +375,7 @@ public class MIInferiorProcess extends Process return fErrorStreamPiped; } + @Override public void eventReceived(Object output) { for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) { if (oobr instanceof MITargetStreamOutput) { @@ -390,20 +392,24 @@ public class MIInferiorProcess extends Process } } + @Override public void commandQueued(ICommandToken token) { // No action } + @Override public void commandSent(ICommandToken token) { if (token.getCommand() instanceof CLICommand) { fSuppressTargetOutputCounter++; } } + @Override public void commandRemoved(ICommandToken token) { // No action } + @Override public void commandDone(ICommandToken token, ICommandResult result) { if (token.getCommand() instanceof CLICommand) { fSuppressTargetOutputCounter--; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java index afbd3ce5138..2fd7e8ea20d 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor.java @@ -113,6 +113,7 @@ public class MIRunControlEventProcessor fServicesTracker.dispose(); } + @Override public void eventReceived(Object output) { for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) { List> events = new LinkedList>(); @@ -294,18 +295,22 @@ public class MIRunControlEventProcessor } } + @Override public void commandQueued(ICommandToken token) { // Do nothing. } + @Override public void commandSent(ICommandToken token) { // Do nothing. } + @Override public void commandRemoved(ICommandToken token) { // Do nothing. } + @Override public void commandDone(ICommandToken token, ICommandResult result) { ICommand cmd = token.getCommand(); MIInfo cmdResult = (MIInfo) result ; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_0.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_0.java index 5591aeb5fa9..03a04a35eeb 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_0.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/MIRunControlEventProcessor_7_0.java @@ -113,6 +113,7 @@ public class MIRunControlEventProcessor_7_0 fServicesTracker.dispose(); } + @Override public void eventReceived(Object output) { for (MIOOBRecord oobr : ((MIOutput)output).getMIOOBRecords()) { List> events = new LinkedList>(); @@ -366,18 +367,22 @@ public class MIRunControlEventProcessor_7_0 return event; } + @Override public void commandQueued(ICommandToken token) { // Do nothing. } + @Override public void commandSent(ICommandToken token) { // Do nothing. } + @Override public void commandRemoved(ICommandToken token) { // Do nothing. } + @Override public void commandDone(ICommandToken token, ICommandResult result) { ICommand cmd = token.getCommand(); MIInfo cmdResult = (MIInfo) result ; diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java index 387f1610b0d..e458e6b0f05 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/ExprMetaCommand.java @@ -29,10 +29,12 @@ public class ExprMetaCommand implements ICommand { * The result is a new third command which represent the two * original command. */ + @Override public ICommand coalesceWith( ICommand command ) { return null ; } + @Override public IDMContext getContext(){ return fCtx; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakCondition.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakCondition.java index b648f25bb1d..068a2183227 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakCondition.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MIBreakCondition.java @@ -54,6 +54,7 @@ public class MIBreakCondition extends MICommand super(param); } + @Override public String getAdjustedValue() { return getValue(); } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MICommand.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MICommand.java index df26dabcd4e..dc11d539c6f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MICommand.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/commands/MICommand.java @@ -190,11 +190,13 @@ public class MICommand implements ICommand { * The result is a new third command which represent the two * original command. */ + @Override public ICommand coalesceWith( ICommand command ) { return null ; } + @Override public IDMContext getContext(){ return fCtx; } @@ -289,6 +291,7 @@ public class MICommand implements ICommand { super(option); } + @Override public String getAdjustedValue() { StringBuilder builder = new StringBuilder(); String option = value; @@ -322,6 +325,7 @@ public class MICommand implements ICommand { super(parameter); } + @Override public String getAdjustedValue() { StringBuilder builder = new StringBuilder(); for (int j = 0; j < value.length(); j++) { @@ -361,6 +365,7 @@ public class MICommand implements ICommand { this.value = value; } + @Override public String getValue() { return value; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java index 967cccf2476..d8cdc8e37ea 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetAttributesInfo.java @@ -23,6 +23,7 @@ public class ExprMetaGetAttributesInfo implements ICommandResult { public boolean getEditable() { return editable; } + @Override public V getSubsetResult(ICommand command) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java index 80715d4fb73..29e4cb78f37 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildCountInfo.java @@ -23,6 +23,7 @@ public class ExprMetaGetChildCountInfo implements ICommandResult { public int getChildNum() { return childNum; } + @Override public V getSubsetResult(ICommand command) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java index 8cc6327f790..c89d44175f7 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetChildrenInfo.java @@ -24,6 +24,7 @@ public class ExprMetaGetChildrenInfo implements ICommandResult { public ExpressionInfo[] getChildrenExpressions() { return childrenExpressions; } + @Override public V getSubsetResult(ICommand command) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java index 0822b9f7099..fe641d193e4 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetValueInfo.java @@ -23,6 +23,7 @@ public class ExprMetaGetValueInfo implements ICommandResult { public String getValue() { return value; } + @Override public V getSubsetResult(ICommand command) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java index 6fc6fa6931f..5785f7a2eff 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/ExprMetaGetVarInfo.java @@ -101,6 +101,7 @@ public class ExprMetaGetVarInfo implements ICommandResult { return isCollectionHint; } + @Override public V getSubsetResult(ICommand command) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfo.java index 05a2e6f081e..ecf7ebb0996 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInfo.java @@ -94,6 +94,7 @@ public class MIInfo implements ICommandResult { * result canot be calculated for the given command. Deriving classes should * override this method as needed. */ + @Override public V getSubsetResult(ICommand command) { return null; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInstruction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInstruction.java index bbfc6563f51..cf3c3e6ae97 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInstruction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIInstruction.java @@ -29,26 +29,32 @@ public class MIInstruction extends AbstractInstruction { parse(tuple); } + @Override public BigInteger getAdress() { return address; } + @Override public String getFuntionName() { return function; } + @Override public long getOffset() { return offset; } + @Override public String getInstruction() { return opcode + " " + args; //$NON-NLS-1$; } + @Override public String getOpcode() { return opcode; } + @Override public String getArgs() { return args; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java index d8269b22f7d..5d085f1906f 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIListThreadGroupsInfo.java @@ -239,18 +239,27 @@ public class MIListThreadGroupsInfo extends MIInfo { return name; } + @Override public String getGroupId() { return fGroupId; } + @Override public String getPid() { return fPid; } + @Override public String getName() { return fName; } + @Override public String getDesciption() { return fDescription; } + @Override public String[] getCores() { return fCores; } + @Override public String getUser() { return fUser; } + @Override public String getType() { return fType; } + @Override public String getExecutable() { return fExecutable; } + @Override public MIThread[] getThreads() { return fThreadList; } } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIMixedInstruction.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIMixedInstruction.java index f4d4647966c..582a84484dd 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIMixedInstruction.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIMixedInstruction.java @@ -29,14 +29,17 @@ public class MIMixedInstruction implements IMixedInstruction { parse(tuple); } + @Override public String getFileName() { return fileName; } + @Override public int getLineNumber() { return lineNumber; } + @Override public IInstruction[] getInstructions() { return assemblyCode; } diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThreadListIdsInfo.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThreadListIdsInfo.java index 7d0131fe67c..2729cecf31e 100644 --- a/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThreadListIdsInfo.java +++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb/src/org/eclipse/cdt/dsf/mi/service/command/output/MIThreadListIdsInfo.java @@ -54,6 +54,7 @@ public class MIThreadListIdsInfo extends MIInfo { // We need our own comparator to treat these strings as integers. Arrays.sort(strThreadIds, new Comparator() { + @Override public int compare(String o1, String o2) { int threadInt1; int threadInt2; diff --git a/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters b/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters index 6dfc9ce04a6..d89b3e85b34 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters +++ b/dsf/org.eclipse.cdt.dsf.ui/.settings/.api_filters @@ -1,5 +1,13 @@ + + + + + + + + diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties index b88d2ccf30c..fa604141f8f 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.properties @@ -66,4 +66,9 @@ debugUpdateModes.label = Debug Update Modes # Pin & Clone PinView.name = Pin to Debug Context -OpenNewView.name = Open New View \ No newline at end of file +OpenNewView.name = Open New View + +# Disassembly ruler columns +disassemblyRulerColumn.addresses=Addresses +disassemblyRulerColumn.functionOffsets=Function Offsets +disassemblyRulerColumn.opcodes=Opcodes diff --git a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml index 6fbd3346834..95ad92131b9 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/plugin.xml +++ b/dsf/org.eclipse.cdt.dsf.ui/plugin.xml @@ -789,6 +789,59 @@ name="%disassemblyView.name"> - + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java index d5cfa50889a..00dee41f8b6 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/AddressRulerColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems and others. + * Copyright (c) 2007, 2011 Wind River Systems 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 @@ -15,6 +15,9 @@ import java.math.BigInteger; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.source.IAnnotationHover; import org.eclipse.jface.text.source.IAnnotationModel; @@ -22,6 +25,7 @@ import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.IVerticalRulerInfo; import org.eclipse.jface.text.source.IVerticalRulerInfoExtension; import org.eclipse.jface.text.source.IVerticalRulerListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.swt.SWT; /** @@ -29,6 +33,8 @@ import org.eclipse.swt.SWT; */ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerticalRulerInfo, IVerticalRulerInfoExtension, IAnnotationHover { + public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.address"; //$NON-NLS-1$ + private int fRadix; private boolean fShowRadixPrefix; private String fRadixPrefix; @@ -40,9 +46,11 @@ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerti */ public AddressRulerColumn() { super(SWT.LEFT); - setShowRadixPrefix(true); + IPreferenceStore prefs = getPreferenceStore(); + setForeground(getColor(DisassemblyPreferenceConstants.ADDRESS_COLOR)); + setRadix(prefs.getInt(DisassemblyPreferenceConstants.ADDRESS_RADIX)); + setShowRadixPrefix(prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX)); setAddressSize(32); - setRadix(16); } @Override @@ -128,49 +136,35 @@ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerti return buf.toString(); } - /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfo#getLineOfLastMouseButtonActivity() - */ + @Override public int getLineOfLastMouseButtonActivity() { return getParentRuler().getLineOfLastMouseButtonActivity(); } - /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfo#toDocumentLineNumber(int) - */ + @Override public int toDocumentLineNumber(int y_coordinate) { return getParentRuler().toDocumentLineNumber(y_coordinate); } - /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getHover() - */ + @Override public IAnnotationHover getHover() { return this; } - /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#getModel() - */ + @Override public IAnnotationModel getModel() { return null; } - /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#addVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) - */ + @Override public void addVerticalRulerListener(IVerticalRulerListener listener) { } - /* - * @see org.eclipse.jface.text.source.IVerticalRulerInfoExtension#removeVerticalRulerListener(org.eclipse.jface.text.source.IVerticalRulerListener) - */ + @Override public void removeVerticalRulerListener(IVerticalRulerListener listener) { } - /* - * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int) - */ + @Override public String getHoverInfo(ISourceViewer sourceViewer, int line) { DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument(); BigInteger address = doc.getAddressOfLine(line); @@ -181,4 +175,30 @@ public class AddressRulerColumn extends DisassemblyRulerColumn implements IVerti return null; } + @Override + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + IPreferenceStore store = getPreferenceStore(); + boolean needRedraw = false; + if (DisassemblyPreferenceConstants.ADDRESS_COLOR.equals(property)) { + setForeground(getColor(property)); + needRedraw = true; + } else if (DisassemblyPreferenceConstants.ADDRESS_RADIX.equals(property)) { + setRadix(store.getInt(property)); + updateNumberOfDigits(); + computeIndentations(); + layout(false); + needRedraw = true; + } else if (DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX.equals(property)) { + setShowRadixPrefix(store.getBoolean(property)); + updateNumberOfDigits(); + computeIndentations(); + layout(false); + needRedraw = true; + } + if (needRedraw) { + redraw(); + } + } + } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java new file mode 100644 index 00000000000..09f48dbba8c --- /dev/null +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyColumnSupport.java @@ -0,0 +1,209 @@ +/******************************************************************************* + * Copyright (c) 2011 Wind River Systems, Inc. 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: + * Wind River Systems - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.cdt.debug.ui.disassembly.rulers.IColumnSupport; +import org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn; +import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnDescriptor; +import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnRegistry; +import org.eclipse.core.runtime.Assert; +import org.eclipse.core.runtime.SafeRunner; +import org.eclipse.jface.text.source.CompositeRuler; +import org.eclipse.jface.text.source.IVerticalRulerColumn; +import org.eclipse.jface.text.source.IVerticalRulerInfo; +import org.eclipse.jface.util.SafeRunnable; + +/** + * Implements the ruler column support of for the given disassembly part. + *

+ * This is currently only used to support vertical ruler columns. + *

+ */ +class DisassemblyColumnSupport implements IColumnSupport { + private final DisassemblyPart fDisassembly; + private final RulerColumnRegistry fRegistry; + private final List fColumns; + + /** + * Creates a new column support for the given disassembly part. Only the disassembly part itself should normally + * create such an instance. + * + * @param editor the disassembly part + * @param registry the contribution registry to refer to + */ + public DisassemblyColumnSupport(DisassemblyPart disassembly, RulerColumnRegistry registry) { + Assert.isLegal(disassembly != null); + Assert.isLegal(registry != null); + fDisassembly= disassembly; + fRegistry= registry; + fColumns= new ArrayList(); + } + + /* + * @see org.eclipse.ui.texteditor.IColumnSupport#setColumnVisible(java.lang.String, boolean) + */ + @Override + public final void setColumnVisible(RulerColumnDescriptor descriptor, boolean visible) { + Assert.isLegal(descriptor != null); + + final CompositeRuler ruler= getRuler(); + if (ruler == null) + return; + + if (!isColumnSupported(descriptor)) + visible= false; + + if (isColumnVisible(descriptor)) { + if (!visible) + removeColumn(ruler, descriptor); + } else { + if (visible) + addColumn(ruler, descriptor); + } + } + + private void addColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) { + + final int idx= computeIndex(ruler, descriptor); + + SafeRunnable runnable= new SafeRunnable() { + @Override + public void run() throws Exception { + IContributedRulerColumn column= descriptor.createColumn(fDisassembly); + fColumns.add(column); + initializeColumn(column); + ruler.addDecorator(idx, column); + } + }; + SafeRunner.run(runnable); + } + + /** + * Hook to let subclasses initialize a newly created column. + *

+ * Subclasses may extend this method.

+ * + * @param column the created column + */ + protected void initializeColumn(IContributedRulerColumn column) { + } + + private void removeColumn(final CompositeRuler ruler, final RulerColumnDescriptor descriptor) { + removeColumn(ruler, getVisibleColumn(ruler, descriptor)); + } + + private void removeColumn(final CompositeRuler ruler, final IContributedRulerColumn rulerColumn) { + if (rulerColumn != null) { + SafeRunnable runnable= new SafeRunnable() { + @Override + public void run() throws Exception { + if (ruler != null) + ruler.removeDecorator(rulerColumn); + rulerColumn.columnRemoved(); + } + }; + SafeRunner.run(runnable); + } + } + + /** + * Returns the currently visible column matching id, null if + * none. + * + * @param ruler the composite ruler to scan + * @param descriptor the descriptor of the column of interest + * @return the matching column or null + */ + private IContributedRulerColumn getVisibleColumn(CompositeRuler ruler, RulerColumnDescriptor descriptor) { + for (Iterator it= ruler.getDecoratorIterator(); it.hasNext();) { + IVerticalRulerColumn column= (IVerticalRulerColumn)it.next(); + if (column instanceof IContributedRulerColumn) { + IContributedRulerColumn rulerColumn= (IContributedRulerColumn)column; + RulerColumnDescriptor rcd= rulerColumn.getDescriptor(); + if (descriptor.equals(rcd)) + return rulerColumn; + } + } + return null; + } + + /** + * Computes the insertion index for a column contribution into the currently visible columns. + * + * @param ruler the composite ruler into which to insert the column + * @param descriptor the descriptor to compute the index for + * @return the insertion index for a new column + */ + private int computeIndex(CompositeRuler ruler, RulerColumnDescriptor descriptor) { + int index= 0; + List all= fRegistry.getColumnDescriptors(); + int newPos= all.indexOf(descriptor); + for (Iterator it= ruler.getDecoratorIterator(); it.hasNext();) { + IVerticalRulerColumn column= (IVerticalRulerColumn) it.next(); + if (column instanceof IContributedRulerColumn) { + RulerColumnDescriptor rcd= ((IContributedRulerColumn)column).getDescriptor(); + if (rcd != null && all.indexOf(rcd) > newPos) + break; + } + index++; + } + return index; + } + + @Override + public final boolean isColumnVisible(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + CompositeRuler ruler= getRuler(); + return ruler != null && getVisibleColumn(ruler, descriptor) != null; + } + + @Override + public final boolean isColumnSupported(RulerColumnDescriptor descriptor) { + Assert.isLegal(descriptor != null); + if (getRuler() == null) + return false; + + if (descriptor == null) + return false; + + return descriptor.matchesPart(fDisassembly); + } + + /** + * Returns the disassembly part's vertical ruler, if it is a {@link CompositeRuler}, null + * otherwise. + * + * @return the disassembly part's {@link CompositeRuler} or null + */ + private CompositeRuler getRuler() { + Object ruler= fDisassembly.getAdapter(IVerticalRulerInfo.class); + if (ruler instanceof CompositeRuler) + return (CompositeRuler) ruler; + return null; + } + + /** + * {@inheritDoc} + *

+ * Subclasses may extend this method.

+ * + */ + @Override + public void dispose() { + for (Iterator iter= new ArrayList(fColumns).iterator(); iter.hasNext();) + removeColumn(getRuler(), iter.next()); + fColumns.clear(); + } +} diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java index 43f06655e32..909f8e9f931 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.java @@ -29,9 +29,6 @@ public final class DisassemblyMessages extends NLS { return fgBundleForConstructedKeys; } - public static String Disassembly_action_ShowAddresses_label; - public static String Disassembly_action_ShowFunctionOffsets_label; - public static String Disassembly_action_ShowOpcode_label; public static String Disassembly_action_ShowSource_label; public static String Disassembly_action_ShowSymbols_label; public static String Disassembly_action_GotoPC_label; @@ -52,6 +49,7 @@ public final class DisassemblyMessages extends NLS { public static String Disassembly_log_error_expression_eval; public static String Disassembly_log_error_locateFile; public static String Disassembly_log_error_readFile; + public static String DisassemblyPart_showRulerColumn_label; public static String DisassemblyPreferencePage_addressFormatTooltip; public static String DisassemblyPreferencePage_addressRadix; public static String DisassemblyPreferencePage_showAddressRadix; diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties index 9ba33204d52..a4098d6aa1b 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyMessages.properties @@ -11,9 +11,6 @@ # Patrick Chuong (Texas Instruments) - Bug fix (329682) ########################################################################## -Disassembly_action_ShowAddresses_label=Show Addresses -Disassembly_action_ShowFunctionOffsets_label=Show Function Offsets -Disassembly_action_ShowOpcode_label=Show Opcodes Disassembly_action_ShowSource_label=Show Source Disassembly_action_ShowSymbols_label=Show Symbols Disassembly_action_GotoPC_label=Go to Program Counter @@ -44,9 +41,10 @@ Disassembly_log_error_expression_eval=Expression does not evaluate to an address Disassembly_log_error_locateFile=Unable to locate file:\ Disassembly_log_error_readFile=Cannot read source file:\ +DisassemblyPart_showRulerColumn_label=Show {0} DisassemblyPreferencePage_addressFormatTooltip=Use this format for the instruction address DisassemblyPreferencePage_addressRadix=Address display format: -DisassemblyPreferencePage_showAddressRadix=Force radix prefixes +DisassemblyPreferencePage_showAddressRadix=Force radix prefix DisassemblyPreferencePage_showSource=Show source DisassemblyPreferencePage_showSourceTooltip=Show source code interleaved with instructions DisassemblyPreferencePage_showSymbols=Show symbols @@ -56,14 +54,8 @@ DisassemblyPreferencePage_error_negative_number=Address cannot be negative DisassemblyPreferencePage_radix_octal=Octal DisassemblyPreferencePage_radix_decimal=Decimal DisassemblyPreferencePage_radix_hexadecimal=Hexadecimal -DisassemblyPreferencePage_showFunctionOffsets=Show function offsets -DisassemblyPreferencePage_showFunctionOffsetsTooltip=Show offsets of addresses in a function -DisassemblyPreferencePage_showCodeBytes=Show instruction code bytes -DisassemblyPreferencePage_showCodeBytesTooltip=Show the value of the address for the instruction code bytes -DisassemblyPreferencePage_showAddress=Show instruction address DisassemblyPreferencePage_OpcodeFormatTooltip=Use this format for the instruction value DisassemblyPreferencePage_OpcodeFormat=Opcode display format: -DisassemblyPreferencePage_showAddressTooltip=Show the address of each instruction DisassemblyPreferencePage_showRadixTooltip=Show '0x' with hexadecimal addresses DisassemblyIPAnnotation_primary=Debug Current Instruction Pointer diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java index b90e8e99e9a..275588b02d8 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyPart.java @@ -38,6 +38,12 @@ import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyBackend; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.LabelPosition; +import org.eclipse.cdt.debug.internal.ui.preferences.StringSetSerializer; +import org.eclipse.cdt.debug.ui.disassembly.rulers.IColumnSupport; +import org.eclipse.cdt.debug.ui.disassembly.rulers.IContributedRulerColumn; +import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnDescriptor; +import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnPreferenceAdapter; +import org.eclipse.cdt.debug.ui.disassembly.rulers.RulerColumnRegistry; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.AbstractDisassemblyAction; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoAddress; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.actions.ActionGotoProgramCounter; @@ -50,6 +56,8 @@ import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocume import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.SourceFileInfo; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.presentation.DisassemblyIPAnnotation; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyViewer; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.IDisassemblyPart; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.util.HSL; import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; @@ -125,6 +133,7 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.custom.VerifyKeyListener; import org.eclipse.swt.dnd.DND; import org.eclipse.swt.dnd.DragSource; import org.eclipse.swt.dnd.DropTarget; @@ -133,6 +142,7 @@ import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.MouseAdapter; import org.eclipse.swt.events.MouseEvent; +import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.FontData; @@ -171,6 +181,9 @@ import org.eclipse.ui.texteditor.IUpdate; import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.eclipse.ui.texteditor.SimpleMarkerAnnotation; import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; + +import com.ibm.icu.text.MessageFormat; + /** * DisassemblyPart */ @@ -206,17 +219,19 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem public static final String KEY_BINDING_CONTEXT_DISASSEMBLY = "org.eclipse.cdt.dsf.debug.ui.disassembly.context"; //$NON-NLS-1$ + /** + * A named preference that controls the visible ruler column contributions. + */ + public static final String PREFERENCE_RULER_CONTRIBUTIONS= "rulerContributions"; //$NON-NLS-1$ + protected DisassemblyViewer fViewer; protected AbstractDisassemblyAction fActionGotoPC; protected AbstractDisassemblyAction fActionGotoAddress; protected AbstractDisassemblyAction fActionToggleSource; - private AbstractDisassemblyAction fActionToggleFunctionColumn; - private AbstractDisassemblyAction fActionToggleOpcodeColumn; protected AbstractDisassemblyAction fActionToggleSymbols; protected AbstractDisassemblyAction fActionRefreshView; protected Action fActionOpenPreferences; - private AbstractDisassemblyAction fActionToggleAddressColumn; private AbstractDisassemblyAction fActionToggleBreakpointEnablement; protected DisassemblyDocument fDocument; @@ -244,10 +259,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem private TextViewerDragAdapter fDragSourceAdapter; private DisassemblyDropAdapter fDropTargetAdapter; - private FunctionOffsetRulerColumn fFunctionOffsetRulerColumn; - private OpcodeRulerColumn fOpcodeRulerColumn; - private AddressRulerColumn fAddressRulerColumn; - private BigInteger fStartAddress; private BigInteger fEndAddress; private int fAddressSize= 32; @@ -272,8 +283,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem private List fSelectionActions = new ArrayList(); private List fStateDependentActions = new ArrayList(); private boolean fShowSource; - private boolean fShowFunctionOffsets; - private boolean fShowOpcodes; private boolean fShowSymbols; private Map fFile2Storage = new HashMap(); private boolean fShowDisassembly = true; @@ -294,26 +303,34 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem protected IPartListener2 fPartListener = new IPartListener2() { + @Override public void partActivated(IWorkbenchPartReference partRef) { } + @Override public void partBroughtToTop(IWorkbenchPartReference partRef) { } + @Override public void partClosed(IWorkbenchPartReference partRef) { } + @Override public void partDeactivated(IWorkbenchPartReference partRef) { } + @Override public void partOpened(IWorkbenchPartReference partRef) { } + @Override public void partHidden(IWorkbenchPartReference partRef) { if (partRef.getPart(false) == DisassemblyPart.this) { setActive(false); } } + @Override public void partVisible(IWorkbenchPartReference partRef) { if (partRef.getPart(false) == DisassemblyPart.this) { setActive(true); } } + @Override public void partInputChanged(IWorkbenchPartReference partRef) { } }; @@ -338,6 +355,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem private IDebugContextListener fDebugContextListener; + private IColumnSupport fColumnSupport; + private final class SyncActiveDebugContextAction extends Action { public SyncActiveDebugContextAction() { setChecked(DisassemblyPart.this.isSyncWithActiveDebugContext()); @@ -380,54 +399,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } } - private final class ActionToggleAddressColumn extends AbstractDisassemblyAction { - ActionToggleAddressColumn () { - super(DisassemblyPart.this); - setText(DisassemblyMessages.Disassembly_action_ShowAddresses_label); - } - @Override - public void run() { - IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore(); - store.setValue(DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER, !isAddressRulerVisible()); - } - @Override - public void update() { - setChecked(isAddressRulerVisible()); - } - } - - private final class ActionToggleFunctionColumn extends AbstractDisassemblyAction { - ActionToggleFunctionColumn() { - super(DisassemblyPart.this); - setText(DisassemblyMessages.Disassembly_action_ShowFunctionOffsets_label); - } - @Override - public void run() { - IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore(); - store.setValue(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS, !isFunctionOffsetsRulerVisible()); - } - @Override - public void update() { - setChecked(isFunctionOffsetsRulerVisible()); - } - } - - private final class ActionToggleOpcodeColumn extends AbstractDisassemblyAction { - ActionToggleOpcodeColumn() { - super(DisassemblyPart.this); - setText(DisassemblyMessages.Disassembly_action_ShowOpcode_label); - } - @Override - public void run() { - IPreferenceStore store = DsfUIPlugin.getDefault().getPreferenceStore(); - store.setValue(DisassemblyPreferenceConstants.SHOW_CODE_BYTES, !isOpcodeRulerVisible()); - } - @Override - public void update() { - setChecked(isOpcodeRulerVisible()); - } - } - private final class ActionToggleBreakpointEnablement extends AbstractDisassemblyAction { private IBreakpoint fBreakpoint; public ActionToggleBreakpointEnablement() { @@ -511,6 +482,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent) */ + @Override public void propertyChange(PropertyChangeEvent event) { handlePreferenceStoreChanged(event); } @@ -537,8 +509,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem else fEndAddress = new BigInteger(endAddressString, 16); fShowSource = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_SOURCE); - fShowFunctionOffsets = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS); - fShowOpcodes = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_CODE_BYTES); fShowSymbols = prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_SYMBOLS); fUpdateBeforeFocus = !prefs.getBoolean(DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC); fPCHistorySizeMax = prefs.getInt(DisassemblyPreferenceConstants.PC_HISTORY_SIZE); @@ -571,13 +541,76 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem return fViewer != null ? fViewer.getTextWidget() : null; } else if (IGotoMarker.class.equals(required)) { return new IGotoMarker() { + @Override public void gotoMarker(IMarker marker) { DisassemblyPart.this.gotoMarker(marker); }}; + } else if (IColumnSupport.class.equals(required)) { + if (fColumnSupport == null) + fColumnSupport= createColumnSupport(); + return fColumnSupport; } + return super.getAdapter(required); } + /** + * Adds "show" actions for all contributed rulers that support it. + * + * @param menu the ruler context menu + */ + private void addRulerContributionActions(IMenuManager menu) { + // store directly in generic editor preferences + final IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class); + IPreferenceStore store= DsfUIPlugin.getDefault().getPreferenceStore(); + final RulerColumnPreferenceAdapter adapter= new RulerColumnPreferenceAdapter(store, PREFERENCE_RULER_CONTRIBUTIONS); + List descriptors= RulerColumnRegistry.getDefault().getColumnDescriptors(); + for (final RulerColumnDescriptor descriptor : descriptors) { + if (!descriptor.isIncludedInMenu() || !support.isColumnSupported(descriptor)) + continue; + final boolean isVisible= support.isColumnVisible(descriptor); + IAction action= new Action(MessageFormat.format(DisassemblyMessages.DisassemblyPart_showRulerColumn_label, new Object[] {descriptor.getName()}), IAction.AS_CHECK_BOX) { + @Override + public void run() { + if (descriptor.isGlobal()) + // column state is modified via preference listener + adapter.setEnabled(descriptor, !isVisible); + else + // directly modify column for this editor instance + support.setColumnVisible(descriptor, !isVisible); + } + }; + action.setChecked(isVisible); + action.setImageDescriptor(descriptor.getIcon()); + menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, action); + } + } + + /** + * Adds enabled ruler contributions to the vertical ruler. + * + * @param ruler the composite ruler to add contributions to + */ + protected void updateContributedRulerColumns(CompositeRuler ruler) { + IColumnSupport support= (IColumnSupport)getAdapter(IColumnSupport.class); + if (support == null) + return; + + RulerColumnPreferenceAdapter adapter= null; + if (fPreferenceStore != null) + adapter= new RulerColumnPreferenceAdapter(getPreferenceStore(), PREFERENCE_RULER_CONTRIBUTIONS); + + RulerColumnRegistry registry= RulerColumnRegistry.getDefault(); + List descriptors= registry.getColumnDescriptors(); + for (RulerColumnDescriptor descriptor : descriptors) { + support.setColumnVisible(descriptor, adapter == null || adapter.isEnabled(descriptor)); + } + } + + protected IColumnSupport createColumnSupport() { + return new DisassemblyColumnSupport(this, RulerColumnRegistry.getDefault()); + } + private void setPreferenceStore(IPreferenceStore store) { if (fPreferenceStore != null) { fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener); @@ -610,28 +643,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem if (getFontPropertyPreferenceKey().equals(property)) { initializeViewerFont(fViewer); - } else if (property.equals(DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER)) { - fActionToggleAddressColumn.update(); - if (isAddressRulerVisible()) { - showAddressRuler(); - } else { - hideAddressRuler(); - } - } else if (property.equals(DisassemblyPreferenceConstants.ADDRESS_RADIX)) { - if (fAddressRulerColumn != null) { - hideAddressRuler(); - showAddressRuler(); - } - } else if (property.equals(DisassemblyPreferenceConstants.OPCODE_RADIX)) { - if (isOpcodeRulerVisible()) { - hideOpcodeRuler(); - showOpcodeRuler(); - } - } else if (property.equals(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX)) { - if (fAddressRulerColumn != null) { - hideAddressRuler(); - showAddressRuler(); - } } else if (property.equals(DisassemblyPreferenceConstants.SHOW_SOURCE)) { boolean showSource = store.getBoolean(property); if (fShowSource == showSource) { @@ -648,22 +659,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fShowSymbols = showSymbols; fActionToggleSymbols.update(); refreshView(10); - } else if (property.equals(DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS)) { - fShowFunctionOffsets = store.getBoolean(property); - fActionToggleFunctionColumn.update(); - if (isFunctionOffsetsRulerVisible()) { - showFunctionOffsetsRuler(); - } else { - hideFunctionOffsetsRuler(); - } - } else if (property.equals(DisassemblyPreferenceConstants.SHOW_CODE_BYTES)) { - fShowOpcodes = store.getBoolean(property); - fActionToggleOpcodeColumn.update(); - if (isOpcodeRulerVisible()) { - showOpcodeRuler(); - } else { - hideOpcodeRuler(); - } } else if (property.equals(DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC)) { fUpdateBeforeFocus = !store.getBoolean(property); updateVisibleArea(); @@ -676,7 +671,18 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } } else if (property.equals(DisassemblyPreferenceConstants.PC_HISTORY_SIZE)) { fPCHistorySizeMax = store.getInt(property); + } else if (PREFERENCE_RULER_CONTRIBUTIONS.equals(property)) { + String[] difference= StringSetSerializer.getDifference((String) event.getOldValue(), (String) event.getNewValue()); + IColumnSupport support= (IColumnSupport) getAdapter(IColumnSupport.class); + for (int i= 0; i < difference.length; i++) { + RulerColumnDescriptor desc= RulerColumnRegistry.getDefault().getColumnDescriptor(difference[i]); + if (desc != null && support.isColumnSupported(desc)) { + boolean newState= !support.isColumnVisible(desc); + support.setColumnVisible(desc, newState); + } + } } + } /** @@ -691,7 +697,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem parent.setLayout(layout); fVerticalRuler = createVerticalRuler(); int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; - fViewer = new DisassemblyViewer(this, parent, fVerticalRuler, getOverviewRuler(), true, styles); + fViewer = new DisassemblyViewer(parent, fVerticalRuler, getOverviewRuler(), true, styles); SourceViewerConfiguration sourceViewerConfig = new DisassemblyViewerConfiguration(this); fViewer.addTextPresentationListener(this); fViewer.configure(sourceViewerConfig); @@ -715,7 +721,21 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem hookContextMenu(); contributeToActionBars(); + fViewer.getTextWidget().addVerifyKeyListener(new VerifyKeyListener() { + @Override + public void verifyKey(VerifyEvent event) { + switch (event.keyCode) { + case SWT.PAGE_UP: + case SWT.PAGE_DOWN: + case SWT.ARROW_UP: + case SWT.ARROW_DOWN: + event.doit = !keyScroll(event.keyCode); + } + } + }); + fViewer.addSelectionChangedListener(new ISelectionChangedListener() { + @Override public void selectionChanged(SelectionChangedEvent event) { updateSelectionDependentActions(); } @@ -726,14 +746,9 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fSourceColor = getSharedColors().getColor(new RGB(64, 0, 80)); fLabelColor = getSharedColors().getColor(new RGB(0, 0, 96)); - if (isAddressRulerVisible()) { - showAddressRuler(); - } - if (isFunctionOffsetsRulerVisible()) { - showFunctionOffsetsRuler(); - } - if (isOpcodeRulerVisible()) { - showOpcodeRuler(); + IVerticalRuler ruler= getVerticalRuler(); + if (ruler instanceof CompositeRuler) { + updateContributedRulerColumns((CompositeRuler) ruler); } initDragAndDrop(); @@ -756,7 +771,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem super.setSite(site); site.getPage().addPartListener(fPartListener); fDebugContextListener = new IDebugContextListener() { - public void debugContextChanged(DebugContextEvent event) { + @Override + public void debugContextChanged(DebugContextEvent event) { if ((event.getFlags() & DebugContextEvent.ACTIVATED) != 0) { updateDebugContext(); } @@ -823,6 +839,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } fPropertyChangeListener = null; } + if (fColumnSupport != null) { + fColumnSupport.dispose(); + fColumnSupport= null; + } fDocument.dispose(); fDocument = null; @@ -1042,44 +1062,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem return ruler; } - /** - * Creates a new address ruler column that is appropriately initialized. - * - * @return the created line number column - */ - protected IVerticalRulerColumn createAddressRulerColumn() { - fAddressRulerColumn= new AddressRulerColumn(); - initializeRulerColumn(fAddressRulerColumn, DisassemblyPreferenceConstants.ADDRESS_COLOR); - IPreferenceStore prefs = getPreferenceStore(); - fAddressRulerColumn.setRadix(prefs.getInt(DisassemblyPreferenceConstants.ADDRESS_RADIX)); - fAddressRulerColumn.setShowRadixPrefix(prefs.getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX)); - return fAddressRulerColumn; - } - - /** - * Creates a new ruler column that is appropriately initialized. - * - * @return the created line number column - */ - protected IVerticalRulerColumn createFunctionOffsetsRulerColumn() { - fFunctionOffsetRulerColumn= new FunctionOffsetRulerColumn(); - - initializeRulerColumn(fFunctionOffsetRulerColumn, DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR); - - return fFunctionOffsetRulerColumn; - } - - protected IVerticalRulerColumn createOpcodeRulerColumn() { - fOpcodeRulerColumn= new OpcodeRulerColumn(); - - initializeRulerColumn(fOpcodeRulerColumn, DisassemblyPreferenceConstants.CODE_BYTES_COLOR); - - IPreferenceStore prefs = getPreferenceStore(); - fOpcodeRulerColumn.setRadix(prefs.getInt(DisassemblyPreferenceConstants.OPCODE_RADIX)); - - return fOpcodeRulerColumn; - } - /** * Initializes the given address ruler column from the preference store. * @@ -1128,99 +1110,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem return ruler; } - private boolean isAddressRulerVisible() { - return getPreferenceStore().getBoolean(DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER); - } - - /** - * Shows the address ruler column. - */ - private void showAddressRuler() { - if (fAddressRulerColumn == null) { - IVerticalRuler v= getVerticalRuler(); - if (v instanceof CompositeRuler) { - CompositeRuler c= (CompositeRuler) v; - c.addDecorator(1, createAddressRulerColumn()); - } - } - } - - /** - * Hides the address ruler column. - */ - private void hideAddressRuler() { - if (fAddressRulerColumn != null) { - IVerticalRuler v= getVerticalRuler(); - if (v instanceof CompositeRuler) { - CompositeRuler c= (CompositeRuler) v; - c.removeDecorator(fAddressRulerColumn); - } - fAddressRulerColumn = null; - } - } - - private boolean isFunctionOffsetsRulerVisible() { - return fShowFunctionOffsets; - } - - private boolean isOpcodeRulerVisible() { - return fShowOpcodes; - } - - /** - * Shows the function offset ruler column. - */ - private void showFunctionOffsetsRuler() { - if (fFunctionOffsetRulerColumn == null) { - IVerticalRuler v= getVerticalRuler(); - if (v instanceof CompositeRuler) { - CompositeRuler c= (CompositeRuler) v; - c.addDecorator(3, createFunctionOffsetsRulerColumn()); - } - } - } - - /** - * Hides the function offset ruler column. - */ - private void hideFunctionOffsetsRuler() { - if (fFunctionOffsetRulerColumn != null) { - IVerticalRuler v= getVerticalRuler(); - if (v instanceof CompositeRuler) { - CompositeRuler c= (CompositeRuler) v; - c.removeDecorator(fFunctionOffsetRulerColumn); - } - fFunctionOffsetRulerColumn = null; - } - } - - /** - * Shows the opcode ruler column. - */ - private void showOpcodeRuler() { - if (fOpcodeRulerColumn == null) { - IVerticalRuler v= getVerticalRuler(); - if (v instanceof CompositeRuler) { - CompositeRuler c= (CompositeRuler) v; - c.addDecorator(2, createOpcodeRulerColumn()); - } - } - } - - /** - * Hides the opcode ruler column. - */ - private void hideOpcodeRuler() { - if (fOpcodeRulerColumn != null) { - IVerticalRuler v= getVerticalRuler(); - if (v instanceof CompositeRuler) { - CompositeRuler c= (CompositeRuler) v; - c.removeDecorator(fOpcodeRulerColumn); - } - fOpcodeRulerColumn = null; - } - } - /** * Returns the annotation access. * @@ -1246,6 +1135,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem MenuManager menuMgr = new MenuManager(id, id); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager manager) { DisassemblyPart.this.fillContextMenu(manager); } @@ -1260,6 +1150,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem MenuManager menuMgr = new MenuManager(id, id); menuMgr.setRemoveAllWhenShown(true); menuMgr.addMenuListener(new IMenuListener() { + @Override public void menuAboutToShow(IMenuManager manager) { DisassemblyPart.this.fillRulerContextMenu(manager); } @@ -1315,9 +1206,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem protected void fillRulerContextMenu(IMenuManager manager) { fActionToggleBreakpointEnablement.update(); - fActionToggleAddressColumn.update(); - fActionToggleOpcodeColumn.update(); - fActionToggleFunctionColumn.update(); manager.add(new GroupMarker("group.top")); // ICommonMenuConstants.GROUP_TOP //$NON-NLS-1$ manager.add(new Separator("group.breakpoints")); //$NON-NLS-1$ @@ -1327,9 +1215,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem manager.add(new GroupMarker(ITextEditorActionConstants.GROUP_RESTORE)); manager.add(new Separator("add")); //$NON-NLS-1$ manager.add(new Separator(ITextEditorActionConstants.GROUP_RULERS)); - manager.add(fActionToggleAddressColumn); - manager.add(fActionToggleOpcodeColumn); - manager.add(fActionToggleFunctionColumn); + addRulerContributionActions(manager); manager.add(new Separator(ITextEditorActionConstants.GROUP_REST)); for (Object listener : fRulerContextMenuListeners.getListeners()) @@ -1429,9 +1315,6 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } }); fActionToggleBreakpointEnablement = new ActionToggleBreakpointEnablement(); - fActionToggleAddressColumn = new ActionToggleAddressColumn(); - fActionToggleOpcodeColumn = new ActionToggleOpcodeColumn(); - fActionToggleFunctionColumn = new ActionToggleFunctionColumn(); fActionToggleSymbols = new ActionToggleSymbols(); fActionRefreshView = new ActionRefreshView(); fSyncAction = new SyncActiveDebugContextAction(); @@ -1457,6 +1340,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoProgramCounter() */ + @Override public final void gotoProgramCounter() { if (fPCAddress != PC_RUNNING) { fPCLastAddress = PC_UNKNOWN; @@ -1467,6 +1351,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoAddress(java.math.BigInteger) */ + @Override public final void gotoAddress(IAddress address) { if (address != null) { gotoAddress(address.getValue()); @@ -1486,6 +1371,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoAddress(java.math.BigInteger) */ + @Override public final void gotoAddress(BigInteger address) { fFocusAddress = address; if (fDebugSessionId == null) { @@ -1517,6 +1403,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#gotoSymbol(java.lang.String) */ + @Override public final void gotoSymbol(final String symbol) { if (!fActive || fBackend == null || !fBackend.hasFrameContext()) { return; @@ -1563,12 +1450,14 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.jface.text.IViewportListener#viewportChanged(int) */ + @Override public void viewportChanged(int verticalOffset) { if (fDebugSessionId != null && fGotoAddressPending == PC_UNKNOWN && fScrollPos == null && !fUpdatePending && !fRefreshViewPending) { fUpdatePending = true; final int updateCount = fUpdateCount; invokeLater(new Runnable() { - public void run() { + @Override + public void run() { if (updateCount == fUpdateCount) { assert fUpdatePending; if (fUpdatePending) { @@ -1586,6 +1475,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem * * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#updateVisibleArea() */ + @Override public void updateVisibleArea() { assert isGuiThread(); if (!fActive || fUpdatePending || fViewer == null || fDebugSessionId == null) { @@ -1699,6 +1589,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#asyncExec(java.lang.Runnable) */ + @Override public void asyncExec(Runnable runnable) { if (fViewer != null) { fViewer.getControl().getDisplay().asyncExec(runnable); @@ -1718,6 +1609,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem * * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#updateInvalidSource() */ + @Override public void updateInvalidSource() { assert isGuiThread(); if (fViewer == null) { @@ -1765,7 +1657,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem return; } startUpdate(new Runnable() { - public void run() { + @Override + public void run() { if (DEBUG) System.out.println("retrieveDisassembly "+file); //$NON-NLS-1$ fBackend.retrieveDisassembly(file, lines, fEndAddress, mixed, fShowSymbols, fShowDisassembly); } @@ -1783,6 +1676,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#retrieveDisassembly(java.math.BigInteger, java.math.BigInteger, int, boolean, boolean) */ + @Override public void retrieveDisassembly(final BigInteger startAddress, BigInteger endAddress, final int linesHint, boolean mixed, boolean ignoreFile) { assert isGuiThread(); assert !fUpdatePending; @@ -1811,6 +1705,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#insertError(java.math.BigInteger, java.lang.String) */ + @Override public void insertError(BigInteger address, String message) { assert isGuiThread(); AddressRangePosition p = null; @@ -1828,6 +1723,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getAddressSize() */ + @Override public int getAddressSize() { assert isGuiThread(); return fAddressSize; @@ -1836,6 +1732,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#addressSizeChanged(int) */ + @Override public void addressSizeChanged(int addressSize) { assert isGuiThread(); BigInteger oldEndAddress= fEndAddress; @@ -1864,7 +1761,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } else { return; } - if (fAddressRulerColumn != null) { + AddressRulerColumn fAddressRulerColumn = (AddressRulerColumn) getRulerColumn(AddressRulerColumn.ID); + if (fAddressRulerColumn != null) { fAddressRulerColumn.setAddressSize(addressSize); if (fComposite != null) { fComposite.layout(true); @@ -1872,9 +1770,24 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } } + private IContributedRulerColumn getRulerColumn(String id) { + CompositeRuler compositeRuler = (CompositeRuler) getVerticalRuler(); + for (Iterator iter = compositeRuler.getDecoratorIterator(); iter.hasNext();) { + IVerticalRulerColumn column = (IVerticalRulerColumn) iter.next(); + if (column instanceof IContributedRulerColumn) { + IContributedRulerColumn contributedColumn = (IContributedRulerColumn) column; + if (id.equals(contributedColumn.getDescriptor().getId())) { + return contributedColumn; + } + } + } + return null; + } + /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getPositionOfAddress(java.math.BigInteger) */ + @Override public AddressRangePosition getPositionOfAddress(BigInteger address) { assert isGuiThread(); if (address == null || address.compareTo(BigInteger.ZERO) < 0) { @@ -1967,6 +1880,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } if (needUpdate && fViewer != null) { startUpdate(new Runnable() { + @Override public void run() { debugContextChanged(); } @@ -1980,7 +1894,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem final int updateCount = fUpdateCount; final SafeRunnable safeUpdate = new SafeRunnable() { - public void run() { + @Override + public void run() { if (updateCount == fUpdateCount) { update.run(); } @@ -1992,7 +1907,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem }; if (fUpdatePending) { invokeLater(new Runnable() { - public void run() { + @Override + public void run() { if (updateCount == fUpdateCount) { SafeRunner.run(safeUpdate); } @@ -2057,6 +1973,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem fRefreshViewPending = true; final long refreshViewScheduled = System.currentTimeMillis() + delay; final Runnable refresh = new Runnable() { + @Override public void run() { fRefreshViewPending = false; long now = System.currentTimeMillis(); @@ -2087,6 +2004,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem }}; if (delay > 0) { invokeLater(delay, new Runnable() { + @Override public void run() { doScrollLocked(refresh); }}); @@ -2230,6 +2148,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoFrame(int) */ + @Override public void gotoFrame(int frame) { assert isGuiThread(); fGotoAddressPending = PC_UNKNOWN; @@ -2239,6 +2158,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoFrameIfActive(int) */ + @Override public void gotoFrameIfActive(int frame) { assert isGuiThread(); if (fActive) { @@ -2252,6 +2172,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#gotoFrame(int, java.math.BigInteger) */ + @Override public void gotoFrame(int frame, BigInteger address) { assert isGuiThread(); if (DEBUG) System.out.println("gotoFrame " + frame + " " + getAddressText(address)); //$NON-NLS-1$ //$NON-NLS-2$ @@ -2332,6 +2253,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#isActive() */ + @Override public final boolean isActive() { return fActive; } @@ -2339,6 +2261,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#isConnected() */ + @Override public final boolean isConnected() { if (fDebugSessionId == null) { return false; @@ -2350,6 +2273,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#isSuspended() */ + @Override public final boolean isSuspended() { return isConnected() && fBackend.isSuspended(); } @@ -2357,10 +2281,12 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#getTextViewer() */ + @Override public final ISourceViewer getTextViewer() { return fViewer; } + @Override public final boolean hasViewer() { return fViewer != null; } @@ -2368,6 +2294,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#addRulerContextMenuListener(org.eclipse.jface.action.IMenuListener) */ + @Override public final void addRulerContextMenuListener(IMenuListener listener) { fRulerContextMenuListeners.add(listener); } @@ -2375,6 +2302,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.cdt.dsf.debug.internal.ui.disassembly.IDisassemblyPart#removeRulerContextMenuListener(org.eclipse.jface.action.IMenuListener) */ + @Override public final void removeRulerContextMenuListener(IMenuListener listener) { fRulerContextMenuListeners.remove(listener); } @@ -2476,6 +2404,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem * means target resumed * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#updatePC(java.math.BigInteger) */ + @Override public void updatePC(BigInteger pc) { assert isGuiThread(); if (!fPendingPCUpdates.isEmpty()) { @@ -2535,6 +2464,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem if (!fUpdatePending && !fDoPendingPosted) { fDoPendingPosted = true; invokeLater(new Runnable() { + @Override public void run() { doPending(); fDoPendingPosted = false; @@ -2546,6 +2476,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#doPending() */ + @Override public void doPending() { assert isGuiThread(); if (fViewer == null || fDocument == null) { @@ -2581,6 +2512,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem * @param doit * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#doScrollLocked(java.lang.Runnable) */ + @Override public void doScrollLocked(final Runnable doit) { assert isGuiThread(); if (fViewer == null || fDebugSessionId == null) { @@ -2600,7 +2532,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem if (fUpdatePending) { if (fRunnableQueue.size() == 1) { Runnable doitlater = new Runnable() { - public void run() { + @Override + public void run() { if (updateCount == fUpdateCount) { doScrollLocked(null); } @@ -2636,14 +2569,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#lockScroller() */ + @Override public void lockScroller() { assert isGuiThread(); assert fScrollPos == null; - if (isFunctionOffsetsRulerVisible()) { - fRedrawControl = fViewer.getControl(); - } else { - fRedrawControl = fViewer.getTextWidget(); - } + fRedrawControl = fViewer.getControl(); fRedrawControl.setRedraw(false); try { int topOffset = fViewer.getTopIndexStartOffset(); @@ -2680,6 +2610,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#unlockScroller() */ + @Override public void unlockScroller() { assert isGuiThread(); try { @@ -2732,7 +2663,8 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#insertSource(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition) */ - public void insertSource(AddressRangePosition _pos) { + @Override + public void insertSource(AddressRangePosition _pos) { assert isGuiThread(); // IDisassemblyPartCallback does not have visibility to the // SourcePosition type, which is DSF-specific, so it uses the base type @@ -2838,6 +2770,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* * @see org.eclipse.jface.text.ITextPresentationListener#applyTextPresentation(org.eclipse.jface.text.TextPresentation) */ + @Override @SuppressWarnings("unchecked") public void applyTextPresentation(TextPresentation textPresentation) { IRegion coverage = textPresentation.getExtent(); @@ -2934,9 +2867,11 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem } } + @Override public AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int lineNumber) { return insertSource(pos, address, file, lineNumber, lineNumber); } + @Override public AddressRangePosition insertSource(AddressRangePosition pos, BigInteger address, final String file, int firstLine, int lastLine) { assert isGuiThread(); Object sourceElement = null; @@ -3020,8 +2955,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#handleTargetSuspended() */ + @Override public void handleTargetSuspended() { asyncExec(new Runnable() { + @Override public void run() { updatePC(PC_UNKNOWN); firePropertyChange(PROP_SUSPENDED); @@ -3032,8 +2969,10 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#handleTargetResumed() */ + @Override public void handleTargetResumed() { asyncExec(new Runnable() { + @Override public void run() { updatePC(PC_RUNNING); firePropertyChange(PROP_SUSPENDED); @@ -3044,12 +2983,15 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#handleTargetEnded() */ + @Override public void handleTargetEnded() { asyncExec(new Runnable() { + @Override public void run() { fDebugSessionId = null; startUpdate(new Runnable() { - public void run() { + @Override + public void run() { debugContextChanged(); } }); @@ -3060,6 +3002,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#setUpdatePending(boolean) */ + @Override public void setUpdatePending(boolean pending) { fUpdatePending = pending; } @@ -3067,6 +3010,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getUpdatePending() */ + @Override public boolean getUpdatePending() { assert isGuiThread(); return fUpdatePending; @@ -3075,6 +3019,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#setGotoAddressPending(java.math.BigInteger) */ + @Override public void setGotoAddressPending(BigInteger address) { assert isGuiThread(); fGotoAddressPending = address; @@ -3083,6 +3028,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getGotoAddressPending() */ + @Override public BigInteger getGotoAddressPending() { assert isGuiThread(); return fGotoAddressPending; @@ -3091,6 +3037,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getDocument() */ + @Override public IDisassemblyDocument getDocument() { assert isGuiThread(); return fDocument; @@ -3099,6 +3046,7 @@ public abstract class DisassemblyPart extends WorkbenchPart implements IDisassem /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyPartCallback#getStorageForFile(java.lang.String) */ + @Override public Object getStorageForFile(String file) { assert isGuiThread(); return fFile2Storage.get(file); diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java index 119cfb845c3..0c2fb8fddce 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/FunctionOffsetRulerColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Wind River Systems and others. + * Copyright (c) 2007, 2011 Wind River Systems 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 @@ -13,13 +13,18 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn; import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.util.PropertyChangeEvent; /** * A vertical ruler column to display the function + offset of instructions. */ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn { + public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.functionOffset"; //$NON-NLS-1$ + /** Maximum width of column (in characters) */ private static final int MAXWIDTH= 20; @@ -28,6 +33,7 @@ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn { */ public FunctionOffsetRulerColumn() { super(); + setForeground(getColor(DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR)); } /* @@ -62,4 +68,17 @@ public class FunctionOffsetRulerColumn extends DisassemblyRulerColumn { return Math.min(MAXWIDTH, doc.getMaxFunctionLength()); } + @Override + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + boolean needRedraw = false; + if (DisassemblyPreferenceConstants.FUNCTION_OFFSETS_COLOR.equals(property)) { + setForeground(getColor(property)); + needRedraw = true; + } + if (needRedraw) { + redraw(); + } + } + } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java index 707d32205d7..bfcf196172f 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/OpcodeRulerColumn.java @@ -13,13 +13,19 @@ package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition; import org.eclipse.cdt.debug.internal.ui.disassembly.dsf.DisassemblyPosition; import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.model.DisassemblyDocument; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.preferences.DisassemblyPreferenceConstants; +import org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional.DisassemblyRulerColumn; +import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; +import org.eclipse.jface.util.PropertyChangeEvent; /** * A vertical ruler column to display the opcodes of instructions. */ public class OpcodeRulerColumn extends DisassemblyRulerColumn { + public static final String ID = "org.eclipse.cdt.dsf.ui.disassemblyColumn.opcode"; //$NON-NLS-1$ + private int fRadix; private String fRadixPrefix; @@ -28,6 +34,8 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn { */ public OpcodeRulerColumn() { super(); + setForeground(getColor(DisassemblyPreferenceConstants.CODE_BYTES_COLOR)); + setRadix(getPreferenceStore().getInt(DisassemblyPreferenceConstants.OPCODE_RADIX)); } public void setRadix(int radix) { @@ -91,4 +99,23 @@ public class OpcodeRulerColumn extends DisassemblyRulerColumn { DisassemblyDocument doc = (DisassemblyDocument)getParentRuler().getTextViewer().getDocument(); return doc.getMaxOpcodeLength(fRadix); } + + @Override + public void propertyChange(PropertyChangeEvent event) { + String property = event.getProperty(); + IPreferenceStore store = getPreferenceStore(); + boolean needRedraw = false; + if (DisassemblyPreferenceConstants.CODE_BYTES_COLOR.equals(property)) { + setForeground(getColor(property)); + needRedraw = true; + } else if (DisassemblyPreferenceConstants.OPCODE_RADIX.equals(property)) { + setRadix(store.getInt(property)); + layout(false); + needRedraw = true; + } + if (needRedraw) { + redraw(); + } + } + } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java index befaeac8abd..a23a5ac80e4 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/model/DisassemblyDocument.java @@ -103,6 +103,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu setShowRadixPrefix(false); fNumberOfInstructions = 0; fMeanSizeOfInstructions = 4; + fMaxFunctionLength = 0; } /** @@ -120,9 +121,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu fi.dispose(); } fFileInfoMap.clear(); - fInvalidAddressRanges.clear(); - fInvalidSource.clear(); } @@ -141,8 +140,8 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu return fInvalidAddressRanges.toArray(new AddressRangePosition[fInvalidAddressRanges.size()]); } - public void setMaxFunctionLength(int opcodeLength) { - fMaxFunctionLength = opcodeLength; + public void setMaxFunctionLength(int functionLength) { + fMaxFunctionLength = functionLength; } public int getMaxFunctionLength() { @@ -1019,6 +1018,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertDisassemblyLine(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, int, java.lang.String, java.lang.String, java.lang.String, int) */ + @Override public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String functionOffset, String instruction, String file, int lineNr) throws BadLocationException { return insertDisassemblyLine(pos, address, length, functionOffset, null, instruction, file, lineNr); @@ -1027,6 +1027,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertDisassemblyLine(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, int, java.lang.String, java.lang.String, java.lang.String, int) */ + @Override public AddressRangePosition insertDisassemblyLine(AddressRangePosition pos, BigInteger address, int length, String functionOffset, BigInteger opcode, String instruction, String file, int lineNr) throws BadLocationException { assert isGuiThread(); @@ -1194,6 +1195,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu /* (non-Javadoc) * @see org.eclipse.cdt.debug.internal.ui.disassembly.dsf.IDisassemblyDocument#insertLabel(org.eclipse.cdt.debug.internal.ui.disassembly.dsf.AddressRangePosition, java.math.BigInteger, java.lang.String, boolean) */ + @Override public AddressRangePosition insertLabel(AddressRangePosition pos, BigInteger address, String label, boolean showLabels) throws BadLocationException { assert isGuiThread(); @@ -1552,6 +1554,7 @@ public class DisassemblyDocument extends REDDocument implements IDisassemblyDocu } } + @Override public void addInvalidAddressRange(AddressRangePosition pos) { assert isGuiThread(); if (DEBUG) System.out.println("Adding to invalid range list: " + pos); //$NON-NLS-1$ diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java index 381ad0c2001..8af99458e51 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferenceConstants.java @@ -32,11 +32,8 @@ public class DisassemblyPreferenceConstants { public static final String ADDRESS_RADIX = "disassembly.addressRadix"; //$NON-NLS-1$ public static final String OPCODE_RADIX = "disassembly.opcodeRadix"; //$NON-NLS-1$ public static final String SHOW_ADDRESS_RADIX = "disassembly.showAddressRadix"; //$NON-NLS-1$ - public static final String SHOW_ADDRESS_RULER = "disassembly.showAddressRuler"; //$NON-NLS-1$ public static final String ADDRESS_COLOR = "disassembly.addressColor"; //$NON-NLS-1$ - public static final String SHOW_FUNCTION_OFFSETS = "disassembly.showFunctionOffsetRuler"; //$NON-NLS-1$ public static final String FUNCTION_OFFSETS_COLOR = "disassembly.functionOffsetsColor"; //$NON-NLS-1$ - public static final String SHOW_CODE_BYTES = "disassembly.showCodeBytesRuler"; //$NON-NLS-1$ public static final String CODE_BYTES_COLOR = "disassembly.codeBytesColor"; //$NON-NLS-1$ public static final String AVOID_READ_BEFORE_PC = "disassembly.avoidReadBeforePC"; //$NON-NLS-1$ public static final String TRACK_EXPRESSION = "disassembly.trackExpression"; //$NON-NLS-1$ @@ -58,13 +55,10 @@ public class DisassemblyPreferenceConstants { store.setDefault(END_ADDRESS, "0x" + BigInteger.ONE.shiftLeft(64).toString(16)); //$NON-NLS-1$ store.setDefault(PC_HISTORY_SIZE, 4); store.setDefault(SHOW_SOURCE, true); - store.setDefault(SHOW_FUNCTION_OFFSETS, false); - store.setDefault(SHOW_CODE_BYTES, false); store.setDefault(SHOW_SYMBOLS, true); store.setDefault(ADDRESS_RADIX, 16); store.setDefault(OPCODE_RADIX, 16); store.setDefault(SHOW_ADDRESS_RADIX, false); - store.setDefault(SHOW_ADDRESS_RULER, true); store.setDefault(AVOID_READ_BEFORE_PC, false); PreferenceConverter.setDefault(store, ADDRESS_COLOR, new RGB(0, 96, 0)); PreferenceConverter.setDefault(store, FUNCTION_OFFSETS_COLOR, new RGB(96, 0, 0)); diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java index 25cc9600e9b..0fa58417d5e 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/preferences/DisassemblyPreferencePage.java @@ -23,8 +23,6 @@ import org.eclipse.jface.preference.PreferencePage; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -46,6 +44,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe private List fComboBoxes = new ArrayList(); private ArrayList fNumberFields = new ArrayList(); private ModifyListener fNumberFieldListener = new ModifyListener() { + @Override public void modifyText(ModifyEvent e) { numberFieldChanged((Text)e.widget); } @@ -93,38 +92,17 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe String label; -// label = DisassemblyMessages.DisassemblyPreferencePage_startAddress; //$NON-NLS-1$ -// addTextField(composite, label, DisassemblyPreferenceConstants.START_ADDRESS, 20, 0, true); -// label = DisassemblyMessages.DisassemblyPreferencePage_endAddress; //$NON-NLS-1$ -// addTextField(composite, label, DisassemblyPreferenceConstants.END_ADDRESS, 20, 0, true); - - label = DisassemblyMessages.DisassemblyPreferencePage_showAddress; - final Button showAddressCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RULER, 0); - showAddressCB.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fAddressFormatCombo.setEnabled(showAddressCB.getSelection()); - } - }); - showAddressCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showAddressTooltip); label = DisassemblyMessages.DisassemblyPreferencePage_addressRadix; fAddressFormatCombo = addComboBox(composite, label, DisassemblyPreferenceConstants.ADDRESS_RADIX, fcRadixItems); fAddressFormatCombo.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_addressFormatTooltip); - label = DisassemblyMessages.DisassemblyPreferencePage_showCodeBytes; - final Button showCodeBytes= addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_CODE_BYTES, 0); - showCodeBytes.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - fOpcodeFormatCombo.setEnabled(showCodeBytes.getSelection()); - } - }); - showCodeBytes.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showCodeBytesTooltip); + label = DisassemblyMessages.DisassemblyPreferencePage_showAddressRadix; + Button showRadixCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX, 0); + showRadixCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showRadixTooltip); + label = DisassemblyMessages.DisassemblyPreferencePage_OpcodeFormat; fOpcodeFormatCombo = addComboBox(composite, label, DisassemblyPreferenceConstants.OPCODE_RADIX, fcRadixItems); fOpcodeFormatCombo.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_OpcodeFormatTooltip); -// label = DisassemblyMessages.DisassemblyPreferencePage_instructionRadix; -// addComboBox(composite, label, DisassemblyPreferenceConstants.INSTRUCTION_RADIX, fcRadixItems); label = DisassemblyMessages.DisassemblyPreferencePage_showSource; Button showSourceCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_SOURCE, 0); @@ -132,42 +110,6 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe label = DisassemblyMessages.DisassemblyPreferencePage_showSymbols; Button showSymbolsCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_SYMBOLS, 0); showSymbolsCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showSymbolsTooltip); -// label = DisassemblyMessages.DisassemblyPreferencePage_simplifiedMnemonics; -// addCheckBox(composite, label, DisassemblyPreferenceConstants.SIMPLIFIED, 0); - label = DisassemblyMessages.DisassemblyPreferencePage_showAddressRadix; - Button showRadixCB = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_ADDRESS_RADIX, 0); - showRadixCB.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showRadixTooltip); - label = DisassemblyMessages.DisassemblyPreferencePage_showFunctionOffsets; - Button showFunctionOffsets = addCheckBox(composite, label, DisassemblyPreferenceConstants.SHOW_FUNCTION_OFFSETS, 0); - showFunctionOffsets.setToolTipText(DisassemblyMessages.DisassemblyPreferencePage_showFunctionOffsetsTooltip); -// label = DisassemblyMessages.DisassemblyPreferencePage_avoidReadBeforePC; -// addCheckBox(composite, label, DisassemblyPreferenceConstants.AVOID_READ_BEFORE_PC, 0); - - // horizontal line -// Label separator = new Label(composite, SWT.SEPARATOR|SWT.HORIZONTAL); -// GridData data; -// data = new GridData(GridData.FILL_HORIZONTAL); -// data.horizontalSpan = layout.numColumns; -// separator.setLayoutData(data); -// -// label = DisassemblyMessages.DisassemblyPreferencePage_useSourceOnlyMode; -// addCheckBox(composite, label, DisassemblyPreferenceConstants.USE_SOURCE_ONLY_MODE, 0); -// -// // note -// String noteTitle = DisassemblyMessages.DisassemblyPreferencePage_useSourceOnlyMode_noteTtitle; -// String noteMessage = DisassemblyMessages.DisassemblyPreferencePage_useSourceOnlyMode_noteMessage; -// Composite note = createNoteComposite(composite.getFont(), composite, noteTitle, noteMessage); -// data = (GridData)note.getLayoutData(); -// if (data == null) { -// data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); -// note.setLayoutData(data); -// } -// data.horizontalSpan = layout.numColumns; -// Control msgControl = note.getChildren()[1]; -// data = new GridData(GridData.FILL_HORIZONTAL); -// data.widthHint = convertWidthInCharsToPixels(65); -// data.heightHint = convertHeightInCharsToPixels(3); -// msgControl.setLayoutData(data); Dialog.applyDialogFont(parent); @@ -179,6 +121,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe /* (non-Javadoc) * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) */ + @Override public void init(IWorkbench workbench) { } @@ -200,7 +143,7 @@ public class DisassemblyPreferencePage extends PreferencePage implements IWorkbe Label labelControl= new Label(parent, SWT.NONE); labelControl.setText(label); GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); - gd.horizontalIndent = 16; + gd.horizontalIndent = 0; gd.horizontalSpan = 2; labelControl.setLayoutData(gd); diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyRulerColumn.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java similarity index 94% rename from dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyRulerColumn.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java index f7017ef1a29..e3edb3db2b4 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyRulerColumn.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyRulerColumn.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2011 IBM Corporation 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 @@ -10,11 +10,15 @@ * Anton Leherbauer (Wind River Systems) *******************************************************************************/ -package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional; import java.util.Arrays; +import org.eclipse.cdt.debug.ui.disassembly.rulers.AbstractContributedRulerColumn; +import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin; import org.eclipse.core.runtime.Assert; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.IRegion; @@ -26,7 +30,8 @@ import org.eclipse.jface.text.IViewportListener; import org.eclipse.jface.text.TextEvent; import org.eclipse.jface.text.source.CompositeRuler; import org.eclipse.jface.text.source.IAnnotationModel; -import org.eclipse.jface.text.source.IVerticalRulerColumn; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.ISelectionChangedListener; import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.swt.SWT; @@ -46,11 +51,13 @@ import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Canvas; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.editors.text.EditorsUI; /** * Vertical ruler column for use with disassembly parts. @@ -58,7 +65,7 @@ import org.eclipse.swt.widgets.Display; * Derived from {@link org.eclipse.jface.text.source.LineNumberRulerColumn}. *

*/ -public class DisassemblyRulerColumn implements IVerticalRulerColumn { +public class DisassemblyRulerColumn extends AbstractContributedRulerColumn implements IPropertyChangeListener { protected final static String DOTS = "......................................................................"; //$NON-NLS-1$ protected final static String SPACES = " "; //$NON-NLS-1$ @@ -70,6 +77,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see IViewportListener#viewportChanged(int) */ + @Override public void viewportChanged(int verticalPosition) { if (verticalPosition != fScrollPos) redraw(); @@ -78,6 +86,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see ITextListener#textChanged(TextEvent) */ + @Override public void textChanged(TextEvent event) { if (updateNumberOfDigits()) { @@ -97,6 +106,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent) */ + @Override public void selectionChanged(SelectionChangedEvent event) { postRedraw(); } @@ -119,6 +129,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseUp(MouseEvent event) { // see bug 45700 if (event.button == 1) { @@ -131,6 +142,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseDown(MouseEvent event) { fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y); // see bug 45700 @@ -142,6 +154,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseDoubleClick(MouseEvent event) { fParentRuler.setLocationOfLastMouseButtonActivity(event.x, event.y); stopSelecting(); @@ -151,6 +164,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseMove(MouseEvent event) { if (!autoScroll(event)) { int newLine = fParentRuler.toDocumentLineNumber(event.y); @@ -161,18 +175,21 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseEnter(MouseEvent event) { } /* * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseExit(MouseEvent event) { } /* * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent) */ + @Override public void mouseHover(MouseEvent event) { } @@ -283,6 +300,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { switch (direction) { case SWT.UP: timer = new Runnable() { + @Override public void run() { if (fAutoScrollDirection == SWT.UP) { int top = getInclusiveTopIndex(); @@ -297,6 +315,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { break; case SWT.DOWN: timer = new Runnable() { + @Override public void run() { if (fAutoScrollDirection == SWT.DOWN) { int top = getInclusiveTopIndex(); @@ -372,6 +391,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { * Redraw runnable */ private Runnable fRunnable = new Runnable() { + @Override public void run() { synchronized (fRunnableLock) { fIsRunnablePosted = false; @@ -402,6 +422,18 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { fPaintStyleBackground = paintStyle; } + @Override + public void columnCreated() { + super.columnCreated(); + getPreferenceStore().addPropertyChangeListener(this); + } + + @Override + public void columnRemoved() { + getPreferenceStore().removePropertyChangeListener(this); + super.columnRemoved(); + } + /** * Sets the foreground color of this column. * @@ -446,9 +478,14 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { return fBackground; } + public IPreferenceStore getPreferenceStore() { + return DsfUIPlugin.getDefault().getPreferenceStore(); + } + /* * @see IVerticalRulerColumn#getControl() */ + @Override public Control getControl() { return fCanvas; } @@ -456,6 +493,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see IVerticalRuleColumnr#getWidth */ + @Override public int getWidth() { return fIndentation[0]; } @@ -556,6 +594,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see IVerticalRulerColumn#createControl(CompositeRuler, Composite) */ + @Override public Control createControl(CompositeRuler parentRuler, Composite parentControl) { fParentRuler= parentRuler; @@ -567,6 +606,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { fCanvas.setForeground(fForeground); fCanvas.addPaintListener(new PaintListener() { + @Override public void paintControl(PaintEvent event) { if (fCachedTextViewer != null) doubleBufferPaint(event.gc); @@ -574,6 +614,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { }); fCanvas.addDisposeListener(new DisposeListener() { + @Override public void widgetDisposed(DisposeEvent e) { handleDispose(); fCachedTextViewer= null; @@ -620,6 +661,14 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { } } + protected Color getColor(String key) { + return EditorsUI.getSharedTextColors().getColor(PreferenceConverter.getColor(getPreferenceStore(), key)); + } + + protected Color getColor(RGB color) { + return EditorsUI.getSharedTextColors().getColor(color); + } + /** * Double buffer drawing. * @@ -769,7 +818,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { * the line number for which the string is generated * @return the string to be printed on the ruler column for line */ - String createDisplayString(int line) { + protected String createDisplayString(int line) { return Integer.toString(line + 1); } @@ -941,6 +990,7 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see IVerticalRulerColumn#redraw() */ + @Override public void redraw() { if (fRelayoutRequired) { @@ -958,12 +1008,14 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { /* * @see IVerticalRulerColumn#setModel(IAnnotationModel) */ + @Override public void setModel(IAnnotationModel model) { } /* * @see IVerticalRulerColumn#setFont(Font) */ + @Override public void setFont(Font font) { fFont= font; if (fCanvas != null && !fCanvas.isDisposed()) { @@ -982,4 +1034,8 @@ public class DisassemblyRulerColumn implements IVerticalRulerColumn { return fParentRuler; } + @Override + public void propertyChange(PropertyChangeEvent event) { + } + } diff --git a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java similarity index 85% rename from dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java rename to dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java index 7d4a4e43006..b790a0339ce 100644 --- a/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/DisassemblyViewer.java +++ b/dsf/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/internal/ui/disassembly/provisional/DisassemblyViewer.java @@ -8,7 +8,7 @@ * Contributors: * Wind River Systems - initial API and implementation *******************************************************************************/ -package org.eclipse.cdt.dsf.debug.internal.ui.disassembly; +package org.eclipse.cdt.dsf.debug.internal.ui.disassembly.provisional; import java.util.Iterator; @@ -24,15 +24,12 @@ import org.eclipse.jface.text.source.IOverviewRuler; import org.eclipse.jface.text.source.IVerticalRuler; import org.eclipse.jface.text.source.IVerticalRulerColumn; import org.eclipse.jface.text.source.SourceViewer; -import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.custom.VerifyKeyListener; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.dnd.TextTransfer; import org.eclipse.swt.dnd.Transfer; import org.eclipse.swt.events.ControlEvent; import org.eclipse.swt.events.ControlListener; -import org.eclipse.swt.events.VerifyEvent; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.widgets.Composite; @@ -43,15 +40,11 @@ import org.eclipse.swt.widgets.Composite; public class DisassemblyViewer extends SourceViewer { class ResizeListener implements ControlListener { - /* - * @see ControlListener#controlResized(ControlEvent) - */ + @Override public void controlResized(ControlEvent e) { updateViewportListeners(RESIZE); } - /* - * @see ControlListener#controlMoved(ControlEvent) - */ + @Override public void controlMoved(ControlEvent e) { } } @@ -59,11 +52,6 @@ public class DisassemblyViewer extends SourceViewer { private boolean fUserTriggeredScrolling; private int fCachedLastTopPixel; - // extra resize listener to workaround bug 171018 - // https://bugs.eclipse.org/bugs/show_bug.cgi?id=171018 - private ResizeListener fResizeListener; - private DisassemblyPart fPart; - /** * Create a new DisassemblyViewer. * @param parent @@ -72,9 +60,8 @@ public class DisassemblyViewer extends SourceViewer { * @param showsAnnotationOverview * @param styles */ - public DisassemblyViewer(DisassemblyPart part, Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) { + public DisassemblyViewer(Composite parent, IVerticalRuler ruler, IOverviewRuler overviewRuler, boolean showsAnnotationOverview, int styles) { super(parent, ruler, overviewRuler, showsAnnotationOverview, styles); - fPart = part; // always readonly setEditable(false); } @@ -86,30 +73,9 @@ public class DisassemblyViewer extends SourceViewer { protected void createControl(Composite parent, int styles) { super.createControl(parent, styles); StyledText textWidget = getTextWidget(); + // extra resize listener to workaround bug 171018 // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=171018 - textWidget.addControlListener(fResizeListener= new ResizeListener()); - textWidget.addVerifyKeyListener(new VerifyKeyListener() { - public void verifyKey(VerifyEvent event) { - switch (event.keyCode) { - case SWT.PAGE_UP: - case SWT.PAGE_DOWN: - case SWT.ARROW_UP: - case SWT.ARROW_DOWN: - event.doit = !fPart.keyScroll(event.keyCode); - } - } - }); - } - - /* - * @see org.eclipse.jface.text.source.SourceViewer#handleDispose() - */ - @Override - protected void handleDispose() { - if (fResizeListener != null) { - getTextWidget().removeControlListener(fResizeListener); - } - super.handleDispose(); + textWidget.addControlListener(new ResizeListener()); } /* @@ -150,7 +116,7 @@ public class DisassemblyViewer extends SourceViewer { * @throws BadLocationException */ public String getSelectedText() throws BadLocationException { - StringBuffer text = new StringBuffer(200); + StringBuilder text = new StringBuilder(200); String lineSeparator = System.getProperty("line.separator"); //$NON-NLS-1$ DisassemblyDocument doc = (DisassemblyDocument)getDocument(); Point selection = getSelectedRange(); @@ -204,7 +170,7 @@ public class DisassemblyViewer extends SourceViewer { * @return the prefix string with trailing blank or the empty string */ public String getLinePrefix(int line) { - StringBuffer prefix = new StringBuffer(10); + StringBuilder prefix = new StringBuilder(10); IVerticalRuler ruler = getVerticalRuler(); if (ruler instanceof CompositeRuler) { for (Iterator iter = ((CompositeRuler)ruler).getDecoratorIterator(); iter.hasNext();) { @@ -280,10 +246,11 @@ public class DisassemblyViewer extends SourceViewer { return -1; } - int getLastTopPixel() { + public int getLastTopPixel() { return fCachedLastTopPixel; } - boolean isUserTriggeredScrolling() { + + public boolean isUserTriggeredScrolling() { return fUserTriggeredScrolling; }