Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVladimir Hirsl2005-06-22 21:10:11 +0000
committerVladimir Hirsl2005-06-22 21:10:11 +0000
commite28ba5192fa86fb96ae2a1e722a833d65cc7eb03 (patch)
tree9d117679eee943c6109b25c3e2efaaecacd34cc3
parent828b704126081fcf776e641bab110cdbc31d2537 (diff)
downloadorg.eclipse.cdt-e28ba5192fa86fb96ae2a1e722a833d65cc7eb03.tar.gz
org.eclipse.cdt-e28ba5192fa86fb96ae2a1e722a833d65cc7eb03.tar.xz
org.eclipse.cdt-e28ba5192fa86fb96ae2a1e722a833d65cc7eb03.zip
Fix for PR 93573: "[Indexer] endl references are not added to the DOM index"
Fixed different encoding of functions references vs. declarations in the index. Applied Devin's patch for PR 101114: "[AST Util] Inconsistent string representation of IType elements" with slight modifications. Modified JUnit tests accordingly.
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java17
-rw-r--r--core/org.eclipse.cdt.core/ChangeLog13
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java2
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java6
-rw-r--r--core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java26
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java81
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java59
7 files changed, 130 insertions, 74 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
index aaed90b1039..c34cf111dd7 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2UtilTests.java
@@ -61,39 +61,46 @@ public class AST2UtilTests extends AST2BaseTest {
buff.append("int * b(char y, int x);\n"); //$NON-NLS-1$
buff.append("void c(int * z, float **b);\n"); //$NON-NLS-1$
buff.append("static int d(int a[restrict]);\n"); //$NON-NLS-1$
+ buff.append("void e(const char* const);\n"); //$NON-NLS-1$
IASTTranslationUnit tu = parse(buff.toString(), ParserLanguage.C);
IASTDeclaration[] d = tu.getDeclarations();
isParameterSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
isParameterSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int *, float **)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int *, float * *)"); //$NON-NLS-1$
isParameterSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "(int [restrict])"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "(const char * const)"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "int (int)"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "int *(char, int)"); //$NON-NLS-1$
- isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void (int *, float **)"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void (int *, float * *)"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "static int (int [restrict])"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "void (const char * const)"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclSpecifier(), "int"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclSpecifier(), "int"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclSpecifier(), "void"); //$NON-NLS-1$
isSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclSpecifier(), "static int"); //$NON-NLS-1$
+ isSignatureEqual(((IASTSimpleDeclaration)d[4]).getDeclSpecifier(), "void"); //$NON-NLS-1$
isTypeEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "int (int)"); //$NON-NLS-1$
isTypeEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "int * (char, int)"); //$NON-NLS-1$
isTypeEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "void (int *, float * *)"); //$NON-NLS-1$
isTypeEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "int (int * restrict)"); //$NON-NLS-1$
+ isTypeEqual(((IASTSimpleDeclaration)d[4]).getDeclarators()[0], "void (const char * const)"); //$NON-NLS-1$
isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getName().resolveBinding()).getType(), "int (int)"); //$NON-NLS-1$
isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getName().resolveBinding()).getType(), "int * (char, int)"); //$NON-NLS-1$
isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getName().resolveBinding()).getType(), "void (int *, float * *)"); //$NON-NLS-1$
isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getName().resolveBinding()).getType(), "int (int * restrict)"); //$NON-NLS-1$
+ isTypeEqual(((IFunction)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getName().resolveBinding()).getType(), "void (const char * const)"); //$NON-NLS-1$
isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int)"); //$NON-NLS-1$
isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[1]).getDeclarators()[0].getName().resolveBinding()).getType(), "(char, int)"); //$NON-NLS-1$
isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[2]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int *, float * *)"); //$NON-NLS-1$
isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[3]).getDeclarators()[0].getName().resolveBinding()).getType(), "(int * restrict)"); //$NON-NLS-1$
+ isParameterTypeEqual(((IFunction)((IASTSimpleDeclaration)d[4]).getDeclarators()[0].getName().resolveBinding()).getType(), "(const char * const)"); //$NON-NLS-1$
}
public void testSimpleCParameterSignature() throws Exception {
@@ -108,7 +115,7 @@ public class AST2UtilTests extends AST2BaseTest {
isParameterSignatureEqual(((IASTSimpleDeclaration)d[0]).getDeclarators()[0], "(int)"); //$NON-NLS-1$
isParameterSignatureEqual(((IASTSimpleDeclaration)d[1]).getDeclarators()[0], "(char, int)"); //$NON-NLS-1$
- isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int *, float **)"); //$NON-NLS-1$
+ isParameterSignatureEqual(((IASTSimpleDeclaration)d[2]).getDeclarators()[0], "(int *, float * *)"); //$NON-NLS-1$
isParameterSignatureEqual(((IASTSimpleDeclaration)d[3]).getDeclarators()[0], "(int [restrict])"); //$NON-NLS-1$
}
@@ -127,12 +134,12 @@ public class AST2UtilTests extends AST2BaseTest {
// verify signatures
isSignatureEqual( ((IASTTypeIdExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId(), "int"); //$NON-NLS-1$
- isSignatureEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "union"); //$NON-NLS-1$
+ isSignatureEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "Squaw"); //$NON-NLS-1$
isSignatureEqual( ((IASTCastExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId() , "jc"); //$NON-NLS-1$
// verify types
isTypeEqual( ((IASTTypeIdExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[0]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId(), "int"); //$NON-NLS-1$
- isTypeEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "union Squaw"); //$NON-NLS-1$
+ isTypeEqual( ((IASTTypeIdExpression)((IASTReturnStatement)((IASTCompoundStatement)((IASTFunctionDefinition)d[2]).getBody()).getStatements()[0]).getReturnValue()).getTypeId(), "Squaw"); //$NON-NLS-1$
isTypeEqual( ((IASTCastExpression)((IASTInitializerExpression)((IASTSimpleDeclaration)d[6]).getDeclarators()[0].getInitializer()).getExpression()).getTypeId() , "short int"); //$NON-NLS-1$
}
diff --git a/core/org.eclipse.cdt.core/ChangeLog b/core/org.eclipse.cdt.core/ChangeLog
index f75ba938282..dbfc6e794a7 100644
--- a/core/org.eclipse.cdt.core/ChangeLog
+++ b/core/org.eclipse.cdt.core/ChangeLog
@@ -1,3 +1,16 @@
+2005-06-22 Vladimir Hirsl
+ Fix for PR 93573: "[Indexer] endl references are not added to the DOM index"
+ Fixed different encoding of functions references vs. declarations in the index.
+ Applied Devin's patch for PR 101114: "[AST Util] Inconsistent string representation
+ of IType elements" with slight modifications.
+ Modified JUnit tests accordingly.
+
+ * index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
+ * index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
+ * index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java
+ * parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+ * parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
+
2005-06-21 Vladimir Hirsl
Fix for 100598: DOM Indexer encodes weird things when indexing a CPP file in a C project
Fixed correlation between parser's parser language and indexer visitor.
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
index 880298e2119..55dc99650fb 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CGenerateIndexVisitor.java
@@ -247,7 +247,7 @@ public class CGenerateIndexVisitor extends CASTVisitor {
}
FunctionEntry indexEntry = new FunctionEntry(IIndex.FUNCTION, entryKind, qualifiedName, modifiers, fileNumber);
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
- indexEntry.setSignature(IndexVisitorUtil.getParameters(name));
+ indexEntry.setSignature(IndexVisitorUtil.getParameters((IFunction) binding));
indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
indexEntry.serialize(indexer.getOutput());
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
index 32c543d8631..fc2e5404e52 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/CPPGenerateIndexVisitor.java
@@ -297,8 +297,8 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
}
FunctionEntry indexEntry = new FunctionEntry(IIndex.METHOD, entryKind, qualifiedName, modifiers, fileNumber);
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
- indexEntry.setSignature(IndexVisitorUtil.getParameters(name));
- indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
+ indexEntry.setSignature(IndexVisitorUtil.getParameters((ICPPMethod) binding));
+ indexEntry.setReturnType(IndexVisitorUtil.getReturnType((ICPPMethod) binding));
serialize(indexEntry);
// TODO In case we want to add friend method declarations to index
@@ -313,7 +313,7 @@ public class CPPGenerateIndexVisitor extends CPPASTVisitor {
}
FunctionEntry indexEntry = new FunctionEntry(IIndex.FUNCTION, entryKind, qualifiedName, modifiers, fileNumber);
indexEntry.setNameOffset(fileLoc.getNodeOffset(), fileLoc.getNodeLength(), IIndex.OFFSET);
- indexEntry.setSignature(IndexVisitorUtil.getParameters(name));
+ indexEntry.setSignature(IndexVisitorUtil.getParameters((IFunction) binding));
indexEntry.setReturnType(IndexVisitorUtil.getReturnType((IFunction) binding));
serialize(indexEntry);
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java
index 190d30f7dfb..4007aa3b9ac 100644
--- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java
+++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java
@@ -10,6 +10,9 @@
***********************************************************************/
package org.eclipse.cdt.internal.core.index.domsourceindexer;
+import java.util.ArrayList;
+import java.util.List;
+
import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil;
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
import org.eclipse.cdt.core.dom.ast.DOMException;
@@ -22,6 +25,7 @@ import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.dom.ast.IEnumeration;
import org.eclipse.cdt.core.dom.ast.IFunction;
import org.eclipse.cdt.core.dom.ast.IFunctionType;
+import org.eclipse.cdt.core.dom.ast.IParameter;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.IVariable;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
@@ -202,7 +206,27 @@ public class IndexVisitorUtil {
}
return new char[0][];
}
-
+
+ /**
+ * @param function
+ * @return
+ */
+ public static char[][] getParameters(IFunction function) {
+ List parameterList = new ArrayList();
+ try {
+ IParameter[] parameters = function.getParameters();
+ for (int i = 0; i < parameters.length; i++) {
+ IType paramType = parameters[i].getType();
+ parameterList.add(ASTTypeUtil.getType(paramType).toCharArray());
+ }
+ if (parameterList.isEmpty()) {
+ parameterList.add("void".toCharArray()); //$NON-NLS-1$
+ }
+ }
+ catch (DOMException e) {
+ }
+ return (char[][]) parameterList.toArray(new char[parameterList.size()][]);
+ }
/**
* @param function
* @return
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
index d6c14b735f3..41578b3614e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java
@@ -13,7 +13,6 @@ package org.eclipse.cdt.core.dom.ast;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayDesignator;
import org.eclipse.cdt.core.dom.ast.c.ICASTArrayModifier;
-import org.eclipse.cdt.core.dom.ast.c.ICASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignatedInitializer;
import org.eclipse.cdt.core.dom.ast.c.ICASTDesignator;
@@ -23,11 +22,9 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.c.ICASTTypeIdInitializerExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCastExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorInitializer;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeclSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTDeleteExpression;
-import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTElaboratedTypeSpecifier;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleDeclSpecifier;
@@ -180,6 +177,7 @@ public class ASTSignatureUtil {
if (ops != null && ops.length > 0) {
for(int i=0; i<ops.length; i++) {
if (ops[i] != null) {
+ if (needSpace) { result.append(SPACE); }
if (ops[i] instanceof IASTPointer) {
result.append(Keywords.cpSTAR); // want to have this before keywords on the pointer
needSpace=true;
@@ -388,43 +386,48 @@ public class ASTSignatureUtil {
// handle complex cases
if (declSpec instanceof IASTCompositeTypeSpecifier) {
- if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
- switch(((ICPPASTCompositeTypeSpecifier)declSpec).getKey()) {
- case ICPPASTCompositeTypeSpecifier.k_class:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
- break;
- case IASTCompositeTypeSpecifier.k_struct:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
- break;
- case IASTCompositeTypeSpecifier.k_union:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
- break;
- }
- } else if (declSpec instanceof ICASTCompositeTypeSpecifier) {
- switch(((ICASTCompositeTypeSpecifier)declSpec).getKey()) {
- case IASTCompositeTypeSpecifier.k_struct:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
- break;
- case IASTCompositeTypeSpecifier.k_union:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
- break;
- }
- }
+ // 101114 fix, do not display class, and for consistency don't display struct/union as well
+// if (declSpec instanceof ICPPASTCompositeTypeSpecifier) {
+// switch(((ICPPASTCompositeTypeSpecifier)declSpec).getKey()) {
+// case ICPPASTCompositeTypeSpecifier.k_class:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
+// break;
+// case IASTCompositeTypeSpecifier.k_struct:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
+// break;
+// case IASTCompositeTypeSpecifier.k_union:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
+// break;
+// }
+// } else if (declSpec instanceof ICASTCompositeTypeSpecifier) {
+// switch(((ICASTCompositeTypeSpecifier)declSpec).getKey()) {
+// case IASTCompositeTypeSpecifier.k_struct:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
+// break;
+// case IASTCompositeTypeSpecifier.k_union:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
+// break;
+// }
+// }
+
+ result.append(((IASTCompositeTypeSpecifier)declSpec).getName());
} else if (declSpec instanceof IASTElaboratedTypeSpecifier) {
- switch(((IASTElaboratedTypeSpecifier)declSpec).getKind()) {
- case ICPPASTElaboratedTypeSpecifier.k_class:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
- break;
- case IASTElaboratedTypeSpecifier.k_enum:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
- break;
- case IASTElaboratedTypeSpecifier.k_struct:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
- break;
- case IASTElaboratedTypeSpecifier.k_union:
- if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
- break;
- }
+// 101114 fix, do not display class, and for consistency don't display struct/union as well
+// switch(((IASTElaboratedTypeSpecifier)declSpec).getKind()) {
+// case ICPPASTElaboratedTypeSpecifier.k_class:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.CLASS); needSpace=true;
+// break;
+// case IASTElaboratedTypeSpecifier.k_enum:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
+// break;
+// case IASTElaboratedTypeSpecifier.k_struct:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.STRUCT); needSpace=true;
+// break;
+// case IASTElaboratedTypeSpecifier.k_union:
+// if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.UNION); needSpace=true;
+// break;
+// }
+ result.append(((IASTElaboratedTypeSpecifier)declSpec).getName());
} else if (declSpec instanceof IASTEnumerationSpecifier) {
if (needSpace) { result.append(SPACE); needSpace=false; } result.append(Keywords.ENUM); needSpace=true;
} else if (declSpec instanceof IASTNamedTypeSpecifier) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
index c5aec95e8b1..fd9827f918e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTTypeUtil.java
@@ -16,7 +16,6 @@ import org.eclipse.cdt.core.dom.ast.c.ICBasicType;
import org.eclipse.cdt.core.dom.ast.c.ICPointerType;
import org.eclipse.cdt.core.dom.ast.c.ICQualifierType;
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.ICPPReferenceType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
@@ -173,29 +172,30 @@ public class ASTTypeUtil {
break;
}
} catch (DOMException e) {}
-
+
} else if (type instanceof ICompositeType) {
- if (type instanceof ICPPClassType) {
- try {
- switch(((ICPPClassType)type).getKey()) {
- case ICPPClassType.k_class:
- result.append(Keywords.CLASS);
- break;
- }
- } catch (DOMException e) {}
- }
-
- try {
- switch(((ICompositeType)type).getKey()) {
- case ICompositeType.k_struct:
- result.append(Keywords.STRUCT);
- break;
- case ICompositeType.k_union:
- result.append(Keywords.UNION);
- break;
- }
- } catch (DOMException e) {}
- result.append(SPACE);
+// 101114 fix, do not display class, and for consistency don't display struct/union as well
+// if (type instanceof ICPPClassType) {
+// try {
+// switch(((ICPPClassType)type).getKey()) {
+// case ICPPClassType.k_class:
+// result.append(Keywords.CLASS);
+// break;
+// }
+// } catch (DOMException e) {}
+// }
+//
+// try {
+// switch(((ICompositeType)type).getKey()) {
+// case ICompositeType.k_struct:
+// result.append(Keywords.STRUCT);
+// break;
+// case ICompositeType.k_union:
+// result.append(Keywords.UNION);
+// break;
+// }
+// } catch (DOMException e) {}
+// result.append(SPACE);
result.append(((ICompositeType)type).getName());
} else if (type instanceof ICPPReferenceType) {
result.append(Keywords.cpAMPER);
@@ -277,8 +277,17 @@ public class ASTTypeUtil {
if (types[j] != null && result.length() > 0) result.append(SPACE); // only add a space if this is not the first type being added
- if (types[j] != null)
- result.append(getTypeString(types[j]));
+ if (types[j] != null) {
+ if (j > 0 && types[j-1] instanceof IQualifierType) {
+ result.append(getTypeString(types[j-1]));
+ result.append(SPACE);
+ result.append(getTypeString(types[j]));
+ --j;
+ }
+ else {
+ result.append(getTypeString(types[j]));
+ }
+ }
}
return result.toString();

Back to the top