mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed NPE in open declaration.
This commit is contained in:
parent
fd1c565981
commit
7c13219552
2 changed files with 17 additions and 7 deletions
|
@ -189,6 +189,7 @@ public class DOMSearchUtil {
|
||||||
public static IASTName[] getSelectedNamesFrom(IASTTranslationUnit tu, int offset, int length, ParserLanguage lang) {
|
public static IASTName[] getSelectedNamesFrom(IASTTranslationUnit tu, int offset, int length, ParserLanguage lang) {
|
||||||
IASTNode node = null;
|
IASTNode node = null;
|
||||||
try{
|
try{
|
||||||
|
if (tu != null)
|
||||||
node = tu.selectNodeForLocation(tu.getFilePath(), offset, length);
|
node = tu.selectNodeForLocation(tu.getFilePath(), offset, length);
|
||||||
}
|
}
|
||||||
catch (ParseError er){}
|
catch (ParseError er){}
|
||||||
|
|
|
@ -104,10 +104,15 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
||||||
if (project instanceof ICProject) {
|
if (project instanceof ICProject) {
|
||||||
IProject p = ((ICProject)project).getProject();
|
IProject p = ((ICProject)project).getProject();
|
||||||
IPDOM pdom = PDOM.getPDOM(p);
|
IPDOM pdom = PDOM.getPDOM(p);
|
||||||
|
if (pdom != null)
|
||||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
input.getStorage(),
|
input.getStorage(),
|
||||||
p,
|
p,
|
||||||
pdom.getCodeReaderFactory());
|
pdom.getCodeReaderFactory());
|
||||||
|
else
|
||||||
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
|
input.getStorage(),
|
||||||
|
p);
|
||||||
lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
|
lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
|
||||||
projectName = ((ICProject)project).getElementName();
|
projectName = ((ICProject)project).getElementName();
|
||||||
}
|
}
|
||||||
|
@ -116,15 +121,19 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// an awful lot of cass goingo on here...
|
// an awful lot of casts goingo on here...
|
||||||
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
|
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
|
||||||
IFile resourceFile = (IFile)workingCopy.getResource();
|
IFile resourceFile = (IFile)workingCopy.getResource();
|
||||||
project = new CProject(null, resourceFile.getProject());
|
project = new CProject(null, resourceFile.getProject());
|
||||||
IPDOM pdom = PDOM.getPDOM(resourceFile.getProject());
|
IPDOM pdom = PDOM.getPDOM(resourceFile.getProject());
|
||||||
try {
|
try {
|
||||||
|
if (pdom != null)
|
||||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
resourceFile,
|
resourceFile,
|
||||||
pdom.getCodeReaderFactory(workingCopy));
|
pdom.getCodeReaderFactory(workingCopy));
|
||||||
|
else
|
||||||
|
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||||
|
resourceFile);
|
||||||
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
||||||
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
|
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue