mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 10:15:39 +02:00
Fixed Bug 84451 - [Offsets] simple multiple #include throws offsets off
Fixed Bug 84356 - [DOM] stdio.h - Location/offsets degrade as parse continues on
This commit is contained in:
parent
cd55cc5761
commit
69d98316f4
4 changed files with 501 additions and 417 deletions
|
@ -58,8 +58,10 @@ public class DOMLocationInclusionTests extends FileBasePluginTest {
|
||||||
|
|
||||||
private static final IParserLogService NULL_LOG = new NullLogService();
|
private static final IParserLogService NULL_LOG = new NullLogService();
|
||||||
|
|
||||||
private static final ICodeReaderFactory factory = CDOM.getInstance()
|
private static final ICodeReaderFactory factory = CDOM
|
||||||
.getCodeReaderFactory(CDOM.PARSE_SAVED_RESOURCES);
|
.getInstance()
|
||||||
|
.getCodeReaderFactory(
|
||||||
|
CDOM.PARSE_SAVED_RESOURCES);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -73,9 +75,8 @@ public class DOMLocationInclusionTests extends FileBasePluginTest {
|
||||||
throws Exception {
|
throws Exception {
|
||||||
InputStream stream = code.getContents();
|
InputStream stream = code.getContents();
|
||||||
IScanner scanner = new DOMScanner(new CodeReader(code.getLocation()
|
IScanner scanner = new DOMScanner(new CodeReader(code.getLocation()
|
||||||
.toOSString(), stream), SCANNER_INFO,
|
.toOSString(), stream), SCANNER_INFO, ParserMode.COMPLETE_PARSE,
|
||||||
ParserMode.COMPLETE_PARSE, language, NULL_LOG,
|
language, NULL_LOG, getScannerConfig(language), factory);
|
||||||
getScannerConfig(language), factory);
|
|
||||||
ISourceCodeParser parser = null;
|
ISourceCodeParser parser = null;
|
||||||
if (language == ParserLanguage.CPP) {
|
if (language == ParserLanguage.CPP) {
|
||||||
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
parser = new GNUCPPSourceParser(scanner, ParserMode.COMPLETE_PARSE,
|
||||||
|
@ -193,52 +194,114 @@ public class DOMLocationInclusionTests extends FileBasePluginTest {
|
||||||
public void testMacrosInIncludeFile() throws Exception {
|
public void testMacrosInIncludeFile() throws Exception {
|
||||||
String c_file_code = "#define X 4\n\n#include \"blarg.h\"\n\n#define POST_INCLUDE\n\n"; //$NON-NLS-1$
|
String c_file_code = "#define X 4\n\n#include \"blarg.h\"\n\n#define POST_INCLUDE\n\n"; //$NON-NLS-1$
|
||||||
String h_file_code = "#ifndef _BLARG_H_\r\n#define _BLARG_H_\r\n// macro\r\n#define PRINT(s,m) printf(s,m)\r\n#endif //_BLARG_H_\r\n"; //$NON-NLS-1$
|
String h_file_code = "#ifndef _BLARG_H_\r\n#define _BLARG_H_\r\n// macro\r\n#define PRINT(s,m) printf(s,m)\r\n#endif //_BLARG_H_\r\n"; //$NON-NLS-1$
|
||||||
importFile( "blarg.h", h_file_code ); //$NON-NLS-1$
|
importFile("blarg.h", h_file_code); //$NON-NLS-1$
|
||||||
IFile c_file = importFile( "blarg.c", c_file_code ); //$NON-NLS-1$
|
IFile c_file = importFile("blarg.c", c_file_code); //$NON-NLS-1$
|
||||||
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
|
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
|
||||||
: null) {
|
: null) {
|
||||||
IASTTranslationUnit tu = parse(c_file, p); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(c_file, p); //$NON-NLS-1$
|
||||||
assertEquals( tu.getDeclarations().length, 0 );
|
assertEquals(tu.getDeclarations().length, 0);
|
||||||
IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
|
IASTPreprocessorMacroDefinition[] macroDefinitions = tu
|
||||||
assertNotNull( macroDefinitions );
|
.getMacroDefinitions();
|
||||||
assertEquals( macroDefinitions.length, 4 );
|
assertNotNull(macroDefinitions);
|
||||||
assertSoleFileLocation( macroDefinitions[0], "blarg.c", c_file_code.indexOf( "#define"), c_file_code.indexOf( "4" ) + 1- c_file_code.indexOf( "#define" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
assertEquals(macroDefinitions.length, 4);
|
||||||
assertSoleFileLocation( macroDefinitions[0].getName(), "blarg.c", c_file_code.indexOf( "X"), 1 ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
assertSoleFileLocation(
|
||||||
assertSoleFileLocation( macroDefinitions[1], "blarg.h", h_file_code.indexOf( "#define _BLARG_H_"), "#define _BLARG_H_\r".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
macroDefinitions[0],
|
||||||
assertSoleFileLocation( macroDefinitions[1].getName(), "blarg.h", h_file_code.indexOf( "e _BLARG_H_") + 2, "_BLARG_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"blarg.c", c_file_code.indexOf("#define"), c_file_code.indexOf("4") + 1 - c_file_code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
assertSoleFileLocation( macroDefinitions[2], "blarg.h", h_file_code.indexOf( "#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
assertSoleFileLocation(macroDefinitions[0].getName(),
|
||||||
assertSoleFileLocation( macroDefinitions[2].getName(), "blarg.h", h_file_code.indexOf( "PRINT"), "PRINT".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
"blarg.c", c_file_code.indexOf("X"), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
assertSoleFileLocation( macroDefinitions[3], "blarg.c", c_file_code.indexOf( "#define POST_INCLUDE"), "#define POST_INCLUDE".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
assertSoleFileLocation(
|
||||||
assertSoleFileLocation( macroDefinitions[3].getName(), "blarg.c", c_file_code.indexOf( "POST_INCLUDE"), "POST_INCLUDE".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
macroDefinitions[1],
|
||||||
|
"blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_\r".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[1].getName(),
|
||||||
|
"blarg.h", h_file_code.indexOf("e _BLARG_H_") + 2, "_BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[2],
|
||||||
|
"blarg.h", h_file_code.indexOf("#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
assertSoleFileLocation(macroDefinitions[2].getName(),
|
||||||
|
"blarg.h", h_file_code.indexOf("PRINT"), "PRINT".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[3],
|
||||||
|
"blarg.c", c_file_code.indexOf("#define POST_INCLUDE"), "#define POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[3].getName(),
|
||||||
|
"blarg.c", c_file_code.indexOf("POST_INCLUDE"), "POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// public void testMacrosInIncludeFile2() throws Exception {
|
public void testBug84451() throws Exception {
|
||||||
// String c_file_code = "#define X 4\n\n#include \"blarg.h\"\n\n#define POST_INCLUDE\n#include \"second.h\"\n#define POST_SECOND\n"; //$NON-NLS-1$
|
String header1_code = "int x;\n"; //$NON-NLS-1$
|
||||||
// String h_file_code = "#ifndef _BLARG_H_\r\n#define _BLARG_H_\r\n// macro\r\n#define PRINT(s,m) printf(s,m)\r\n#endif //_BLARG_H_\r\n"; //$NON-NLS-1$
|
String header2_code = "int y;\n"; //$NON-NLS-1$
|
||||||
// String h_file2_code = "#ifndef _SECOND_H_ \n#define _SECOND_H_\n#endif\n"; //$NON-NLS-1$
|
String cpp_code = "#include \"header1.h\"\n#include \"header2.h\"\nint z;\n"; //$NON-NLS-1$
|
||||||
// importFile( "blarg.h", h_file_code ); //$NON-NLS-1$
|
importFile("header1.h", header1_code); //$NON-NLS-1$
|
||||||
// importFile( "second.h", h_file2_code ); //$NON-NLS-1$
|
importFile("header2.h", header2_code); //$NON-NLS-1$
|
||||||
// IFile c_file = importFile( "blarg.c", c_file_code ); //$NON-NLS-1$
|
IFile f = importFile("source.c", cpp_code); //$NON-NLS-1$
|
||||||
// for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
|
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
|
||||||
// : null) {
|
: null) {
|
||||||
// IASTTranslationUnit tu = parse(c_file, p); //$NON-NLS-1$
|
IASTTranslationUnit tu = parse(f, p);
|
||||||
// assertEquals( tu.getDeclarations().length, 0 );
|
IASTDeclaration[] declarations = tu.getDeclarations();
|
||||||
// IASTPreprocessorMacroDefinition[] macroDefinitions = tu.getMacroDefinitions();
|
IASTPreprocessorIncludeStatement[] includeDirectives = tu
|
||||||
// assertNotNull( macroDefinitions );
|
.getIncludeDirectives();
|
||||||
// assertEquals( macroDefinitions.length, 6 );
|
assertSoleFileLocation(
|
||||||
// assertSoleFileLocation( macroDefinitions[0], "blarg.c", c_file_code.indexOf( "#define"), c_file_code.indexOf( "4" ) + 1- c_file_code.indexOf( "#define" ) ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
includeDirectives[0],
|
||||||
// assertSoleFileLocation( macroDefinitions[0].getName(), "blarg.c", c_file_code.indexOf( "X"), 1 ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
"source.c", cpp_code.indexOf("#include \"header1.h\""), "#include \"header1.h\"".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// assertSoleFileLocation( macroDefinitions[1], "blarg.h", h_file_code.indexOf( "#define _BLARG_H_"), "#define _BLARG_H_\r".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
assertSoleFileLocation(declarations[0],
|
||||||
// assertSoleFileLocation( macroDefinitions[1].getName(), "blarg.h", h_file_code.indexOf( "e _BLARG_H_") + 2, "_BLARG_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"header1.h", 0, "int x;".length()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// assertSoleFileLocation( macroDefinitions[2], "blarg.h", h_file_code.indexOf( "#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
assertSoleFileLocation(declarations[1],
|
||||||
// assertSoleFileLocation( macroDefinitions[2].getName(), "blarg.h", h_file_code.indexOf( "PRINT"), "PRINT".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
"header2.h", 0, "int y;".length()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||||
// assertSoleFileLocation( macroDefinitions[3], "blarg.c", c_file_code.indexOf( "#define POST_INCLUDE"), "#define POST_INCLUDE".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
assertSoleFileLocation(
|
||||||
// assertSoleFileLocation( macroDefinitions[3].getName(), "blarg.c", c_file_code.indexOf( "POST_INCLUDE"), "POST_INCLUDE".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
includeDirectives[1],
|
||||||
// assertSoleFileLocation( macroDefinitions[4], "second.h", h_file2_code.indexOf( "#define _SECOND_H_"), "#define _SECOND_H_".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
"source.c", cpp_code.indexOf("#include \"header2.h\""), "#include \"header2.h\"".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// assertSoleFileLocation( macroDefinitions[5], "blarg.c", c_file_code.indexOf( "#define POST_SECOND"), "#define POST_SECOND".length() ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
assertSoleFileLocation(declarations[2],
|
||||||
// }
|
"source.c", cpp_code.indexOf("int z;"), "int z;".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void testMacrosInIncludeFile2() throws Exception {
|
||||||
|
String c_file_code = "#define X 4\n\n#include \"blarg.h\"\n\n#define POST_INCLUDE\n#include \"second.h\"\n#define POST_SECOND\n"; //$NON-NLS-1$
|
||||||
|
String h_file_code = "#ifndef _BLARG_H_\r\n#define _BLARG_H_\r\n//macro\r\n#define PRINT(s,m) printf(s,m)\r\n#endif //_BLARG_H_\r\n"; //$NON-NLS-1$
|
||||||
|
String h_file2_code = "#ifndef _SECOND_H_ \n#define _SECOND_H_\n#endif\n"; //$NON-NLS-1$
|
||||||
|
importFile("blarg.h", h_file_code); //$NON-NLS-1$
|
||||||
|
importFile("second.h", h_file2_code); //$NON-NLS-1$
|
||||||
|
IFile c_file = importFile("blarg.c", c_file_code); //$NON-NLS-1$
|
||||||
|
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
|
||||||
|
: null) {
|
||||||
|
IASTTranslationUnit tu = parse(c_file, p); //$NON-NLS-1$
|
||||||
|
assertEquals(tu.getDeclarations().length, 0);
|
||||||
|
IASTPreprocessorMacroDefinition[] macroDefinitions = tu
|
||||||
|
.getMacroDefinitions();
|
||||||
|
assertNotNull(macroDefinitions);
|
||||||
|
assertEquals(macroDefinitions.length, 6);
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[0],
|
||||||
|
"blarg.c", c_file_code.indexOf("#define"), c_file_code.indexOf("4") + 1 - c_file_code.indexOf("#define")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
assertSoleFileLocation(macroDefinitions[0].getName(),
|
||||||
|
"blarg.c", c_file_code.indexOf("X"), 1); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[1],
|
||||||
|
"blarg.h", h_file_code.indexOf("#define _BLARG_H_"), "#define _BLARG_H_\r".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[1].getName(),
|
||||||
|
"blarg.h", h_file_code.indexOf("e _BLARG_H_") + 2, "_BLARG_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[2],
|
||||||
|
"blarg.h", h_file_code.indexOf("#define PRINT(s,m) printf(s,m)\r"), "#define PRINT(s,m) printf(s,m)".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
assertSoleFileLocation(macroDefinitions[2].getName(),
|
||||||
|
"blarg.h", h_file_code.indexOf("PRINT"), "PRINT".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[3],
|
||||||
|
"blarg.c", c_file_code.indexOf("#define POST_INCLUDE"), "#define POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[3].getName(),
|
||||||
|
"blarg.c", c_file_code.indexOf("POST_INCLUDE"), "POST_INCLUDE".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[4],
|
||||||
|
"second.h", h_file2_code.indexOf("#define _SECOND_H_"), "#define _SECOND_H_".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
||||||
|
assertSoleFileLocation(
|
||||||
|
macroDefinitions[5],
|
||||||
|
"blarg.c", c_file_code.indexOf("#define POST_SECOND"), "#define POST_SECOND".length()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
TestSuite suite = new TestSuite(DOMLocationInclusionTests.class);
|
TestSuite suite = new TestSuite(DOMLocationInclusionTests.class);
|
||||||
|
|
|
@ -1247,6 +1247,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
System.arraycopy(oldLineOffsets, 0, lineOffsets, 0,
|
System.arraycopy(oldLineOffsets, 0, lineOffsets, 0,
|
||||||
oldLineOffsets.length);
|
oldLineOffsets.length);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bufferStack[bufferStackPos] = buffer;
|
bufferStack[bufferStackPos] = buffer;
|
||||||
|
@ -1283,6 +1284,8 @@ abstract class BaseScanner implements IScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Object popContext() {
|
protected Object popContext() {
|
||||||
|
//NOTE - do not set counters to 0 or -1 or something
|
||||||
|
//Subclasses may require those values in their popContext()
|
||||||
bufferStack[bufferStackPos] = null;
|
bufferStack[bufferStackPos] = null;
|
||||||
|
|
||||||
Object result = bufferData[bufferStackPos];
|
Object result = bufferData[bufferStackPos];
|
||||||
|
@ -1293,7 +1296,6 @@ abstract class BaseScanner implements IScanner {
|
||||||
pushForcedInclusion();
|
pushForcedInclusion();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -2466,19 +2468,19 @@ abstract class BaseScanner implements IScanner {
|
||||||
skipOverConditionalCode(true);
|
skipOverConditionalCode(true);
|
||||||
if (isLimitReached())
|
if (isLimitReached())
|
||||||
handleInvalidCompletion();
|
handleInvalidCompletion();
|
||||||
processIf( pos, bufferPos[bufferStackPos], true );
|
processIf(pos, bufferPos[bufferStackPos], true);
|
||||||
}
|
}
|
||||||
processIf( pos, bufferPos[bufferStackPos], false );
|
processIf(pos, bufferPos[bufferStackPos], false);
|
||||||
return;
|
return;
|
||||||
case ppElse:
|
case ppElse:
|
||||||
case ppElif:
|
case ppElif:
|
||||||
// Condition must have been true, skip over the rest
|
// Condition must have been true, skip over the rest
|
||||||
|
|
||||||
if (branchState(type == ppElse ? BRANCH_ELSE : BRANCH_ELIF)) {
|
if (branchState(type == ppElse ? BRANCH_ELSE : BRANCH_ELIF)) {
|
||||||
if( type == ppElse )
|
if (type == ppElse)
|
||||||
processElse( pos, bufferPos[bufferStackPos], false );
|
processElse(pos, bufferPos[bufferStackPos], false);
|
||||||
else
|
else
|
||||||
processElsif( pos, bufferPos[bufferStackPos], false );
|
processElsif(pos, bufferPos[bufferStackPos], false);
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
skipOverConditionalCode(false);
|
skipOverConditionalCode(false);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2501,17 +2503,17 @@ abstract class BaseScanner implements IScanner {
|
||||||
len = bufferPos[bufferStackPos] - start;
|
len = bufferPos[bufferStackPos] - start;
|
||||||
handleProblem(IProblem.PREPROCESSOR_POUND_ERROR, start,
|
handleProblem(IProblem.PREPROCESSOR_POUND_ERROR, start,
|
||||||
CharArrayUtils.extract(buffer, start, len));
|
CharArrayUtils.extract(buffer, start, len));
|
||||||
processError( pos, pos + len );
|
processError(pos, pos + len);
|
||||||
break;
|
break;
|
||||||
case ppEndif:
|
case ppEndif:
|
||||||
if (!branchState(BRANCH_END))
|
if (!branchState(BRANCH_END))
|
||||||
handleProblem(IProblem.PREPROCESSOR_UNBALANCE_CONDITION,
|
handleProblem(IProblem.PREPROCESSOR_UNBALANCE_CONDITION,
|
||||||
start, ppKeywords.findKey(buffer, start, len));
|
start, ppKeywords.findKey(buffer, start, len));
|
||||||
processEndif( pos, bufferPos[bufferStackPos ] );
|
processEndif(pos, bufferPos[bufferStackPos]);
|
||||||
break;
|
break;
|
||||||
case ppPragma:
|
case ppPragma:
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
processPragma( pos, bufferPos[bufferStackPos ]);
|
processPragma(pos, bufferPos[bufferStackPos]);
|
||||||
default:
|
default:
|
||||||
problem = true;
|
problem = true;
|
||||||
break;
|
break;
|
||||||
|
@ -2545,7 +2547,9 @@ abstract class BaseScanner implements IScanner {
|
||||||
* @param endPos
|
* @param endPos
|
||||||
*/
|
*/
|
||||||
protected abstract void processError(int startPos, int endPos);
|
protected abstract void processError(int startPos, int endPos);
|
||||||
|
|
||||||
protected abstract void processElsif(int startPos, int endPos, boolean taken);
|
protected abstract void processElsif(int startPos, int endPos, boolean taken);
|
||||||
|
|
||||||
protected abstract void processElse(int startPos, int endPos, boolean taken);
|
protected abstract void processElse(int startPos, int endPos, boolean taken);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2553,9 +2557,10 @@ abstract class BaseScanner implements IScanner {
|
||||||
* @param i
|
* @param i
|
||||||
* @param b
|
* @param b
|
||||||
*/
|
*/
|
||||||
protected abstract void processIf(int startPos, int endPos, boolean taken );
|
protected abstract void processIf(int startPos, int endPos, boolean taken);
|
||||||
|
|
||||||
protected void handlePPInclude(int pos2, boolean include_next, int startingLineNumber) {
|
protected void handlePPInclude(int pos2, boolean include_next,
|
||||||
|
int startingLineNumber) {
|
||||||
char[] buffer = bufferStack[bufferStackPos];
|
char[] buffer = bufferStack[bufferStackPos];
|
||||||
int limit = bufferLimit[bufferStackPos];
|
int limit = bufferLimit[bufferStackPos];
|
||||||
|
|
||||||
|
@ -2578,9 +2583,9 @@ abstract class BaseScanner implements IScanner {
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case '\n' :
|
case '\n':
|
||||||
return;
|
return;
|
||||||
case '"' :
|
case '"':
|
||||||
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
||||||
local = true;
|
local = true;
|
||||||
start = bufferPos[bufferStackPos] + 1;
|
start = bufferPos[bufferStackPos] + 1;
|
||||||
|
@ -2605,7 +2610,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
nameEndOffset = start + length;
|
nameEndOffset = start + length;
|
||||||
endOffset = start + length + 1;
|
endOffset = start + length + 1;
|
||||||
break;
|
break;
|
||||||
case '<' :
|
case '<':
|
||||||
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
nameLine = getLineNumber(bufferPos[bufferStackPos]);
|
||||||
local = false;
|
local = false;
|
||||||
start = bufferPos[bufferStackPos] + 1;
|
start = bufferPos[bufferStackPos] + 1;
|
||||||
|
@ -2688,12 +2693,12 @@ abstract class BaseScanner implements IScanner {
|
||||||
CodeReader reader = null;
|
CodeReader reader = null;
|
||||||
File currentDirectory = null;
|
File currentDirectory = null;
|
||||||
if (local || include_next) {
|
if (local || include_next) {
|
||||||
// if the include is eclosed in quotes OR we are in an include_next then we need to know what the current directory is!
|
// if the include is eclosed in quotes OR we are in an include_next
|
||||||
|
// then we need to know what the current directory is!
|
||||||
File file = new File(String.valueOf(getCurrentFilename()));
|
File file = new File(String.valueOf(getCurrentFilename()));
|
||||||
currentDirectory = file.getParentFile();
|
currentDirectory = file.getParentFile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (local && !include_next) {
|
if (local && !include_next) {
|
||||||
// Check to see if we find a match in the current directory
|
// Check to see if we find a match in the current directory
|
||||||
if (currentDirectory != null) {
|
if (currentDirectory != null) {
|
||||||
|
@ -2701,18 +2706,17 @@ abstract class BaseScanner implements IScanner {
|
||||||
reader = createReader(absolutePath, filename);
|
reader = createReader(absolutePath, filename);
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
pushContext(reader.buffer, new InclusionData(reader,
|
pushContext(reader.buffer, new InclusionData(reader,
|
||||||
createInclusionConstruct(fileNameArray,
|
createInclusionConstruct(fileNameArray, reader.filename,
|
||||||
reader.filename, local, startOffset,
|
local, startOffset, startingLineNumber, nameOffset,
|
||||||
startingLineNumber, nameOffset,
|
nameEndOffset, nameLine, endOffset, endLine, false)));
|
||||||
nameEndOffset, nameLine, endOffset,
|
|
||||||
endLine, false)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// if we're not include_next, then we are looking for the
|
// if we're not include_next, then we are looking for the
|
||||||
// first occurance of the file, otherwise, we ignore all the paths before the
|
// first occurance of the file, otherwise, we ignore all the paths before
|
||||||
|
// the
|
||||||
// current directory
|
// current directory
|
||||||
if (includePaths != null) {
|
if (includePaths != null) {
|
||||||
int startpos = 0;
|
int startpos = 0;
|
||||||
|
@ -2722,28 +2726,27 @@ abstract class BaseScanner implements IScanner {
|
||||||
reader = createReader(includePaths[i], filename);
|
reader = createReader(includePaths[i], filename);
|
||||||
if (reader != null) {
|
if (reader != null) {
|
||||||
pushContext(reader.buffer, new InclusionData(reader,
|
pushContext(reader.buffer, new InclusionData(reader,
|
||||||
createInclusionConstruct(fileNameArray,
|
createInclusionConstruct(fileNameArray, reader.filename,
|
||||||
reader.filename, local, startOffset,
|
local, startOffset, startingLineNumber, nameOffset,
|
||||||
startingLineNumber, nameOffset,
|
nameEndOffset, nameLine, endOffset, endLine, false)));
|
||||||
nameEndOffset, nameLine, endOffset,
|
|
||||||
endLine, false)));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleProblem(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, startOffset, fileNameArray);
|
handleProblem(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, startOffset,
|
||||||
|
fileNameArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
private CodeReader createReader(String path, String fileName)
|
protected CodeReader createReader(String path, String fileName) {
|
||||||
{
|
|
||||||
String finalPath = ScannerUtility.createReconciledPath(path, fileName);
|
String finalPath = ScannerUtility.createReconciledPath(path, fileName);
|
||||||
char [] finalPathc = finalPath.toCharArray();
|
char[] finalPathc = finalPath.toCharArray();
|
||||||
CodeReader reader = (CodeReader) fileCache.get(finalPathc);
|
CodeReader reader = (CodeReader) fileCache.get(finalPathc);
|
||||||
if (reader != null)
|
if (reader != null)
|
||||||
return reader; // found the file in the cache
|
return reader; // found the file in the cache
|
||||||
|
|
||||||
// create a new reader on this file (if the file does not exist we will get null)
|
// create a new reader on this file (if the file does not exist we will
|
||||||
|
// get null)
|
||||||
reader = createReaderDuple(finalPath);
|
reader = createReaderDuple(finalPath);
|
||||||
if (reader == null)
|
if (reader == null)
|
||||||
return null; // the file was not found
|
return null; // the file was not found
|
||||||
|
@ -2755,8 +2758,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
return reader;
|
return reader;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int findIncludePos( String[] paths, File currentDirectory)
|
private int findIncludePos(String[] paths, File currentDirectory) {
|
||||||
{
|
|
||||||
for (int i = 0; i < paths.length; ++i)
|
for (int i = 0; i < paths.length; ++i)
|
||||||
try {
|
try {
|
||||||
String path = new File(paths[i]).getCanonicalPath();
|
String path = new File(paths[i]).getCanonicalPath();
|
||||||
|
@ -2768,6 +2770,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param finalPath
|
* @param finalPath
|
||||||
* @return
|
* @return
|
||||||
|
@ -3103,7 +3106,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
handleCompletionOnDefinition(new String(buffer, idstart, idlen));
|
handleCompletionOnDefinition(new String(buffer, idstart, idlen));
|
||||||
|
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
processUndef( pos, bufferPos[bufferStackPos] );
|
processUndef(pos, bufferPos[bufferStackPos]);
|
||||||
|
|
||||||
definitions.remove(buffer, idstart, idlen);
|
definitions.remove(buffer, idstart, idlen);
|
||||||
}
|
}
|
||||||
|
@ -3114,7 +3117,8 @@ abstract class BaseScanner implements IScanner {
|
||||||
*/
|
*/
|
||||||
protected abstract void processUndef(int pos, int endPos);
|
protected abstract void processUndef(int pos, int endPos);
|
||||||
|
|
||||||
protected void handlePPIfdef(int pos, boolean positive) throws EndOfFileException {
|
protected void handlePPIfdef(int pos, boolean positive)
|
||||||
|
throws EndOfFileException {
|
||||||
char[] buffer = bufferStack[bufferStackPos];
|
char[] buffer = bufferStack[bufferStackPos];
|
||||||
int limit = bufferLimit[bufferStackPos];
|
int limit = bufferLimit[bufferStackPos];
|
||||||
|
|
||||||
|
@ -3161,18 +3165,19 @@ abstract class BaseScanner implements IScanner {
|
||||||
branchState(BRANCH_IF);
|
branchState(BRANCH_IF);
|
||||||
|
|
||||||
if ((definitions.get(buffer, idstart, idlen) != null) == positive) {
|
if ((definitions.get(buffer, idstart, idlen) != null) == positive) {
|
||||||
processIfdef( pos, bufferPos[bufferStackPos], positive, true );
|
processIfdef(pos, bufferPos[bufferStackPos], positive, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
processIfdef( pos, bufferPos[bufferStackPos], positive, false );
|
processIfdef(pos, bufferPos[bufferStackPos], positive, false);
|
||||||
// skip over this group
|
// skip over this group
|
||||||
skipOverConditionalCode(true);
|
skipOverConditionalCode(true);
|
||||||
if (isLimitReached())
|
if (isLimitReached())
|
||||||
handleInvalidCompletion();
|
handleInvalidCompletion();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void processIfdef(int startPos, int endPos, boolean positive, boolean taken);
|
protected abstract void processIfdef(int startPos, int endPos,
|
||||||
|
boolean positive, boolean taken);
|
||||||
|
|
||||||
// checkelse - if potential for more, otherwise skip to endif
|
// checkelse - if potential for more, otherwise skip to endif
|
||||||
protected void skipOverConditionalCode(boolean checkelse) {
|
protected void skipOverConditionalCode(boolean checkelse) {
|
||||||
|
@ -3218,21 +3223,25 @@ abstract class BaseScanner implements IScanner {
|
||||||
++nesting;
|
++nesting;
|
||||||
branchState(BRANCH_IF);
|
branchState(BRANCH_IF);
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
if( type == ppIfdef )
|
if (type == ppIfdef)
|
||||||
processIfdef( startPos, bufferPos[bufferStackPos], true, false );
|
processIfdef(startPos, bufferPos[bufferStackPos],
|
||||||
else if( type == ppIfndef )
|
true, false);
|
||||||
processIfdef( startPos, bufferPos[bufferStackPos], false, false );
|
else if (type == ppIfndef)
|
||||||
|
processIfdef(startPos, bufferPos[bufferStackPos],
|
||||||
|
false, false);
|
||||||
else
|
else
|
||||||
processIf( startPos, bufferPos[bufferStackPos], false );
|
processIf(startPos, bufferPos[bufferStackPos], false);
|
||||||
break;
|
break;
|
||||||
case ppElse:
|
case ppElse:
|
||||||
if (branchState(BRANCH_ELSE)) {
|
if (branchState(BRANCH_ELSE)) {
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
if (checkelse && nesting == 0) {
|
if (checkelse && nesting == 0) {
|
||||||
processElse( startPos, bufferPos[ bufferStackPos], true );
|
processElse(startPos, bufferPos[bufferStackPos],
|
||||||
|
true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processElse( startPos, bufferPos[ bufferStackPos], false );
|
processElse(startPos, bufferPos[bufferStackPos],
|
||||||
|
false);
|
||||||
} else {
|
} else {
|
||||||
//problem, ignore this one.
|
//problem, ignore this one.
|
||||||
handleProblem(
|
handleProblem(
|
||||||
|
@ -3251,18 +3260,18 @@ abstract class BaseScanner implements IScanner {
|
||||||
if (expressionEvaluator.evaluate(buffer, start,
|
if (expressionEvaluator.evaluate(buffer, start,
|
||||||
len, definitions,
|
len, definitions,
|
||||||
getLineNumber(bufferPos[bufferStackPos]),
|
getLineNumber(bufferPos[bufferStackPos]),
|
||||||
getCurrentFilename()) != 0)
|
getCurrentFilename()) != 0) {
|
||||||
{
|
|
||||||
// condition passed, we're good
|
// condition passed, we're good
|
||||||
processElsif( start, bufferPos[bufferStackPos], true);
|
processElsif(start, bufferPos[bufferStackPos],
|
||||||
|
true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
processElsif( start, bufferPos[bufferStackPos], false );
|
processElsif(start, bufferPos[bufferStackPos],
|
||||||
}
|
false);
|
||||||
else
|
} else {
|
||||||
{
|
|
||||||
skipToNewLine();
|
skipToNewLine();
|
||||||
processElsif( start, bufferPos[bufferStackPos], false );
|
processElsif(start, bufferPos[bufferStackPos],
|
||||||
|
false);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
//problem, ignore this one.
|
//problem, ignore this one.
|
||||||
|
@ -3274,7 +3283,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
break;
|
break;
|
||||||
case ppEndif:
|
case ppEndif:
|
||||||
if (branchState(BRANCH_END)) {
|
if (branchState(BRANCH_END)) {
|
||||||
processEndif( startPos, bufferPos[ bufferStackPos ]);
|
processEndif(startPos, bufferPos[bufferStackPos]);
|
||||||
if (nesting > 0) {
|
if (nesting > 0) {
|
||||||
--nesting;
|
--nesting;
|
||||||
} else {
|
} else {
|
||||||
|
@ -4395,8 +4404,7 @@ abstract class BaseScanner implements IScanner {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CodeReader getMainReader()
|
protected CodeReader getMainReader() {
|
||||||
{
|
|
||||||
if (bufferData != null && bufferData[0] != null
|
if (bufferData != null && bufferData[0] != null
|
||||||
&& bufferData[0] instanceof CodeReader)
|
&& bufferData[0] instanceof CodeReader)
|
||||||
return ((CodeReader) bufferData[0]);
|
return ((CodeReader) bufferData[0]);
|
||||||
|
|
|
@ -13,7 +13,6 @@ package org.eclipse.cdt.internal.core.parser.scanner2;
|
||||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||||
import org.eclipse.cdt.core.parser.CodeReader;
|
import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
import org.eclipse.cdt.core.parser.EndOfFileException;
|
|
||||||
import org.eclipse.cdt.core.parser.IMacro;
|
import org.eclipse.cdt.core.parser.IMacro;
|
||||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
|
@ -31,9 +30,8 @@ import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
||||||
*/
|
*/
|
||||||
public class DOMScanner extends BaseScanner {
|
public class DOMScanner extends BaseScanner {
|
||||||
|
|
||||||
private final ICodeReaderFactory codeReaderFactory;
|
protected final ICodeReaderFactory codeReaderFactory;
|
||||||
private int globalCounter = 0;
|
protected int [] bufferDelta = new int[ bufferInitialSize ];
|
||||||
private int contextDelta = 0;
|
|
||||||
|
|
||||||
private static class DOMInclusion {
|
private static class DOMInclusion {
|
||||||
public final char[] pt;
|
public final char[] pt;
|
||||||
|
@ -138,16 +136,25 @@ public class DOMScanner extends BaseScanner {
|
||||||
* java.lang.Object)
|
* java.lang.Object)
|
||||||
*/
|
*/
|
||||||
protected void pushContext(char[] buffer, Object data) {
|
protected void pushContext(char[] buffer, Object data) {
|
||||||
|
if( bufferStackPos + 1 == bufferDelta.length )
|
||||||
|
{
|
||||||
|
int size = bufferDelta.length * 2;
|
||||||
|
int[] oldBufferDelta = bufferDelta;
|
||||||
|
bufferDelta = new int[size];
|
||||||
|
System.arraycopy(oldBufferDelta, 0, bufferDelta, 0, oldBufferDelta.length);
|
||||||
|
}
|
||||||
|
|
||||||
if (data instanceof InclusionData) {
|
if (data instanceof InclusionData) {
|
||||||
|
|
||||||
if (log.isTracing()) {
|
if (log.isTracing()) {
|
||||||
StringBuffer b = new StringBuffer("Entering inclusion "); //$NON-NLS-1$
|
StringBuffer b = new StringBuffer("Entering inclusion "); //$NON-NLS-1$
|
||||||
b.append(((InclusionData) data).reader.filename);
|
b.append(((InclusionData) data).reader.filename);
|
||||||
log.traceLog(b.toString());
|
log.traceLog(b.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
DOMInclusion inc = ((DOMInclusion) ((InclusionData) data).inclusion);
|
DOMInclusion inc = ((DOMInclusion) ((InclusionData) data).inclusion);
|
||||||
globalCounter += getCurrentOffset();
|
locationMap.startInclusion(((InclusionData)data).reader, inc.o, resolveOffset( getCurrentOffset() ));
|
||||||
locationMap.startInclusion(((InclusionData)data).reader, inc.o, globalCounter);
|
bufferDelta[bufferStackPos + 1 ] = 0;
|
||||||
contextDelta = 0;
|
|
||||||
}
|
}
|
||||||
super.pushContext(buffer, data);
|
super.pushContext(buffer, data);
|
||||||
}
|
}
|
||||||
|
@ -161,24 +168,38 @@ public class DOMScanner extends BaseScanner {
|
||||||
//TODO calibrate offsets
|
//TODO calibrate offsets
|
||||||
Object result = super.popContext();
|
Object result = super.popContext();
|
||||||
if (result instanceof CodeReader) {
|
if (result instanceof CodeReader) {
|
||||||
globalCounter += (((CodeReader) result).buffer.length - contextDelta);
|
locationMap.endTranslationUnit( bufferDelta[0] + ((CodeReader)result).buffer.length );
|
||||||
locationMap.endTranslationUnit(globalCounter);
|
|
||||||
}
|
}
|
||||||
if (result instanceof InclusionData) {
|
if (result instanceof InclusionData) {
|
||||||
|
CodeReader codeReader = ((InclusionData) result).reader;
|
||||||
if (log.isTracing()) {
|
if (log.isTracing()) {
|
||||||
StringBuffer buffer = new StringBuffer("Exiting inclusion "); //$NON-NLS-1$
|
StringBuffer buffer = new StringBuffer("Exiting inclusion "); //$NON-NLS-1$
|
||||||
buffer
|
buffer.append(codeReader.filename);
|
||||||
.append(((InclusionData) bufferData[bufferStackPos]).reader.filename);
|
|
||||||
log.traceLog(buffer.toString());
|
log.traceLog(buffer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
globalCounter += (((InclusionData) result).reader.buffer.length - contextDelta);
|
locationMap.endInclusion(getGlobalCounter( bufferStackPos + 1 ) + bufferPos[ bufferStackPos + 1 ]);
|
||||||
contextDelta = getCurrentOffset();
|
bufferDelta[ bufferStackPos ] += bufferDelta[ bufferStackPos + 1 ] + codeReader.buffer.length;
|
||||||
locationMap.endInclusion(globalCounter);
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected int getGlobalCounter( int value )
|
||||||
|
{
|
||||||
|
if( value < 0 ) return 0;
|
||||||
|
int result = bufferDelta[ value ];
|
||||||
|
for( int i = value - 1; i >= 0; --i )
|
||||||
|
result += bufferPos[ i ] + bufferDelta[ i ];
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected int getGlobalCounter()
|
||||||
|
{
|
||||||
|
return getGlobalCounter( bufferStackPos );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
@ -252,7 +273,7 @@ public class DOMScanner extends BaseScanner {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private int resolveOffset(int offset) {
|
private int resolveOffset(int offset) {
|
||||||
return globalCounter - contextDelta + offset;
|
return getGlobalCounter() + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -266,16 +287,6 @@ public class DOMScanner extends BaseScanner {
|
||||||
locationMap.startTranslationUnit(getMainReader());
|
locationMap.startTranslationUnit(getMainReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#throwEOF()
|
|
||||||
*/
|
|
||||||
protected void throwEOF() throws EndOfFileException {
|
|
||||||
locationMap.endTranslationUnit(globalCounter);
|
|
||||||
super.throwEOF();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processIfdef(int, int, boolean, boolean)
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processIfdef(int, int, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -839,6 +839,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
if (tu == null)
|
if (tu == null)
|
||||||
return EMPTY_LOCATION_ARRAY;
|
return EMPTY_LOCATION_ARRAY;
|
||||||
_Context c = findContextForOffset(offset);
|
_Context c = findContextForOffset(offset);
|
||||||
|
if( c == null )
|
||||||
|
return EMPTY_LOCATION_ARRAY;
|
||||||
if (c.context_ends >= offset + length)
|
if (c.context_ends >= offset + length)
|
||||||
return createSoleLocation(c, offset, length);
|
return createSoleLocation(c, offset, length);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue