Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java25
1 files changed, 17 insertions, 8 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java
index 6c2a465bd7b..29a9dc9b4c8 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/Lexer.java
@@ -63,6 +63,7 @@ final public class Lexer {
// configuration
private final LexerOptions fOptions;
private final ILexerLog fLog;
+ private final Object fSource;
// the input to the lexer
private final char[] fInput;
@@ -84,21 +85,29 @@ final public class Lexer {
private boolean fFirstTokenAfterNewline= true;
- public Lexer(char[] input, LexerOptions options, ILexerLog log) {
- this(input, 0, input.length, options, log);
+ public Lexer(char[] input, LexerOptions options, ILexerLog log, Object source) {
+ this(input, 0, input.length, options, log, source);
}
- public Lexer(char[] input, int start, int end, LexerOptions options, ILexerLog log) {
+ public Lexer(char[] input, int start, int end, LexerOptions options, ILexerLog log, Object source) {
fInput= input;
fStart= fOffset= fEndOffset= start;
fLimit= end;
fOptions= options;
fLog= log;
- fToken= new SimpleToken(tBEFORE_INPUT, start, start);
+ fSource= source;
+ fToken= new SimpleToken(tBEFORE_INPUT, source, start, start);
nextCharPhase3();
}
/**
+ * Returns the source that is attached to the tokens generated by this lexer
+ */
+ public Object getSource() {
+ return fSource;
+ }
+
+ /**
* Resets the lexer to the first char and prepares for content-assist mode.
*/
public void setContentAssistMode(int offset) {
@@ -542,20 +551,20 @@ final public class Lexer {
}
private Token newToken(int kind, int offset) {
- return new SimpleToken(kind, offset, fOffset);
+ return new SimpleToken(kind, fSource, offset, fOffset);
}
private Token newDigraphToken(int kind, int offset) {
- return new DigraphToken(kind, offset, fOffset);
+ return new DigraphToken(kind, fSource, offset, fOffset);
}
private Token newToken(int kind, int offset, int imageLength) {
final int endOffset= fOffset;
int sourceLen= endOffset-offset;
if (sourceLen != imageLength) {
- return new ImageToken(kind, offset, endOffset, getCharImage(offset, endOffset, imageLength));
+ return new ImageToken(kind, fSource, offset, endOffset, getCharImage(offset, endOffset, imageLength));
}
- return new SourceImageToken(kind, offset, endOffset, fInput);
+ return new SourceImageToken(kind, fSource, offset, endOffset, fInput);
}
private void handleProblem(int problemID, char[] arg, int offset) {

Back to the top