mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 14:42:11 +02:00
Bug 327878: Normalize arguments of unknown class instances.
This commit is contained in:
parent
9d1a38c5e3
commit
eedb362a66
11 changed files with 62 additions and 49 deletions
|
@ -16,6 +16,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.dom.IPDOMManager;
|
import org.eclipse.cdt.core.dom.IPDOMManager;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
|
import org.eclipse.cdt.core.dom.ast.IASTNodeSelector;
|
||||||
|
@ -38,7 +39,6 @@ import org.eclipse.cdt.core.testplugin.util.BaseTestCase;
|
||||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
import org.eclipse.cdt.internal.core.dom.parser.ITypeContainer;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|
||||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||||
import org.eclipse.cdt.internal.pdom.tests.PDOMPrettyPrinter;
|
import org.eclipse.cdt.internal.pdom.tests.PDOMPrettyPrinter;
|
||||||
|
@ -155,15 +155,11 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void assertQNEquals(String expectedQN, IBinding b) {
|
protected static void assertQNEquals(String expectedQN, IBinding b) {
|
||||||
try {
|
assertInstance(b, IBinding.class);
|
||||||
assertInstance(b, IBinding.class);
|
if (b instanceof ICPPBinding) {
|
||||||
if (b instanceof ICPPBinding) {
|
assertEquals(expectedQN, ASTTypeUtil.getQualifiedName((ICPPBinding)b));
|
||||||
assertEquals(expectedQN, CPPVisitor.renderQualifiedName(((ICPPBinding)b).getQualifiedName()));
|
} else {
|
||||||
} else {
|
assertEquals(expectedQN, b.getName());
|
||||||
assertEquals(expectedQN, b.getName());
|
|
||||||
}
|
|
||||||
} catch (DOMException de) {
|
|
||||||
fail(de.getMessage());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +186,7 @@ public abstract class IndexBindingResolutionTestBase extends BaseTestCase {
|
||||||
IFunctionType ft = (IFunctionType) function;
|
IFunctionType ft = (IFunctionType) function;
|
||||||
assertTrue(ICPPClassType.class.isInstance((ft.getParameterTypes()[index])));
|
assertTrue(ICPPClassType.class.isInstance((ft.getParameterTypes()[index])));
|
||||||
assertEquals(compositeTypeKey, ((ICPPClassType)ft.getParameterTypes()[index]).getKey());
|
assertEquals(compositeTypeKey, ((ICPPClassType)ft.getParameterTypes()[index]).getKey());
|
||||||
assertEquals(qn, CPPVisitor.renderQualifiedName(((ICPPClassType)ft.getParameterTypes()[index]).getQualifiedName()));
|
assertEquals(qn, ASTTypeUtil.getQualifiedName((ICPPClassType)ft.getParameterTypes()[index]));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static <T> T assertInstance(Object o, Class<T> clazz, Class ... cs) {
|
protected static <T> T assertInstance(Object o, Class<T> clazz, Class ... cs) {
|
||||||
|
|
|
@ -340,13 +340,13 @@ public class ASTTypeUtil {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (type instanceof ICPPTemplateParameter) {
|
} else if (type instanceof ICPPTemplateParameter) {
|
||||||
appendCppName((ICPPTemplateParameter) type, normalize, true, result);
|
appendCppName((ICPPTemplateParameter) type, normalize, normalize, result);
|
||||||
} else if (type instanceof ICPPBinding) {
|
} else if (type instanceof ICPPBinding) {
|
||||||
if (type instanceof IEnumeration) {
|
if (type instanceof IEnumeration) {
|
||||||
result.append(Keywords.ENUM);
|
result.append(Keywords.ENUM);
|
||||||
result.append(SPACE);
|
result.append(SPACE);
|
||||||
}
|
}
|
||||||
appendCppName((ICPPBinding) type, normalize, true, result);
|
appendCppName((ICPPBinding) type, normalize, normalize, result);
|
||||||
} else if (type instanceof ICompositeType) {
|
} else if (type instanceof ICompositeType) {
|
||||||
// 101114 fix, do not display class, and for consistency don't display struct/union as well
|
// 101114 fix, do not display class, and for consistency don't display struct/union as well
|
||||||
appendNameCheckAnonymous((ICompositeType) type, result);
|
appendNameCheckAnonymous((ICompositeType) type, result);
|
||||||
|
@ -694,16 +694,27 @@ public class ASTTypeUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void appendCppName(IBinding binding, boolean normalize, boolean addTemplateArgs, StringBuilder result) {
|
/**
|
||||||
|
* Returns the qualified name for the given binding including template arguments.
|
||||||
|
* If there are template arguments the arguments are neither normalized nor qualified.
|
||||||
|
* @since 5.3
|
||||||
|
*/
|
||||||
|
public static String getQualifiedName(ICPPBinding binding) {
|
||||||
|
StringBuilder buf= new StringBuilder();
|
||||||
|
appendCppName(binding, false, true, buf);
|
||||||
|
return buf.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void appendCppName(IBinding binding, boolean normalize, boolean qualify, StringBuilder result) {
|
||||||
ICPPTemplateParameter tpar= getTemplateParameter(binding);
|
ICPPTemplateParameter tpar= getTemplateParameter(binding);
|
||||||
if (tpar != null) {
|
if (tpar != null) {
|
||||||
appendTemplateParameter(tpar, normalize, result);
|
appendTemplateParameter(tpar, normalize, result);
|
||||||
} else {
|
} else {
|
||||||
if (normalize) {
|
if (qualify) {
|
||||||
IBinding owner= binding.getOwner();
|
IBinding owner= binding.getOwner();
|
||||||
if (owner instanceof ICPPNamespace || owner instanceof IType) {
|
if (owner instanceof ICPPNamespace || owner instanceof IType) {
|
||||||
int pos= result.length();
|
int pos= result.length();
|
||||||
appendCppName(owner, normalize, normalize, result);
|
appendCppName(owner, normalize, qualify, result);
|
||||||
if (result.length() > pos)
|
if (result.length() > pos)
|
||||||
result.append("::"); //$NON-NLS-1$
|
result.append("::"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
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.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||||
|
@ -189,7 +190,7 @@ public class CPPTypedef extends PlatformObject implements ITypedef, ITypeContain
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getName();
|
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(this, true); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public IBinding getOwner() {
|
public IBinding getOwner() {
|
||||||
|
|
|
@ -21,7 +21,7 @@ import java.util.HashSet;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||||
|
@ -64,7 +64,6 @@ import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPSemantics;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
|
||||||
|
@ -627,12 +626,11 @@ public class ClassTypeHelper {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef, List<ICPPBinding> result, HashSet<String> handled) throws CoreException {
|
private static void getSubClasses(IIndex index, ICPPBinding classOrTypedef, List<ICPPBinding> result, HashSet<String> handled) throws CoreException {
|
||||||
try {
|
if (!(classOrTypedef instanceof IType))
|
||||||
final String key = CPPVisitor.renderQualifiedName(classOrTypedef.getQualifiedName());
|
return;
|
||||||
if (!handled.add(key)) {
|
|
||||||
return;
|
final String key = ASTTypeUtil.getType((IType) classOrTypedef, true);
|
||||||
}
|
if (!handled.add(key)) {
|
||||||
} catch (DOMException e) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -433,6 +433,7 @@ public class CPPTemplates {
|
||||||
if (defaultArg == null)
|
if (defaultArg == null)
|
||||||
return null;
|
return null;
|
||||||
arg= instantiateArgument(defaultArg, map, -1, null);
|
arg= instantiateArgument(defaultArg, map, -1, null);
|
||||||
|
arg= SemanticUtil.getSimplifiedArgument(arg);
|
||||||
if (!isValidArgument(arg)) {
|
if (!isValidArgument(arg)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -645,6 +646,7 @@ public class CPPTemplates {
|
||||||
IBinding owner= template.getOwner();
|
IBinding owner= template.getOwner();
|
||||||
if (owner instanceof ICPPUnknownBinding) {
|
if (owner instanceof ICPPUnknownBinding) {
|
||||||
ICPPTemplateArgument[] args= createTemplateArgumentArray(id);
|
ICPPTemplateArgument[] args= createTemplateArgumentArray(id);
|
||||||
|
args= SemanticUtil.getSimplifiedArguments(args);
|
||||||
return new CPPUnknownClassInstance((ICPPUnknownBinding) template.getOwner(), id.getSimpleID(), args);
|
return new CPPUnknownClassInstance((ICPPUnknownBinding) template.getOwner(), id.getSimpleID(), args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2186,6 +2188,7 @@ public class CPPTemplates {
|
||||||
final ICPPTemplateArgument[] arguments = ucli.getArguments();
|
final ICPPTemplateArgument[] arguments = ucli.getArguments();
|
||||||
ICPPTemplateArgument[] newArgs = CPPTemplates.instantiateArguments(arguments, tpMap, packOffset, within);
|
ICPPTemplateArgument[] newArgs = CPPTemplates.instantiateArguments(arguments, tpMap, packOffset, within);
|
||||||
if (!t.equals(owner) && newArgs != arguments) {
|
if (!t.equals(owner) && newArgs != arguments) {
|
||||||
|
newArgs= SemanticUtil.getSimplifiedArguments(newArgs);
|
||||||
result= new CPPUnknownClassInstance((ICPPUnknownBinding) t, ucli.getNameCharArray(), newArgs);
|
result= new CPPUnknownClassInstance((ICPPUnknownBinding) t, ucli.getNameCharArray(), newArgs);
|
||||||
}
|
}
|
||||||
} else if (!t.equals(owner)) {
|
} else if (!t.equals(owner)) {
|
||||||
|
|
|
@ -2093,20 +2093,6 @@ public class CPPVisitor extends ASTQueries {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the qualified name by concatenating component names with the
|
|
||||||
* Scope resolution operator ::
|
|
||||||
* @param qn the component names
|
|
||||||
* @return the qualified name
|
|
||||||
*/
|
|
||||||
public static String renderQualifiedName(String[] qn) {
|
|
||||||
StringBuilder result = new StringBuilder();
|
|
||||||
for (int i = 0; i < qn.length; i++) {
|
|
||||||
result.append(qn[i] + (i + 1 < qn.length ? "::" : "")); //$NON-NLS-1$//$NON-NLS-2$
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String[] getQualifiedName(IBinding binding) {
|
public static String[] getQualifiedName(IBinding binding) {
|
||||||
String[] ns = null;
|
String[] ns = null;
|
||||||
for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) {
|
for (IBinding owner= binding.getOwner(); owner != null; owner= owner.getOwner()) {
|
||||||
|
|
|
@ -34,7 +34,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateParameterMap;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||||
|
@ -64,7 +63,7 @@ class PDOMCPPDeferredClassInstance extends PDOMCPPSpecialization implements ICPP
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(linkage, parent, classType, instantiated);
|
super(linkage, parent, classType, instantiated);
|
||||||
|
|
||||||
final ICPPTemplateArgument[] args= SemanticUtil.getSimplifiedArguments(classType.getTemplateArguments());
|
final ICPPTemplateArgument[] args= classType.getTemplateArguments();
|
||||||
final long argListRec= PDOMCPPArgumentList.putArguments(this, args);
|
final long argListRec= PDOMCPPArgumentList.putArguments(this, args);
|
||||||
getDB().putRecPtr(record+ARGUMENTS, argListRec);
|
getDB().putRecPtr(record+ARGUMENTS, argListRec);
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.CCorePlugin;
|
import org.eclipse.cdt.core.CCorePlugin;
|
||||||
|
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IType;
|
import org.eclipse.cdt.core.dom.ast.IType;
|
||||||
|
@ -131,7 +132,7 @@ class PDOMCPPTypedef extends PDOMCPPBinding implements ITypedef, ITypeContainer,
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected String toStringBase() {
|
protected String toStringBase() {
|
||||||
return getName() + ": " + super.toStringBase(); //$NON-NLS-1$
|
return ASTTypeUtil.getQualifiedName(this) + " -> " + super.toStringBase(); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(IType type) {
|
public void setType(IType type) {
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownClassInstance;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
|
||||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||||
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
import org.eclipse.cdt.internal.core.index.IndexCPPSignatureUtil;
|
||||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||||
|
@ -46,7 +45,7 @@ class PDOMCPPUnknownClassInstance extends PDOMCPPUnknownClassType implements ICP
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
super(linkage, parent, classInstance);
|
super(linkage, parent, classInstance);
|
||||||
|
|
||||||
final ICPPTemplateArgument[] args= SemanticUtil.getSimplifiedArguments(classInstance.getArguments());
|
final ICPPTemplateArgument[] args= classInstance.getArguments();
|
||||||
long rec= PDOMCPPArgumentList.putArguments(this, args);
|
long rec= PDOMCPPArgumentList.putArguments(this, args);
|
||||||
final Database db = getDB();
|
final Database db = getDB();
|
||||||
db.putRecPtr(record + ARGUMENTS, rec);
|
db.putRecPtr(record + ARGUMENTS, rec);
|
||||||
|
|
|
@ -78,6 +78,7 @@ import org.eclipse.cdt.core.model.ILanguage;
|
||||||
import org.eclipse.cdt.core.model.ITranslationUnit;
|
import org.eclipse.cdt.core.model.ITranslationUnit;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
import org.eclipse.cdt.ui.IFunctionSummary;
|
import org.eclipse.cdt.ui.IFunctionSummary;
|
||||||
import org.eclipse.cdt.ui.IRequiredInclude;
|
import org.eclipse.cdt.ui.IRequiredInclude;
|
||||||
|
@ -85,7 +86,6 @@ import org.eclipse.cdt.ui.text.ICHelpInvocationContext;
|
||||||
import org.eclipse.cdt.ui.text.SharedASTJob;
|
import org.eclipse.cdt.ui.text.SharedASTJob;
|
||||||
import org.eclipse.cdt.utils.PathUtil;
|
import org.eclipse.cdt.utils.PathUtil;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.SemanticUtil;
|
||||||
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
|
||||||
import org.eclipse.cdt.internal.corext.codemanipulation.AddIncludesOperation;
|
import org.eclipse.cdt.internal.corext.codemanipulation.AddIncludesOperation;
|
||||||
|
@ -648,7 +648,15 @@ public class AddIncludeOnSelectionAction extends TextEditorAction {
|
||||||
*/
|
*/
|
||||||
private static String getBindingQualifiedName(IIndexBinding binding) throws CoreException {
|
private static String getBindingQualifiedName(IIndexBinding binding) throws CoreException {
|
||||||
String[] qname= binding.getQualifiedName();
|
String[] qname= binding.getQualifiedName();
|
||||||
return CPPVisitor.renderQualifiedName(qname);
|
StringBuilder result = new StringBuilder();
|
||||||
|
boolean needSep= false;
|
||||||
|
for (String element : qname) {
|
||||||
|
if (needSep)
|
||||||
|
result.append(Keywords.cpCOLONCOLON);
|
||||||
|
result.append(element);
|
||||||
|
needSep= true;
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -58,10 +58,9 @@ import org.eclipse.cdt.core.model.ICProject;
|
||||||
import org.eclipse.cdt.core.model.ISourceRoot;
|
import org.eclipse.cdt.core.model.ISourceRoot;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfo;
|
import org.eclipse.cdt.core.parser.IScannerInfo;
|
||||||
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
import org.eclipse.cdt.core.parser.IScannerInfoProvider;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.ui.CUIPlugin;
|
import org.eclipse.cdt.ui.CUIPlugin;
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
|
||||||
|
|
||||||
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
import org.eclipse.cdt.internal.ui.editor.CEditor;
|
||||||
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
import org.eclipse.cdt.internal.ui.viewsupport.IViewPartInputProvider;
|
||||||
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
|
import org.eclipse.cdt.internal.ui.wizards.filewizard.NewSourceFileGenerator;
|
||||||
|
@ -429,7 +428,7 @@ public class NewClassWizardUtil {
|
||||||
ICPPBinding binding = (ICPPBinding)bindings[i];
|
ICPPBinding binding = (ICPPBinding)bindings[i];
|
||||||
|
|
||||||
//get the fully qualified name of this binding
|
//get the fully qualified name of this binding
|
||||||
String bindingFullName = CPPVisitor.renderQualifiedName(binding.getQualifiedName());
|
String bindingFullName = renderQualifiedName(binding.getQualifiedName());
|
||||||
Class<? extends ICPPBinding> currentNodeType = binding.getClass();
|
Class<? extends ICPPBinding> currentNodeType = binding.getClass();
|
||||||
// full binding
|
// full binding
|
||||||
if (queryType.isAssignableFrom(currentNodeType)) {
|
if (queryType.isAssignableFrom(currentNodeType)) {
|
||||||
|
@ -475,4 +474,16 @@ public class NewClassWizardUtil {
|
||||||
index.releaseReadLock();
|
index.releaseReadLock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static String renderQualifiedName(String[] qn) {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
boolean needSep= false;
|
||||||
|
for (String element : qn) {
|
||||||
|
if (needSep)
|
||||||
|
result.append(Keywords.cpCOLONCOLON);
|
||||||
|
result.append(element);
|
||||||
|
needSep= true;
|
||||||
|
}
|
||||||
|
return result.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue