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

Follow up for bug 209614.

This commit is contained in:
Markus Schorn 2008-01-10 08:58:17 +00:00
parent 88ac1b7a85
commit a9013f9b08

View file

@ -10,7 +10,6 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner; package org.eclipse.cdt.internal.core.parser.scanner;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.index.IIndexMacro; import org.eclipse.cdt.core.index.IIndexMacro;
@ -37,29 +36,56 @@ public class FileInclusionHandling {
USE_CODE_READER USE_CODE_READER
} }
private InclusionKind fKind; private final InclusionKind fKind;
private CodeReader fCodeReader; private final CodeReader fCodeReader;
private ArrayList<IIndexMacro> fMacroDefinitions; private final List<IIndexMacro> fMacroDefinitions;
private String fFileLocation; private final String fFileLocation;
public FileInclusionHandling(String fileLocation, InclusionKind kind) { /**
assert kind == InclusionKind.SKIP_FILE; * For skipping include files.
fFileLocation= fileLocation; * @param fileLocation the location of the file.
* @param kind must be {@link InclusionKind#SKIP_FILE}.
* @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 {
if (fileLocation == null || kind != InclusionKind.SKIP_FILE) {
throw new IllegalArgumentException();
}
fKind= kind; fKind= kind;
fFileLocation= fileLocation;
fMacroDefinitions= null;
fCodeReader= null;
} }
public FileInclusionHandling(CodeReader codeReader) { /**
assert codeReader != null; * For reading include files from disk.
* @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 {
if (codeReader == null) {
throw new IllegalArgumentException();
}
fKind= InclusionKind.USE_CODE_READER; fKind= InclusionKind.USE_CODE_READER;
fFileLocation= codeReader.getPath();
fCodeReader= codeReader; fCodeReader= codeReader;
if (codeReader != null) { fMacroDefinitions= null;
fFileLocation= codeReader.getPath(); if (fFileLocation == null) {
throw new IllegalArgumentException();
} }
} }
public FileInclusionHandling(String fileLocation, ArrayList<IIndexMacro> macroDefinitions) { /**
* For using information about an include file from the index.
* @param fileLocation the location of the file
* @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) {
fKind= InclusionKind.FOUND_IN_INDEX; fKind= InclusionKind.FOUND_IN_INDEX;
fFileLocation= fileLocation; fFileLocation= fileLocation;
fCodeReader= null;
fMacroDefinitions= macroDefinitions; fMacroDefinitions= macroDefinitions;
} }
@ -70,9 +96,16 @@ public class FileInclusionHandling {
return fKind; return fKind;
} }
/**
* Returns the location of the file to be included.
*/
public String getFileLocation() {
return fFileLocation;
}
/** /**
* Valid with {@link InclusionKind#USE_CODE_READER}. * Valid with {@link InclusionKind#USE_CODE_READER}.
* @return the codeReader * @return the codeReader or <code>null</code> if kind is different to {@link InclusionKind#USE_CODE_READER}.
*/ */
public CodeReader getCodeReader() { public CodeReader getCodeReader() {
return fCodeReader; return fCodeReader;
@ -80,16 +113,9 @@ public class FileInclusionHandling {
/** /**
* Valid with {@link InclusionKind#FOUND_IN_INDEX}. * Valid with {@link InclusionKind#FOUND_IN_INDEX}.
* @return the macroDefinitions * @return the macroDefinitions or <code>null</code> if kind is different to {@link InclusionKind#FOUND_IN_INDEX}.
*/ */
public List<IIndexMacro> getMacroDefinitions() { public List<IIndexMacro> getMacroDefinitions() {
return fMacroDefinitions; return fMacroDefinitions;
} }
/**
* Returns the location of the file to be included.
*/
public String getFileLocation() {
return fFileLocation;
}
} }