1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Fixed Bug 91086 - Indexer problem: Preprocessor inclusion not found

This commit is contained in:
John Camelon 2005-04-19 19:32:33 +00:00
parent ccee647b44
commit e7d6eed46d
2 changed files with 35 additions and 0 deletions

View file

@ -25,6 +25,7 @@ import org.eclipse.cdt.core.parser.NullLogService;
import org.eclipse.cdt.core.parser.ParserFactory;
import org.eclipse.cdt.core.parser.ParserLanguage;
import org.eclipse.cdt.core.parser.ParserMode;
import org.eclipse.cdt.core.parser.ScannerInfo;
import org.eclipse.cdt.core.parser.ast.IASTScope;
import org.eclipse.cdt.core.parser.ast.IASTVariable;
import org.eclipse.cdt.core.parser.tests.CompleteParseBaseTest;
@ -164,4 +165,22 @@ public class IncludeTest extends FileBasePluginTest {
assertEquals( v.getName(), "three" ); //$NON-NLS-1$
assertFalse( i.hasNext() );
}
public void testBug91086() throws Exception {
IFile inclusion = importFile( "file.h", "#define FOUND 666\n" ); //$NON-NLS-1$ //$NON-NLS-2$
StringBuffer buffer = new StringBuffer( "#include \"" ); //$NON-NLS-1$
buffer.append( inclusion.getLocation().toOSString() );
buffer.append( "\"\n"); //$NON-NLS-1$
buffer.append( "int var = FOUND;\n"); //$NON-NLS-1$
IFile code = importFile( "code.c", buffer.toString() ); //$NON-NLS-1$
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
: null) {
Iterator i = parse( code, p, new ScannerInfo() ).getDeclarations();
IASTVariable var = (IASTVariable) i.next();
assertEquals( var.getInitializerClause().getAssigmentExpression().getLiteralString(), "666" ); //$NON-NLS-1$
assertFalse( i.hasNext() );
}
}
}

View file

@ -2882,6 +2882,22 @@ abstract class BaseScanner implements IScanner {
}
}
// if not found by this point, and the inclusion is local, try just the
// path as is (bug 91086)
if( local )
{
reader = createReader( EMPTY_STRING, filename );
if (reader != null) {
pushContext(reader.buffer, new InclusionData(reader,
createInclusionConstruct(fileNameArray,
reader.filename, local, startOffset,
startingLine, nameOffset,
nameEndOffset, nameLine, endOffset,
endLine, false)));
return;
}
}
handleProblem(IProblem.PREPROCESSOR_INCLUSION_NOT_FOUND, startOffset,
fileNameArray);
}