Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMarkus Schorn2010-10-21 10:38:51 +0000
committerMarkus Schorn2010-10-21 10:38:51 +0000
commitbefb4d9e04c354d51a34c1408eb773080db65bdf (patch)
treeb31885ee47c0492a618e9e6ee8d680056347ff9a /core
parent7b99473f65e4c5d141a9e9ea5bc3f082e57893f2 (diff)
downloadorg.eclipse.cdt-befb4d9e04c354d51a34c1408eb773080db65bdf.tar.gz
org.eclipse.cdt-befb4d9e04c354d51a34c1408eb773080db65bdf.tar.xz
org.eclipse.cdt-befb4d9e04c354d51a34c1408eb773080db65bdf.zip
Bug 328259: Differentiate function-style and object-style macros, by Patrick Hofer.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacro.java8
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java4
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java14
-rw-r--r--core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java9
-rw-r--r--core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java4
-rw-r--r--core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java6
6 files changed, 40 insertions, 5 deletions
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacro.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacro.java
index 541a7997202..87691ab101e 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacro.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/core/model/IMacro.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2002, 2009 IBM Corporation and others.
+ * Copyright (c) 2002, 2010 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
@@ -28,4 +28,10 @@ public interface IMacro extends ICElement, ISourceManipulation, ISourceReference
* @return String
*/
String getTokenSequence();
+
+ /**
+ * Returns true if this macro is of function style.
+ * @since 5.3
+ */
+ boolean isFunctionStyle();
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java
index 009e1bd8626..d82be49c883 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/CModelBuilder2.java
@@ -37,6 +37,7 @@ import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTNamedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
+import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTProblem;
@@ -305,6 +306,9 @@ public class CModelBuilder2 implements IContributedModelBuilder {
// set positions
setIdentifierPosition(element, name);
setBodyPosition(element, macro);
+ if (macro instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
+ element.setFunctionStyle(true);
+ }
return element;
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java
index 66bd26e130e..49c4aed6107 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/Macro.java
@@ -1,12 +1,12 @@
/*******************************************************************************
- * Copyright (c) 2002, 2008 IBM Corporation and others.
+ * Copyright (c) 2002, 2010 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Rational Software - Initial API and implementation
+ * Rational Software - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.internal.core.model;
@@ -16,6 +16,12 @@ import org.eclipse.cdt.core.model.IMacro;
public class Macro extends SourceManipulation implements IMacro {
+ private boolean fFunctionStyle = false;
+
+ public void setFunctionStyle(boolean isFunctionStyle) {
+ this.fFunctionStyle = isFunctionStyle;
+ }
+
public Macro(ICElement parent, String name) {
super(parent, name, ICElement.C_MACRO);
}
@@ -32,4 +38,8 @@ public class Macro extends SourceManipulation implements IMacro {
protected CElementInfo createElementInfo () {
return new SourceManipulationInfo(this);
}
+
+ public boolean isFunctionStyle() {
+ return fFunctionStyle;
+ }
}
diff --git a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java
index acf1f45f39a..39c6ca8a6f2 100644
--- a/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java
+++ b/core/org.eclipse.cdt.core/model/org/eclipse/cdt/internal/core/model/ext/MacroHandle.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007 Wind River Systems, Inc. and others.
+ * Copyright (c) 2007, 2010 Wind River Systems, Inc. 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
@@ -17,8 +17,11 @@ import org.eclipse.cdt.core.model.ITranslationUnit;
public class MacroHandle extends CElementHandle implements IMacro {
+ private final boolean fFunctionStyle;
+
public MacroHandle(ITranslationUnit tu, IIndexMacro macro) {
super(tu, ICElement.C_MACRO, new String(macro.getName()));
+ fFunctionStyle= macro.isFunctionStyle();
}
public String getIdentifierList() {
@@ -28,4 +31,8 @@ public class MacroHandle extends CElementHandle implements IMacro {
public String getTokenSequence() {
return ""; //$NON-NLS-1$
}
+
+ public boolean isFunctionStyle() {
+ return fFunctionStyle;
+ }
}
diff --git a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java
index 88e75bdeb5d..6f32fa976bc 100644
--- a/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java
+++ b/core/org.eclipse.cdt.ui.tests/ui/org/eclipse/cdt/ui/tests/outline/BasicOutlineTest.java
@@ -92,6 +92,7 @@ public class BasicOutlineTest extends BaseUITestCase {
//#include "user.h"
//#include <system.h>
//#define MACRO
+ //#define MACRO2()
//int main(int argc, char** argv) {}
public void testSimpleOutlineContent() throws Exception {
StringBuffer[] contents= getContentsForTest(1);
@@ -105,7 +106,8 @@ public class BasicOutlineTest extends BaseUITestCase {
Tree tree= checkTreeNode(outline, 0, "user.h").getParent();
checkTreeNode(tree, 1, "system.h");
checkTreeNode(tree, 2, "MACRO");
- checkTreeNode(tree, 3, "main(int, char**) : int");
+ checkTreeNode(tree, 3, "MACRO2()");
+ checkTreeNode(tree, 4, "main(int, char**) : int");
}
//class Foo {
diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
index 224b77a5304..27608bc6dd4 100644
--- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
+++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/viewsupport/CElementLabelComposer.java
@@ -296,6 +296,12 @@ public class CElementLabelComposer {
*/
public void appendMacroLabel(IMacro macro, long flags) {
fBuffer.append(macro.getElementName());
+ if( getFlag( flags, CElementLabels.M_PARAMETER_TYPES ) ) {
+ if (macro.isFunctionStyle()) {
+ fBuffer.append("()"); //$NON-NLS-1$
+ }
+ }
+
if( getFlag(flags, CElementLabels.MF_POST_FILE_QUALIFIED)) {
IPath path= macro.getPath();
if (path != null) {

Back to the top