mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
org.eclipse.cdt.core
Refactored Parser.java to allow inline small functions and tightened the signatures for statement(). Refactored Scanner.java to allow for data to be encapsulated to allow for IScannerExtension to act upon it. Partially fixed Bug 47628 - signed char is parsed as char (affects the outline view) org.eclipse.cdt.core.tests Added testBug47682() to QuickParseASTTests.java.
This commit is contained in:
parent
728eeb85f8
commit
f596606ff7
16 changed files with 604 additions and 253 deletions
|
@ -1,3 +1,6 @@
|
|||
2004-02-10 John Camelon
|
||||
Added testBug47682() to QuickParseASTTests.java.
|
||||
|
||||
2004-02-06 Bogdan Gheorghe
|
||||
Added FunctionMethodPatternTests.testMethodDeclarationWithNoParameters
|
||||
|
||||
|
|
|
@ -1203,5 +1203,35 @@ public class CompleteParseASTTest extends CompleteParseBaseTest
|
|||
assertAllReferences( 1, createTaskList( new Task( x )));
|
||||
}
|
||||
|
||||
// public void testBug47628() throws Exception
|
||||
// {
|
||||
// Writer writer = new StringWriter();
|
||||
// writer.write( "void h(char) { }\n");
|
||||
// writer.write( "void h(unsigned char) { }\n");
|
||||
// writer.write( "void h(signed char) { } // not shown in outline, parsed as char\n");
|
||||
// Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
// IASTFunction h1 = (IASTFunction) i.next();
|
||||
// assertEquals( h1.getName(), "h");
|
||||
// Iterator parms = h1.getParameters();
|
||||
// IASTParameterDeclaration parm = (IASTParameterDeclaration) parms.next();
|
||||
// assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier );
|
||||
// assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "char" );
|
||||
// IASTFunction h2 = (IASTFunction) i.next();
|
||||
// assertEquals( h2.getName(), "h");
|
||||
// parms = h2.getParameters();
|
||||
// parm = (IASTParameterDeclaration) parms.next();
|
||||
// assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier );
|
||||
// assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "unsigned char" );
|
||||
//
|
||||
// IASTFunction h3 = (IASTFunction) i.next();
|
||||
// assertEquals( h3.getName(), "h");
|
||||
// parms = h3.getParameters();
|
||||
// parm = (IASTParameterDeclaration) parms.next();
|
||||
// assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier );
|
||||
// assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "signed char" );
|
||||
//
|
||||
// assertFalse( i.hasNext() );
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2085,4 +2085,34 @@ public class QuickParseASTTests extends BaseASTTest
|
|||
{
|
||||
parse("void func( cFoo bar ) try { } catch ( const char * error ){ }" );
|
||||
}
|
||||
|
||||
public void testBug47628() throws Exception
|
||||
{
|
||||
Writer writer = new StringWriter();
|
||||
writer.write( "void h(char) { }\n");
|
||||
writer.write( "void h(unsigned char) { }\n");
|
||||
writer.write( "void h(signed char) { } // not shown in outline, parsed as char\n");
|
||||
Iterator i = parse( writer.toString() ).getDeclarations();
|
||||
IASTFunction h1 = (IASTFunction) i.next();
|
||||
assertEquals( h1.getName(), "h");
|
||||
Iterator parms = h1.getParameters();
|
||||
IASTParameterDeclaration parm = (IASTParameterDeclaration) parms.next();
|
||||
assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier );
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "char" );
|
||||
IASTFunction h2 = (IASTFunction) i.next();
|
||||
assertEquals( h2.getName(), "h");
|
||||
parms = h2.getParameters();
|
||||
parm = (IASTParameterDeclaration) parms.next();
|
||||
assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier );
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "unsigned char" );
|
||||
|
||||
IASTFunction h3 = (IASTFunction) i.next();
|
||||
assertEquals( h3.getName(), "h");
|
||||
parms = h3.getParameters();
|
||||
parm = (IASTParameterDeclaration) parms.next();
|
||||
assertTrue( parm.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier );
|
||||
assertEquals( ((IASTSimpleTypeSpecifier)parm.getTypeSpecifier()).getTypename(), "signed char" );
|
||||
|
||||
assertFalse( i.hasNext() );
|
||||
}
|
||||
}
|
|
@ -1,3 +1,8 @@
|
|||
2004-02-10 John Camelon
|
||||
Refactored Parser.java to allow inline small functions and tightened the signatures for statement().
|
||||
Refactored Scanner.java to allow for data to be encapsulated to allow for IScannerExtension to act upon it.
|
||||
Partially fixed Bug 47628 - signed char is parsed as char (affects the outline view)
|
||||
|
||||
2004-02-08 John Camelon
|
||||
Added support for inline method x-references.
|
||||
Fixed Bug 44340 - Inline functions fail to resolve references
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
***********************************************************************/
|
||||
package org.eclipse.cdt.core.parser.extension;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
|
||||
/**
|
||||
|
@ -18,13 +17,11 @@ import org.eclipse.cdt.core.parser.ParserLanguage;
|
|||
*/
|
||||
public interface IScannerExtension extends Cloneable {
|
||||
|
||||
public void setScanner( IScanner scanner );
|
||||
public Object clone( );
|
||||
|
||||
public String initializeMacroValue( String original );
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void setupBuiltInMacros(ParserLanguage language);
|
||||
|
||||
public boolean canHandlePreprocessorDirective( String directive );
|
||||
public void handlePreprocessorDirective( String directive, String restOfLine );
|
||||
}
|
||||
|
|
|
@ -1356,11 +1356,6 @@ public abstract class Parser implements IParser
|
|||
|| (LT(3) != IToken.tLPAREN && LT(3) != IToken.tASSIGN))
|
||||
&& !LA(2).isPointer());
|
||||
}
|
||||
private void callbackSimpleDeclToken(Flags flags) throws EndOfFileException
|
||||
{
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
}
|
||||
/**
|
||||
* This function parses a declaration specifier sequence, as according to the ANSI C++ spec.
|
||||
*
|
||||
|
@ -1451,7 +1446,8 @@ public abstract class Parser implements IParser
|
|||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
||||
break;
|
||||
case IToken.t_unsigned :
|
||||
|
@ -1459,7 +1455,8 @@ public abstract class Parser implements IParser
|
|||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
||||
break;
|
||||
case IToken.t_short :
|
||||
|
@ -1467,14 +1464,16 @@ public abstract class Parser implements IParser
|
|||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
||||
break;
|
||||
case IToken.t_long :
|
||||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
||||
sdw.setLong(true);
|
||||
break;
|
||||
|
@ -1496,14 +1495,16 @@ public abstract class Parser implements IParser
|
|||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.CHAR);
|
||||
break;
|
||||
case IToken.t_wchar_t :
|
||||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(
|
||||
IASTSimpleTypeSpecifier.Type.WCHAR_T);
|
||||
break;
|
||||
|
@ -1511,35 +1512,40 @@ public abstract class Parser implements IParser
|
|||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.BOOL);
|
||||
break;
|
||||
case IToken.t__Bool:
|
||||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type._BOOL);
|
||||
break;
|
||||
case IToken.t_int :
|
||||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.INT);
|
||||
break;
|
||||
case IToken.t_float :
|
||||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.FLOAT);
|
||||
break;
|
||||
case IToken.t_double :
|
||||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(
|
||||
IASTSimpleTypeSpecifier.Type.DOUBLE);
|
||||
break;
|
||||
|
@ -1547,7 +1553,8 @@ public abstract class Parser implements IParser
|
|||
if (typeNameBegin == null)
|
||||
typeNameBegin = LA(1);
|
||||
typeNameEnd = LA(1);
|
||||
callbackSimpleDeclToken(flags);
|
||||
flags.setEncounteredRawType(true);
|
||||
consume();
|
||||
sdw.setSimpleType(IASTSimpleTypeSpecifier.Type.VOID);
|
||||
break;
|
||||
case IToken.t_typename :
|
||||
|
@ -2945,7 +2952,7 @@ public abstract class Parser implements IParser
|
|||
*
|
||||
* @throws BacktrackException request a backtrack
|
||||
*/
|
||||
protected void statement(IASTScope scope) throws EndOfFileException, BacktrackException
|
||||
protected void statement(IASTCodeScope scope) throws EndOfFileException, BacktrackException
|
||||
{
|
||||
setCompletionValues(scope, CompletionKind.SINGLE_NAME_REFERENCE, Key.STATEMENT);
|
||||
|
||||
|
@ -3207,7 +3214,7 @@ public abstract class Parser implements IParser
|
|||
checkToken = LA(1);
|
||||
try
|
||||
{
|
||||
statement(createNewScope ? newScope : scope );
|
||||
statement((IASTCodeScope) (createNewScope ? newScope : scope) );
|
||||
}
|
||||
catch( BacktrackException b )
|
||||
{
|
||||
|
|
|
@ -1745,7 +1745,8 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
TypeInfo type = new TypeInfo();
|
||||
if( absDecl.getTypeSpecifier() instanceof IASTSimpleTypeSpecifier )
|
||||
{
|
||||
IASTSimpleTypeSpecifier.Type kind = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier()).getType();
|
||||
IASTSimpleTypeSpecifier simpleType = ((IASTSimpleTypeSpecifier)absDecl.getTypeSpecifier());
|
||||
IASTSimpleTypeSpecifier.Type kind = simpleType.getType();
|
||||
if( kind == IASTSimpleTypeSpecifier.Type.BOOL )
|
||||
type.setType(TypeInfo.t_bool);
|
||||
else if( kind == IASTSimpleTypeSpecifier.Type.CHAR )
|
||||
|
@ -1767,6 +1768,12 @@ public class CompleteParseASTFactory extends BaseASTFactory implements IASTFacto
|
|||
}
|
||||
else
|
||||
throw new ASTSemanticException();
|
||||
type.setBit( simpleType.isLong(), TypeInfo.isLong);
|
||||
type.setBit( simpleType.isShort(), TypeInfo.isShort);
|
||||
type.setBit( simpleType.isUnsigned(), TypeInfo.isUnsigned);
|
||||
type.setBit( simpleType.isComplex(), TypeInfo.isComplex);
|
||||
type.setBit( simpleType.isImaginary(), TypeInfo.isImaginary);
|
||||
type.setBit( simpleType.isSigned(), TypeInfo.isSigned);
|
||||
}
|
||||
else if( absDecl.getTypeSpecifier() instanceof IASTClassSpecifier )
|
||||
{
|
||||
|
|
|
@ -64,6 +64,8 @@ public class ASTSimpleTypeSpecifier extends ASTNode implements IASTSimpleTypeSpe
|
|||
{
|
||||
if (isUnsigned())
|
||||
type.append("unsigned ");
|
||||
else if( isSigned() )
|
||||
type.append("signed ");
|
||||
type.append( (String)nameMap.get( this.kind ));
|
||||
}
|
||||
else if( this.kind == Type.BOOL || this.kind == Type.VOID || this.kind == Type._BOOL )
|
||||
|
|
|
@ -89,6 +89,7 @@ public class TypeInfo {
|
|||
public static final int isComplex = 0x200000;
|
||||
public static final int isImaginary= 0x400000;
|
||||
public static final int isLongLong = 0x800000;
|
||||
public static final int isSigned = 0x1000000;
|
||||
|
||||
// Types (maximum type is typeMask
|
||||
// Note that these should be considered ordered and if you change
|
||||
|
@ -530,4 +531,5 @@ public class TypeInfo {
|
|||
private Object _defaultValue = null;
|
||||
private LinkedList _ptrOperators;
|
||||
private LinkedList _operatorExpressions;
|
||||
|
||||
}
|
|
@ -19,7 +19,8 @@ import org.eclipse.cdt.core.parser.extension.IScannerExtension;
|
|||
*/
|
||||
public class GCCScannerExtension implements IScannerExtension {
|
||||
|
||||
private IScanner scanner;
|
||||
|
||||
private IScannerData scannerData;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.IScannerExtension#initializeMacroValue(java.lang.String)
|
||||
|
@ -35,18 +36,16 @@ public class GCCScannerExtension implements IScannerExtension {
|
|||
*/
|
||||
public void setupBuiltInMacros(ParserLanguage language) {
|
||||
if( language == ParserLanguage.CPP )
|
||||
if( scanner.getDefinition( IScanner.__CPLUSPLUS ) == null )
|
||||
scanner.addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1"));
|
||||
if( scanner.getDefinition(IScanner.__STDC_HOSTED__) == null )
|
||||
scanner.addDefinition(IScanner.__STDC_HOSTED__, new ObjectMacroDescriptor( IScanner.__STDC_HOSTED__, "0"));
|
||||
if( scanner.getDefinition( IScanner.__STDC_VERSION__) == null )
|
||||
scanner.addDefinition( IScanner.__STDC_VERSION__, new ObjectMacroDescriptor( IScanner.__STDC_VERSION__, "199001L"));
|
||||
if( scannerData.getScanner().getDefinition( IScanner.__CPLUSPLUS ) == null )
|
||||
scannerData.getScanner().addDefinition( IScanner.__CPLUSPLUS, new ObjectMacroDescriptor( IScanner.__CPLUSPLUS, "1"));
|
||||
if( scannerData.getScanner().getDefinition(IScanner.__STDC_HOSTED__) == null )
|
||||
scannerData.getScanner().addDefinition(IScanner.__STDC_HOSTED__, new ObjectMacroDescriptor( IScanner.__STDC_HOSTED__, "0"));
|
||||
if( scannerData.getScanner().getDefinition( IScanner.__STDC_VERSION__) == null )
|
||||
scannerData.getScanner().addDefinition( IScanner.__STDC_VERSION__, new ObjectMacroDescriptor( IScanner.__STDC_VERSION__, "199001L"));
|
||||
}
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#setScanner(org.eclipse.cdt.core.parser.IScanner)
|
||||
*/
|
||||
public void setScanner(IScanner scanner) {
|
||||
this.scanner = scanner;
|
||||
|
||||
public void setScannerData(IScannerData scannerData) {
|
||||
this.scannerData = scannerData;
|
||||
}
|
||||
|
||||
public Object clone( ) {
|
||||
|
@ -57,4 +56,23 @@ public class GCCScannerExtension implements IScannerExtension {
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#canHandlePreprocessorDirective(java.lang.String)
|
||||
*/
|
||||
public boolean canHandlePreprocessorDirective(String directive) {
|
||||
if( directive.equals("#include_next")) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.parser.extension.IScannerExtension#handlePreprocessorDirective(java.lang.String, java.lang.String)
|
||||
*/
|
||||
public void handlePreprocessorDirective(String directive, String restOfLine) {
|
||||
if( directive.equals("#include_next") )
|
||||
{
|
||||
// figure out the name of the current file and its path
|
||||
// search through include paths
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
|
||||
/**
|
||||
* @author jcamelon
|
||||
*/
|
||||
public interface IScannerData {
|
||||
/**
|
||||
* @return Returns the contextStack.
|
||||
*/
|
||||
public abstract ContextStack getContextStack();
|
||||
/**
|
||||
* @param includePathNames The includePathNames to set.
|
||||
*/
|
||||
public abstract void setIncludePathNames(List includePathNames);
|
||||
/**
|
||||
* @param includePaths The includePaths to set.
|
||||
*/
|
||||
public abstract void setIncludePaths(List includePaths);
|
||||
/**
|
||||
* @return Returns the includePathNames.
|
||||
*/
|
||||
public abstract List getIncludePathNames();
|
||||
/**
|
||||
* @return Returns the includePaths.
|
||||
*/
|
||||
public abstract List getIncludePaths();
|
||||
/**
|
||||
* @return Returns the originalConfig.
|
||||
*/
|
||||
public abstract IScannerInfo getOriginalConfig();
|
||||
/**
|
||||
* @return Returns the scanner.
|
||||
*/
|
||||
public abstract IScanner getScanner();
|
||||
public abstract IASTFactory getASTFactory();
|
||||
public abstract void setASTFactory(IASTFactory factory);
|
||||
public abstract BranchTracker getBranchTracker();
|
||||
public abstract Map getDefinitions();
|
||||
/**
|
||||
* @return Returns the problemFactory.
|
||||
*/
|
||||
public abstract IProblemFactory getProblemFactory();
|
||||
/**
|
||||
* @return Returns the filename.
|
||||
*/
|
||||
public abstract String getInitialFilename();
|
||||
/**
|
||||
* @return Returns the language.
|
||||
*/
|
||||
public abstract ParserLanguage getLanguage();
|
||||
/**
|
||||
* @return Returns the parserMode.
|
||||
*/
|
||||
public abstract ParserMode getParserMode();
|
||||
/**
|
||||
* @return Returns the reader.
|
||||
*/
|
||||
public abstract Reader getInitialReader();
|
||||
/**
|
||||
* @return Returns the requestor.
|
||||
*/
|
||||
public abstract ISourceElementRequestor getClientRequestor();
|
||||
public abstract IParserLogService getLogService();
|
||||
/**
|
||||
* @param empty_map
|
||||
*/
|
||||
public abstract void setDefinitions(Map map);
|
||||
}
|
|
@ -48,7 +48,7 @@ public class Preprocessor extends Scanner implements IPreprocessor {
|
|||
catch( ScannerException se )
|
||||
{
|
||||
// callback IProblem here
|
||||
log.errorLog("Preprocessor Exception "+ se.getProblem().getMessage()); //$NON-NLS-1$h
|
||||
scannerData.getLogService().errorLog("Preprocessor Exception "+ se.getProblem().getMessage()); //$NON-NLS-1$h
|
||||
}
|
||||
catch( EndOfFileException eof )
|
||||
{
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -0,0 +1,188 @@
|
|||
/**********************************************************************
|
||||
* Copyright (c) 2002,2003 Rational Software Corporation and others.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Common Public License v0.5
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/cpl-v05.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Rational Software - Initial API and implementation
|
||||
***********************************************************************/
|
||||
package org.eclipse.cdt.internal.core.parser.scanner;
|
||||
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.core.parser.IParserLogService;
|
||||
import org.eclipse.cdt.core.parser.IScanner;
|
||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||
import org.eclipse.cdt.core.parser.ISourceElementRequestor;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.ParserMode;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.problem.IProblemFactory;
|
||||
|
||||
|
||||
public class ScannerData implements IScannerData
|
||||
{
|
||||
private final ContextStack contextStack;
|
||||
private IASTFactory astFactory = null;
|
||||
private final ISourceElementRequestor requestor;
|
||||
private final ParserMode parserMode;
|
||||
private final String filename;
|
||||
private final Reader reader;
|
||||
private final ParserLanguage language;
|
||||
private final IParserLogService log;
|
||||
private final IProblemFactory problemFactory = new ScannerProblemFactory();
|
||||
private Map definitions = new Hashtable();
|
||||
private BranchTracker branches = new BranchTracker();
|
||||
private final IScanner scanner;
|
||||
private final IScannerInfo originalConfig;
|
||||
private List includePathNames = new ArrayList();
|
||||
private List includePaths = new ArrayList();
|
||||
|
||||
/**
|
||||
* @return Returns the contextStack.
|
||||
*/
|
||||
public ContextStack getContextStack() {
|
||||
return contextStack;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param includePathNames The includePathNames to set.
|
||||
*/
|
||||
public void setIncludePathNames(List includePathNames) {
|
||||
this.includePathNames = includePathNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param includePaths The includePaths to set.
|
||||
*/
|
||||
public void setIncludePaths(List includePaths) {
|
||||
this.includePaths = includePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the includePathNames.
|
||||
*/
|
||||
public List getIncludePathNames() {
|
||||
return includePathNames;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the includePaths.
|
||||
*/
|
||||
public List getIncludePaths() {
|
||||
return includePaths;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the originalConfig.
|
||||
*/
|
||||
public IScannerInfo getOriginalConfig() {
|
||||
return originalConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the scanner.
|
||||
*/
|
||||
public IScanner getScanner() {
|
||||
return scanner;
|
||||
}
|
||||
|
||||
public IASTFactory getASTFactory()
|
||||
{
|
||||
return astFactory;
|
||||
}
|
||||
|
||||
public void setASTFactory( IASTFactory factory )
|
||||
{
|
||||
astFactory = factory;
|
||||
}
|
||||
|
||||
public BranchTracker getBranchTracker()
|
||||
{
|
||||
return branches;
|
||||
}
|
||||
|
||||
public Map getDefinitions()
|
||||
{
|
||||
return definitions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the problemFactory.
|
||||
*/
|
||||
public IProblemFactory getProblemFactory() {
|
||||
return problemFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the filename.
|
||||
*/
|
||||
public String getInitialFilename() {
|
||||
return filename;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the language.
|
||||
*/
|
||||
public ParserLanguage getLanguage() {
|
||||
return language;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the parserMode.
|
||||
*/
|
||||
public ParserMode getParserMode() {
|
||||
return parserMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the reader.
|
||||
*/
|
||||
public Reader getInitialReader() {
|
||||
return reader;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the requestor.
|
||||
*/
|
||||
public ISourceElementRequestor getClientRequestor() {
|
||||
return requestor;
|
||||
}
|
||||
|
||||
public ScannerData( IScanner scanner, IParserLogService log,
|
||||
ISourceElementRequestor requestor,
|
||||
ParserMode parserMode,
|
||||
String filename,
|
||||
Reader reader,
|
||||
ParserLanguage language, IScannerInfo info, ContextStack stack )
|
||||
{
|
||||
this.scanner = scanner;
|
||||
this.log = log;
|
||||
this.requestor = requestor;
|
||||
this.parserMode = parserMode;
|
||||
this.filename = filename;
|
||||
this.reader = reader;
|
||||
this.language = language;
|
||||
this.originalConfig = info;
|
||||
this.contextStack = stack;
|
||||
}
|
||||
|
||||
|
||||
public IParserLogService getLogService()
|
||||
{
|
||||
return log;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param empty_map
|
||||
*/
|
||||
public void setDefinitions(Map map) {
|
||||
definitions = map;
|
||||
}
|
||||
}
|
|
@ -34,7 +34,7 @@ public class Symbol implements ISymbol {
|
|||
binary = bin;
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getFilename()
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getInitialFilename()
|
||||
*/
|
||||
public IPath getFilename() {
|
||||
return filename;
|
||||
|
|
|
@ -34,7 +34,7 @@ public class Symbol implements ISymbol, Comparable {
|
|||
binary = bin;
|
||||
}
|
||||
/**
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getFilename()
|
||||
* @see org.eclipse.cdt.core.model.IBinaryParser.ISymbol#getInitialFilename()
|
||||
*/
|
||||
public IPath getFilename() {
|
||||
return filename;
|
||||
|
|
Loading…
Add table
Reference in a new issue