mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-09 09:15:38 +02:00
Format.
This commit is contained in:
parent
0c4f633ecc
commit
d77e74d43e
4 changed files with 4613 additions and 4394 deletions
File diff suppressed because it is too large
Load diff
|
@ -31,10 +31,12 @@ import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
||||||
public class DOMScanner extends BaseScanner {
|
public class DOMScanner extends BaseScanner {
|
||||||
|
|
||||||
protected final ICodeReaderFactory codeReaderFactory;
|
protected final ICodeReaderFactory codeReaderFactory;
|
||||||
protected int [] bufferDelta = new int[ bufferInitialSize ];
|
|
||||||
|
protected int[] bufferDelta = new int[bufferInitialSize];
|
||||||
|
|
||||||
private static class DOMInclusion {
|
private static class DOMInclusion {
|
||||||
public final char[] pt;
|
public final char[] pt;
|
||||||
|
|
||||||
public final int o;
|
public final int o;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +59,8 @@ public class DOMScanner extends BaseScanner {
|
||||||
* @param requestor
|
* @param requestor
|
||||||
*/
|
*/
|
||||||
public DOMScanner(CodeReader reader, IScannerInfo info,
|
public DOMScanner(CodeReader reader, IScannerInfo info,
|
||||||
ParserMode parserMode, ParserLanguage language, IParserLogService log,
|
ParserMode parserMode, ParserLanguage language,
|
||||||
|
IParserLogService log,
|
||||||
IScannerExtensionConfiguration configuration,
|
IScannerExtensionConfiguration configuration,
|
||||||
ICodeReaderFactory readerFactory) {
|
ICodeReaderFactory readerFactory) {
|
||||||
super(reader, info, parserMode, language, log, configuration);
|
super(reader, info, parserMode, language, log, configuration);
|
||||||
|
@ -112,10 +115,12 @@ public class DOMScanner extends BaseScanner {
|
||||||
int textEnd, int endingLine, IMacro macro) {
|
int textEnd, int endingLine, IMacro macro) {
|
||||||
if (macro instanceof FunctionStyleMacro)
|
if (macro instanceof FunctionStyleMacro)
|
||||||
locationMap.defineFunctionStyleMacro((FunctionStyleMacro) macro,
|
locationMap.defineFunctionStyleMacro((FunctionStyleMacro) macro,
|
||||||
resolveOffset( startingOffset ), resolveOffset( idstart ), resolveOffset( idend ), resolveOffset( textEnd) );
|
resolveOffset(startingOffset), resolveOffset(idstart),
|
||||||
|
resolveOffset(idend), resolveOffset(textEnd));
|
||||||
else if (macro instanceof ObjectStyleMacro)
|
else if (macro instanceof ObjectStyleMacro)
|
||||||
locationMap.defineObjectStyleMacro((ObjectStyleMacro) macro,
|
locationMap.defineObjectStyleMacro((ObjectStyleMacro) macro,
|
||||||
resolveOffset( startingOffset ), resolveOffset( idstart ), resolveOffset( idend ), resolveOffset( textEnd ) );
|
resolveOffset(startingOffset), resolveOffset(idstart),
|
||||||
|
resolveOffset(idend), resolveOffset(textEnd));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,7 +133,6 @@ public class DOMScanner extends BaseScanner {
|
||||||
return codeReaderFactory.createCodeReaderForInclusion(finalPath);
|
return codeReaderFactory.createCodeReaderForInclusion(finalPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -136,12 +140,12 @@ 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 )
|
if (bufferStackPos + 1 == bufferDelta.length) {
|
||||||
{
|
|
||||||
int size = bufferDelta.length * 2;
|
int size = bufferDelta.length * 2;
|
||||||
int[] oldBufferDelta = bufferDelta;
|
int[] oldBufferDelta = bufferDelta;
|
||||||
bufferDelta = new int[size];
|
bufferDelta = new int[size];
|
||||||
System.arraycopy(oldBufferDelta, 0, bufferDelta, 0, oldBufferDelta.length);
|
System.arraycopy(oldBufferDelta, 0, bufferDelta, 0,
|
||||||
|
oldBufferDelta.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data instanceof InclusionData) {
|
if (data instanceof InclusionData) {
|
||||||
|
@ -153,8 +157,9 @@ public class DOMScanner extends BaseScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
DOMInclusion inc = ((DOMInclusion) ((InclusionData) data).inclusion);
|
DOMInclusion inc = ((DOMInclusion) ((InclusionData) data).inclusion);
|
||||||
locationMap.startInclusion(((InclusionData)data).reader, inc.o, resolveOffset( getCurrentOffset() ));
|
locationMap.startInclusion(((InclusionData) data).reader, inc.o,
|
||||||
bufferDelta[bufferStackPos + 1 ] = 0;
|
resolveOffset(getCurrentOffset()));
|
||||||
|
bufferDelta[bufferStackPos + 1] = 0;
|
||||||
}
|
}
|
||||||
super.pushContext(buffer, data);
|
super.pushContext(buffer, data);
|
||||||
}
|
}
|
||||||
|
@ -168,7 +173,8 @@ 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) {
|
||||||
locationMap.endTranslationUnit( bufferDelta[0] + ((CodeReader)result).buffer.length );
|
locationMap.endTranslationUnit(bufferDelta[0]
|
||||||
|
+ ((CodeReader) result).buffer.length);
|
||||||
}
|
}
|
||||||
if (result instanceof InclusionData) {
|
if (result instanceof InclusionData) {
|
||||||
CodeReader codeReader = ((InclusionData) result).reader;
|
CodeReader codeReader = ((InclusionData) result).reader;
|
||||||
|
@ -178,26 +184,27 @@ public class DOMScanner extends BaseScanner {
|
||||||
log.traceLog(buffer.toString());
|
log.traceLog(buffer.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
locationMap.endInclusion(getGlobalCounter( bufferStackPos + 1 ) + bufferPos[ bufferStackPos + 1 ]);
|
locationMap.endInclusion(getGlobalCounter(bufferStackPos + 1)
|
||||||
bufferDelta[ bufferStackPos ] += bufferDelta[ bufferStackPos + 1 ] + codeReader.buffer.length;
|
+ bufferPos[bufferStackPos + 1]);
|
||||||
|
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
||||||
|
+ codeReader.buffer.length;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getGlobalCounter( int value )
|
protected int getGlobalCounter(int value) {
|
||||||
{
|
if (value < 0)
|
||||||
if( value < 0 ) return 0;
|
return 0;
|
||||||
int result = bufferDelta[ value ];
|
int result = bufferDelta[value];
|
||||||
for( int i = value - 1; i >= 0; --i )
|
for (int i = value - 1; i >= 0; --i)
|
||||||
result += bufferPos[ i ] + bufferDelta[ i ];
|
result += bufferPos[i] + bufferDelta[i];
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getGlobalCounter()
|
protected int getGlobalCounter() {
|
||||||
{
|
return getGlobalCounter(bufferStackPos);
|
||||||
return getGlobalCounter( bufferStackPos );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -217,7 +224,8 @@ public class DOMScanner extends BaseScanner {
|
||||||
getLineNumber(bufferPos[mostRelevant] + 1));
|
getLineNumber(bufferPos[mostRelevant] + 1));
|
||||||
}
|
}
|
||||||
return new SimpleToken(signal,
|
return new SimpleToken(signal,
|
||||||
resolveOffset(bufferPos[bufferStackPos] + 1), getCurrentFilename(),
|
resolveOffset(bufferPos[bufferStackPos] + 1),
|
||||||
|
getCurrentFilename(),
|
||||||
getLineNumber(bufferPos[bufferStackPos] + 1));
|
getLineNumber(bufferPos[bufferStackPos] + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -287,64 +295,98 @@ public class DOMScanner extends BaseScanner {
|
||||||
locationMap.startTranslationUnit(getMainReader());
|
locationMap.startTranslationUnit(getMainReader());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processIfdef(int, int, boolean, boolean)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processIfdef(int,
|
||||||
|
* int, boolean, boolean)
|
||||||
*/
|
*/
|
||||||
protected void processIfdef(int startPos, int endPos, boolean positive, boolean taken) {
|
protected void processIfdef(int startPos, int endPos, boolean positive,
|
||||||
if( positive )
|
boolean taken) {
|
||||||
locationMap.encounterPoundIfdef( resolveOffset(startPos), resolveOffset(endPos), taken );
|
if (positive)
|
||||||
|
locationMap.encounterPoundIfdef(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos), taken);
|
||||||
else
|
else
|
||||||
locationMap.encounterPoundIfndef( resolveOffset(startPos), resolveOffset(endPos), taken );
|
locationMap.encounterPoundIfndef(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos), taken);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processIf(int, int, boolean)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processIf(int,
|
||||||
|
* int, boolean)
|
||||||
*/
|
*/
|
||||||
protected void processIf(int startPos, int endPos, boolean taken) {
|
protected void processIf(int startPos, int endPos, boolean taken) {
|
||||||
locationMap.encounterPoundIf( resolveOffset( startPos ), resolveOffset( endPos ), taken );
|
locationMap.encounterPoundIf(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos), taken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processElsif(int, int, boolean)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processElsif(int,
|
||||||
|
* int, boolean)
|
||||||
*/
|
*/
|
||||||
protected void processElsif(int startPos, int endPos, boolean taken) {
|
protected void processElsif(int startPos, int endPos, boolean taken) {
|
||||||
locationMap.encounterPoundElif( resolveOffset( startPos ), resolveOffset( endPos ), taken );
|
locationMap.encounterPoundElif(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos), taken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processElse(int, int, boolean)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processElse(int,
|
||||||
|
* int, boolean)
|
||||||
*/
|
*/
|
||||||
protected void processElse(int startPos, int endPos, boolean taken) {
|
protected void processElse(int startPos, int endPos, boolean taken) {
|
||||||
locationMap.encounterPoundElse( resolveOffset( startPos ), resolveOffset( endPos ), taken );
|
locationMap.encounterPoundElse(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos), taken);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processUndef(int, int)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processUndef(int,
|
||||||
|
* int)
|
||||||
*/
|
*/
|
||||||
protected void processUndef(int pos, int endPos) {
|
protected void processUndef(int pos, int endPos) {
|
||||||
locationMap.encounterPoundUndef( resolveOffset( pos ), resolveOffset( endPos ));
|
locationMap.encounterPoundUndef(resolveOffset(pos),
|
||||||
|
resolveOffset(endPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processError(int, int)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processError(int,
|
||||||
|
* int)
|
||||||
*/
|
*/
|
||||||
protected void processError(int startPos, int endPos) {
|
protected void processError(int startPos, int endPos) {
|
||||||
locationMap.encounterPoundError( resolveOffset( startPos), resolveOffset( endPos ));
|
locationMap.encounterPoundError(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processEndif(int, int)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processEndif(int,
|
||||||
|
* int)
|
||||||
*/
|
*/
|
||||||
protected void processEndif(int startPos , int endPos ) {
|
protected void processEndif(int startPos, int endPos) {
|
||||||
locationMap.encounterPoundEndIf( resolveOffset( startPos ), resolveOffset( endPos ));
|
locationMap.encounterPoundEndIf(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/*
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processPragma(int, int)
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processPragma(int,
|
||||||
|
* int)
|
||||||
*/
|
*/
|
||||||
protected void processPragma(int startPos, int endPos) {
|
protected void processPragma(int startPos, int endPos) {
|
||||||
locationMap.encounterPoundPragma( resolveOffset( startPos ), resolveOffset(endPos));
|
locationMap.encounterPoundPragma(resolveOffset(startPos),
|
||||||
|
resolveOffset(endPos));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -18,34 +18,49 @@ import org.eclipse.cdt.core.parser.CodeReader;
|
||||||
*/
|
*/
|
||||||
public interface IScannerPreprocessorLog {
|
public interface IScannerPreprocessorLog {
|
||||||
|
|
||||||
public void startTranslationUnit( CodeReader tu_reader );
|
public void startTranslationUnit(CodeReader tu_reader);
|
||||||
|
|
||||||
public void endTranslationUnit(int offset);
|
public void endTranslationUnit(int offset);
|
||||||
|
|
||||||
public void startInclusion(CodeReader reader, int offset, int endOffset);
|
public void startInclusion(CodeReader reader, int offset, int endOffset);
|
||||||
|
|
||||||
public void endInclusion(int offset);
|
public void endInclusion(int offset);
|
||||||
|
|
||||||
public void enterObjectStyleMacroExpansion(char[] name, char[] expansion,
|
public void enterObjectStyleMacroExpansion(char[] name, char[] expansion,
|
||||||
int offset);
|
int offset);
|
||||||
|
|
||||||
public void exitObjectStyleMacroExpansion(char[] name, int offset);
|
public void exitObjectStyleMacroExpansion(char[] name, int offset);
|
||||||
|
|
||||||
public void enterFunctionStyleExpansion(char[] name, char[][] parameters,
|
public void enterFunctionStyleExpansion(char[] name, char[][] parameters,
|
||||||
char[] expansion, int offset);
|
char[] expansion, int offset);
|
||||||
|
|
||||||
public void exitFunctionStyleExpansion(char[] name, int offset);
|
public void exitFunctionStyleExpansion(char[] name, int offset);
|
||||||
|
|
||||||
public void defineObjectStyleMacro(ObjectStyleMacro m, int startOffset,
|
public void defineObjectStyleMacro(ObjectStyleMacro m, int startOffset,
|
||||||
int nameOffset, int nameEndOffset, int endOffset);
|
int nameOffset, int nameEndOffset, int endOffset);
|
||||||
|
|
||||||
public void defineFunctionStyleMacro(FunctionStyleMacro m, int startOffset,
|
public void defineFunctionStyleMacro(FunctionStyleMacro m, int startOffset,
|
||||||
int nameOffset, int nameEndOffset, int endOffset);
|
int nameOffset, int nameEndOffset, int endOffset);
|
||||||
|
|
||||||
public void encounterPoundIf(int startOffset, int endOffset, boolean taken);
|
public void encounterPoundIf(int startOffset, int endOffset, boolean taken);
|
||||||
public void encounterPoundIfdef(int startOffset, int endOffset, boolean taken);
|
|
||||||
public void encounterPoundIfndef( int startOffset, int endOffset, boolean taken );
|
public void encounterPoundIfdef(int startOffset, int endOffset,
|
||||||
public void encounterPoundElse(int startOffset, int endOffset, boolean taken );
|
boolean taken);
|
||||||
|
|
||||||
|
public void encounterPoundIfndef(int startOffset, int endOffset,
|
||||||
|
boolean taken);
|
||||||
|
|
||||||
|
public void encounterPoundElse(int startOffset, int endOffset, boolean taken);
|
||||||
|
|
||||||
public void encounterPoundElif(int startOffset, int endOffset, boolean taken);
|
public void encounterPoundElif(int startOffset, int endOffset, boolean taken);
|
||||||
|
|
||||||
public void encounterPoundEndIf(int startOffset, int endOffset);
|
public void encounterPoundEndIf(int startOffset, int endOffset);
|
||||||
|
|
||||||
public void encounterPoundPragma(int startOffset, int endOffset);
|
public void encounterPoundPragma(int startOffset, int endOffset);
|
||||||
|
|
||||||
public void encounterPoundError(int startOffset, int endOffset);
|
public void encounterPoundError(int startOffset, int endOffset);
|
||||||
|
|
||||||
public void encounterPoundUndef(int startOffset, int endOffset);
|
public void encounterPoundUndef(int startOffset, int endOffset);
|
||||||
|
|
||||||
public void encounterProblem( IASTProblem problem );
|
public void encounterProblem(IASTProblem problem);
|
||||||
}
|
}
|
|
@ -53,6 +53,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorEndifStatement {
|
IASTPreprocessorEndifStatement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -60,12 +61,16 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorElifStatement {
|
IASTPreprocessorElifStatement {
|
||||||
|
|
||||||
private final boolean taken;
|
private final boolean taken;
|
||||||
/* (non-Javadoc)
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
||||||
*/
|
*/
|
||||||
public boolean taken() {
|
public boolean taken() {
|
||||||
return taken;
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param taken
|
* @param taken
|
||||||
*/
|
*/
|
||||||
|
@ -74,13 +79,17 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
static class ASTElse extends ScannerASTNode implements
|
static class ASTElse extends ScannerASTNode implements
|
||||||
IASTPreprocessorElseStatement {
|
IASTPreprocessorElseStatement {
|
||||||
private final boolean taken;
|
private final boolean taken;
|
||||||
/* (non-Javadoc)
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
||||||
*/
|
*/
|
||||||
public boolean taken() {
|
public boolean taken() {
|
||||||
|
@ -95,20 +104,24 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
static class ASTIfndef extends ScannerASTNode implements IASTPreprocessorIfndefStatement {
|
static class ASTIfndef extends ScannerASTNode implements
|
||||||
|
IASTPreprocessorIfndefStatement {
|
||||||
|
|
||||||
private final boolean taken;
|
private final boolean taken;
|
||||||
/* (non-Javadoc)
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
||||||
*/
|
*/
|
||||||
public boolean taken() {
|
public boolean taken() {
|
||||||
return taken;
|
return taken;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param taken
|
* @param taken
|
||||||
*/
|
*/
|
||||||
|
@ -117,6 +130,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -124,7 +138,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorIfdefStatement {
|
IASTPreprocessorIfdefStatement {
|
||||||
|
|
||||||
private final boolean taken;
|
private final boolean taken;
|
||||||
/* (non-Javadoc)
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
||||||
*/
|
*/
|
||||||
public boolean taken() {
|
public boolean taken() {
|
||||||
|
@ -139,6 +156,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -146,7 +164,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorIfStatement {
|
IASTPreprocessorIfStatement {
|
||||||
|
|
||||||
private final boolean taken;
|
private final boolean taken;
|
||||||
/* (non-Javadoc)
|
|
||||||
|
/*
|
||||||
|
* (non-Javadoc)
|
||||||
|
*
|
||||||
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#taken()
|
||||||
*/
|
*/
|
||||||
public boolean taken() {
|
public boolean taken() {
|
||||||
|
@ -161,6 +182,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -168,6 +190,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorErrorStatement {
|
IASTPreprocessorErrorStatement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -175,6 +198,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorPragmaStatement {
|
IASTPreprocessorPragmaStatement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -182,6 +206,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
IASTPreprocessorUndefStatement {
|
IASTPreprocessorUndefStatement {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author jcamelon
|
* @author jcamelon
|
||||||
*/
|
*/
|
||||||
|
@ -886,9 +911,13 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final IASTProblem[] EMPTY_PROBLEMS_ARRAY = new IASTProblem[0];
|
private static final IASTProblem[] EMPTY_PROBLEMS_ARRAY = new IASTProblem[0];
|
||||||
|
|
||||||
private static final IASTNodeLocation[] EMPTY_LOCATION_ARRAY = new IASTNodeLocation[0];
|
private static final IASTNodeLocation[] EMPTY_LOCATION_ARRAY = new IASTNodeLocation[0];
|
||||||
|
|
||||||
private static final IASTPreprocessorMacroDefinition[] EMPTY_MACRO_DEFINITIONS_ARRAY = new IASTPreprocessorMacroDefinition[0];
|
private static final IASTPreprocessorMacroDefinition[] EMPTY_MACRO_DEFINITIONS_ARRAY = new IASTPreprocessorMacroDefinition[0];
|
||||||
|
|
||||||
private static final IASTPreprocessorIncludeStatement[] EMPTY_INCLUDES_ARRAY = new IASTPreprocessorIncludeStatement[0];
|
private static final IASTPreprocessorIncludeStatement[] EMPTY_INCLUDES_ARRAY = new IASTPreprocessorIncludeStatement[0];
|
||||||
|
|
||||||
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_ARRAY = new IASTPreprocessorStatement[0];
|
private static final IASTPreprocessorStatement[] EMPTY_PREPROCESSOR_ARRAY = new IASTPreprocessorStatement[0];
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -969,8 +998,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
private IASTPreprocessorIncludeStatement createASTInclusion(_Inclusion inc) {
|
private IASTPreprocessorIncludeStatement createASTInclusion(_Inclusion inc) {
|
||||||
IASTPreprocessorIncludeStatement result = new ASTInclusionStatement(
|
IASTPreprocessorIncludeStatement result = new ASTInclusionStatement(
|
||||||
inc.reader.filename);
|
inc.reader.filename);
|
||||||
((ScannerASTNode) result).setOffsetAndLength(inc.context_directive_start,
|
((ScannerASTNode) result).setOffsetAndLength(
|
||||||
inc.context_directive_end - inc.context_directive_start);
|
inc.context_directive_start, inc.context_directive_end
|
||||||
|
- inc.context_directive_start);
|
||||||
((ASTInclusionStatement) result).startOffset = inc.context_directive_end;
|
((ASTInclusionStatement) result).startOffset = inc.context_directive_end;
|
||||||
((ASTInclusionStatement) result).endOffset = inc.context_ends;
|
((ASTInclusionStatement) result).endOffset = inc.context_ends;
|
||||||
return result;
|
return result;
|
||||||
|
@ -988,30 +1018,29 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
_Context[] contexts = new _Context[size];
|
_Context[] contexts = new _Context[size];
|
||||||
collectContexts(V_PREPROCESSOR, tu, contexts, 0);
|
collectContexts(V_PREPROCESSOR, tu, contexts, 0);
|
||||||
IASTPreprocessorStatement[] result = new IASTPreprocessorStatement[size];
|
IASTPreprocessorStatement[] result = new IASTPreprocessorStatement[size];
|
||||||
for (int i = 0; i < size; ++i)
|
for (int i = 0; i < size; ++i) {
|
||||||
{
|
if (contexts[i] instanceof _Inclusion)
|
||||||
if( contexts[i] instanceof _Inclusion )
|
|
||||||
result[i] = createASTInclusion(((_Inclusion) contexts[i]));
|
result[i] = createASTInclusion(((_Inclusion) contexts[i]));
|
||||||
else if( contexts[i] instanceof _MacroDefinition )
|
else if (contexts[i] instanceof _MacroDefinition)
|
||||||
result[i] = createASTMacroDefinition( (_MacroDefinition) contexts[i] );
|
result[i] = createASTMacroDefinition((_MacroDefinition) contexts[i]);
|
||||||
else if ( contexts[i] instanceof _Undef )
|
else if (contexts[i] instanceof _Undef)
|
||||||
result[i] = createASTUndef( (_Undef)contexts[i] );
|
result[i] = createASTUndef((_Undef) contexts[i]);
|
||||||
else if ( contexts[i] instanceof _Pragma )
|
else if (contexts[i] instanceof _Pragma)
|
||||||
result[i] = createASTPragma( (_Pragma)contexts[i]);
|
result[i] = createASTPragma((_Pragma) contexts[i]);
|
||||||
else if ( contexts[i] instanceof _Error )
|
else if (contexts[i] instanceof _Error)
|
||||||
result[i] = createASTError( (_Error)contexts[i] );
|
result[i] = createASTError((_Error) contexts[i]);
|
||||||
else if ( contexts[i] instanceof _If )
|
else if (contexts[i] instanceof _If)
|
||||||
result[i] = createASTIf( (_If)contexts[i] );
|
result[i] = createASTIf((_If) contexts[i]);
|
||||||
else if( contexts[i] instanceof _Ifdef )
|
else if (contexts[i] instanceof _Ifdef)
|
||||||
result[i] = createASTIfdef( (_Ifdef)contexts[i] );
|
result[i] = createASTIfdef((_Ifdef) contexts[i]);
|
||||||
else if( contexts[i] instanceof _Ifndef )
|
else if (contexts[i] instanceof _Ifndef)
|
||||||
result[i] = createASTIfndef( (_Ifndef)contexts[i]);
|
result[i] = createASTIfndef((_Ifndef) contexts[i]);
|
||||||
else if( contexts[i] instanceof _Else )
|
else if (contexts[i] instanceof _Else)
|
||||||
result[i] = createASTElse( (_Else)contexts[i] );
|
result[i] = createASTElse((_Else) contexts[i]);
|
||||||
else if ( contexts[i] instanceof _Elif )
|
else if (contexts[i] instanceof _Elif)
|
||||||
result[i] = createASTElif( (_Elif)contexts[i] );
|
result[i] = createASTElif((_Elif) contexts[i]);
|
||||||
else if( contexts[i] instanceof _Endif )
|
else if (contexts[i] instanceof _Endif)
|
||||||
result[i] = createASTEndif( (_Endif)contexts[i ]);
|
result[i] = createASTEndif((_Endif) contexts[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -1023,7 +1052,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTEndif(_Endif endif) {
|
private IASTPreprocessorStatement createASTEndif(_Endif endif) {
|
||||||
IASTPreprocessorEndifStatement result = new ASTEndif();
|
IASTPreprocessorEndifStatement result = new ASTEndif();
|
||||||
((ASTNode)result).setOffsetAndLength( endif.context_directive_start, endif.context_directive_end - endif.context_directive_start );
|
((ASTNode) result).setOffsetAndLength(endif.context_directive_start,
|
||||||
|
endif.context_directive_end - endif.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1033,7 +1063,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTElif(_Elif elif) {
|
private IASTPreprocessorStatement createASTElif(_Elif elif) {
|
||||||
IASTPreprocessorElifStatement result = new ASTElif(elif.taken);
|
IASTPreprocessorElifStatement result = new ASTElif(elif.taken);
|
||||||
((ASTNode)result).setOffsetAndLength( elif.context_directive_start, elif.context_directive_end - elif.context_directive_start);
|
((ASTNode) result).setOffsetAndLength(elif.context_directive_start,
|
||||||
|
elif.context_directive_end - elif.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1043,7 +1074,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTElse(_Else e) {
|
private IASTPreprocessorStatement createASTElse(_Else e) {
|
||||||
IASTPreprocessorElseStatement result = new ASTElse(e.taken);
|
IASTPreprocessorElseStatement result = new ASTElse(e.taken);
|
||||||
((ASTNode)result).setOffsetAndLength( e.context_directive_start, e.context_directive_end- e.context_directive_start );
|
((ASTNode) result).setOffsetAndLength(e.context_directive_start,
|
||||||
|
e.context_directive_end - e.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1053,7 +1085,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTIfndef(_Ifndef ifndef) {
|
private IASTPreprocessorStatement createASTIfndef(_Ifndef ifndef) {
|
||||||
IASTPreprocessorIfndefStatement result = new ASTIfndef(ifndef.taken);
|
IASTPreprocessorIfndefStatement result = new ASTIfndef(ifndef.taken);
|
||||||
((ASTNode)result).setOffsetAndLength( ifndef.context_directive_start, ifndef.context_directive_end - ifndef.context_directive_start );
|
((ASTNode) result).setOffsetAndLength(ifndef.context_directive_start,
|
||||||
|
ifndef.context_directive_end - ifndef.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1063,7 +1096,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTIfdef(_Ifdef ifdef) {
|
private IASTPreprocessorStatement createASTIfdef(_Ifdef ifdef) {
|
||||||
IASTPreprocessorIfdefStatement result = new ASTIfdef(ifdef.taken);
|
IASTPreprocessorIfdefStatement result = new ASTIfdef(ifdef.taken);
|
||||||
((ASTNode)result).setOffsetAndLength( ifdef.context_directive_start, ifdef.context_directive_end - ifdef.context_directive_start);
|
((ASTNode) result).setOffsetAndLength(ifdef.context_directive_start,
|
||||||
|
ifdef.context_directive_end - ifdef.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1071,9 +1105,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
* @param if1
|
* @param if1
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTIf(_If i ) {
|
private IASTPreprocessorStatement createASTIf(_If i) {
|
||||||
IASTPreprocessorIfStatement result = new ASTIf(i.taken);
|
IASTPreprocessorIfStatement result = new ASTIf(i.taken);
|
||||||
((ASTNode)result).setOffsetAndLength( i.context_directive_start, i.context_directive_end - - i.context_directive_start );
|
((ASTNode) result).setOffsetAndLength(i.context_directive_start,
|
||||||
|
i.context_directive_end - -i.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1083,7 +1118,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTError(_Error error) {
|
private IASTPreprocessorStatement createASTError(_Error error) {
|
||||||
IASTPreprocessorErrorStatement result = new ASTError();
|
IASTPreprocessorErrorStatement result = new ASTError();
|
||||||
((ASTNode)result).setOffsetAndLength( error.context_directive_start, error.context_directive_end - error.context_directive_start);
|
((ASTNode) result).setOffsetAndLength(error.context_directive_start,
|
||||||
|
error.context_directive_end - error.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1102,7 +1138,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
*/
|
*/
|
||||||
private IASTPreprocessorStatement createASTUndef(_Undef undef) {
|
private IASTPreprocessorStatement createASTUndef(_Undef undef) {
|
||||||
IASTPreprocessorUndefStatement result = new ASTUndef();
|
IASTPreprocessorUndefStatement result = new ASTUndef();
|
||||||
((ASTNode)result).setOffsetAndLength( undef.context_directive_start, undef.context_directive_end - undef.context_directive_start );
|
((ASTNode) result).setOffsetAndLength(undef.context_directive_start,
|
||||||
|
undef.context_directive_end - undef.context_directive_start);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue