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