mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-29 11:55:40 +02:00
Extracted a constant.
This commit is contained in:
parent
94a11113b4
commit
68db07fc5d
1 changed files with 20 additions and 21 deletions
|
@ -28,6 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPReferenceType;
|
||||||
import org.eclipse.cdt.core.parser.Keywords;
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||||
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
import org.eclipse.cdt.core.parser.util.CharArraySet;
|
||||||
|
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||||
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
import org.eclipse.cdt.core.parser.util.ObjectSet;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
|
|
||||||
|
@ -35,6 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.OverloadableOperator;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class SemanticUtil {
|
public class SemanticUtil {
|
||||||
|
private static final char[] OPERATOR_CHARS = Keywords.OPERATOR.toCharArray();
|
||||||
/**
|
/**
|
||||||
* Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
|
* Cache of overloadable operator names for fast lookup. Used by isConversionOperator.
|
||||||
*/
|
*/
|
||||||
|
@ -103,8 +105,9 @@ public class SemanticUtil {
|
||||||
IBinding binding= base.getBaseClass();
|
IBinding binding= base.getBaseClass();
|
||||||
if(binding instanceof ICPPClassType && !(binding instanceof IProblemBinding)) {
|
if(binding instanceof ICPPClassType && !(binding instanceof IProblemBinding)) {
|
||||||
ICPPClassType ct= (ICPPClassType) binding;
|
ICPPClassType ct= (ICPPClassType) binding;
|
||||||
if(!done.containsKey(ct))
|
if(!done.containsKey(ct)) {
|
||||||
next.put(ct);
|
next.put(ct);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -122,16 +125,12 @@ public class SemanticUtil {
|
||||||
private static final boolean isConversionOperator(ICPPMethod method) {
|
private static final boolean isConversionOperator(ICPPMethod method) {
|
||||||
boolean result= false;
|
boolean result= false;
|
||||||
if(!method.isImplicit()) {
|
if(!method.isImplicit()) {
|
||||||
char[] name= method.getNameCharArray();
|
final char[] name= method.getNameCharArray();
|
||||||
char[] expected= Keywords.OPERATOR.toCharArray();
|
if (name.length > OPERATOR_CHARS.length + 1 &&
|
||||||
if(name.length > expected.length + 1) {
|
CharArrayUtils.equals(name, 0, OPERATOR_CHARS.length, OPERATOR_CHARS)) {
|
||||||
for(int i=0; i<expected.length; i++) {
|
if(name[OPERATOR_CHARS.length]==' ') {
|
||||||
if(name[i] != expected[i])
|
result= !cas.containsKey(name, OPERATOR_CHARS.length+1, name.length - (OPERATOR_CHARS.length+1));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
if(name[expected.length]!=' ')
|
|
||||||
return false;
|
|
||||||
result= !cas.containsKey(name, expected.length+1, name.length - (expected.length+1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
@ -159,20 +158,20 @@ public class SemanticUtil {
|
||||||
static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) {
|
static IType getUltimateType(IType type, IType[] lastPointerType, boolean stopAtPointerToMember) {
|
||||||
try {
|
try {
|
||||||
while( true ){
|
while( true ){
|
||||||
if( type instanceof ITypedef )
|
if( type instanceof ITypedef ) {
|
||||||
type= ((ITypedef)type).getType();
|
type= ((ITypedef)type).getType();
|
||||||
else if( type instanceof IQualifierType )
|
} else if( type instanceof IQualifierType ) {
|
||||||
type= ((IQualifierType)type).getType();
|
type= ((IQualifierType)type).getType();
|
||||||
else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType )
|
} else if( stopAtPointerToMember && type instanceof ICPPPointerToMemberType )
|
||||||
return type;
|
return type;
|
||||||
else if( type instanceof IPointerType ) {
|
else if( type instanceof IPointerType ) {
|
||||||
if(lastPointerType!=null) {
|
if(lastPointerType!=null) {
|
||||||
lastPointerType[0]= type;
|
lastPointerType[0]= type;
|
||||||
}
|
}
|
||||||
type= ((IPointerType) type).getType();
|
type= ((IPointerType) type).getType();
|
||||||
} else if( type instanceof ICPPReferenceType )
|
} else if( type instanceof ICPPReferenceType ) {
|
||||||
type= ((ICPPReferenceType)type).getType();
|
type= ((ICPPReferenceType)type).getType();
|
||||||
else
|
} else
|
||||||
return type;
|
return type;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -190,13 +189,13 @@ public class SemanticUtil {
|
||||||
public static IType getUltimateTypeUptoPointers(IType type){
|
public static IType getUltimateTypeUptoPointers(IType type){
|
||||||
try {
|
try {
|
||||||
while( true ){
|
while( true ){
|
||||||
if( type instanceof ITypedef )
|
if( type instanceof ITypedef ) {
|
||||||
type = ((ITypedef)type).getType();
|
type = ((ITypedef)type).getType();
|
||||||
else if( type instanceof IQualifierType )
|
} else if( type instanceof IQualifierType ) {
|
||||||
type = ((IQualifierType)type).getType();
|
type = ((IQualifierType)type).getType();
|
||||||
else if( type instanceof ICPPReferenceType )
|
} else if( type instanceof ICPPReferenceType ) {
|
||||||
type = ((ICPPReferenceType)type).getType();
|
type = ((ICPPReferenceType)type).getType();
|
||||||
else
|
} else
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
} catch ( DOMException e ) {
|
} catch ( DOMException e ) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue