diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
index bee233fde39..df65c4a96b9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IASTTranslationUnit.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -139,6 +139,14 @@ public interface IASTTranslationUnit extends IASTNode {
*/
public IASTPreprocessorMacroDefinition[] getMacroDefinitions();
+ /**
+ * Get builtin macro definitions used when parsing this translation unit.
+ * This includes macros obtained from the index.
+ *
+ * @return IASTPreprocessorMacroDefinition[]
+ */
+ public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions();
+
/**
* Get the #include directives encountered in parsing this translation unit.
* @return IASTPreprocessorIncludeStatement[]
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
index d46fcaeb710..6c9084ee9b9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTTranslationUnit.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2006 IBM Corporation and others.
+ * Copyright (c) 2002, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -427,6 +427,19 @@ public class CASTTranslationUnit extends CASTNode implements
return result;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
+ */
+ public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
+ if (resolver == null)
+ return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
+ IASTPreprocessorMacroDefinition[] result = resolver
+ .getBuiltinMacroDefinitions();
+ return result;
+ }
+
/*
* (non-Javadoc)
*
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
index 2c83ae09a3e..de587c1d6cc 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPASTTranslationUnit.java
@@ -464,6 +464,17 @@ public class CPPASTTranslationUnit extends CPPASTNode implements
return result;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
+ */
+ public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
+ if( resolver == null ) return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
+ IASTPreprocessorMacroDefinition [] result = resolver.getBuiltinMacroDefinitions();
+ return result;
+ }
+
/*
* (non-Javadoc)
*
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java
index 5f8a7e87cd1..c31a2ece765 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/ILocationResolver.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2005 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM - Initial API and implementation
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2;
@@ -28,6 +29,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTPreprocessorSelectionResult;
public interface ILocationResolver {
public IASTPreprocessorMacroDefinition [] getMacroDefinitions();
+ public IASTPreprocessorMacroDefinition [] getBuiltinMacroDefinitions();
public IASTPreprocessorIncludeStatement [] getIncludeDirectives();
public IASTPreprocessorStatement [] getAllPreprocessorStatements();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java
index e2c8cb46240..6dc23da038a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner2/LocationMap.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -12,6 +12,8 @@
*******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2;
+import java.util.ArrayList;
+
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
@@ -1452,6 +1454,20 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
return result;
}
+ public IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
+ IMacroDefinition[] mdefs= tu.getBuiltinMacroDefinitions();
+ if (mdefs.length == 0)
+ return EMPTY_MACRO_DEFINITIONS_ARRAY;
+ ArrayList result= new ArrayList(mdefs.length);
+ for (int i = 0; i < mdefs.length; i++) {
+ IMacroDefinition mdef = mdefs[i];
+ if (mdef instanceof _MacroDefinition) {
+ result.add(createASTMacroDefinition((_MacroDefinition) mdef));
+ }
+ }
+ return (IASTPreprocessorMacroDefinition[]) result.toArray(new IASTPreprocessorMacroDefinition[result.size()]);
+ }
+
public IMacroBinding resolveBindingForMacro(char[] name, int offset ) {
_Context search = findContextForOffset( offset );
IMacroDefinition macroDefinition = null;
@@ -1478,9 +1494,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
private IASTPreprocessorMacroDefinition createASTMacroDefinition(
_MacroDefinition d) {
IASTPreprocessorMacroDefinition r = null;
- if (d instanceof _ObjectMacroDefinition)
- r = new ASTObjectMacro();
- else if (d instanceof _FunctionMacroDefinition) {
+ if (d instanceof _FunctionMacroDefinition) {
IASTPreprocessorFunctionStyleMacroDefinition f = new ASTFunctionMacro();
char[][] parms = ((_FunctionMacroDefinition) d).getParms();
for (int j = 0; j < parms.length; ++j) {
@@ -1493,7 +1507,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
}
r = f;
}
-
+ else {
+ r = new ASTObjectMacro();
+ }
+
IASTName name = new ASTMacroName(d.name);
name.setPropertyInParent(IASTPreprocessorMacroDefinition.MACRO_NAME);
name.setParent(r);
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix.java
index 1bcf3615f96..a484dcce3c0 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/text/contentassist2/CompletionTest_SingleName_Prefix.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 IBM Corporation and others.
+ * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -32,7 +32,6 @@ public class CompletionTest_SingleName_Prefix extends CompletionProposalsBaseTe
public CompletionTest_SingleName_Prefix(String name) {
super(name);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=171708
- setExpectFailure(171708);
}
public static Test suite() {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java
index a0d51b5814d..bafe97d6d62 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/text/contentassist/DOMCompletionContributor.java
@@ -9,6 +9,7 @@
* IBM Corporation - initial API and implementation
* Anton Leherbauer (Wind River Systems)
* Bryan Wilkinson (QNX)
+ * Markus Schorn (Wind River Systems)
*******************************************************************************/
package org.eclipse.cdt.internal.ui.text.contentassist;
@@ -103,6 +104,11 @@ public class DOMCompletionContributor implements ICompletionContributor {
for (int i = 0; i < macros.length; ++i)
if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefix.length(), prefix.toCharArray(), false))
handleMacro(macros[i], completionNode, offset, viewer, proposals);
+ macros = completionNode.getTranslationUnit().getBuiltinMacroDefinitions();
+ if (macros != null)
+ for (int i = 0; i < macros.length; ++i)
+ if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefix.length(), prefix.toCharArray(), false))
+ handleMacro(macros[i], completionNode, offset, viewer, proposals);
}
}
}