[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] FIXED 72716- [Search] Search actions in "magic" include files do not work.
|
FIXED 72716- [Search] Search actions
in "magic" include files do not work.
Note: PR 93573 was raised to track
the specific example in 72716
Devin Steffler
IBM's Eclipse CDT
Ottawa (Palladium), Ontario, Canada
Index: search/org/eclipse/cdt/core/search/DOMSearchUtil.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.core/search/org/eclipse/cdt/core/search/DOMSearchUtil.java,v
retrieving revision 1.4
diff -u -r1.4 DOMSearchUtil.java
--- search/org/eclipse/cdt/core/search/DOMSearchUtil.java 3 May 2005 15:48:30 -0000 1.4
+++ search/org/eclipse/cdt/core/search/DOMSearchUtil.java 3 May 2005 18:25:59 -0000
@@ -50,6 +50,7 @@
import org.eclipse.cdt.internal.core.search.matching.CSearchPattern;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.IPath;
/**
* Utility class to have commonly used algorithms in one place for searching with the DOM.
@@ -171,7 +172,75 @@
}
/**
- * This is used to get a List of selected names in an IFile based on the offset and length into that IFile.
+ * This is used to get an array of selected names in an IASTTranslationUnit based on the offset
+ * and length into that IASTTranslationUnit.
+ *
+ * ex: IASTTranslationUnit contains: int foo;
+ * then getSelectedNamesFrom(file, 4, 3) will return the IASTName corresponding to foo
+ *
+ * @param tu
+ * @param offset
+ * @param length
+ * @param lang
+ * @return
+ */
+ public static IASTName[] getSelectedNamesFrom(IASTTranslationUnit tu, int offset, int length, ParserLanguage lang) {
+ IASTNode node = null;
+ try{
+ node = tu.selectNodeForLocation(tu.getFilePath(), offset, length); // TODO Devin untested tu.getContainingFilename() ...
+ }
+ catch (ParseError er){}
+ catch ( VirtualMachineError vmErr){
+ if (vmErr instanceof OutOfMemoryError){
+ org.eclipse.cdt.internal.core.model.Util.log(null, "Open Declarations Out Of Memory error: " + vmErr.getMessage() + " on File: " + tu.getContainingFilename(), ICLogConstants.CDT); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ catch (Exception ex){}
+
+ finally{
+ if (node == null){
+ return EMPTY_NAME_LIST;
+ }
+ }
+
+ if (node instanceof IASTName) {
+ IASTName[] results = new IASTName[1];
+ results[0] = (IASTName)node;
+ return results;
+ }
+
+ ASTVisitor collector = null;
+ if (lang == ParserLanguage.CPP) {
+ collector = new CPPNameCollector();
+ } else {
+ collector = new CNameCollector();
+ }
+
+ node.accept( collector );
+
+ List names = null;
+ if (collector instanceof CPPNameCollector) {
+ names = ((CPPNameCollector)collector).nameList;
+ } else {
+ names = ((CNameCollector)collector).nameList;
+ }
+
+ IASTName[] results = new IASTName[names.size()];
+ for(int i=0; i<names.size(); i++) {
+ if (names.get(i) instanceof IASTName)
+ results[i] = (IASTName)names.get(i);
+ }
+
+ return results;
+ }
+
+
+ /**
+ * This is used to get an array of selected names in an IFile based on the offset and length
+ * into that IFile.
+ *
+ * NOTE: Invoking this method causes a parse, if an IASTTranslationUnit is already obtained then
+ * invoke getSelectedNamesFrom(IASTTranslationUnit, int, int, ParserLanguage) instead.
*
* ex: IFile contains: int foo;
* then getSelectedNamesFrom(file, 4, 3) will return the IASTName corresponding to foo
@@ -340,4 +409,18 @@
}
public int size() { return nameList.size(); }
}
+
+ public static ParserLanguage getLanguage( IPath path, IProject project )
+ {
+ ICFileType type = CCorePlugin.getDefault().getFileType(project, path.lastSegment());
+ boolean isHeader= type.isHeader();
+ if( isHeader )
+ return ParserLanguage.CPP; // assumption
+ String lid = type.getLanguage().getId();
+ if( lid.equals(ICFileTypeConstants.LANG_CXX))
+ return ParserLanguage.CPP;
+ if( lid.equals( ICFileTypeConstants.LANG_C ) )
+ return ParserLanguage.C;
+ return ParserLanguage.CPP;
+ }
}
Index: src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java,v
retrieving revision 1.38
diff -u -r1.38 DOMAST.java
--- src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java 27 Apr 2005 17:43:31 -0000 1.38
+++ src/org/eclipse/cdt/ui/tests/DOMAST/DOMAST.java 3 May 2005 18:26:27 -0000
@@ -1226,6 +1226,11 @@
IFile aFile = ((CEditor)editor).getInputFile();
// check if the file is a valid "compilation unit" (based on file extension)
+ if (aFile == null) {
+ MessageDialog.openInformation(shell, DOMAST.VIEW_NAME, NOT_VALID_COMPILATION_UNIT);
+ return null;
+ }
+
String ext = aFile.getFileExtension().toUpperCase();
if (!(ext.equals(EXTENSION_C) || ext.equals(EXTENSION_CC) || ext.equals(EXTENSION_CPP) || ext.equals(EXTENSION_CXX))) {
MessageDialog.openInformation(shell, DOMAST.VIEW_NAME, NOT_VALID_COMPILATION_UNIT);
@@ -1247,6 +1252,10 @@
}
public static ParserLanguage getLanguageFromFile(IFile file) {
+ if (file == null) { // assume CPP
+ return ParserLanguage.CPP;
+ }
+
IProject project = file.getProject();
ICFileType type = CCorePlugin.getDefault().getFileType(project, file.getFullPath().lastSegment());
String lid = type.getLanguage().getId();
Index: src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java,v
retrieving revision 1.16
diff -u -r1.16 FindAction.java
--- src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java 29 Apr 2005 00:56:11 -0000 1.16
+++ src/org/eclipse/cdt/internal/ui/search/actions/FindAction.java 3 May 2005 18:26:10 -0000
@@ -19,6 +19,7 @@
import org.eclipse.cdt.core.ICLogConstants;
import org.eclipse.cdt.core.dom.CDOM;
import org.eclipse.cdt.core.dom.IASTServiceProvider;
+import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException;
@@ -31,6 +32,7 @@
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.c.ICExternalBinding;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.parser.ParseError;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.search.DOMSearchUtil;
@@ -148,9 +150,10 @@
if( obj == null || !(obj instanceof ICElement ) ){
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
return;
- } else {
- clearStatusLine();
}
+
+ clearStatusLine();
+
ICElement element = (ICElement) obj;
CSearchQuery job = createSearchQuery( element.getElementName(), CSearchUtil.getSearchForFromElement(element));
@@ -191,23 +194,18 @@
SelSearchNode selNode = getSelection( sel );
- IFile resourceFile = null;
- if (fEditor.getEditorInput() instanceof ExternalEditorInput) {
- // TODO Devin should be able to implement this somehow, see PR 78118
- operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
- return;
- }
-
- resourceFile = fEditor.getInputFile();
-
- IASTTranslationUnit tu = null;
- IASTNode foundNode = null;
+ IASTNode foundNode = null;
+ IASTTranslationUnit tu = null;
+ ParserLanguage lang = null;
+ String file = null;
- ParseWithProgress runnable = new ParseWithProgress(resourceFile);
+ ParseWithProgress runnable = new ParseWithProgress();
ProgressMonitorDialog progressMonitor = new ProgressMonitorDialog(fEditor.getSite().getShell());
try {
progressMonitor.run(true, true, runnable);
tu = runnable.getTu();
+ file = runnable.getFile();
+ lang = runnable.getLang();
} catch (InvocationTargetException e1) {
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
return;
@@ -215,15 +213,7 @@
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
return;
}
-
- String file=null;
- if( resourceFile != null )
- file = resourceFile.getLocation().toOSString();
- else
- {
- if( resourceFile instanceof ExternalEditorInput )
- file = ((ExternalEditorInput)resourceFile).getStorage().getFullPath().toOSString();
- }
+
try{
foundNode = tu.selectNodeForLocation(file, selNode.selStart, selNode.selEnd - selNode.selStart);
}
@@ -231,7 +221,7 @@
catch (Exception ex){}
catch ( VirtualMachineError vmErr){
if (vmErr instanceof OutOfMemoryError){
- org.eclipse.cdt.internal.core.model.Util.log(null, "Selection Search Out Of Memory error: " + vmErr.getMessage() + " on File: " + resourceFile.getName(), ICLogConstants.CDT); //$NON-NLS-1$ //$NON-NLS-2$
+ org.eclipse.cdt.internal.core.model.Util.log(null, "Selection Search Out Of Memory error: " + vmErr.getMessage() + " on File: " + file, ICLogConstants.CDT); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -240,7 +230,7 @@
foundName = (IASTName)foundNode;
} else {
ASTVisitor collector = null;
- if (DOMSearchUtil.getLanguageFromFile(resourceFile) == ParserLanguage.CPP) {
+ if (lang == ParserLanguage.CPP) {
collector = new DOMSearchUtil.CPPNameCollector();
} else {
collector = new DOMSearchUtil.CNameCollector();
@@ -289,28 +279,62 @@
private class ParseWithProgress implements IRunnableWithProgress
{
- private IFile file=null;
private IASTTranslationUnit tu = null;
+ private String file=null;
+ private ParserLanguage lang=null;
- public ParseWithProgress(IFile file) {
- this.file = file;
- }
+ public ParseWithProgress() {}
public void run(IProgressMonitor monitor) {
- try {
- tu = CDOM.getInstance().getASTService().getTranslationUnit(
- file,
- CDOM.getInstance().getCodeReaderFactory(
- CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
- } catch (IASTServiceProvider.UnsupportedDialectException e) {
- operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
- return;
+ if (fEditor.getEditorInput() instanceof ExternalEditorInput) {
+ ExternalEditorInput input = (ExternalEditorInput)fEditor.getEditorInput();
+ try {
+ // get the project for the external editor input's translation unit
+ ICElement project = input.getTranslationUnit();
+ while (!(project instanceof ICProject) && project != null) {
+ project = project.getParent();
+ }
+
+ if (project instanceof ICProject) {
+ tu = CDOM.getInstance().getASTService().getTranslationUnit(input.getStorage(), ((ICProject)project).getProject());
+ lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
+ }
+ } catch (UnsupportedDialectException e) {
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
+ }
+
+ file = input.getStorage().getFullPath().toOSString();
+ } else {
+ IFile resourceFile = null;
+ resourceFile = fEditor.getInputFile();
+
+ try {
+ tu = CDOM.getInstance().getASTService().getTranslationUnit(
+ resourceFile,
+ CDOM.getInstance().getCodeReaderFactory(
+ CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
+ } catch (IASTServiceProvider.UnsupportedDialectException e) {
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
+ }
+
+ file = resourceFile.getLocation().toOSString();
+ lang = DOMSearchUtil.getLanguageFromFile(resourceFile);
}
}
public IASTTranslationUnit getTu() {
return tu;
}
+
+ public String getFile() {
+ return file;
+ }
+
+ public ParserLanguage getLang() {
+ return lang;
+ }
};
abstract protected String getScopeDescription();
Index: src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java,v
retrieving revision 1.4
diff -u -r1.4 FindRefsAction.java
--- src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java 29 Apr 2005 00:56:11 -0000 1.4
+++ src/org/eclipse/cdt/internal/ui/search/actions/FindRefsAction.java 3 May 2005 18:26:10 -0000
@@ -10,15 +10,12 @@
******************************************************************************/
package org.eclipse.cdt.internal.ui.search.actions;
-import org.eclipse.cdt.core.model.ICElement;
import org.eclipse.cdt.core.search.ICSearchConstants;
import org.eclipse.cdt.core.search.ICSearchScope;
import org.eclipse.cdt.core.search.SearchEngine;
import org.eclipse.cdt.core.search.ICSearchConstants.LimitTo;
-import org.eclipse.cdt.internal.core.model.CProject;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.search.CSearchMessages;
-import org.eclipse.core.resources.IProject;
import org.eclipse.ui.IWorkbenchSite;
Index: src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java,v
retrieving revision 1.14
diff -u -r1.14 OpenDeclarationsAction.java
--- src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java 3 May 2005 15:48:34 -0000 1.14
+++ src/org/eclipse/cdt/internal/ui/search/actions/OpenDeclarationsAction.java 3 May 2005 18:26:11 -0000
@@ -14,9 +14,15 @@
import java.util.Iterator;
import java.util.Set;
+import org.eclipse.cdt.core.dom.CDOM;
+import org.eclipse.cdt.core.dom.IASTServiceProvider;
+import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.search.DOMSearchUtil;
import org.eclipse.cdt.core.search.ICSearchConstants;
@@ -25,12 +31,10 @@
import org.eclipse.cdt.internal.core.model.CProject;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
-import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
@@ -79,34 +83,47 @@
int selectionStart = selNode.selStart;
int selectionLength = selNode.selEnd - selNode.selStart;
- IFile resourceFile = null;
-
IASTName[] selectedNames = BLANK_NAME_ARRAY;
+ IASTTranslationUnit tu=null;
+ ParserLanguage lang=null;
+
if (fEditor.getEditorInput() instanceof ExternalEditorInput) {
- if( fEditor.getEditorInput() instanceof ITranslationUnitEditorInput )
- {
- ITranslationUnitEditorInput ip = (ITranslationUnitEditorInput) fEditor.getEditorInput();
- IResource r = ip.getTranslationUnit().getUnderlyingResource();
- if( r.getType() == IResource.FILE )
- resourceFile = (IFile) r;
- else
- {
- operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
- return;
-
+ ExternalEditorInput input = (ExternalEditorInput)fEditor.getEditorInput();
+ try {
+ // get the project for the external editor input's translation unit
+ ICElement project = input.getTranslationUnit();
+ while (!(project instanceof ICProject) && project != null) {
+ project = project.getParent();
+ }
+
+ if (project instanceof ICProject) {
+ tu = CDOM.getInstance().getASTService().getTranslationUnit(input.getStorage(), ((ICProject)project).getProject());
+ lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
+ projectName = ((ICProject)project).getElementName();
}
+ } catch (UnsupportedDialectException e) {
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
}
- }
- else
+ } else {
+ IFile resourceFile = null;
resourceFile = fEditor.getInputFile();
-
-
- if (resourceFile != null)
+
+ try {
+ tu = CDOM.getInstance().getASTService().getTranslationUnit(
+ resourceFile,
+ CDOM.getInstance().getCodeReaderFactory(
+ CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
+ } catch (IASTServiceProvider.UnsupportedDialectException e) {
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
+ }
+ lang = DOMSearchUtil.getLanguageFromFile(resourceFile);
projectName = findProjectName(resourceFile);
+ }
// step 1 starts here
- if (resourceFile != null)
- selectedNames = DOMSearchUtil.getSelectedNamesFrom(resourceFile, selectionStart, selectionLength);
+ selectedNames = DOMSearchUtil.getSelectedNamesFrom(tu, selectionStart, selectionLength, lang);
if (selectedNames.length > 0 && selectedNames[0] != null) { // just right, only one name selected
IASTName searchName = selectedNames[0];
Index: src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt-core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java,v
retrieving revision 1.1
diff -u -r1.1 OpenDefinitionAction.java
--- src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java 3 May 2005 15:48:34 -0000 1.1
+++ src/org/eclipse/cdt/internal/ui/search/actions/OpenDefinitionAction.java 3 May 2005 18:26:11 -0000
@@ -13,9 +13,15 @@
import java.util.Iterator;
import java.util.Set;
+import org.eclipse.cdt.core.dom.CDOM;
+import org.eclipse.cdt.core.dom.IASTServiceProvider;
+import org.eclipse.cdt.core.dom.IASTServiceProvider.UnsupportedDialectException;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTName;
+import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.model.ICElement;
+import org.eclipse.cdt.core.model.ICProject;
+import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserUtil;
import org.eclipse.cdt.core.search.DOMSearchUtil;
import org.eclipse.cdt.core.search.ICSearchConstants;
@@ -24,12 +30,10 @@
import org.eclipse.cdt.internal.core.model.CProject;
import org.eclipse.cdt.internal.ui.editor.CEditor;
import org.eclipse.cdt.internal.ui.editor.CEditorMessages;
-import org.eclipse.cdt.internal.ui.editor.ITranslationUnitEditorInput;
import org.eclipse.cdt.internal.ui.util.ExternalEditorInput;
import org.eclipse.cdt.ui.CUIPlugin;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ProgressMonitorDialog;
@@ -91,34 +95,47 @@
int selectionStart = selNode.selStart;
int selectionLength = selNode.selEnd - selNode.selStart;
- IFile resourceFile = null;
-
IASTName[] selectedNames = BLANK_NAME_ARRAY;
+ IASTTranslationUnit tu=null;
+ ParserLanguage lang=null;
+
if (fEditor.getEditorInput() instanceof ExternalEditorInput) {
- if( fEditor.getEditorInput() instanceof ITranslationUnitEditorInput )
- {
- ITranslationUnitEditorInput ip = (ITranslationUnitEditorInput) fEditor.getEditorInput();
- IResource r = ip.getTranslationUnit().getUnderlyingResource();
- if( r.getType() == IResource.FILE )
- resourceFile = (IFile) r;
- else
- {
- operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
- return;
-
+ ExternalEditorInput input = (ExternalEditorInput)fEditor.getEditorInput();
+ try {
+ // get the project for the external editor input's translation unit
+ ICElement project = input.getTranslationUnit();
+ while (!(project instanceof ICProject) && project != null) {
+ project = project.getParent();
}
+
+ if (project instanceof ICProject) {
+ tu = CDOM.getInstance().getASTService().getTranslationUnit(input.getStorage(), ((ICProject)project).getProject());
+ lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
+ projectName = ((ICProject)project).getElementName();
+ }
+ } catch (UnsupportedDialectException e) {
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
}
- }
- else
+ } else {
+ IFile resourceFile = null;
resourceFile = fEditor.getInputFile();
-
-
- if (resourceFile != null)
+
+ try {
+ tu = CDOM.getInstance().getASTService().getTranslationUnit(
+ resourceFile,
+ CDOM.getInstance().getCodeReaderFactory(
+ CDOM.PARSE_WORKING_COPY_WHENEVER_POSSIBLE));
+ } catch (IASTServiceProvider.UnsupportedDialectException e) {
+ operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
+ return;
+ }
+ lang = DOMSearchUtil.getLanguageFromFile(resourceFile);
projectName = findProjectName(resourceFile);
+ }
// step 1 starts here
- if (resourceFile != null)
- selectedNames = DOMSearchUtil.getSelectedNamesFrom(resourceFile, selectionStart, selectionLength);
+ selectedNames = DOMSearchUtil.getSelectedNamesFrom(tu, selectionStart, selectionLength, lang);
if (selectedNames.length > 0 && selectedNames[0] != null) { // just right, only one name selected
IASTName searchName = selectedNames[0];