mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Bug 312399: NPE using F3 on undef.
This commit is contained in:
parent
bc7368e9cf
commit
2cdd5df347
2 changed files with 26 additions and 5 deletions
|
@ -1229,4 +1229,22 @@ public abstract class CPPSelectionTestsAnyIndexer extends BaseSelectionTestsInde
|
|||
assertEquals("ambiguous input: 2", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
// #define MYMACRO
|
||||
|
||||
// #undef MYMACRO
|
||||
public void testUndef_312399() throws Exception {
|
||||
StringBuffer[] buffers= getContents(2);
|
||||
String hcode= buffers[0].toString();
|
||||
String scode= buffers[1].toString();
|
||||
IFile hfile = importFile("testUndef_312399.h", hcode);
|
||||
IFile file = importFile("testUndef_312399.cpp", scode);
|
||||
waitUntilFileIsIndexed(index, file, MAX_WAIT_TIME);
|
||||
|
||||
IASTNode target = testF3(file, scode.indexOf("MYMACRO"));
|
||||
assertTrue(target instanceof IASTName);
|
||||
assertEquals("MYMACRO", ((IASTName) target).toString());
|
||||
assertEquals(hcode.indexOf("MYMACRO"), target.getFileLocation().getNodeOffset());
|
||||
assertEquals("MYMACRO".length(), ((ASTNode) target).getLength());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -677,11 +677,14 @@ class OpenDeclarationsJob extends Job implements ASTRunnable {
|
|||
String[] sourceQualifiedName= null;
|
||||
int funcArgCount= -1;
|
||||
if (sourceName != null) {
|
||||
sourceQualifiedName= CPPVisitor.getQualifiedName(sourceName.resolveBinding());
|
||||
if (sourceName.resolveBinding() instanceof ICPPUnknownBinding) {
|
||||
LookupData data= CPPSemantics.createLookupData(sourceName, false);
|
||||
if (data.isFunctionCall()) {
|
||||
funcArgCount= data.getFunctionArgumentCount();
|
||||
final IBinding binding = sourceName.resolveBinding();
|
||||
if (binding != null) {
|
||||
sourceQualifiedName= CPPVisitor.getQualifiedName(binding);
|
||||
if (binding instanceof ICPPUnknownBinding) {
|
||||
LookupData data= CPPSemantics.createLookupData(sourceName, false);
|
||||
if (data.isFunctionCall()) {
|
||||
funcArgCount= data.getFunctionArgumentCount();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue