Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Schorn2008-03-28 17:59:10 +0000
committerMarkus Schorn2008-03-28 17:59:10 +0000
commitbb469b32ee9326eb3ecbf565e51c2b2f5b681197 (patch)
treef1f0f1ce85ec7b91abffda626da23ffe9308e83a /core/org.eclipse.cdt.ui
parentdb312ccd1b4aa8f9319c3757cbe6a6e13d08ceac (diff)
downloadorg.eclipse.cdt-bb469b32ee9326eb3ecbf565e51c2b2f5b681197.tar.gz
org.eclipse.cdt-bb469b32ee9326eb3ecbf565e51c2b2f5b681197.tar.xz
org.eclipse.cdt-bb469b32ee9326eb3ecbf565e51c2b2f5b681197.zip
Search for macro references, bug 156561.
Diffstat (limited to 'core/org.eclipse.cdt.ui')
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java20
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java10
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java28
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java2
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties1
6 files changed, 47 insertions, 16 deletions
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java
index 4da1c76281c..2d530d0a924 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchPatternQuery.java
@@ -6,11 +6,10 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * QNX - Initial API and implementation
- * IBM Corporation
- * Markus Schorn (Wind River Systems)
+ * QNX - Initial API and implementation
+ * IBM Corporation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.search;
import java.util.ArrayList;
@@ -85,7 +84,7 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
this.patternStr = patternStr.trim();
// Parse the pattern string
- List patternList = new ArrayList();
+ List<Pattern> patternList = new ArrayList<Pattern>();
StringBuffer buff = new StringBuffer();
int n = patternStr.length();
for (int i = 0; i < n; ++i) {
@@ -120,9 +119,10 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
patternList.add(Pattern.compile(buff.toString(),Pattern.CASE_INSENSITIVE));
}
- pattern = (Pattern[])patternList.toArray(new Pattern[patternList.size()]);
+ pattern = patternList.toArray(new Pattern[patternList.size()]);
}
+ @Override
public IStatus runWithIndex(IIndex index, IProgressMonitor monitor) throws OperationCanceledException {
try {
IndexFilter filter= IndexFilter.ALL;
@@ -179,6 +179,12 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
createMatches(index, pdomBinding);
}
}
+ if ((flags & FIND_MACRO) != 0 && pattern.length == 1) {
+ bindings = index.findMacroContainers(pattern[0], filter, monitor);
+ for (IIndexBinding indexBinding : bindings) {
+ createMatches(index, indexBinding);
+ }
+ }
} catch (CoreException e) {
return e.getStatus();
} catch (DOMException e) {
@@ -188,8 +194,8 @@ public class PDOMSearchPatternQuery extends PDOMSearchQuery {
return Status.OK_STATUS;
}
+ @Override
public String getLabel() {
return Messages.format(CSearchMessages.PDOMSearchPatternQuery_PatternQuery_labelPatternInScope, super.getLabel(), patternStr, scopeDesc);
}
-
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
index 81ff3a5fed8..b85cec9da48 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/PDOMSearchTextSelectionQuery.java
@@ -50,7 +50,7 @@ public class PDOMSearchTextSelectionQuery extends PDOMSearchQuery {
if (ast != null) {
IASTName searchName= ast.getNodeSelector(null).findEnclosingName(selection.getOffset(), selection.getLength());
if (searchName != null) {
- IBinding binding = searchName.resolveBinding();
+ IBinding binding = index.findBinding(searchName);
if (binding != null)
createMatches(index, binding);
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
index 22acf2669ee..6b8751046cf 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/IndexUI.java
@@ -9,7 +9,6 @@
* Markus Schorn - initial API and implementation
* Ed Swartz (Nokia)
*******************************************************************************/
-
package org.eclipse.cdt.internal.ui.viewsupport;
import java.util.ArrayList;
@@ -346,9 +345,12 @@ public class IndexUI {
throws CoreException {
ITranslationUnit tu= getTranslationUnit(preferProject, macro.getFileLocation());
if (tu != null) {
- IRegion region= new Region(macro.getNodeOffset(), macro.getNodeLength());
- long timestamp= macro.getFile().getTimestamp();
- return CElementHandleFactory.create(tu, macro, region, timestamp);
+ IIndexName def= macro.getDefinition();
+ if (def != null) {
+ IRegion region= new Region(def.getNodeOffset(), def.getNodeLength());
+ long timestamp= macro.getFile().getTimestamp();
+ return CElementHandleFactory.create(tu, macro, region, timestamp);
+ }
}
return null;
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
index cef684153e4..5cb379cfecb 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/AbstractIndexerPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
+ * Copyright (c) 2005, 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
@@ -39,6 +39,7 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
private Text fFilesToParseUpFront;
private Button fSkipReferences;
private Button fSkipTypeReferences;
+ private Button fSkipMacroReferences;
protected AbstractIndexerPage() {
super();
@@ -52,14 +53,17 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
return null;
}
+ @Override
public void createControl(Composite parent) {
Composite page = ControlFactory.createComposite(parent, 1);
fAllFiles= createAllFilesButton(page);
fSkipReferences= createSkipReferencesButton(page);
fSkipTypeReferences= createSkipTypeReferencesButton(page);
+ fSkipMacroReferences= createSkipMacroReferencesButton(page);
fFilesToParseUpFront= createParseUpFrontTextField(page);
fSkipReferences.addSelectionListener(new SelectionAdapter() {
+ @Override
public void widgetSelected(SelectionEvent e) {
updateEnablement();
}
@@ -85,6 +89,10 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
boolean skipTypeReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES));
fSkipTypeReferences.setSelection(skipTypeReferences);
}
+ if (fSkipMacroReferences != null) {
+ boolean skipMacroReferences= TRUE.equals(properties.get(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES));
+ fSkipMacroReferences.setSelection(skipMacroReferences);
+ }
if (fFilesToParseUpFront != null) {
String files = getNotNull(properties, IndexerPreferences.KEY_FILES_TO_PARSE_UP_FRONT);
fFilesToParseUpFront.setText(files);
@@ -110,12 +118,16 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
if (fSkipTypeReferences != null) {
props.put(IndexerPreferences.KEY_SKIP_TYPE_REFERENCES, String.valueOf(fSkipTypeReferences.getSelection()));
}
+ if (fSkipMacroReferences != null) {
+ props.put(IndexerPreferences.KEY_SKIP_MACRO_REFERENCES, String.valueOf(fSkipMacroReferences.getSelection()));
+ }
return props;
}
/**
* {@link #getProperties()} will be called instead.
*/
+ @Override
final public void performApply(IProgressMonitor monitor) {
throw new UnsupportedOperationException();
}
@@ -123,13 +135,19 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
/**
* {@link #setProperties(Properties)} will be called instead.
*/
+ @Override
final public void performDefaults() {
throw new UnsupportedOperationException();
}
public void updateEnablement() {
- if (fSkipReferences != null && fSkipTypeReferences != null) {
- fSkipTypeReferences.setEnabled(!fSkipReferences.getSelection());
+ if (fSkipReferences != null) {
+ if (fSkipTypeReferences != null) {
+ fSkipTypeReferences.setEnabled(!fSkipReferences.getSelection());
+ }
+ if (fSkipMacroReferences != null) {
+ fSkipMacroReferences.setEnabled(!fSkipReferences.getSelection());
+ }
}
}
@@ -158,4 +176,8 @@ public abstract class AbstractIndexerPage extends AbstractCOptionPage {
private Button createSkipTypeReferencesButton(Composite page) {
return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipTypeReferences);
}
+
+ private Button createSkipMacroReferencesButton(Composite page) {
+ return ControlFactory.createCheckBox(page, DialogsMessages.AbstractIndexerPage_skipMacroReferences);
+ }
}
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
index b6e577d80f8..a7791950b94 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.java
@@ -10,7 +10,6 @@
* IBM Corporation
* Andrew Ferguson (Symbian)
*******************************************************************************/
-
package org.eclipse.cdt.ui.dialogs;
import org.eclipse.osgi.util.NLS;
@@ -21,6 +20,7 @@ public class DialogsMessages extends NLS {
public static String AbstractIndexerPage_indexUpFront;
public static String AbstractIndexerPage_skipAllReferences;
public static String AbstractIndexerPage_skipTypeReferences;
+ public static String AbstractIndexerPage_skipMacroReferences;
public static String CacheSizeBlock_MB;
public static String IndexerBlock_fixedBuildConfig;
public static String IndexerStrategyBlock_activeBuildConfig;
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
index 9ce9d8c61de..162629498fc 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/ui/dialogs/DialogsMessages.properties
@@ -16,6 +16,7 @@ PreferenceScopeBlock_preferenceLink=<a>Configure Workspace Settings...</a>
AbstractIndexerPage_indexAllFiles=Index all files (files neither built nor included, also)
AbstractIndexerPage_skipAllReferences=Skip all references (Call Hierarchy and Search will not work)
AbstractIndexerPage_skipTypeReferences=Skip type references (Search for type references will not work)
+AbstractIndexerPage_skipMacroReferences=Skip macro references (Search for macro references will not work)
AbstractIndexerPage_indexUpFront=Files to index up-front:
CacheSizeBlock_cacheLimitGroup=Cache limits
CacheSizeBlock_indexDatabaseCache=Index database cache:

Back to the top