Java Code Examples for org.eclipse.jdt.core.dom.IVariableBinding#getDeclaringClass()

The following examples show how to use org.eclipse.jdt.core.dom.IVariableBinding#getDeclaringClass() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnonymousTypeCompletionProposal.java    From eclipse.jdt.ls with Eclipse Public License 2.0 6 votes vote down vote up
private IBinding getEnclosingDeclaration(ASTNode node) {
	while (node != null) {
		if (node instanceof AbstractTypeDeclaration) {
			return ((AbstractTypeDeclaration) node).resolveBinding();
		} else if (node instanceof AnonymousClassDeclaration) {
			return ((AnonymousClassDeclaration) node).resolveBinding();
		} else if (node instanceof MethodDeclaration) {
			return ((MethodDeclaration) node).resolveBinding();
		} else if (node instanceof FieldDeclaration) {
			List<?> fragments = ((FieldDeclaration) node).fragments();
			if (fragments.size() > 0) {
				return ((VariableDeclarationFragment) fragments.get(0)).resolveBinding();
			}
		} else if (node instanceof VariableDeclarationFragment) {
			IVariableBinding variableBinding = ((VariableDeclarationFragment) node).resolveBinding();
			if (variableBinding.getDeclaringMethod() != null || variableBinding.getDeclaringClass() != null) {
				return variableBinding;
				// workaround for incomplete wiring of DOM bindings: keep searching when variableBinding is unparented
			}
		}
		node = node.getParent();
	}
	return null;
}
 
Example 2
Source File: InJavaImporter.java    From jdt2famix with Eclipse Public License 1.0 6 votes vote down vote up
Attribute ensureAttributeForVariableBinding(IVariableBinding binding) {
	String name = binding.getName();
	ITypeBinding parentTypeBinding = binding.getDeclaringClass();
	Type parentType;
	if (parentTypeBinding == null)
		/*
		 * for example String[] args; args.length appears like an attribute, but the
		 * declaring class is not present
		 */
		parentType = unknownType();
	else
		parentType = ensureTypeFromTypeBinding(parentTypeBinding);
	String qualifiedName = Famix.qualifiedNameOf(parentType) + NAME_SEPARATOR + name;
	if (attributes.has(qualifiedName))
		return attributes.named(qualifiedName);
	Attribute attribute = ensureBasicAttribute(parentType, name, qualifiedName,
			ensureTypeFromTypeBinding(binding.getType()));
	return attribute;
}
 
Example 3
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@Override
public boolean visit(final SimpleName node) {
	Assert.isNotNull(node);
	if (fAnonymousClass > 0) {
		if (!(node.getParent() instanceof FieldAccess)) {
			final IBinding binding= node.resolveBinding();
			if (binding instanceof IVariableBinding) {
				final IVariableBinding variable= (IVariableBinding) binding;
				final ITypeBinding declaring= variable.getDeclaringClass();
				if (declaring != null && Bindings.equals(declaring, fDeclaringType))
					fResult.add(node);
			}
		}
	}
	return false;
}
 
Example 4
Source File: ASTResolving.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static boolean isVariableDefinedInContext(IBinding binding, ITypeBinding typeVariable) {
	if (binding.getKind() == IBinding.VARIABLE) {
		IVariableBinding var= (IVariableBinding) binding;
		binding= var.getDeclaringMethod();
		if (binding == null) {
			binding= var.getDeclaringClass();
		}
	}
	if (binding instanceof IMethodBinding) {
		if (binding == typeVariable.getDeclaringMethod()) {
			return true;
		}
		binding= ((IMethodBinding) binding).getDeclaringClass();
	}

	while (binding instanceof ITypeBinding) {
		if (binding == typeVariable.getDeclaringClass()) {
			return true;
		}
		if (Modifier.isStatic(binding.getModifiers())) {
			break;
		}
		binding= ((ITypeBinding) binding).getDeclaringClass();
	}
	return false;
}
 
Example 5
Source File: LocalCorrectionsSubProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private static ASTRewriteCorrectionProposal createNoSideEffectProposal(IInvocationContext context, SimpleName nodeToQualify, IVariableBinding fieldBinding, String label, int relevance) {
	AST ast= nodeToQualify.getAST();

	Expression qualifier;
	if (Modifier.isStatic(fieldBinding.getModifiers())) {
		ITypeBinding declaringClass= fieldBinding.getDeclaringClass();
		qualifier= ast.newSimpleName(declaringClass.getTypeDeclaration().getName());
	} else {
		qualifier= ast.newThisExpression();
	}

	ASTRewrite rewrite= ASTRewrite.create(ast);
	FieldAccess access= ast.newFieldAccess();
	access.setName((SimpleName) rewrite.createCopyTarget(nodeToQualify));
	access.setExpression(qualifier);
	rewrite.replace(nodeToQualify, access, null);


	Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
	return new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite, relevance, image);
}
 
Example 6
Source File: SuperTypeConstraintsCreator.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * End of visit the field access.
 *
 * @param binding the variable binding
 * @param qualifier the qualifier expression, or <code>null</code>
 * @param access the access expression
 */
private void endVisit(final IVariableBinding binding, final Expression qualifier, final Expression access) {
	access.setProperty(PROPERTY_CONSTRAINT_VARIABLE, fModel.createVariableVariable(binding));
	if (qualifier != null) {
		final ITypeBinding type= binding.getDeclaringClass();
		if (type != null) {
			// array.length does not have a declaring class
			final ConstraintVariable2 ancestor= fModel.createDeclaringTypeVariable(type);
			if (ancestor != null) {
				final ConstraintVariable2 descendant= (ConstraintVariable2) qualifier.getProperty(PROPERTY_CONSTRAINT_VARIABLE);
				if (descendant != null)
					fModel.createSubtypeConstraint(descendant, ancestor);
			}
		}
	}
}
 
Example 7
Source File: ConvertAnonymousToNestedRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
private boolean areLocalsUsedIn(Expression fieldInitializer, List<VariableDeclarationFragment> fieldsToInitialize) {
      Set<IBinding> localsUsed= new HashSet<IBinding>(0);
      collectRefrencedVariables(fieldInitializer, localsUsed);

      ITypeBinding anonType= fAnonymousInnerClassNode.resolveBinding();

      for (Iterator<IBinding> iterator= localsUsed.iterator(); iterator.hasNext();) {
	IVariableBinding curr= (IVariableBinding) iterator.next();
	if (isBindingToTemp(curr)) { // reference a local from outside
		return true;
	} else if (curr.isField() && (curr.getDeclaringClass() == anonType) && fieldsToInitialize.contains(fCompilationUnitNode.findDeclaringNode(curr))) {
		return true; // references a field that references a local from outside
	}
}
      return false;
  }
 
Example 8
Source File: SystemObject.java    From JDeodorant with MIT License 5 votes vote down vote up
private boolean allStaticFieldsWithinSystemBoundary(List<SimpleName> staticFields) {
	for(SimpleName staticField : staticFields) {
		IBinding binding = staticField.resolveBinding();
		if(binding != null && binding.getKind() == IBinding.VARIABLE) {
			IVariableBinding variableBinding = (IVariableBinding)binding;
			ITypeBinding declaringClassTypeBinding = variableBinding.getDeclaringClass();
			if(declaringClassTypeBinding != null) {
				if(getPositionInClassList(declaringClassTypeBinding.getQualifiedName()) == -1 && !declaringClassTypeBinding.isEnum())
					return false;
			}
		}
	}
	return true;
}
 
Example 9
Source File: SrcTreeGenerator.java    From sahagin-java with Apache License 2.0 5 votes vote down vote up
@Override
public boolean visit(FieldDeclaration node) {
    IVariableBinding variable = getVariableBinding(node);
    if (variable == null) {
        return super.visit(node);
    }
    ITypeBinding classBinding = variable.getDeclaringClass();
    if (!classBinding.isClass() && !classBinding.isInterface()) {
        // enum method, etc
        return super.visit(node);
    }

    // TODO support additional testDoc for Field
    String testDoc = ASTUtils.getTestDoc(variable, locales);
    if (testDoc == null) {
        return super.visit(node);
    }

    TestClass testClass = classBindingTestClass(classBinding);
    TestField testField = new TestField();
    testField.setTestClassKey(testClass.getKey());
    testField.setTestClass(testClass);
    testField.setKey(testClass.getKey() + "." + variable.getName());
    testField.setSimpleName(variable.getName());
    testField.setTestDoc(testDoc);
    testField.setValue(null); // TODO currently not supported
    fieldTable.addTestField(testField);

    testClass.addTestFieldKey(testField.getKey());
    testClass.addTestField(testField);

    return super.visit(node);
}
 
Example 10
Source File: CodeStyleFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private void handleVariable(SimpleName node, IVariableBinding varbinding) {
	if (!varbinding.isField())
		return;

	if (varbinding.isEnumConstant())
		return;

	ITypeBinding declaringClass= varbinding.getDeclaringClass();
	if (Modifier.isStatic(varbinding.getModifiers())) {
		if (fFindUnqualifiedStaticAccesses) {
			Initializer initializer= (Initializer) ASTNodes.getParent(node, Initializer.class);
			//Do not qualify assignments to static final fields in static initializers (would result in compile error)
			StructuralPropertyDescriptor parentDescription= node.getLocationInParent();
			if (initializer != null && Modifier.isStatic(initializer.getModifiers())
					&& Modifier.isFinal(varbinding.getModifiers()) && parentDescription == Assignment.LEFT_HAND_SIDE_PROPERTY)
				return;

			//Do not qualify static fields if defined inside an anonymous class
			if (declaringClass.isAnonymous())
				return;

			fResult.add(new AddStaticQualifierOperation(declaringClass, node));
		}
	} else if (fFindUnqualifiedAccesses){
		String qualifier= getThisExpressionQualifier(declaringClass, fImportRewrite, node);
		if (qualifier == null)
			return;

		if (qualifier.length() == 0)
			qualifier= null;

		fResult.add(new AddThisQualifierOperation(qualifier, node));
	}
}
 
Example 11
Source File: Bindings.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private static String asString(IVariableBinding variableBinding) {
	if (! variableBinding.isField())
		return variableBinding.toString();
	if (variableBinding.getDeclaringClass() == null) {
		Assert.isTrue(variableBinding.getName().equals("length"));//$NON-NLS-1$
		return ARRAY_LENGTH_FIELD_BINDING_STRING;
	}
	StringBuffer result= new StringBuffer();
	result.append(variableBinding.getDeclaringClass().getName());
	result.append(':');
	result.append(variableBinding.getName());
	return result.toString();
}
 
Example 12
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public final boolean visit(final SimpleName node) {
	Assert.isNotNull(node);
	final IBinding binding= node.resolveBinding();
	ITypeBinding declaring= null;
	if (binding instanceof IVariableBinding) {
		final IVariableBinding variable= (IVariableBinding) binding;
		if (Flags.isStatic(variable.getModifiers()))
			return false;
		declaring= variable.getDeclaringClass();
	} else if (binding instanceof IMethodBinding) {
		final IMethodBinding method= (IMethodBinding) binding;
		if (Flags.isStatic(method.getModifiers()))
			return false;
		declaring= method.getDeclaringClass();
	}
	if (declaring != null) {
		ITypeBinding enclosing= null;
		for (final Iterator<ITypeBinding> iterator= fEnclosingTypes.iterator(); iterator.hasNext();) {
			enclosing= iterator.next();
			if (Bindings.equals(enclosing, declaring)) {
				fStatus.merge(RefactoringStatus.createFatalErrorStatus(RefactoringCoreMessages.MoveInstanceMethodProcessor_refers_enclosing_instances, JavaStatusContext.create(fMethod.getCompilationUnit(), node)));
				fResult.add(node);
				break;
			}
		}
	}
	return false;
}
 
Example 13
Source File: ExtractClassRefactoring.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
private boolean checkVariableBinding(IVariableBinding fieldBinding) {
	if (fieldBinding != null) {
		if (fieldBinding.isField()) {
			ITypeBinding declaringClass= fieldBinding.getDeclaringClass();
			if ((declaringClass != null) && declaringClass.getQualifiedName().equals(fDescriptor.getType().getFullyQualifiedName())) {
				FieldInfo fi= fVariables.get(fieldBinding.getName());
				if (fi != null && isCreateField(fi) && Bindings.equals(fieldBinding, fi.pi.getOldBinding())) {
					fFieldRefFound= true;
					return false;
				}
			}
		}
	}
	return true;
}
 
Example 14
Source File: StubUtility2.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static MethodDeclaration createDelegationStub(ICompilationUnit unit, ASTRewrite rewrite, ImportRewrite imports, ImportRewriteContext context, IMethodBinding delegate, IVariableBinding delegatingField, CodeGenerationSettings settings) throws CoreException {
	Assert.isNotNull(delegate);
	Assert.isNotNull(delegatingField);
	Assert.isNotNull(settings);

	AST ast= rewrite.getAST();

	MethodDeclaration decl= ast.newMethodDeclaration();
	decl.modifiers().addAll(ASTNodeFactory.newModifiers(ast, delegate.getModifiers() & ~Modifier.SYNCHRONIZED & ~Modifier.ABSTRACT & ~Modifier.NATIVE));

	decl.setName(ast.newSimpleName(delegate.getName()));
	decl.setConstructor(false);

	createTypeParameters(imports, context, ast, delegate, decl);

	decl.setReturnType2(imports.addImport(delegate.getReturnType(), ast, context));

	List<SingleVariableDeclaration> params= createParameters(unit.getJavaProject(), imports, context, ast, delegate, null, decl);

	createThrownExceptions(decl, delegate, imports, context, ast);

	Block body= ast.newBlock();
	decl.setBody(body);

	String delimiter= StubUtility.getLineDelimiterUsed(unit);

	Statement statement= null;
	MethodInvocation invocation= ast.newMethodInvocation();
	invocation.setName(ast.newSimpleName(delegate.getName()));
	List<Expression> arguments= invocation.arguments();
	for (int i= 0; i < params.size(); i++)
		arguments.add(ast.newSimpleName(params.get(i).getName().getIdentifier()));
	if (settings.useKeywordThis) {
		FieldAccess access= ast.newFieldAccess();
		access.setExpression(ast.newThisExpression());
		access.setName(ast.newSimpleName(delegatingField.getName()));
		invocation.setExpression(access);
	} else
		invocation.setExpression(ast.newSimpleName(delegatingField.getName()));
	if (delegate.getReturnType().isPrimitive() && delegate.getReturnType().getName().equals("void")) {//$NON-NLS-1$
		statement= ast.newExpressionStatement(invocation);
	} else {
		ReturnStatement returnStatement= ast.newReturnStatement();
		returnStatement.setExpression(invocation);
		statement= returnStatement;
	}
	body.statements().add(statement);

	ITypeBinding declaringType= delegatingField.getDeclaringClass();
	if (declaringType == null) { // can be null for
		return decl;
	}

	String qualifiedName= declaringType.getQualifiedName();
	IPackageBinding packageBinding= declaringType.getPackage();
	if (packageBinding != null) {
		if (packageBinding.getName().length() > 0 && qualifiedName.startsWith(packageBinding.getName()))
			qualifiedName= qualifiedName.substring(packageBinding.getName().length());
	}

	if (settings.createComments) {
		/*
		 * TODO: have API for delegate method comments This is an inlined
		 * version of
		 * {@link CodeGeneration#getMethodComment(ICompilationUnit, String, MethodDeclaration, IMethodBinding, String)}
		 */
		delegate= delegate.getMethodDeclaration();
		String declaringClassQualifiedName= delegate.getDeclaringClass().getQualifiedName();
		String linkToMethodName= delegate.getName();
		String[] parameterTypesQualifiedNames= StubUtility.getParameterTypeNamesForSeeTag(delegate);
		String string= StubUtility.getMethodComment(unit, qualifiedName, decl, delegate.isDeprecated(), linkToMethodName, declaringClassQualifiedName, parameterTypesQualifiedNames, true, delimiter);
		if (string != null) {
			Javadoc javadoc= (Javadoc) rewrite.createStringPlaceholder(string, ASTNode.JAVADOC);
			decl.setJavadoc(javadoc);
		}
	}
	return decl;
}
 
Example 15
Source File: DeclaringTypeVariable.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
protected DeclaringTypeVariable(IVariableBinding fieldBinding) {
	super(fieldBinding.getDeclaringClass());
	Assert.isTrue(fieldBinding.isField());
	fMemberBinding= fieldBinding;
}
 
Example 16
Source File: CodeStyleFix.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public boolean visit(final FieldAccess node) {
	if (!fRemoveFieldQualifiers)
		return true;

	Expression expression= node.getExpression();
	if (!(expression instanceof ThisExpression))
		return true;

	final SimpleName name= node.getName();
	if (hasConflict(expression.getStartPosition(), name, ScopeAnalyzer.VARIABLES | ScopeAnalyzer.CHECK_VISIBILITY))
		return true;

	Name qualifier= ((ThisExpression) expression).getQualifier();
	if (qualifier != null) {
		ITypeBinding outerClass= (ITypeBinding) qualifier.resolveBinding();
		if (outerClass == null)
			return true;

		IVariableBinding nameBinding= (IVariableBinding) name.resolveBinding();
		if (nameBinding == null)
			return true;

		ITypeBinding variablesDeclaringClass= nameBinding.getDeclaringClass();
		if (outerClass != variablesDeclaringClass)
			//be conservative: We have a reference to a field of an outer type, and this type inherited
			//the field. It's possible that the inner type inherits the same field. We must not remove
			//the qualifier in this case.
			return true;
		
		ITypeBinding enclosingTypeBinding= Bindings.getBindingOfParentType(node);
		if (enclosingTypeBinding == null || Bindings.isSuperType(variablesDeclaringClass, enclosingTypeBinding))
			//We have a reference to a field of an outer type, and this type inherited
			//the field. The inner type inherits the same field. We must not remove
			//the qualifier in this case.
			return true;
	}

	fOperations.add(new CompilationUnitRewriteOperation() {
		@Override
		public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel model) throws CoreException {
			ASTRewrite rewrite= cuRewrite.getASTRewrite();
			TextEditGroup group= createTextEditGroup(FixMessages.CodeStyleFix_removeThis_groupDescription, cuRewrite);
			rewrite.replace(node, rewrite.createCopyTarget(name), group);
		}
	});
	return super.visit(node);
}
 
Example 17
Source File: MoveInstanceMethodProcessor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
@Override
public final boolean visit(final SimpleName node) {
	Assert.isNotNull(node);
	final AST ast= node.getAST();
	final ASTRewrite rewrite= fRewrite;
	final IBinding binding= node.resolveBinding();
	if (binding instanceof ITypeBinding) {
		ITypeBinding type= (ITypeBinding) binding;
		String name= fTargetRewrite.getImportRewrite().addImport(type.getTypeDeclaration());
		if (name != null && name.indexOf('.') != -1) {
			fRewrite.replace(node, ASTNodeFactory.newName(ast, name), null);
			return false;
		}
	}
	if (Bindings.equals(fTarget, binding))
		if (fAnonymousClass > 0) {
			final ThisExpression target= ast.newThisExpression();
			target.setQualifier(ast.newSimpleName(fTargetType.getElementName()));
			fRewrite.replace(node, target, null);
		} else
			rewrite.replace(node, ast.newThisExpression(), null);
	else if (binding instanceof IVariableBinding) {
		final IVariableBinding variable= (IVariableBinding) binding;
		final IMethodBinding method= fDeclaration.resolveBinding();
		ITypeBinding declaring= variable.getDeclaringClass();
		if (method != null) {
			if (declaring != null && Bindings.isSuperType(declaring, method.getDeclaringClass(), false)) {
				declaring= declaring.getTypeDeclaration();
				if (JdtFlags.isStatic(variable))
					rewrite.replace(node, ast.newQualifiedName(ASTNodeFactory.newName(ast, fTargetRewrite.getImportRewrite().addImport(declaring)), ast.newSimpleName(node.getFullyQualifiedName())), null);
				else {
					final FieldAccess access= ast.newFieldAccess();
					access.setExpression(ast.newSimpleName(fTargetName));
					access.setName(ast.newSimpleName(node.getFullyQualifiedName()));
					rewrite.replace(node, access, null);
				}
			} else if (!(node.getParent() instanceof QualifiedName) && JdtFlags.isStatic(variable) && !fStaticImports.contains(variable) && !Checks.isEnumCase(node.getParent())) {
				rewrite.replace(node, ast.newQualifiedName(ASTNodeFactory.newName(ast, fTargetRewrite.getImportRewrite().addImport(declaring)), ast.newSimpleName(node.getFullyQualifiedName())), null);
			}
		}
	}
	return false;
}
 
Example 18
Source File: SystemObject.java    From JDeodorant with MIT License 4 votes vote down vote up
private void inheritanceHierarchyMatchingWithStaticTypes(TypeCheckElimination typeCheckElimination,
		CompleteInheritanceDetection inheritanceDetection) {
	List<SimpleName> staticFields = typeCheckElimination.getStaticFields();
	String abstractClassType = typeCheckElimination.getAbstractClassType();
	InheritanceTree tree = null;
	if(abstractClassType != null)
		tree = inheritanceDetection.getTree(abstractClassType);
	if(tree != null) {
		DefaultMutableTreeNode rootNode = tree.getRootNode();
		DefaultMutableTreeNode leaf = rootNode.getFirstLeaf();
		List<String> inheritanceHierarchySubclassNames = new ArrayList<String>();
		while(leaf != null) {
			inheritanceHierarchySubclassNames.add((String)leaf.getUserObject());
			leaf = leaf.getNextLeaf();
		}
		int matchCounter = 0;
		for(SimpleName staticField : staticFields) {
			for(String subclassName : inheritanceHierarchySubclassNames) {
				ClassObject classObject = getClassObject(subclassName);
				AbstractTypeDeclaration abstractTypeDeclaration = classObject.getAbstractTypeDeclaration();
				if(abstractTypeDeclaration instanceof TypeDeclaration) {
					TypeDeclaration typeDeclaration = (TypeDeclaration)abstractTypeDeclaration;
					Javadoc javadoc = typeDeclaration.getJavadoc();
					if(javadoc != null) {
						List<TagElement> tagElements = javadoc.tags();
						for(TagElement tagElement : tagElements) {
							if(tagElement.getTagName() != null && tagElement.getTagName().equals(TagElement.TAG_SEE)) {
								List<ASTNode> fragments = tagElement.fragments();
								for(ASTNode fragment : fragments) {
									if(fragment instanceof MemberRef) {
										MemberRef memberRef = (MemberRef)fragment;
										IBinding staticFieldNameBinding = staticField.resolveBinding();
										ITypeBinding staticFieldNameDeclaringClass = null;
										if(staticFieldNameBinding != null && staticFieldNameBinding.getKind() == IBinding.VARIABLE) {
											IVariableBinding staticFieldNameVariableBinding = (IVariableBinding)staticFieldNameBinding;
											staticFieldNameDeclaringClass = staticFieldNameVariableBinding.getDeclaringClass();
										}
										if(staticFieldNameBinding.getName().equals(memberRef.getName().getIdentifier()) &&
												staticFieldNameDeclaringClass.getQualifiedName().equals(memberRef.getQualifier().getFullyQualifiedName())) {
											typeCheckElimination.putStaticFieldSubclassTypeMapping(staticField, subclassName);
											matchCounter++;
											break;
										}
									}
								}
							}
						}
					}
				}
			}
		}
		if(matchCounter == staticFields.size()) {
			typeCheckElimination.setInheritanceTreeMatchingWithStaticTypes(tree);
			return;
		}
	}
}
 
Example 19
Source File: JdtUtils.java    From j2cl with Apache License 2.0 4 votes vote down vote up
private static boolean isArrayLengthBinding(IVariableBinding variableBinding) {
  return variableBinding.getName().equals("length")
      && variableBinding.isField()
      && variableBinding.getDeclaringClass() == null;
}