Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java18
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IIndexBasedCodeReaderFactory.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeFileContent.java (renamed from core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/FileInclusionHandling.java)8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java33
5 files changed, 41 insertions, 37 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
index c38462a7822..2f25ced71cf 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/IndexBasedCodeReaderFactory.java
@@ -31,9 +31,9 @@ import org.eclipse.cdt.core.index.IIndexMacro;
import org.eclipse.cdt.core.parser.CodeReader;
import org.eclipse.cdt.core.parser.ICodeReaderCache;
import org.eclipse.cdt.core.parser.ParserUtil;
-import org.eclipse.cdt.internal.core.parser.scanner.FileInclusionHandling;
+import org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent;
import org.eclipse.cdt.internal.core.parser.scanner.IIndexBasedCodeReaderFactory;
-import org.eclipse.cdt.internal.core.parser.scanner.FileInclusionHandling.InclusionKind;
+import org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent.InclusionKind;
import org.eclipse.cdt.internal.core.pdom.ASTFilePathResolver;
import org.eclipse.cdt.internal.core.pdom.AbstractIndexerTask;
import org.eclipse.core.runtime.CoreException;
@@ -85,7 +85,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
return ParserUtil.createReader(path, null);
}
- public FileInclusionHandling getInclusionHandling(String path) {
+ public IncludeFileContent getContentForInclusion(String path) {
IIndexFileLocation ifl= fPathResolver.resolveIncludeFile(path);
if (ifl == null) {
return null;
@@ -94,7 +94,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
// include files once, only.
if (!fIncludedFiles.add(ifl)) {
- return new FileInclusionHandling(path, InclusionKind.SKIP_FILE);
+ return new IncludeFileContent(path, InclusionKind.SKIP_FILE);
}
try {
@@ -108,7 +108,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
allMacros.addAll(Arrays.asList(entry.getValue()));
fIncludedFiles.add(entry.getKey());
}
- return new FileInclusionHandling(path, allMacros);
+ return new IncludeFileContent(path, allMacros);
}
catch (NeedToParseException e) {
}
@@ -120,7 +120,7 @@ public final class IndexBasedCodeReaderFactory implements IIndexBasedCodeReaderF
CodeReader codeReader= createCodeReaderForInclusion(path);
if (codeReader != null) {
- return new FileInclusionHandling(codeReader);
+ return new IncludeFileContent(codeReader);
}
return null;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
index 03a2ce8e21c..f9a6baf3b69 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
@@ -206,7 +206,7 @@ public class CPreprocessor implements ILexerLog, IScanner {
fExpressionEvaluator= new ExpressionEvaluator();
fMacroDefinitionParser= new MacroDefinitionParser();
- fMacroExpander= new MacroExpander(this, fMacroDictionary, fLocationMap, fMacroDefinitionParser, fLexOptions);
+ fMacroExpander= new MacroExpander(this, fMacroDictionary, fLocationMap, fLexOptions);
fCodeReaderFactory= wrapReaderFactory(readerFactory);
setupMacroDictionary(configuration, info, language);
@@ -233,10 +233,10 @@ public class CPreprocessor implements ILexerLog, IScanner {
public CodeReader createCodeReaderForInclusion(String path) {
return readerFactory.createCodeReaderForInclusion(path);
}
- public FileInclusionHandling getInclusionHandling(String path) {
+ public IncludeFileContent getContentForInclusion(String path) {
CodeReader reader= readerFactory.createCodeReaderForInclusion(path);
if (reader != null) {
- return new FileInclusionHandling(reader);
+ return new IncludeFileContent(reader);
}
return null;
}
@@ -777,9 +777,9 @@ public class CPreprocessor implements ILexerLog, IScanner {
}
}
- private FileInclusionHandling findInclusion(final String filename, final boolean quoteInclude,
+ private IncludeFileContent findInclusion(final String filename, final boolean quoteInclude,
final boolean includeNext, final File currentDir) {
- return (FileInclusionHandling) findInclusion(filename, quoteInclude, includeNext, currentDir, createCodeReaderTester);
+ return (IncludeFileContent) findInclusion(filename, quoteInclude, includeNext, currentDir, createCodeReaderTester);
}
private Object findInclusion(final String filename, final boolean quoteInclude,
@@ -863,9 +863,9 @@ public class CPreprocessor implements ILexerLog, IScanner {
fLocationMap.encounterProblem(id, arg, offset, endOffset);
}
- private FileInclusionHandling createReader(String path, String fileName){
+ private IncludeFileContent createReader(String path, String fileName){
String finalPath = ScannerUtility.createReconciledPath(path, fileName);
- return fCodeReaderFactory.getInclusionHandling(finalPath);
+ return fCodeReaderFactory.getContentForInclusion(finalPath);
}
@@ -1068,7 +1068,7 @@ public class CPreprocessor implements ILexerLog, IScanner {
}
else {
final File currentDir= userInclude || include_next ? new File(String.valueOf(getCurrentFilename())).getParentFile() : null;
- final FileInclusionHandling fi= findInclusion(new String(headerName), userInclude, include_next, currentDir);
+ final IncludeFileContent fi= findInclusion(new String(headerName), userInclude, include_next, currentDir);
if (fi != null) {
path= fi.getFileLocation();
switch(fi.getKind()) {
@@ -1100,7 +1100,7 @@ public class CPreprocessor implements ILexerLog, IScanner {
}
}
- private void processInclusionFromIndex(String path, FileInclusionHandling fi) {
+ private void processInclusionFromIndex(String path, IncludeFileContent fi) {
List<IIndexMacro> mdefs= fi.getMacroDefinitions();
for (IIndexMacro macro : mdefs) {
addMacroDefinition(macro);
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IIndexBasedCodeReaderFactory.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IIndexBasedCodeReaderFactory.java
index 1fabbc75656..3b0f437115a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IIndexBasedCodeReaderFactory.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IIndexBasedCodeReaderFactory.java
@@ -25,8 +25,9 @@ public interface IIndexBasedCodeReaderFactory extends ICodeReaderFactory {
boolean hasFileBeenIncludedInCurrentTranslationUnit(String path);
/**
- * Create include information object for the given location.
- * @see FileInclusionHandling
+ * Create an InclusionContent object for the given location.
+ * return an inclusion content or <code>null</code> if the location does not exist.
+ * @see IncludeFileContent
*/
- public FileInclusionHandling getInclusionHandling(String fileLocation);
+ public IncludeFileContent getContentForInclusion(String fileLocation);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/FileInclusionHandling.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeFileContent.java
index 3a46796200a..78baa786761 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/FileInclusionHandling.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/IncludeFileContent.java
@@ -19,7 +19,7 @@ import org.eclipse.cdt.core.parser.CodeReader;
* Instructs the preprocessor on how to handle a file-inclusion.
* @since 5.0
*/
-public class FileInclusionHandling {
+public class IncludeFileContent {
public enum InclusionKind {
/**
* Instruct the preprocessor to skip this inclusion.
@@ -48,7 +48,7 @@ public class FileInclusionHandling {
* @throws IllegalArgumentException if fileLocation is <code>null</code> or the kind value is illegal for
* this constructor.
*/
- public FileInclusionHandling(String fileLocation, InclusionKind kind) throws IllegalArgumentException {
+ public IncludeFileContent(String fileLocation, InclusionKind kind) throws IllegalArgumentException {
if (fileLocation == null || kind != InclusionKind.SKIP_FILE) {
throw new IllegalArgumentException();
}
@@ -63,7 +63,7 @@ public class FileInclusionHandling {
* @param codeReader the code reader for the inclusion.
* @throws IllegalArgumentException in case the codeReader or its location is <code>null</code>.
*/
- public FileInclusionHandling(CodeReader codeReader) throws IllegalArgumentException {
+ public IncludeFileContent(CodeReader codeReader) throws IllegalArgumentException {
if (codeReader == null) {
throw new IllegalArgumentException();
}
@@ -82,7 +82,7 @@ public class FileInclusionHandling {
* @param macroDefinitions a list of macro definitions
* @throws IllegalArgumentException in case the fileLocation or the macroDefinitions are <code>null</code>.
*/
- public FileInclusionHandling(String fileLocation, List<IIndexMacro> macroDefinitions) {
+ public IncludeFileContent(String fileLocation, List<IIndexMacro> macroDefinitions) {
fKind= InclusionKind.FOUND_IN_INDEX;
fFileLocation= fileLocation;
fCodeReader= null;
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java
index 2902bb90595..6aef6aded7a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/MacroExpander.java
@@ -134,10 +134,10 @@ public class MacroExpander {
private int fStartOffset;
private int fEndOffset;
- public MacroExpander(ILexerLog log, CharArrayObjectMap dict, LocationMap locationMap, MacroDefinitionParser mdp, LexerOptions lexOptions) {
+ public MacroExpander(ILexerLog log, CharArrayObjectMap dict, LocationMap locationMap, LexerOptions lexOptions) {
fDictionary= dict;
fLocationMap= locationMap;
- fDefinitionParser= mdp;
+ fDefinitionParser= new MacroDefinitionParser();
fLexOptions= lexOptions;
fLog= log;
}
@@ -217,12 +217,13 @@ public class MacroExpander {
result.append(t);
}
else {
- ImageLocationInfo info= null;
- if (fLexOptions.fCreateImageLocations) {
- info = createImageLocationInfo(t);
+ if (fLocationMap != null) {
+ ImageLocationInfo info= null;
+ if (fLexOptions.fCreateImageLocations) {
+ info = createImageLocationInfo(t);
+ }
+ fImplicitMacroExpansions.add(fLocationMap.encounterImplicitMacroExpansion(macro, info));
}
- fImplicitMacroExpansions.add(fLocationMap.encounterImplicitMacroExpansion(macro, info));
-
TokenList replacement= new TokenList();
addSpacemarker(l, t, replacement); // start expansion
@@ -243,14 +244,16 @@ public class MacroExpander {
}
private ImageLocationInfo createImageLocationInfo(Token t) {
- final Object s= t.fSource;
- if (s instanceof ObjectStyleMacro) {
- return new MacroImageLocationInfo((ObjectStyleMacro) s, t.getOffset(), t.getEndOffset());
- }
- else if (s instanceof CPreprocessor) {
- int sequenceNumber= fLocationMap.getSequenceNumberForOffset(t.getOffset());
- int sequenceEndNumber= fLocationMap.getSequenceNumberForOffset(t.getEndOffset());
- return new ParameterImageLocationInfo(sequenceNumber, sequenceEndNumber);
+ if (fLocationMap != null) {
+ final Object s= t.fSource;
+ if (s instanceof ObjectStyleMacro) {
+ return new MacroImageLocationInfo((ObjectStyleMacro) s, t.getOffset(), t.getEndOffset());
+ }
+ else if (s instanceof CPreprocessor) {
+ int sequenceNumber= fLocationMap.getSequenceNumberForOffset(t.getOffset());
+ int sequenceEndNumber= fLocationMap.getSequenceNumberForOffset(t.getEndOffset());
+ return new ParameterImageLocationInfo(sequenceNumber, sequenceEndNumber);
+ }
}
return null;
}

Back to the top