diff options
author | Anton Leherbauer | 2010-05-28 08:00:01 +0000 |
---|---|---|
committer | Anton Leherbauer | 2010-05-28 08:00:01 +0000 |
commit | 599285f0c3feb5222774868d21a202c09b1cecfb (patch) | |
tree | 2535c935c930f28f341c531e6a6e11844908a3b2 /core | |
parent | ca9f612e04648c2c5aa924872ea7d7e37527ac6a (diff) | |
download | org.eclipse.cdt-599285f0c3feb5222774868d21a202c09b1cecfb.tar.gz org.eclipse.cdt-599285f0c3feb5222774868d21a202c09b1cecfb.tar.xz org.eclipse.cdt-599285f0c3feb5222774868d21a202c09b1cecfb.zip |
Bug 314635 - Marking occurrences is very slow on a large file due to searching for implicitReferences (interim fix)
Diffstat (limited to 'core')
3 files changed, 43 insertions, 11 deletions
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java index 922db6353c4..bb43b37e797 100644 --- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java +++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/MarkOccurrenceTest.java @@ -54,6 +54,7 @@ import org.eclipse.cdt.ui.testplugin.EditorTestHelper; import org.eclipse.cdt.ui.tests.BaseUITestCase; import org.eclipse.cdt.internal.ui.editor.CEditor; +import org.eclipse.cdt.internal.ui.editor.SemanticHighlightings; import org.eclipse.cdt.internal.ui.viewsupport.ISelectionListenerWithAST; import org.eclipse.cdt.internal.ui.viewsupport.SelectionListenerWithASTManager; @@ -116,7 +117,12 @@ public class MarkOccurrenceTest extends BaseUITestCase { fProjectSetup.setUp(); } assertNotNull(fgHighlightRGB); - CUIPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true); + final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); + store.setValue(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true); + // TLETODO temporary fix for bug 314635 + store.setValue(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + + SemanticHighlightings.OVERLOADED_OPERATOR + + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX, true); fEditor= openCEditor(new Path("/" + PROJECT + "/src/occurrences.cpp")); assertNotNull(fEditor); fTextWidget= fEditor.getViewer().getTextWidget(); @@ -153,6 +159,12 @@ public class MarkOccurrenceTest extends BaseUITestCase { */ @Override protected void tearDown() throws Exception { + final IPreferenceStore store = CUIPlugin.getDefault().getPreferenceStore(); + store.setToDefault(PreferenceConstants.EDITOR_MARK_OCCURRENCES); + // TLETODO temporary fix for bug 314635 + store.setToDefault(PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + + SemanticHighlightings.OVERLOADED_OPERATOR + + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX); SelectionListenerWithASTManager.getDefault().removeListener(fEditor, fSelWASTListener); EditorTestHelper.closeAllEditors(); if (fProjectSetup != null) { 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 3eb3b9386a6..100679ec8f3 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 @@ -3283,18 +3283,18 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IC } if (name != null) { -// try { -// IASTFileLocation location= name.getFileLocation(); -// if (!document.get(location.getNodeOffset(), location.getNodeLength()).equals(name.toString())) { -// System.err.println("CEditor.updateOccurrenceAnnotations() invalid ast"); -// return; -// } -// } catch (BadLocationException exc) { -// } IBinding binding= name.resolveBinding(); if (binding != null) { OccurrencesFinder occurrencesFinder= new OccurrencesFinder(); if (occurrencesFinder.initialize(astRoot, name) == null) { + // TLETODO temporary fix for bug 314635 + boolean overloadedOperatorsEnabled = getPreferenceStore().getBoolean( + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_PREFIX + + SemanticHighlightings.OVERLOADED_OPERATOR + + PreferenceConstants.EDITOR_SEMANTIC_HIGHLIGHTING_ENABLED_SUFFIX); + if (!overloadedOperatorsEnabled) { + occurrencesFinder.setOptions(OccurrencesFinder.OPTION_EXCLUDE_IMPLICIT_REFERENCES); + } locations= occurrencesFinder.getOccurrences(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java index ee7611a522c..8060750acd4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/OccurrencesFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2009 IBM Corporation and others. + * Copyright (c) 2000, 2010 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 @@ -32,12 +32,19 @@ public class OccurrencesFinder implements IOccurrencesFinder { public static final String ID= "OccurrencesFinder"; //$NON-NLS-1$ + /** + * If set, don't search for implicit references. + */ + public static final int OPTION_EXCLUDE_IMPLICIT_REFERENCES = 1; + private IASTTranslationUnit fRoot; private IASTName fSelectedNode; private IBinding fTarget; private List<OccurrenceLocation> fResult; private String fDescription; + + private int fOptions; public OccurrencesFinder() { super(); @@ -56,6 +63,15 @@ public class OccurrencesFinder implements IOccurrencesFinder { return null; } + /** + * Specify search options. + * + * @param options + */ + public void setOptions(int options) { + fOptions = options; + } + private void performSearch() { if (fResult == null) { fResult= new ArrayList<OccurrenceLocation>(); @@ -71,7 +87,7 @@ public class OccurrencesFinder implements IOccurrencesFinder { addUsage(candidate, candidate.resolveBinding()); } } - if (canHaveImplicitReference(fTarget)) { + if (needImplicitReferences() && canHaveImplicitReference(fTarget)) { names= CPPVisitor.getImplicitReferences(fRoot, fTarget); for (IASTName candidate : names) { if (candidate.isPartOfTranslationUnitFile()) { @@ -82,6 +98,10 @@ public class OccurrencesFinder implements IOccurrencesFinder { } } + private boolean needImplicitReferences() { + return (fOptions & OPTION_EXCLUDE_IMPLICIT_REFERENCES) == 0; + } + private boolean canHaveImplicitReference(IBinding binding) { final char[] op = Keywords.cOPERATOR; final char[] nameCharArray = binding.getNameCharArray(); |