mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Patch for Devin Steffler.
Fixed Bug 96702 [Scanner] ASTNode offsets are wrong.
This commit is contained in:
parent
cf31ad398a
commit
89ec5fadf6
2 changed files with 15 additions and 5 deletions
|
@ -1581,6 +1581,18 @@ public class AST2SelectionParseTest extends AST2SelectionParseBaseTest {
|
|||
IASTNode node = parse( code, ParserLanguage.C, offset1, length );
|
||||
assertNotNull(node);
|
||||
}
|
||||
|
||||
public void testBug96702() throws Exception {
|
||||
importFile("test.h", "int x;\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
String code = "#include \"test.h\" // comment \nvoid f(); // comment \n"; //$NON-NLS-1$
|
||||
|
||||
int offset = code.indexOf( "f()" ); //$NON-NLS-1$
|
||||
IFile file = importFile("blah.c", code);
|
||||
IASTNode node = parse( file, ParserLanguage.C, offset, 1 ); // select f();
|
||||
assertTrue(node instanceof IASTName);
|
||||
assertEquals(((ASTNode)node).getOffset(), 44);
|
||||
assertEquals(((ASTNode)node).getLength(), 1);
|
||||
}
|
||||
|
||||
public void testBug86126() throws Exception {
|
||||
importFile("foo.h", "int x;\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
|
|
|
@ -42,15 +42,13 @@ public class DOMScanner extends BaseScanner {
|
|||
public final char[] pt;
|
||||
|
||||
public final int o;
|
||||
public final int eo;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DOMInclusion(char[] path, int offset, int endOffset) {
|
||||
public DOMInclusion(char[] path, int offset) {
|
||||
this.pt = path;
|
||||
this.o = offset;
|
||||
this.eo = endOffset;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +135,7 @@ public class DOMScanner extends BaseScanner {
|
|||
char[] filenamePath, boolean local, int startOffset,
|
||||
int startingLineNumber, int nameOffset, int nameEndOffset,
|
||||
int nameLine, int endOffset, int endLine, boolean isForced) {
|
||||
return new DOMInclusion(filenamePath, resolveOffset(startOffset), resolveOffset(endOffset));
|
||||
return new DOMInclusion(filenamePath, resolveOffset(startOffset));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -198,7 +196,7 @@ public class DOMScanner extends BaseScanner {
|
|||
if( ! isCircularInclusion( (InclusionData) data ))
|
||||
{
|
||||
DOMInclusion inc = ((DOMInclusion) ((InclusionData) data).inclusion);
|
||||
locationMap.startInclusion(((InclusionData) data).reader, inc.o, inc.eo);
|
||||
locationMap.startInclusion(((InclusionData) data).reader, inc.o, resolveOffset(getCurrentOffset()));
|
||||
bufferDelta[bufferStackPos + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue