mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
109724: apply patch for Bryan Wilkinson
This commit is contained in:
parent
58342e9fad
commit
b2b1287072
14 changed files with 23 additions and 105 deletions
|
@ -616,7 +616,7 @@ public class CVisitor {
|
|||
char [] p = fieldReference.getFieldName().toCharArray();
|
||||
IField [] fields = ((ICompositeType) type).getFields();
|
||||
for ( int i = 0; i < fields.length; i++ ) {
|
||||
if( CharArrayUtils.equals( fields[i].getNameCharArray(), 0, p.length, p, false ) ){
|
||||
if( CharArrayUtils.equals( fields[i].getNameCharArray(), 0, p.length, p, true ) ){
|
||||
result = (IBinding[]) ArrayUtil.append( IBinding.class, result, fields[i] );
|
||||
}
|
||||
}
|
||||
|
@ -1446,7 +1446,7 @@ public class CVisitor {
|
|||
char [] c = candidate.toCharArray();
|
||||
if( prefixMap == null && CharArrayUtils.equals( c, name ) ){
|
||||
return candidate;
|
||||
} else if( prefixMap != null && CharArrayUtils.equals( c, 0, name.length, name, false ) && !prefixMap.containsKey( c ) ){
|
||||
} else if( prefixMap != null && CharArrayUtils.equals( c, 0, name.length, name, true ) && !prefixMap.containsKey( c ) ){
|
||||
prefixMap.put( c, candidate );
|
||||
}
|
||||
return prefixMap;
|
||||
|
@ -1468,7 +1468,7 @@ public class CVisitor {
|
|||
char [] n = name.toCharArray();
|
||||
if( prefixMap == null && CharArrayUtils.equals( c, n ) )
|
||||
return tempName;
|
||||
else if( prefixMap != null && CharArrayUtils.equals( c, 0, n.length, n, false ) && !prefixMap.containsKey( c ) )
|
||||
else if( prefixMap != null && CharArrayUtils.equals( c, 0, n.length, n, true ) && !prefixMap.containsKey( c ) )
|
||||
prefixMap.put( c, tempName );
|
||||
} else {
|
||||
return checkForBinding( scope, paramDecl.getDeclSpecifier(), name, typesOnly, prefixMap );
|
||||
|
@ -1994,7 +1994,7 @@ public class CVisitor {
|
|||
ILabel label = labels[i];
|
||||
if (prefixLookup) {
|
||||
if (CharArrayUtils.equals(label.getNameCharArray(),
|
||||
0, n.length, n, false)) {
|
||||
0, n.length, n, true)) {
|
||||
b3.add(label);
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -369,7 +369,7 @@ public class CPPASTQualifiedName extends CPPASTNode implements
|
|||
|
||||
private boolean nameMatches(char[] potential, char[] name, boolean isPrefix) {
|
||||
if (isPrefix) {
|
||||
return CharArrayUtils.equals(potential, 0, name.length, name, false);
|
||||
return CharArrayUtils.equals(potential, 0, name.length, name, true);
|
||||
} else {
|
||||
return CharArrayUtils.equals(potential, name);
|
||||
}
|
||||
|
|
|
@ -319,7 +319,7 @@ public class CPPClassScope extends CPPScope implements ICPPClassScope {
|
|||
IBinding[] results = null;
|
||||
results = (IBinding[]) ArrayUtil.addAll( IBinding.class, results, super.find( name, prefixLookup ));
|
||||
|
||||
if((prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, n.length, n, false))
|
||||
if((prefixLookup && CharArrayUtils.equals(compName.toCharArray(), 0, n.length, n, true))
|
||||
|| (!prefixLookup && CharArrayUtils.equals(compName.toCharArray(), n))) {
|
||||
results = (IBinding[]) ArrayUtil.addAll( IBinding.class, results, getConstructors( bindings, true ) );
|
||||
}
|
||||
|
|
|
@ -89,7 +89,7 @@ public class CPPFunctionScope extends CPPScope implements ICPPFunctionScope {
|
|||
|
||||
for (int i = 0; i < labels.size(); i++) {
|
||||
char[] key = labels.keyAt(i);
|
||||
if ((prefixLookup && CharArrayUtils.equals(key, 0, n.length, n, false))
|
||||
if ((prefixLookup && CharArrayUtils.equals(key, 0, n.length, n, true))
|
||||
|| (!prefixLookup && CharArrayUtils.equals(key, n))) {
|
||||
bindings.add(labels.get(key));
|
||||
}
|
||||
|
|
|
@ -1844,7 +1844,7 @@ public class CPPSemantics {
|
|||
}
|
||||
char[] c = potential.toCharArray();
|
||||
char [] n = data.name();
|
||||
return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, false))
|
||||
return (data.prefixLookup && CharArrayUtils.equals(c, 0, n.length, n, true))
|
||||
|| (!data.prefixLookup && CharArrayUtils.equals(c, n));
|
||||
}
|
||||
|
||||
|
|
|
@ -29,15 +29,14 @@ import org.eclipse.cdt.core.dom.ast.IType;
|
|||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.c.ICCompositeTypeScope;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexScope;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNotImplementedError;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
@ -204,40 +203,13 @@ public class PDOMCStructure extends PDOMBinding implements ICompositeType, ICCom
|
|||
fail(); return null;
|
||||
}
|
||||
|
||||
private static class BindingFinder implements IPDOMVisitor {
|
||||
private List fBindings = new ArrayList();
|
||||
private char[] fName;
|
||||
private boolean fPrefixLookup;
|
||||
|
||||
public BindingFinder(char[] name, boolean prefiexLookup) {
|
||||
fName= name;
|
||||
fPrefixLookup= prefiexLookup;
|
||||
}
|
||||
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMNamedNode && node instanceof IBinding) {
|
||||
char[] n= ((PDOMNamedNode) node).getDBName().getChars();
|
||||
if ((fPrefixLookup && CharArrayUtils.equals(n, 0, fName.length, fName, false))
|
||||
|| (!fPrefixLookup && CharArrayUtils.equals(n, fName))) {
|
||||
fBindings.add(node);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IBinding[] getBindings() {
|
||||
return (IBinding[])fBindings.toArray(new IBinding[fBindings.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
return find(name, false);
|
||||
}
|
||||
|
||||
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||
try {
|
||||
BindingFinder visitor= new BindingFinder(name.toCharArray(), prefixLookup);
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
accept(visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPConstructor;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPField;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
import org.eclipse.cdt.core.index.IIndexBinding;
|
||||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.Util;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassScope;
|
||||
|
@ -46,10 +45,10 @@ import org.eclipse.cdt.internal.core.index.IIndexScope;
|
|||
import org.eclipse.cdt.internal.core.index.IIndexType;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.PDOMNodeLinkedList;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.BindingCollector;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.IPDOMMemberOwner;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMLinkage;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMName;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNamedNode;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -366,30 +365,6 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
|||
return true;
|
||||
}
|
||||
|
||||
private static class BindingCollector implements IPDOMVisitor {
|
||||
private List fBindings = new ArrayList();
|
||||
private char[] fName;
|
||||
|
||||
public BindingCollector(char[] name) {
|
||||
fName= name;
|
||||
}
|
||||
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMNamedNode && node instanceof IBinding) {
|
||||
PDOMNamedNode nn= (PDOMNamedNode) node;
|
||||
if (nn.getDBName().equals(fName)) {
|
||||
fBindings.add(node);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IBinding[] getBindings() {
|
||||
return (IBinding[])fBindings.toArray(new IBinding[fBindings.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding getBinding(IASTName name, boolean resolve) throws DOMException {
|
||||
try {
|
||||
if (getDBName().equals(name.toCharArray())) {
|
||||
|
@ -400,7 +375,7 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
|||
return this;
|
||||
}
|
||||
|
||||
BindingCollector visitor= new BindingCollector(name.toCharArray());
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray());
|
||||
accept(visitor);
|
||||
return CPPSemantics.resolveAmbiguities(name, visitor.getBindings());
|
||||
} catch (CoreException e) {
|
||||
|
@ -408,33 +383,6 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static class BindingFinder implements IPDOMVisitor {
|
||||
private List fBindings = new ArrayList();
|
||||
private char[] fName;
|
||||
private boolean fPrefixLookup;
|
||||
|
||||
public BindingFinder(char[] name, boolean prefiexLookup) {
|
||||
fName= name;
|
||||
fPrefixLookup= prefiexLookup;
|
||||
}
|
||||
|
||||
public boolean visit(IPDOMNode node) throws CoreException {
|
||||
if (node instanceof PDOMNamedNode && node instanceof IBinding) {
|
||||
char[] n= ((PDOMNamedNode) node).getDBName().getChars();
|
||||
if ((fPrefixLookup && CharArrayUtils.equals(n, 0, fName.length, fName, false))
|
||||
|| (!fPrefixLookup && CharArrayUtils.equals(n, fName))) {
|
||||
fBindings.add(node);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
public void leave(IPDOMNode node) throws CoreException {
|
||||
}
|
||||
public IBinding[] getBindings() {
|
||||
return (IBinding[])fBindings.toArray(new IBinding[fBindings.size()]);
|
||||
}
|
||||
}
|
||||
|
||||
public IBinding[] find(String name) throws DOMException {
|
||||
return find(name, false);
|
||||
|
@ -442,7 +390,7 @@ ICPPClassScope, IPDOMMemberOwner, IIndexType, IIndexScope {
|
|||
|
||||
public IBinding[] find(String name, boolean prefixLookup) throws DOMException {
|
||||
try {
|
||||
BindingFinder visitor= new BindingFinder(name.toCharArray(), prefixLookup);
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
acceptInHierarchy(new HashSet(), visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -107,7 +107,7 @@ class PDOMCPPNamespace extends PDOMCPPBinding implements ICPPNamespace, ICPPName
|
|||
|
||||
public IBinding[] find(String name, boolean prefixLookup) {
|
||||
try {
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, true);
|
||||
BindingCollector visitor = new BindingCollector(getLinkageImpl(), name.toCharArray(), null, prefixLookup, !prefixLookup);
|
||||
getIndex().accept(visitor);
|
||||
return visitor.getBindings();
|
||||
} catch (CoreException e) {
|
||||
|
|
|
@ -40,14 +40,14 @@ public class CompletionTest_FunctionReference_Prefix extends CompletionProposal
|
|||
"xSecondEnum",
|
||||
"xThirdEnum",
|
||||
"xEnumeration",
|
||||
/* FIXME: DOM search is currently case sensitive? */
|
||||
"XMacro(x,y)"
|
||||
"XMacro(x, y)",
|
||||
"XStruct"
|
||||
};
|
||||
|
||||
public CompletionTest_FunctionReference_Prefix(String name) {
|
||||
super(name);
|
||||
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
|
||||
setExpectFailure(109724);
|
||||
//setExpectFailure(109724);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
|
|
|
@ -31,7 +31,6 @@ public class CompletionTest_NewTypeReference_Prefix extends CompletionProposals
|
|||
"aClass",
|
||||
"anotherClass",
|
||||
"aNamespace",
|
||||
// missing proposal:
|
||||
"AStruct"
|
||||
// extra proposal:
|
||||
// anEnumeration
|
||||
|
|
|
@ -38,7 +38,6 @@ public class CompletionTest_SingleName_Method_Prefix extends CompletionProposa
|
|||
"aFirstEnum",
|
||||
"aSecondEnum",
|
||||
"aThirdEnum",
|
||||
// missing proposals:
|
||||
"AStruct",
|
||||
"AMacro(x)"
|
||||
};
|
||||
|
|
|
@ -35,14 +35,14 @@ public class CompletionTest_SingleName_Prefix2 extends CompletionProposalsBaseT
|
|||
"aFirstEnum",
|
||||
"aSecondEnum",
|
||||
"aThirdEnum",
|
||||
// missing proposal:
|
||||
"AMacro(x)"
|
||||
"AMacro(x)",
|
||||
"AStruct"
|
||||
};
|
||||
|
||||
public CompletionTest_SingleName_Prefix2(String name) {
|
||||
super(name);
|
||||
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=109724
|
||||
setExpectFailure(109724);
|
||||
//setExpectFailure(109724);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
|
|
|
@ -335,7 +335,7 @@ public class CompletionTests extends AbstractContentAssistTest {
|
|||
//void C3::f() {e/*cursor*/
|
||||
public void testEnums_MethodScope() throws Exception {
|
||||
final String[] expected= {
|
||||
"e11", "e12", "e21", "e22", "E1"
|
||||
"e11", "e12", "e21", "e22", "E1", "E2"
|
||||
};
|
||||
assertCompletionResults(fCursorOffset, expected, true);
|
||||
}
|
||||
|
|
|
@ -139,12 +139,12 @@ public class DOMCompletionProposalComputer extends ParsingBasedProposalComputer
|
|||
IASTPreprocessorMacroDefinition[] macros = completionNode.getTranslationUnit().getMacroDefinitions();
|
||||
if (macros != null)
|
||||
for (int i = 0; i < macros.length; ++i)
|
||||
if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefixChars.length, prefixChars, false))
|
||||
if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefixChars.length, prefixChars, true))
|
||||
handleMacro(macros[i], context, proposals);
|
||||
macros = completionNode.getTranslationUnit().getBuiltinMacroDefinitions();
|
||||
if (macros != null)
|
||||
for (int i = 0; i < macros.length; ++i)
|
||||
if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefixChars.length, prefixChars, false))
|
||||
if (CharArrayUtils.equals(macros[i].getName().toCharArray(), 0, prefixChars.length, prefixChars, true))
|
||||
handleMacro(macros[i], context, proposals);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue