mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Further DOMScanner updates.
This commit is contained in:
parent
861c8d0a15
commit
f1c7d7672e
3 changed files with 91 additions and 30 deletions
|
@ -1272,7 +1272,7 @@ abstract class BaseScanner implements IScanner {
|
|||
protected void popContext() {
|
||||
bufferStack[bufferStackPos] = null;
|
||||
if( bufferData[bufferStackPos] instanceof InclusionData )
|
||||
popInclusion();
|
||||
popInclusion(((InclusionData)bufferData[bufferStackPos]).inclusion);
|
||||
|
||||
bufferData[bufferStackPos] = null;
|
||||
--bufferStackPos;
|
||||
|
@ -1282,9 +1282,10 @@ abstract class BaseScanner implements IScanner {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param data TODO
|
||||
*
|
||||
*/
|
||||
protected void popInclusion() {
|
||||
protected void popInclusion(java.lang.Object data) {
|
||||
if( log.isTracing() )
|
||||
{
|
||||
StringBuffer buffer = new StringBuffer( "Exiting inclusion "); //$NON-NLS-1$
|
||||
|
@ -2124,8 +2125,7 @@ abstract class BaseScanner implements IScanner {
|
|||
/**
|
||||
* @param p
|
||||
*/
|
||||
protected void pushProblem(IProblem p) {
|
||||
}
|
||||
protected abstract void pushProblem(IProblem p);
|
||||
|
||||
/**
|
||||
* @param i
|
||||
|
@ -2710,11 +2710,11 @@ abstract class BaseScanner implements IScanner {
|
|||
/**
|
||||
* @param inclusion
|
||||
*/
|
||||
protected void quickParsePushPopInclusion(Object inclusion) {
|
||||
}
|
||||
protected abstract void quickParsePushPopInclusion(Object inclusion);
|
||||
|
||||
|
||||
/**
|
||||
* @param fileNameArray
|
||||
* @param fileName
|
||||
* @param local
|
||||
* @param startOffset
|
||||
* @param startingLineNumber
|
||||
|
@ -2727,7 +2727,7 @@ abstract class BaseScanner implements IScanner {
|
|||
* @param reader
|
||||
* @return
|
||||
*/
|
||||
protected abstract Object createInclusionConstruct(char[] fileNameArray, char [] filename, boolean local, int startOffset, int startingLineNumber, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endLine, boolean isForced );
|
||||
protected abstract Object createInclusionConstruct(char[] fileName, char [] filenamePath, boolean local, int startOffset, int startingLineNumber, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endLine, boolean isForced );
|
||||
|
||||
protected void handlePPDefine(int pos2, int startingLineNumber) {
|
||||
char[] buffer = bufferStack[bufferStackPos];
|
||||
|
@ -2847,17 +2847,21 @@ abstract class BaseScanner implements IScanner {
|
|||
text = removeMultilineCommentFromBuffer( text );
|
||||
text = removedEscapedNewline( text, 0, text.length );
|
||||
|
||||
IMacro result = null;
|
||||
if( arglist == null )
|
||||
result = new ObjectStyleMacro(name, text);
|
||||
else
|
||||
result = new FunctionStyleMacro(name, text, arglist);
|
||||
|
||||
// Throw it in
|
||||
definitions.put(name, arglist == null
|
||||
? new ObjectStyleMacro(name, text)
|
||||
: new FunctionStyleMacro(name, text, arglist) );
|
||||
definitions.put(name, result);
|
||||
|
||||
if (usesVarArgInDefinition && definitions.get(name) instanceof FunctionStyleMacro && !((FunctionStyleMacro)definitions.get(name)).hasVarArgs())
|
||||
handleProblem(IProblem.PREPROCESSOR_INVALID_VA_ARGS, varArgDefinitionInd, null);
|
||||
|
||||
int idend = idstart + idlen;
|
||||
int textEnd = textstart + textlen;
|
||||
processMacro(name, startingOffset, startingLineNumber, idstart, idend, nameLine, textEnd, endingLine);
|
||||
processMacro(name, startingOffset, startingLineNumber, idstart, idend, nameLine, textEnd, endingLine, result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2869,8 +2873,9 @@ abstract class BaseScanner implements IScanner {
|
|||
* @param nameLine
|
||||
* @param textEnd
|
||||
* @param endingLine
|
||||
* @param macro TODO
|
||||
*/
|
||||
protected abstract void processMacro(char[] name, int startingOffset, int startingLineNumber, int idstart, int idend, int nameLine, int textEnd, int endingLine);
|
||||
protected abstract void processMacro(char[] name, int startingOffset, int startingLineNumber, int idstart, int idend, int nameLine, int textEnd, int endingLine, org.eclipse.cdt.core.parser.IMacro macro);
|
||||
|
||||
protected char[][] extractMacroParameters( int idstart, char[] name, boolean reportProblems ){
|
||||
char[] buffer = bufferStack[bufferStackPos];
|
||||
|
|
|
@ -13,7 +13,9 @@ package org.eclipse.cdt.internal.core.parser.scanner2;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ICodeReaderFactory;
|
||||
import org.eclipse.cdt.core.parser.CodeReader;
|
||||
import org.eclipse.cdt.core.parser.IMacro;
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IProblem;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
@ -32,6 +34,19 @@ public class DOMScanner extends BaseScanner {
|
|||
private final ICodeReaderFactory codeReaderFactory;
|
||||
// private int overallOffset = 0;
|
||||
|
||||
private static class DOMInclusion
|
||||
{
|
||||
public final char[] pt;
|
||||
public final int o;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public DOMInclusion( char [] path, int offset ) {
|
||||
this.pt = path;
|
||||
this.o = offset;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param reader
|
||||
|
@ -72,15 +87,18 @@ public class DOMScanner extends BaseScanner {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#createInclusionConstruct(char[], char[], boolean, int, int, int, int, int, int, int, boolean)
|
||||
*/
|
||||
protected Object createInclusionConstruct(char[] fileNameArray, char[] filename, boolean local, int startOffset, int startingLineNumber, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endLine, boolean isForced) {
|
||||
return null;
|
||||
protected Object createInclusionConstruct(char[] fileName, char[] filenamePath, boolean local, int startOffset, int startingLineNumber, int nameOffset, int nameEndOffset, int nameLine, int endOffset, int endLine, boolean isForced) {
|
||||
return new DOMInclusion( filenamePath, startOffset );
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processMacro(char[], int, int, int, int, int, int, int)
|
||||
*/
|
||||
protected void processMacro(char[] name, int startingOffset, int startingLineNumber, int idstart, int idend, int nameLine, int textEnd, int endingLine) {
|
||||
// TODO Auto-generated method stub
|
||||
protected void processMacro(char[] name, int startingOffset, int startingLineNumber, int idstart, int idend, int nameLine, int textEnd, int endingLine, IMacro macro) {
|
||||
if( macro instanceof ObjectStyleMacro )
|
||||
locationMap.defineObjectStyleMacro( (ObjectStyleMacro) macro, startingLineNumber, idstart, idend, textEnd );
|
||||
else if( macro instanceof FunctionStyleMacro )
|
||||
locationMap.defineFunctionStyleMacro( (FunctionStyleMacro) macro, startingLineNumber, idstart, idend, textEnd );
|
||||
|
||||
}
|
||||
|
||||
|
@ -126,4 +144,42 @@ public class DOMScanner extends BaseScanner {
|
|||
return i;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#pushProblem(org.eclipse.cdt.core.parser.IProblem)
|
||||
*/
|
||||
protected void pushProblem(IProblem p) {
|
||||
locationMap.encounterProblem(p);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#quickParsePushPopInclusion(java.lang.Object)
|
||||
*/
|
||||
protected void quickParsePushPopInclusion(Object inclusion) {
|
||||
//do nothing
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#pushInclusion(java.lang.Object)
|
||||
*/
|
||||
protected void pushInclusion(Object data) {
|
||||
super.pushInclusion(data);
|
||||
if( data instanceof DOMInclusion )
|
||||
{
|
||||
DOMInclusion d = (DOMInclusion)data;
|
||||
locationMap.startInclusion( d.pt, d.o );
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#popInclusion()
|
||||
*/
|
||||
protected void popInclusion(Object data) {
|
||||
super.popInclusion(data);
|
||||
if( data instanceof DOMInclusion )
|
||||
{
|
||||
DOMInclusion d = (DOMInclusion)data;
|
||||
locationMap.endInclusion( d.pt, d.o );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -83,11 +83,11 @@ public class Scanner2 extends BaseScanner {
|
|||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#createInclusionConstruct(char[],
|
||||
* char[], boolean, int, int, int, int, int, int, int, boolean)
|
||||
*/
|
||||
protected Object createInclusionConstruct(char[] fileNameArray,
|
||||
char[] filename, boolean local, int startOffset,
|
||||
protected Object createInclusionConstruct(char[] fileName,
|
||||
char[] filenamePath, boolean local, int startOffset,
|
||||
int startingLineNumber, int nameOffset, int nameEndOffset,
|
||||
int nameLine, int endOffset, int endLine, boolean isForced) {
|
||||
return getASTFactory().createInclusion(fileNameArray, filename, local,
|
||||
return getASTFactory().createInclusion(fileName, filenamePath, local,
|
||||
startOffset, startingLineNumber, nameOffset, nameEndOffset,
|
||||
nameLine, endOffset, endLine, getCurrentFilename(), isForced);
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ public class Scanner2 extends BaseScanner {
|
|||
*/
|
||||
protected void processMacro(char[] name, int startingOffset,
|
||||
int startingLineNumber, int idstart, int idend, int nameLine,
|
||||
int textEnd, int endingLine) {
|
||||
int textEnd, int endingLine, org.eclipse.cdt.core.parser.IMacro macro) {
|
||||
callbackManager.pushCallback(getASTFactory().createMacro(name,
|
||||
startingOffset, startingLineNumber, idstart, idend, nameLine,
|
||||
textEnd, endingLine, getCurrentFilename(), !isInitialized));
|
||||
|
@ -117,8 +117,8 @@ public class Scanner2 extends BaseScanner {
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#popInclusion()
|
||||
*/
|
||||
protected void popInclusion() {
|
||||
super.popInclusion();
|
||||
protected void popInclusion(java.lang.Object data) {
|
||||
super.popInclusion(data);
|
||||
callbackManager.pushCallback( ((InclusionData) bufferData[bufferStackPos]).inclusion );
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue