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

Patch for Devin Steffler.

Fixed Bug 99421 [Open Declaration/Definition] [NPE] caused by external file
This commit is contained in:
John Camelon 2005-06-22 19:28:14 +00:00
parent fa843ff2ed
commit 15ddfc4c44
2 changed files with 8 additions and 4 deletions

View file

@ -86,12 +86,13 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
IASTName[] selectedNames = BLANK_NAME_ARRAY;
IASTTranslationUnit tu=null;
ParserLanguage lang=null;
ICElement project=null;
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();
project = input.getTranslationUnit();
while (!(project instanceof ICProject) && project != null) {
project = project.getParent();
}
@ -108,6 +109,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
} else {
IFile resourceFile = null;
resourceFile = fEditor.getInputFile();
project = new CProject(null, resourceFile.getProject());
try {
tu = CDOM.getInstance().getASTService().getTranslationUnit(
@ -163,7 +165,7 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
} else {
// step 3 starts here
ICElement[] scope = new ICElement[1];
scope[0] = new CProject(null, fEditor.getInputFile().getProject());
scope[0] = project;
Set matches = DOMSearchUtil.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), searchName, ICSearchConstants.DECLARATIONS_DEFINITIONS);
if (matches != null && matches.size() > 0) {

View file

@ -100,12 +100,13 @@ public class OpenDefinitionAction extends SelectionParseAction implements
IASTName[] selectedNames = BLANK_NAME_ARRAY;
IASTTranslationUnit tu=null;
ParserLanguage lang=null;
ICElement project=null;
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();
project = input.getTranslationUnit();
while (!(project instanceof ICProject) && project != null) {
project = project.getParent();
}
@ -122,6 +123,7 @@ public class OpenDefinitionAction extends SelectionParseAction implements
} else {
IFile resourceFile = null;
resourceFile = fEditor.getInputFile();
project = new CProject(null, resourceFile.getProject());
try {
tu = CDOM.getInstance().getASTService().getTranslationUnit(
@ -177,7 +179,7 @@ public class OpenDefinitionAction extends SelectionParseAction implements
} else {
// step 3 starts here
ICElement[] scope = new ICElement[1];
scope[0] = new CProject(null, fEditor.getInputFile().getProject());
scope[0] = project;
Set matches = DOMSearchUtil.getMatchesFromSearchEngine(SearchEngine.createCSearchScope(scope), searchName, ICSearchConstants.DEFINITIONS);
if (matches != null && matches.size() > 0) {