mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Merge remote branch 'cdt/master' into sd90
This commit is contained in:
commit
1a71211195
23 changed files with 323 additions and 185 deletions
|
@ -100,12 +100,19 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
protected static boolean sValidateCopy;
|
||||
|
||||
private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
|
||||
private static final ScannerInfo SCANNER_INFO = new ScannerInfo();
|
||||
private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap());
|
||||
|
||||
private static Map<String, String> getGnuMap() {
|
||||
Map<String, String> map= new HashMap<String, String>();
|
||||
map.put("__GNUC__", "4");
|
||||
map.put("__GNUC_MINOR__", "5");
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<String, String> getStdMap() {
|
||||
Map<String, String> map= new HashMap<String, String>();
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
@ -7375,4 +7375,16 @@ public class AST2Tests extends AST2BaseTest {
|
|||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// typedef int T[sizeof(int)];
|
||||
public void testSizeofExpression_Bug362464() throws Exception {
|
||||
String code= getAboveComment();
|
||||
for (ParserLanguage l : ParserLanguage.values()) {
|
||||
IASTTranslationUnit tu= parseAndCheckBindings(code, l);
|
||||
IASTSimpleDeclaration sdecl= getDeclaration(tu, 0);
|
||||
ITypedef tdef= (ITypedef) sdecl.getDeclarators()[0].getName().resolveBinding();
|
||||
IArrayType at= (IArrayType) tdef.getType();
|
||||
IValue v= at.getSize();
|
||||
assertTrue(v.numericalValue() == 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -341,4 +341,26 @@ public class PreprocessorBugsTests extends PreprocessorTestsBase {
|
|||
validateProblem(0, IProblem.PREPROCESSOR_MACRO_PASTING_ERROR, "foo");
|
||||
validateProblemCount(1);
|
||||
}
|
||||
|
||||
// #define PR ""
|
||||
// A
|
||||
// #ifdef _DEBUG
|
||||
// PR"";
|
||||
// #endif
|
||||
// B
|
||||
public void testRawString_Bug362562() throws Exception {
|
||||
initializeScanner();
|
||||
validateIdentifier("A");
|
||||
validateIdentifier("B");
|
||||
validateProblemCount(0);
|
||||
}
|
||||
|
||||
// __COUNTER__
|
||||
// __COUNTER__
|
||||
public void testCounter_Bug362148() throws Exception {
|
||||
initializeScanner();
|
||||
validateInteger("0");
|
||||
validateInteger("1");
|
||||
validateProblemCount(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,11 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
|
@ -84,6 +86,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addDeclaration(IASTDeclaration d) {
|
||||
if (d != null) {
|
||||
d.setParent(this);
|
||||
|
@ -94,6 +97,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTDeclaration[] getDeclarations() {
|
||||
IASTDeclaration[] active= fActiveDeclarations;
|
||||
if (active == null) {
|
||||
|
@ -103,6 +107,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTDeclaration[] getDeclarations(boolean includeInactive) {
|
||||
if (includeInactive) {
|
||||
fAllDeclarations= (IASTDeclaration[]) ArrayUtil.removeNullsAfter(IASTDeclaration.class,
|
||||
|
@ -130,6 +135,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDeclarations(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public final IName[] getDeclarations(IBinding binding) {
|
||||
IName[] names= getDeclarationsInAST(binding);
|
||||
if (names.length == 0 && fIndex != null) {
|
||||
|
@ -161,6 +167,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDefinitions(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public final IName[] getDefinitions(IBinding binding) {
|
||||
IName[] names= getDefinitionsInAST(binding);
|
||||
if (names.length == 0 && fIndex != null) {
|
||||
|
@ -179,6 +186,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
|
||||
|
@ -188,6 +196,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroExpansions()
|
||||
*/
|
||||
@Override
|
||||
public IASTPreprocessorMacroExpansion[] getMacroExpansions() {
|
||||
if (fLocationResolver == null)
|
||||
return IASTPreprocessorMacroExpansion.EMPTY_ARRAY;
|
||||
|
@ -199,6 +208,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getBuiltinMacroDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
|
||||
|
@ -210,6 +220,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_INCLUSION_ARRAY;
|
||||
|
@ -221,6 +232,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_STATEMENT_ARRAY;
|
||||
|
@ -242,6 +254,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getPreprocesorProblems()
|
||||
*/
|
||||
@Override
|
||||
public final IASTProblem[] getPreprocessorProblems() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PROBLEM_ARRAY;
|
||||
|
@ -255,6 +268,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final int getPreprocessorProblemsCount() {
|
||||
return fLocationResolver == null ? 0 : fLocationResolver.getScannerProblemsCount();
|
||||
}
|
||||
|
@ -264,6 +278,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getFilePath()
|
||||
*/
|
||||
@Override
|
||||
public final String getFilePath() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_STRING;
|
||||
|
@ -290,28 +305,33 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTFileLocation flattenLocationsToFile(IASTNodeLocation[] nodeLocations) {
|
||||
if (fLocationResolver == null)
|
||||
return null;
|
||||
return fLocationResolver.flattenLocations(nodeLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IDependencyTree getDependencyTree() {
|
||||
if (fLocationResolver == null)
|
||||
return null;
|
||||
return fLocationResolver.getDependencyTree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getContainingFilename(int offset) {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_STRING;
|
||||
return fLocationResolver.getContainingFilePath(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IIndex getIndex() {
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setIndex(IIndex index) {
|
||||
this.fIndex = index;
|
||||
if (index != null) {
|
||||
|
@ -320,6 +340,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final INodeFactory getASTNodeFactory() {
|
||||
return fNodeFactory;
|
||||
}
|
||||
|
@ -328,6 +349,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
this.fNodeFactory = nodeFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTComment[] getComments() {
|
||||
if (fLocationResolver != null) {
|
||||
return fLocationResolver.getComments();
|
||||
|
@ -335,6 +357,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return new IASTComment[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public final Object getAdapter(Class adapter) {
|
||||
if (adapter.isAssignableFrom(fLocationResolver.getClass())) {
|
||||
|
@ -349,10 +372,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isHeaderUnit() {
|
||||
return fIsHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setIsHeaderUnit(boolean headerUnit) {
|
||||
fIsHeader= headerUnit;
|
||||
}
|
||||
|
@ -368,6 +393,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent)
|
||||
*/
|
||||
@Override
|
||||
public void skippedFile(int offset, InternalFileContent fileContent) {
|
||||
if (fIndexFileSet != null) {
|
||||
List<IIndexFile> files= fileContent.getFilesIncluded();
|
||||
|
@ -378,10 +404,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IIndexFileSet getIndexFileSet() {
|
||||
return fIndexFileSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parsingFile(InternalFileContentProvider provider, InternalFileContent fc) {
|
||||
if (fASTFileSet != null) {
|
||||
if (provider instanceof IndexBasedFileContentProvider) {
|
||||
|
@ -398,6 +426,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IIndexFileSet getASTFileSet() {
|
||||
return fASTFileSet;
|
||||
}
|
||||
|
@ -407,10 +436,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
||||
*/
|
||||
@Override
|
||||
public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
|
||||
return getNodeSelector(path).findNode(realOffset, realLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTNodeSelector getNodeSelector(String filePath) {
|
||||
return new ASTNodeSelector(this, fLocationResolver, filePath);
|
||||
}
|
||||
|
@ -420,6 +451,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*/
|
||||
public abstract void resolveAmbiguities();
|
||||
|
||||
/**
|
||||
* Can be called to create a type for a type-id.
|
||||
*/
|
||||
abstract protected IType createType(IASTTypeId typeid);
|
||||
|
||||
protected void copyAbstractTU(ASTTranslationUnit copy, CopyStyle style) {
|
||||
copy.setIndex(fIndex);
|
||||
copy.fIsHeader = fIsHeader;
|
||||
|
@ -434,6 +470,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
copy.setOffsetAndLength(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void freeze() {
|
||||
accept(new ASTGenericVisitor(true) {
|
||||
@Override
|
||||
|
@ -449,6 +486,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getOriginatingTranslationUnit()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getOriginatingTranslationUnit() {
|
||||
return fOriginatingTranslationUnit;
|
||||
}
|
||||
|
@ -457,20 +495,24 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
this.fOriginatingTranslationUnit = tu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISignificantMacros getSignificantMacros() {
|
||||
return fSignificantMacros;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSignificantMacros(ISignificantMacros sigMacros) {
|
||||
assertNotFrozen();
|
||||
if (sigMacros != null)
|
||||
fSignificantMacros= sigMacros;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPragmaOnceSemantics() {
|
||||
return fPragmaOnceSemantics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPragmaOnceSemantics(boolean value) {
|
||||
assertNotFrozen();
|
||||
fPragmaOnceSemantics= value;
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -111,7 +110,7 @@ public class SizeofCalculator {
|
|||
public SizeAndAlignment sizeAndAlignment(IType type) {
|
||||
type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF);
|
||||
|
||||
if (type instanceof ICPPBasicType) {
|
||||
if (type instanceof IBasicType) {
|
||||
return sizeAndAlignment((IBasicType) type);
|
||||
}
|
||||
if (type instanceof IPointerType || type instanceof ICPPReferenceType) {
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
|
||||
|
@ -118,14 +117,17 @@ public class Value implements IValue {
|
|||
fUnknownBindings= unknown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return fExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return fUnknownBindings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getSignature() {
|
||||
if (fSignature == null) {
|
||||
if (fUnknownBindings.length == 0) {
|
||||
|
@ -148,6 +150,7 @@ public class Value implements IValue {
|
|||
return fSignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return parseLong(fExpression);
|
||||
}
|
||||
|
@ -468,8 +471,9 @@ public class Value implements IValue {
|
|||
IASTTypeIdExpression typeIdEx = (IASTTypeIdExpression) e;
|
||||
switch (typeIdEx.getOperator()) {
|
||||
case IASTTypeIdExpression.op_sizeof:
|
||||
IType type = CPPVisitor.createType(typeIdEx.getTypeId());
|
||||
final IType type;
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) typeIdEx.getTranslationUnit();
|
||||
type = ast.createType(typeIdEx.getTypeId());
|
||||
SizeofCalculator calculator = ast.getSizeofCalculator();
|
||||
SizeAndAlignment info = calculator.sizeAndAlignment(type);
|
||||
if (info == null)
|
||||
|
|
|
@ -16,10 +16,12 @@ import org.eclipse.cdt.core.dom.ILinkage;
|
|||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
|
@ -37,10 +39,12 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
fStructMapper= new CStructMapper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CASTTranslationUnit copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CASTTranslationUnit copy(CopyStyle style) {
|
||||
CASTTranslationUnit copy = new CASTTranslationUnit();
|
||||
copyAbstractTU(copy, style);
|
||||
|
@ -55,6 +59,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getScope()
|
||||
*/
|
||||
@Override
|
||||
public IScope getScope() {
|
||||
if (compilationUnit == null)
|
||||
compilationUnit = new CScope(this, EScopeKind.eGlobal);
|
||||
|
@ -62,6 +67,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTName[] getDeclarationsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
|
@ -69,6 +75,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
return CVisitor.getDeclarations(this, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName[] getDefinitionsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
|
@ -87,17 +94,20 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getReferences(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public IASTName[] getReferences(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding)
|
||||
return getMacroReferencesInAST((IMacroBinding) binding);
|
||||
return CVisitor.getReferences(this, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ParserLanguage getParserLanguage() {
|
||||
return ParserLanguage.C;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.C_LINKAGE;
|
||||
}
|
||||
|
@ -113,4 +123,9 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
public ICompositeType mapToASTType(ICompositeType type) {
|
||||
return fStructMapper.mapToAST(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IType createType(IASTTypeId typeid) {
|
||||
return CVisitor.createType(typeid.getAbstractDeclarator());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -45,10 +46,12 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
public CPPASTTranslationUnit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTTranslationUnit copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTTranslationUnit copy(CopyStyle style) {
|
||||
CPPASTTranslationUnit copy = new CPPASTTranslationUnit();
|
||||
copyAbstractTU(copy, style);
|
||||
|
@ -58,6 +61,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPNamespaceScope getScope() {
|
||||
if (fScope == null) {
|
||||
fScope = new CPPNamespaceScope(this);
|
||||
|
@ -105,6 +109,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
theScope.addBinding(temp);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName[] getDeclarationsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
|
@ -112,6 +117,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return CPPVisitor.getDeclarations(this, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName[] getDefinitionsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
|
@ -125,6 +131,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return (IASTName[]) ArrayUtil.removeNulls(IASTName.class, names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName[] getReferences(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroReferencesInAST((IMacroBinding) binding);
|
||||
|
@ -132,12 +139,14 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return CPPVisitor.getReferences(this, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding resolveBinding() {
|
||||
if (fBinding == null)
|
||||
fBinding = new CPPNamespace(this);
|
||||
return fBinding;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ParserLanguage getParserLanguage() {
|
||||
return ParserLanguage.CPP;
|
||||
|
@ -146,6 +155,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLinkage()
|
||||
*/
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
@ -180,4 +190,9 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
public void resolveAmbiguities() {
|
||||
accept(new CPPASTAmbiguityResolver());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IType createType(IASTTypeId typeid) {
|
||||
return CPPVisitor.createType(typeid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -99,6 +99,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
private static final DynamicMacro __DATE__= new DateMacro("__DATE__".toCharArray()); //$NON-NLS-1$
|
||||
private static final DynamicMacro __TIME__ = new TimeMacro("__TIME__".toCharArray()); //$NON-NLS-1$
|
||||
private static final DynamicMacro __LINE__ = new LineMacro("__LINE__".toCharArray()); //$NON-NLS-1$
|
||||
private static final char[] __COUNTER__ = "__COUNTER__".toCharArray(); //$NON-NLS-1$
|
||||
private static final char[] ONCE = "once".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
static final int NO_EXPANSION = 0x01;
|
||||
|
@ -114,18 +115,22 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
|
||||
|
||||
private final class MacroDictionary implements IMacroDictionary, ISignificantMacros.IVisitor {
|
||||
@Override
|
||||
public boolean satisfies(ISignificantMacros significantMacros) {
|
||||
return significantMacros.accept(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitDefined(char[] macro) {
|
||||
return isDefined(macro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitUndefined(char[] macro) {
|
||||
return !isDefined(macro);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean visitValue(char[] macro, char[] value) {
|
||||
PreprocessorMacro m = fMacroDictionary.get(macro);
|
||||
return m != null && CharArrayUtils.equals(m.getExpansion(), value);
|
||||
|
@ -141,6 +146,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
}
|
||||
|
||||
final private IIncludeFileTester<InternalFileContent> createCodeReaderTester= new IIncludeFileTester<InternalFileContent>() {
|
||||
@Override
|
||||
public InternalFileContent checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) {
|
||||
final InternalFileContent fc;
|
||||
IFileNomination once= fFileContentProvider.isIncludedWithPragmaOnceSemantics(path);
|
||||
|
@ -163,6 +169,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
}
|
||||
|
||||
final private IIncludeFileTester<IncludeResolution> createPathTester= new IIncludeFileTester<IncludeResolution>() {
|
||||
@Override
|
||||
public IncludeResolution checkFile(String path, boolean isHeuristicMatch, IncludeSearchPathElement onPath) {
|
||||
if (fFileContentProvider.getInclusionExists(path)) {
|
||||
IncludeResolution res= new IncludeResolution();
|
||||
|
@ -181,6 +188,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
fStopAtNewline= stopAtNewline;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token nextToken() throws OffsetLimitReachedException {
|
||||
final Lexer lexer= fCurrentContext.getLexer();
|
||||
Token t= lexer.nextToken();
|
||||
|
@ -194,10 +202,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLastEndOffset() {
|
||||
return fCurrentContext.getLexer().getLastEndOffset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token currentToken() {
|
||||
Token t= fCurrentContext.currentLexerToken();
|
||||
if (fStopAtNewline && t.getType() == Lexer.tNEWLINE)
|
||||
|
@ -323,14 +333,17 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSplitShiftROperator(boolean val) {
|
||||
fSplitShiftRightOperator= val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setComputeImageLocations(boolean val) {
|
||||
fLexOptions.fCreateImageLocations= val;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setContentAssistMode(int offset) {
|
||||
fContentAssistLimit= offset;
|
||||
fRootLexer.setContentAssistMode(offset);
|
||||
|
@ -340,13 +353,16 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return fRootLexer.isContentAssistMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setProcessInactiveCode(boolean val) {
|
||||
fRootContext.setParseInactiveCode(val);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setScanComments(boolean val) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILocationResolver getLocationResolver() {
|
||||
return fLocationMap;
|
||||
}
|
||||
|
@ -413,6 +429,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
fMacroDictionary.put(__DATE__.getNameCharArray(), __DATE__);
|
||||
fMacroDictionary.put(__TIME__.getNameCharArray(), __TIME__);
|
||||
fMacroDictionary.put(__LINE__.getNameCharArray(), __LINE__);
|
||||
fMacroDictionary.put(__COUNTER__, new CounterMacro(__COUNTER__));
|
||||
|
||||
if (lang == ParserLanguage.CPP) {
|
||||
fMacroDictionary.put(__cplusplus.getNameCharArray(), __cplusplus);
|
||||
|
@ -520,6 +537,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, IMacroBinding> getMacroDefinitions() {
|
||||
Map<String, IMacroBinding> hashMap = new HashMap<String, IMacroBinding>(fMacroDictionary.size());
|
||||
for (char[] key : fMacroDictionary.keys()) {
|
||||
|
@ -528,6 +546,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return hashMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnTopContext() {
|
||||
ScannerContext ctx= fCurrentContext;
|
||||
while (ctx != null && ctx.getLocationCtx() instanceof LocationCtxMacroExpansion) {
|
||||
|
@ -536,6 +555,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return ctx == fRootContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel() {
|
||||
isCancelled= true;
|
||||
}
|
||||
|
@ -648,6 +668,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
* @throws EndOfFileException when the end of the translation unit has been reached.
|
||||
* @throws OffsetLimitReachedException see {@link Lexer}.
|
||||
*/
|
||||
@Override
|
||||
public IToken nextToken() throws EndOfFileException {
|
||||
if (isCancelled) {
|
||||
throw new ParseError(ParseError.ParseErrorKind.TIMEOUT_OR_CANCELLED);
|
||||
|
@ -746,6 +767,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return t1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void skipInactiveCode() throws OffsetLimitReachedException {
|
||||
final Lexer lexer= fCurrentContext.getLexer();
|
||||
if (lexer != null) {
|
||||
|
@ -758,6 +780,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCodeBranchNesting() {
|
||||
return fCurrentContext.getCodeBranchNesting();
|
||||
}
|
||||
|
@ -1142,10 +1165,12 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return fLocationMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleComment(boolean isBlockComment, int offset, int endOffset) {
|
||||
fLocationMap.encounteredComment(offset, endOffset, isBlockComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleProblem(int id, char[] arg, int offset, int endOffset) {
|
||||
fLocationMap.encounterProblem(id, arg, offset, endOffset);
|
||||
}
|
||||
|
@ -1856,6 +1881,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
public Object getAdapter(Class adapter) {
|
||||
if (adapter.isAssignableFrom(fMacroExpander.getClass())) {
|
||||
|
|
|
@ -155,6 +155,7 @@ final public class Lexer implements ITokenSequence {
|
|||
/**
|
||||
* Returns the current preprocessor token, does not advance.
|
||||
*/
|
||||
@Override
|
||||
public Token currentToken() {
|
||||
return fToken;
|
||||
}
|
||||
|
@ -162,6 +163,7 @@ final public class Lexer implements ITokenSequence {
|
|||
/**
|
||||
* Returns the endoffset of the token before the current one.
|
||||
*/
|
||||
@Override
|
||||
public int getLastEndOffset() {
|
||||
return fLastToken.getEndOffset();
|
||||
}
|
||||
|
@ -170,6 +172,7 @@ final public class Lexer implements ITokenSequence {
|
|||
* Advances to the next token, skipping whitespace other than newline.
|
||||
* @throws OffsetLimitReachedException when completion is requested in a literal or a header-name.
|
||||
*/
|
||||
@Override
|
||||
public Token nextToken() throws OffsetLimitReachedException {
|
||||
fLastToken= fToken;
|
||||
return fToken= fetchToken();
|
||||
|
@ -222,124 +225,22 @@ final public class Lexer implements ITokenSequence {
|
|||
* @throws OffsetLimitReachedException when completion is requested in a literal or an header-name.
|
||||
*/
|
||||
public Token nextDirective() throws OffsetLimitReachedException {
|
||||
fInsideIncludeDirective= false;
|
||||
final Token t= fToken;
|
||||
boolean haveNL= t==null || t.getType() == tNEWLINE;
|
||||
while (true) {
|
||||
final boolean hadNL= haveNL;
|
||||
haveNL= false;
|
||||
final int start= fOffset;
|
||||
final int c= fCharPhase3;
|
||||
|
||||
// optimization avoids calling nextCharPhase3
|
||||
int d;
|
||||
final int pos= fEndOffset;
|
||||
if (!isValidOffset(pos+1)) {
|
||||
d= nextCharPhase3();
|
||||
} else {
|
||||
d= fInput.get(pos);
|
||||
switch(d) {
|
||||
case '\\':
|
||||
d= nextCharPhase3();
|
||||
Token t0;
|
||||
Token t1= fToken;
|
||||
for(;;) {
|
||||
t0= t1;
|
||||
t1= fetchToken();
|
||||
final int tt1 = t1.getType();
|
||||
if (tt1 == IToken.tEND_OF_INPUT)
|
||||
break;
|
||||
case '?':
|
||||
if (fInput.get(pos+1) == '?') {
|
||||
d= nextCharPhase3();
|
||||
break;
|
||||
}
|
||||
fOffset= pos;
|
||||
fCharPhase3= d;
|
||||
fEndOffset= pos+1;
|
||||
break;
|
||||
default:
|
||||
fOffset= pos;
|
||||
fCharPhase3= d;
|
||||
fEndOffset= pos+1;
|
||||
if (tt1 == IToken.tPOUND) {
|
||||
final int tt0= t0.getType();
|
||||
if (tt0 == tNEWLINE || tt0 == tBEFORE_INPUT)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch(c) {
|
||||
case END_OF_INPUT:
|
||||
fLastToken= fToken= newToken(IToken.tEND_OF_INPUT, start);
|
||||
return fToken;
|
||||
case '\n':
|
||||
haveNL= true;
|
||||
continue;
|
||||
case ' ':
|
||||
case '\t':
|
||||
case 0xb: // vertical tab
|
||||
case '\f':
|
||||
case '\r':
|
||||
haveNL= hadNL;
|
||||
continue;
|
||||
|
||||
case 'R':
|
||||
if (d == '"') {
|
||||
nextCharPhase3();
|
||||
rawStringLiteral(start, 2, IToken.tSTRING);
|
||||
}
|
||||
continue;
|
||||
|
||||
case '"':
|
||||
stringLiteral(start, 1, IToken.tSTRING);
|
||||
continue;
|
||||
|
||||
case '\'':
|
||||
charLiteral(start, IToken.tCHAR);
|
||||
continue;
|
||||
|
||||
case '/':
|
||||
switch (d) {
|
||||
case '/':
|
||||
nextCharPhase3();
|
||||
lineComment(start);
|
||||
continue;
|
||||
case '*':
|
||||
blockComment(start, '*');
|
||||
haveNL= hadNL;
|
||||
continue;
|
||||
case '%':
|
||||
if (fOptions.fSupportSlashPercentComments) {
|
||||
blockComment(start, '%');
|
||||
}
|
||||
continue;
|
||||
}
|
||||
continue;
|
||||
|
||||
case '%':
|
||||
if (hadNL) {
|
||||
if (d == ':') {
|
||||
// found at least '#'
|
||||
final int e= nextCharPhase3();
|
||||
if (e == '%') {
|
||||
markPhase3();
|
||||
if (nextCharPhase3() == ':') {
|
||||
// found '##'
|
||||
nextCharPhase3();
|
||||
continue;
|
||||
}
|
||||
restorePhase3();
|
||||
}
|
||||
fLastToken= new Token(tNEWLINE, fSource, 0, start); // offset not significant
|
||||
fToken= newDigraphToken(IToken.tPOUND, start);
|
||||
return fToken;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
case '#':
|
||||
if (hadNL && d != '#') {
|
||||
fLastToken= new Token(tNEWLINE, fSource, 0, start); // offset not significant
|
||||
fToken= newToken(IToken.tPOUND, start);
|
||||
return fToken;
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fLastToken= t0;
|
||||
return fToken=t1;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.core.parser.scanner;
|
|||
|
||||
import java.util.Calendar;
|
||||
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
|
@ -24,6 +22,8 @@ import org.eclipse.cdt.core.parser.OffsetLimitReachedException;
|
|||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.Lexer.LexerOptions;
|
||||
|
||||
import com.ibm.icu.text.DateFormatSymbols;
|
||||
|
||||
/**
|
||||
* Models macros used by the preprocessor
|
||||
* @since 5.0
|
||||
|
@ -35,38 +35,47 @@ abstract class PreprocessorMacro implements IMacroBinding {
|
|||
fName= name;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public ILinkage getLinkage() {
|
||||
return Linkage.NO_LINKAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public char[] getNameCharArray() {
|
||||
return fName;
|
||||
}
|
||||
|
||||
@Override
|
||||
final public String getName() {
|
||||
return new String(fName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getScope() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getOwner() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFunctionStyle() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[][] getParameterList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[][] getParameterPlaceholderList() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("rawtypes")
|
||||
public Object getAdapter(Class clazz) {
|
||||
return null;
|
||||
|
@ -139,10 +148,12 @@ class ObjectStyleMacro extends PreprocessorMacro {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansion() {
|
||||
return MacroDefinitionParser.getExpansion(fExpansion, fExpansionOffset, fEndOffset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
final int length = fEndOffset - fExpansionOffset;
|
||||
char[] result= new char[length];
|
||||
|
@ -164,6 +175,7 @@ class ObjectStyleMacro extends PreprocessorMacro {
|
|||
return fExpansionTokens;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isDynamic() {
|
||||
return false;
|
||||
}
|
||||
|
@ -283,14 +295,17 @@ final class UndefinedMacro extends PreprocessorMacro {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansion() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamic() {
|
||||
return false;
|
||||
}
|
||||
|
@ -301,6 +316,7 @@ abstract class DynamicMacro extends PreprocessorMacro {
|
|||
public DynamicMacro(char[] name) {
|
||||
super(name);
|
||||
}
|
||||
@Override
|
||||
public final char[] getExpansion() {
|
||||
return getExpansionImage();
|
||||
}
|
||||
|
@ -319,6 +335,7 @@ abstract class DynamicMacro extends PreprocessorMacro {
|
|||
buffer.append(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isDynamic() {
|
||||
return true;
|
||||
}
|
||||
|
@ -349,6 +366,7 @@ final class DateMacro extends DynamicMacro {
|
|||
return charArray;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
return createDate();
|
||||
}
|
||||
|
@ -367,6 +385,7 @@ final class FileMacro extends DynamicMacro {
|
|||
return new TokenWithImage(IToken.tSTRING, null, 0, 0, buffer.toString().toCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
return "\"file\"".toCharArray(); //$NON-NLS-1$
|
||||
}
|
||||
|
@ -383,6 +402,7 @@ final class LineMacro extends DynamicMacro {
|
|||
return new TokenWithImage(IToken.tINTEGER, null, 0, 0, Long.toString(lineNumber).toCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
return new char[] {'1'};
|
||||
}
|
||||
|
@ -410,7 +430,27 @@ final class TimeMacro extends DynamicMacro {
|
|||
return buffer.toString().toCharArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
return createDate();
|
||||
}
|
||||
}
|
||||
|
||||
final class CounterMacro extends DynamicMacro {
|
||||
private static final char[] ZERO = {'0'};
|
||||
|
||||
private long fValue= 0;
|
||||
CounterMacro(char[] name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Token execute(MacroExpander expander) {
|
||||
return new TokenWithImage(IToken.tINTEGER, null, 0, 0, String.valueOf(fValue++).toCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getExpansionImage() {
|
||||
return ZERO;
|
||||
}
|
||||
}
|
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.ui.tests.callhierarchy;
|
|||
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.runtime.jobs.Job;
|
||||
import org.eclipse.jface.text.ITextSelection;
|
||||
import org.eclipse.jface.viewers.TreeViewer;
|
||||
import org.eclipse.swt.SWTException;
|
||||
|
@ -81,24 +82,21 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
|||
return editor;
|
||||
}
|
||||
|
||||
protected void openCallHierarchy(CEditor editor) {
|
||||
protected void openCallHierarchy(CEditor editor) throws InterruptedException {
|
||||
CallHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection());
|
||||
for (Job job : Job.getJobManager().find(CallHierarchyUI.class)) {
|
||||
job.join();
|
||||
}
|
||||
runEventQueue(0);
|
||||
}
|
||||
|
||||
protected void openCallHierarchy(CEditor editor, boolean showReferencedBy) {
|
||||
CallHierarchyUI.setIsJUnitTest(true);
|
||||
CallHierarchyUI.open(editor, (ITextSelection) editor.getSelectionProvider().getSelection());
|
||||
runEventQueue(0);
|
||||
CHViewPart ch= null;
|
||||
protected void openCallHierarchy(CEditor editor, boolean showReferencedBy) throws InterruptedException {
|
||||
openCallHierarchy(editor);
|
||||
IWorkbenchPage page = editor.getSite().getPage();
|
||||
for (int i = 0; i < 400; i++) {
|
||||
ch= (CHViewPart)page.findView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||
if (ch != null)
|
||||
break;
|
||||
runEventQueue(10);
|
||||
}
|
||||
CHViewPart ch= (CHViewPart)page.findView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||
assertNotNull(ch);
|
||||
ch.onSetShowReferencedBy(showReferencedBy);
|
||||
runEventQueue(0);
|
||||
}
|
||||
|
||||
protected TreeViewer getCHTreeViewer() {
|
||||
|
@ -111,7 +109,6 @@ public class CallHierarchyBaseTest extends BaseUITestCase {
|
|||
break;
|
||||
runEventQueue(10);
|
||||
}
|
||||
assertNotNull(ch);
|
||||
return ch.getTreeViewer();
|
||||
}
|
||||
|
||||
|
|
|
@ -479,4 +479,30 @@ public class CallHierarchyBugs extends CallHierarchyBaseTest {
|
|||
checkTreeNode(chTree, 0, 1, "Derived::dosomething() : void");
|
||||
checkTreeNode(chTree, 0, 2, null);
|
||||
}
|
||||
|
||||
// template<typename T> struct Array {
|
||||
// template<typename TIterator> void erase(TIterator it) {}
|
||||
// };
|
||||
//
|
||||
// int main() {
|
||||
// Array<int> test;
|
||||
// test.erase(1);
|
||||
// }
|
||||
public void testCallsToInstanceofSpecializedTemplate_361999() throws Exception {
|
||||
final String content = getAboveComment();
|
||||
IFile f2= createFile(getProject(), "testCallsToInstanceofSpecializedTemplate_361999.cpp", content);
|
||||
waitForIndexer(fIndex, f2, CallHierarchyBaseTest.INDEXER_WAIT_TIME);
|
||||
|
||||
final CHViewPart ch= (CHViewPart) activateView(CUIPlugin.ID_CALL_HIERARCHY);
|
||||
|
||||
// open editor, check outline
|
||||
CEditor editor= openEditor(f2);
|
||||
int idx = content.indexOf("erase(TIterator it)");
|
||||
editor.selectAndReveal(idx, 0);
|
||||
openCallHierarchy(editor, true);
|
||||
|
||||
Tree chTree= checkTreeNode(ch, 0, "Array<T>::erase(TIterator) : void").getParent();
|
||||
TreeItem ti= checkTreeNode(chTree, 0, 0, "main() : int");
|
||||
checkTreeNode(chTree, 0, 1, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,6 +31,7 @@ public class CompletionTest_MacroRef_NoPrefix extends CompletionProposalsBaseTe
|
|||
"DEBUG",
|
||||
"XMacro(x, y)",
|
||||
"__CDT_PARSER__",
|
||||
"__COUNTER__",
|
||||
"__DATE__",
|
||||
"__FILE__",
|
||||
"__LINE__",
|
||||
|
|
|
@ -29,7 +29,6 @@ import org.eclipse.jface.text.IDocument;
|
|||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.testplugin.TestScannerProvider;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
|
||||
/**
|
||||
* A collection of code completion tests.
|
||||
|
@ -959,8 +958,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
createFile(fProject, "header191315.h", content[0].toString());
|
||||
createFile(fProject, "source191315.c", content[1].toString());
|
||||
createFile(fProject, "source191315.cpp", content[1].toString());
|
||||
IFile dfile= createFile(fProject, "header191315.h", content[0].toString());
|
||||
TestSourceReader.waitUntilFileIsIndexed(CCorePlugin.getIndexManager().getIndex(fCProject), dfile, 8000);
|
||||
waitForIndexer(fCProject);
|
||||
final String[] expected= {
|
||||
"c_linkage()"
|
||||
};
|
||||
|
|
|
@ -22,7 +22,6 @@ import org.eclipse.jface.text.IDocument;
|
|||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
|
||||
/**
|
||||
* Completion tests for plain C.
|
||||
|
@ -313,8 +312,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
|
|||
createFile(fProject, "header191315.h", content[0].toString());
|
||||
createFile(fProject, "source191315.c", content[1].toString());
|
||||
createFile(fProject, "source191315.cpp", content[1].toString());
|
||||
IFile dfile= createFile(fProject, "header191315.h", content[0].toString());
|
||||
TestSourceReader.waitUntilFileIsIndexed(CCorePlugin.getIndexManager().getIndex(fCProject), dfile, 8000);
|
||||
waitForIndexer(fCProject);
|
||||
final String[] expected= {
|
||||
"c_linkage(void)"
|
||||
};
|
||||
|
@ -360,6 +358,7 @@ public class CompletionTests_PlainC extends AbstractContentAssistTest {
|
|||
"DEBUG",
|
||||
"XMacro(x, y)",
|
||||
"__CDT_PARSER__",
|
||||
"__COUNTER__",
|
||||
"__DATE__",
|
||||
"__FILE__",
|
||||
"__LINE__",
|
||||
|
|
|
@ -93,7 +93,7 @@ public class CHQueries {
|
|||
private static void findCalledBy1(IIndex index, IBinding callee, boolean includeOrdinaryCalls,
|
||||
ICProject project, CalledByResult result) throws CoreException {
|
||||
findCalledBy2(index, callee, includeOrdinaryCalls, project, result);
|
||||
List<? extends IBinding> specializations = IndexUI.findSpecializations(callee);
|
||||
List<? extends IBinding> specializations = IndexUI.findSpecializations(index, callee);
|
||||
for (IBinding spec : specializations) {
|
||||
findCalledBy2(index, spec, includeOrdinaryCalls, project, result);
|
||||
}
|
||||
|
|
|
@ -71,6 +71,7 @@ public class CallHierarchyUI {
|
|||
final ICElement[] elems= findDefinitions(input);
|
||||
if (elems != null && elems.length > 0) {
|
||||
display.asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
internalOpen(window, elems);
|
||||
}});
|
||||
|
@ -134,6 +135,7 @@ public class CallHierarchyUI {
|
|||
final ICElement[] elems= findDefinitions(project, editorInput, sel);
|
||||
if (elems.length > 0) {
|
||||
display.asyncExec(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
internalOpen(editor.getSite().getWorkbenchWindow(), elems);
|
||||
}});
|
||||
|
@ -146,6 +148,10 @@ public class CallHierarchyUI {
|
|||
return e.getStatus();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean belongsTo(Object family) {
|
||||
return family == CallHierarchyUI.class;
|
||||
}
|
||||
};
|
||||
job.setUser(true);
|
||||
job.schedule();
|
||||
|
|
|
@ -147,6 +147,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
return defaultLabel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLabel() {
|
||||
String type;
|
||||
if ((flags & FIND_REFERENCES) != 0) {
|
||||
|
@ -197,14 +198,17 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
return label + " " + countLabel; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRerun() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRunInBackground() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISearchResult getSearchResult() {
|
||||
return result;
|
||||
}
|
||||
|
@ -344,7 +348,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
if ((flags & FIND_REFERENCES) != 0) {
|
||||
for (IBinding binding : bindings) {
|
||||
if (binding != null) {
|
||||
List<? extends IBinding> specializations = IndexUI.findSpecializations(binding);
|
||||
List<? extends IBinding> specializations = IndexUI.findSpecializations(index, binding);
|
||||
for (IBinding spec : specializations) {
|
||||
if (spec != null && handled.add(spec)) {
|
||||
createMatches1(index, spec, names);
|
||||
|
@ -481,6 +485,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
|||
return preferred;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IStatus run(IProgressMonitor monitor) throws OperationCanceledException {
|
||||
PDOMSearchResult result= (PDOMSearchResult) getSearchResult();
|
||||
result.removeAll();
|
||||
|
|
|
@ -409,6 +409,7 @@ public class IndexUI {
|
|||
|
||||
final IASTName[] result= {null};
|
||||
ASTProvider.getASTProvider().runOnAST(workingCopy, ASTProvider.WAIT_ACTIVE_ONLY, null, new ASTRunnable() {
|
||||
@Override
|
||||
public IStatus runOnAST(ILanguage lang, IASTTranslationUnit ast) {
|
||||
if (ast != null) {
|
||||
final IASTNodeSelector nodeSelector = ast.getNodeSelector(null);
|
||||
|
@ -490,29 +491,39 @@ public class IndexUI {
|
|||
/**
|
||||
* Searches for all specializations that depend on the definition of the given binding.
|
||||
*/
|
||||
public static List<? extends IBinding> findSpecializations(IBinding binding) throws CoreException {
|
||||
public static List<? extends IBinding> findSpecializations(IIndex index, IBinding binding) throws CoreException {
|
||||
List<IBinding> result= null;
|
||||
|
||||
IBinding owner = binding.getOwner();
|
||||
if (owner != null) {
|
||||
List<? extends IBinding> specializedOwners= findSpecializations(owner);
|
||||
if (!specializedOwners.isEmpty()) {
|
||||
result= new ArrayList<IBinding>(specializedOwners.size());
|
||||
|
||||
for (IBinding specOwner : specializedOwners) {
|
||||
if (specOwner instanceof ICPPClassSpecialization) {
|
||||
result.add(((ICPPClassSpecialization) specOwner).specializeMember(binding));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for instances of the given binding
|
||||
if (binding instanceof ICPPInstanceCache) {
|
||||
final List<ICPPTemplateInstance> instances= Arrays.asList(((ICPPInstanceCache) binding).getAllInstances());
|
||||
if (!instances.isEmpty()) {
|
||||
for (ICPPTemplateInstance inst : instances) {
|
||||
if (!ASTInternal.hasDeclaration(inst)) {
|
||||
if (result == null)
|
||||
result= new ArrayList<IBinding>(instances.size());
|
||||
result.add(inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check for specializations of the owner
|
||||
IBinding owner = binding.getOwner();
|
||||
if (owner != null) {
|
||||
for (IBinding specOwner : findSpecializations(index, owner)) {
|
||||
if (specOwner instanceof ICPPClassSpecialization) {
|
||||
// Add the specialized member
|
||||
IBinding specializedMember = ((ICPPClassSpecialization) specOwner).specializeMember(binding);
|
||||
specializedMember= index.adaptBinding(specializedMember);
|
||||
if (specializedMember != null) {
|
||||
if (result == null)
|
||||
result= new ArrayList<IBinding>(findSpecializations(index, owner).size());
|
||||
result.add(specializedMember);
|
||||
// Also add instances of the specialized member
|
||||
if (specializedMember instanceof ICPPInstanceCache) {
|
||||
final List<ICPPTemplateInstance> instances= Arrays.asList(((ICPPInstanceCache) specializedMember).getAllInstances());
|
||||
if (!instances.isEmpty()) {
|
||||
for (ICPPTemplateInstance inst : instances) {
|
||||
if (!ASTInternal.hasDeclaration(inst)) {
|
||||
result.add(inst);
|
||||
|
@ -520,6 +531,11 @@ public class IndexUI {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (result != null) {
|
||||
return result;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* QNX Software Systems - Initial API and implementation
|
||||
* Vadimir Prus (vladimir@codesourcery.com) - bug 156114: GDB options layout
|
||||
* Vladimir Prus (vladimir@codesourcery.com) - bug 156114: GDB options layout
|
||||
* problem
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.debug.mi.internal.ui;
|
||||
|
|
|
@ -65,6 +65,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIBreakpointHitEvent;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.events.MICatchpointHitEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIErrorEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIFunctionFinishedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIInferiorExitEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIRunningEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MISharedLibEvent;
|
||||
|
@ -157,6 +158,8 @@ public class GDBRunControl_7_0_NS extends AbstractDsfService implements IMIRunCo
|
|||
return StateChangeReason.BREAKPOINT;
|
||||
} else if (getMIEvent() instanceof MISteppingRangeEvent) {
|
||||
return StateChangeReason.STEP;
|
||||
} else if (getMIEvent() instanceof MIFunctionFinishedEvent) {
|
||||
return StateChangeReason.STEP;
|
||||
} else if (getMIEvent() instanceof MISharedLibEvent) {
|
||||
return StateChangeReason.SHAREDLIB;
|
||||
}else if (getMIEvent() instanceof MISignalEvent) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Wind River Systems - initial API and implementation
|
||||
* Ericsson AB - Modified for handling of multiple threads
|
||||
* Vladimir Prus (Mentor Graphics) - Add proper stop reason for step return (Bug 362274)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.dsf.mi.service;
|
||||
|
||||
|
@ -51,6 +52,7 @@ import org.eclipse.cdt.dsf.mi.service.command.events.MIBreakpointHitEvent;
|
|||
import org.eclipse.cdt.dsf.mi.service.command.events.MICatchpointHitEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIErrorEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIFunctionFinishedEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MIRunningEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MISharedLibEvent;
|
||||
import org.eclipse.cdt.dsf.mi.service.command.events.MISignalEvent;
|
||||
|
@ -187,6 +189,8 @@ public class MIRunControl extends AbstractDsfService implements IMIRunControl, I
|
|||
return StateChangeReason.BREAKPOINT;
|
||||
} else if (getMIEvent() instanceof MISteppingRangeEvent) {
|
||||
return StateChangeReason.STEP;
|
||||
} else if (getMIEvent() instanceof MIFunctionFinishedEvent) {
|
||||
return StateChangeReason.STEP;
|
||||
} else if (getMIEvent() instanceof MISharedLibEvent) {
|
||||
return StateChangeReason.SHAREDLIB;
|
||||
}else if (getMIEvent() instanceof MISignalEvent) {
|
||||
|
|
Loading…
Add table
Reference in a new issue