mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
ea4ce17b7d
commit
fae15af193
1 changed files with 19 additions and 25 deletions
|
@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
|
||||||
* determine if methods are in the same class.
|
* determine if methods are in the same class.
|
||||||
*/
|
*/
|
||||||
public class MethodContext {
|
public class MethodContext {
|
||||||
public enum ContextType{ NONE, FUNCTION, METHOD }
|
public enum ContextType { NONE, FUNCTION, METHOD }
|
||||||
|
|
||||||
private ContextType type;
|
private ContextType type;
|
||||||
private IASTName declarationName;
|
private IASTName declarationName;
|
||||||
|
@ -48,14 +48,14 @@ public class MethodContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMethodDeclarationName(IASTName tmpname) {
|
public void setMethodDeclarationName(IASTName tmpname) {
|
||||||
this.declarationName=tmpname;
|
this.declarationName = tmpname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTName getMethodDeclarationName(){
|
public IASTName getMethodDeclarationName() {
|
||||||
return declarationName;
|
return declarationName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IASTDeclaration getMethodDeclaration(){
|
public IASTDeclaration getMethodDeclaration() {
|
||||||
IASTNode parent = declarationName.getParent().getParent();
|
IASTNode parent = declarationName.getParent().getParent();
|
||||||
if (parent instanceof IASTDeclaration) {
|
if (parent instanceof IASTDeclaration) {
|
||||||
return (IASTDeclaration) parent;
|
return (IASTDeclaration) parent;
|
||||||
|
@ -63,15 +63,14 @@ public class MethodContext {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICPPASTVisibilityLabel getMethodDeclarationASTVisibility(){
|
public ICPPASTVisibilityLabel getMethodDeclarationASTVisibility() {
|
||||||
ICPPASTVisibilityLabel label = new CPPASTVisibilityLabel();
|
ICPPASTVisibilityLabel label = new CPPASTVisibilityLabel();
|
||||||
ICPPMember member = ((ICPPMember)qname.resolveBinding());
|
ICPPMember member = (ICPPMember) qname.resolveBinding();
|
||||||
|
|
||||||
label.setVisibility(member.getVisibility());
|
label.setVisibility(member.getVisibility());
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Visibility getMethodDeclarationVisibility(){
|
public Visibility getMethodDeclarationVisibility() {
|
||||||
return Visibility.getVisibility(declarationName);
|
return Visibility.getVisibility(declarationName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +91,7 @@ public class MethodContext {
|
||||||
public static boolean isSameOrSubClass(MethodContext context1, MethodContext contextOfSameOrSubclass) {
|
public static boolean isSameOrSubClass(MethodContext context1, MethodContext contextOfSameOrSubclass) {
|
||||||
ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
|
ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
|
||||||
ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass);
|
ICPPInternalBinding subclassBind = getICPPInternalBinding(contextOfSameOrSubclass);
|
||||||
if(isSameClass(bind1,subclassBind)){
|
if (isSameClass(bind1,subclassBind)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return isSubclass(bind1,subclassBind);
|
return isSubclass(bind1,subclassBind);
|
||||||
|
@ -104,7 +103,7 @@ public class MethodContext {
|
||||||
ICPPBase[] bases;
|
ICPPBase[] bases;
|
||||||
bases = classType.getBases();
|
bases = classType.getBases();
|
||||||
for (ICPPBase base : bases) {
|
for (ICPPBase base : bases) {
|
||||||
if(isSameClass(base,bind1)){
|
if (isSameClass(base,bind1)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -115,7 +114,6 @@ public class MethodContext {
|
||||||
public static boolean isSameClass(MethodContext context1, MethodContext context2) {
|
public static boolean isSameClass(MethodContext context1, MethodContext context2) {
|
||||||
ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
|
ICPPInternalBinding bind1 = getICPPInternalBinding(context1);
|
||||||
ICPPInternalBinding bind2 = getICPPInternalBinding(context2);
|
ICPPInternalBinding bind2 = getICPPInternalBinding(context2);
|
||||||
|
|
||||||
return isSameClass(bind1,bind2);
|
return isSameClass(bind1,bind2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,16 +121,16 @@ public class MethodContext {
|
||||||
try {
|
try {
|
||||||
IBinding bind1 = base.getBaseClass();
|
IBinding bind1 = base.getBaseClass();
|
||||||
IScope scope1 = bind1.getScope();
|
IScope scope1 = bind1.getScope();
|
||||||
if(scope1 == null)
|
if (scope1 == null)
|
||||||
return false;
|
return false;
|
||||||
IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(scope1);
|
IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(scope1);
|
||||||
|
|
||||||
IScope scope2 = bind2.getScope();
|
IScope scope2 = bind2.getScope();
|
||||||
if(scope2 == null)
|
if (scope2 == null)
|
||||||
return false;
|
return false;
|
||||||
IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(scope2);
|
IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(scope2);
|
||||||
|
|
||||||
if( node1.equals(node2) ){
|
if (node1.equals(node2)) {
|
||||||
if (bind1 instanceof ICPPInternalBinding) {
|
if (bind1 instanceof ICPPInternalBinding) {
|
||||||
ICPPInternalBinding bind1int = (ICPPInternalBinding) bind1;
|
ICPPInternalBinding bind1int = (ICPPInternalBinding) bind1;
|
||||||
return bind1int.getDefinition().equals(bind2.getDefinition());
|
return bind1int.getDefinition().equals(bind2.getDefinition());
|
||||||
|
@ -148,16 +146,16 @@ public class MethodContext {
|
||||||
private static boolean isSameClass(ICPPInternalBinding bind1, ICPPInternalBinding bind2) {
|
private static boolean isSameClass(ICPPInternalBinding bind1, ICPPInternalBinding bind2) {
|
||||||
try {
|
try {
|
||||||
IScope scope1 = bind1.getScope();
|
IScope scope1 = bind1.getScope();
|
||||||
if(scope1 == null)
|
if (scope1 == null)
|
||||||
return false;
|
return false;
|
||||||
IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(scope1);
|
IASTNode node1 = ASTInternal.getPhysicalNodeOfScope(scope1);
|
||||||
|
|
||||||
IScope scope2 = bind2.getScope();
|
IScope scope2 = bind2.getScope();
|
||||||
if(scope2 == null)
|
if (scope2 == null)
|
||||||
return false;
|
return false;
|
||||||
IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(scope2);
|
IASTNode node2 = ASTInternal.getPhysicalNodeOfScope(scope2);
|
||||||
|
|
||||||
if( node1.equals(node2) ){
|
if (node1.equals(node2)) {
|
||||||
return bind1.getDefinition().equals(bind2.getDefinition());
|
return bind1.getDefinition().equals(bind2.getDefinition());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -169,15 +167,12 @@ public class MethodContext {
|
||||||
public static ICPPInternalBinding getICPPInternalBinding(MethodContext context) {
|
public static ICPPInternalBinding getICPPInternalBinding(MethodContext context) {
|
||||||
IASTName decl = context.getMethodDeclarationName();
|
IASTName decl = context.getMethodDeclarationName();
|
||||||
IASTNode node = decl;
|
IASTNode node = decl;
|
||||||
while(node != null){
|
while (node != null) {
|
||||||
if (node instanceof ICPPASTCompositeTypeSpecifier) {
|
if (node instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
ICPPASTCompositeTypeSpecifier type = (ICPPASTCompositeTypeSpecifier) node;
|
ICPPASTCompositeTypeSpecifier type = (ICPPASTCompositeTypeSpecifier) node;
|
||||||
IASTName classname = type.getName();
|
IASTName classname = type.getName();
|
||||||
ICPPInternalBinding bind = (ICPPInternalBinding)classname.resolveBinding();
|
return (ICPPInternalBinding)classname.resolveBinding();
|
||||||
|
|
||||||
return bind;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -188,14 +183,13 @@ public class MethodContext {
|
||||||
return qname == null;
|
return qname == null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ICPPClassType getClassBinding(ICPPASTQualifiedName qname){
|
private static ICPPClassType getClassBinding(ICPPASTQualifiedName qname) {
|
||||||
IASTName classname = qname.getNames()[qname.getNames().length - 2];
|
IASTName classname = qname.getNames()[qname.getNames().length - 2];
|
||||||
ICPPClassType bind = (ICPPClassType)classname.resolveBinding();
|
ICPPClassType bind = (ICPPClassType)classname.resolveBinding();
|
||||||
return bind;
|
return bind;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSameClass(IASTName declName1,
|
public static boolean isSameClass(IASTName declName1, IASTName declName2) {
|
||||||
IASTName declName2) {
|
|
||||||
ICPPClassType bind1 = getClassBinding(declName1);
|
ICPPClassType bind1 = getClassBinding(declName1);
|
||||||
ICPPClassType bind2 = getClassBinding(declName2);
|
ICPPClassType bind2 = getClassBinding(declName2);
|
||||||
return bind1.equals(bind2);
|
return bind1.equals(bind2);
|
||||||
|
|
Loading…
Add table
Reference in a new issue