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,7 +189,8 @@ public class DOMSearchUtil {
|
|||
public static IASTName[] getSelectedNamesFrom(IASTTranslationUnit tu, int offset, int length, ParserLanguage lang) {
|
||||
IASTNode node = null;
|
||||
try{
|
||||
node = tu.selectNodeForLocation(tu.getFilePath(), offset, length);
|
||||
if (tu != null)
|
||||
node = tu.selectNodeForLocation(tu.getFilePath(), offset, length);
|
||||
}
|
||||
catch (ParseError er){}
|
||||
catch ( VirtualMachineError vmErr){
|
||||
|
|
|
@ -104,10 +104,15 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
|||
if (project instanceof ICProject) {
|
||||
IProject p = ((ICProject)project).getProject();
|
||||
IPDOM pdom = PDOM.getPDOM(p);
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
input.getStorage(),
|
||||
p,
|
||||
pdom.getCodeReaderFactory());
|
||||
if (pdom != null)
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
input.getStorage(),
|
||||
p,
|
||||
pdom.getCodeReaderFactory());
|
||||
else
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
input.getStorage(),
|
||||
p);
|
||||
lang = DOMSearchUtil.getLanguage(input.getStorage().getFullPath(), ((ICProject)project).getProject());
|
||||
projectName = ((ICProject)project).getElementName();
|
||||
}
|
||||
|
@ -116,15 +121,19 @@ public class OpenDeclarationsAction extends SelectionParseAction implements IUpd
|
|||
return;
|
||||
}
|
||||
} else {
|
||||
// an awful lot of cass goingo on here...
|
||||
// an awful lot of casts goingo on here...
|
||||
IWorkingCopy workingCopy = (IWorkingCopy)fEditor.getInputCElement();
|
||||
IFile resourceFile = (IFile)workingCopy.getResource();
|
||||
project = new CProject(null, resourceFile.getProject());
|
||||
IPDOM pdom = PDOM.getPDOM(resourceFile.getProject());
|
||||
try {
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
if (pdom != null)
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
resourceFile,
|
||||
pdom.getCodeReaderFactory(workingCopy));
|
||||
else
|
||||
tu = CDOM.getInstance().getASTService().getTranslationUnit(
|
||||
resourceFile);
|
||||
} catch (IASTServiceProvider.UnsupportedDialectException e) {
|
||||
operationNotAvailable(CSEARCH_OPERATION_OPERATION_UNAVAILABLE_MESSAGE);
|
||||
return;
|
||||
|
|
Loading…
Add table
Reference in a new issue