Java IVariableBinding.getDeclaringClass方法代码示例(javaivariablebinding.getdeclaringclass方法的典型用法代码示例)

本文整理汇总了Java中org.eclipse.jdt.core.dom.IVariableBinding.getDeclaringClass方法的典型用法代码示例。如果您正苦于以下问题:Java IVariableBinding.getDeclaringClass方法的具体用法?Java IVariableBinding.getDeclaringClass怎么用?Java IVariableBinding.getDeclaringClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jdt.core.dom.IVariableBinding的用法示例。


Java IVariableBinding.getDeclaringClass方法代码示例(javaivariablebinding.getdeclaringclass方法的典型用法代码示例)

在下文中一共展示了IVariableBinding.getDeclaringClass方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getEnclosingDeclaration

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
public static 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;
} 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:26,代码来源:ASTNodes.java

示例2: visit

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
@Override
public boolean visit(SimpleName node) {
	if (currentMethod == null)
		return false;
	IBinding binding = node.resolveBinding();
	if (binding == null)
		return false;
	if (node.isDeclaration())
		return true;
	if (node.resolveBinding() instanceof IVariableBinding) {
		IVariableBinding iVariableBinding = (IVariableBinding) node.resolveBinding();
		if (iVariableBinding.isField()) {
			IVariableBinding variableDeclarationBinding = iVariableBinding.getVariableDeclaration();
			if (variableDeclarationBinding.getDeclaringClass() != null) {
				IJavaElement accessedField = variableDeclarationBinding.getJavaElement();
				if (accessedField instanceof IField) {
					if (!((IField) accessedField).isReadOnly())
						methodDetails.addAccess((IField) accessedField);
				}
			}
		}
	}
	return true;
} 
开发者ID:ioanaverebi,项目名称:Sparrow,代码行数:25,代码来源:OutCodeVisitor.java

示例3: extractDataFromVariableBinding

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
/**
 * Extracts the fully qualified name from a variable binding and applies
 * them to the name in a SourceCodeEntity.
 * @param binding The variable binding.
 * @param sce SourceCodeEntity to which to apply changes. Name must be set
 *            to the entity's unqualified name.
 */
private static void extractDataFromVariableBinding(
        IVariableBinding binding, SourceCodeEntity sce) {
    if (binding != null) {
        //Type member variable.
        ITypeBinding type = binding.getDeclaringClass();
        if (type != null)
            sce.name = type.getQualifiedName() + "." + sce.name;
        //Variable declared in method.
        else {
            IMethodBinding method = binding.getDeclaringMethod();
            if (method != null) {
                type = method.getDeclaringClass();
                if (type != null) {
                    sce.name = type.getQualifiedName() + "."
                             + method.getName() + "." + sce.name;
                } else
                    sce.name = "?." + method.getName() + "." + sce.name;
            } else
                sce.name = "?." + sce.name;
        }
    } else {
        //If binding fails, mark the qualification as "?" to show it could
        //not be determined.
        sce.name = "?." + sce.name;
    }
} 
开发者ID:SERESLab,项目名称:iTrace-Archive,代码行数:34,代码来源:AstManager.java

示例4: visitNameNode

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
private boolean visitNameNode(Name node) {
	IBinding binding = node.resolveBinding();
	if (binding instanceof IVariableBinding) {
		IVariableBinding variableBindig = (IVariableBinding) binding;
		if (variableBindig.isField()) {
			ITypeBinding declaringClass = variableBindig.getDeclaringClass();
			handleTypeBinding(node, declaringClass, false);
			handleFieldBinding(node, variableBindig);
		} else if (!variableBindig.isEnumConstant()) {
			handleVariableBinding(node, variableBindig);
		}
	}
	return true;
} 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:15,代码来源:DependenciesAstVisitor.java

示例5: handleFieldBinding

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
private void handleFieldBinding(ASTNode node, IVariableBinding variableBindig) {
	if (variableBindig == null) {
		StructuralPropertyDescriptor locationInParent = node.getLocationInParent();
		//System.out.println(locationInParent.getId() + " has no field binding");
	} else {
		ITypeBinding declaringClass = variableBindig.getDeclaringClass();
		if (declaringClass != null && !this.ignoreType(declaringClass)) {
			this.onFieldAccess(node, variableBindig);
		}
	}
} 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:12,代码来源:DependenciesAstVisitor.java

示例6: asString

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
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();
} 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:15,代码来源:Bindings.java

示例7: findNullnessDefault

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
/**
 * Answer the annotation binding representing a nullness default
 * effective at the point denoted by 'contextBinding'.
 * @param contextBinding method binding or type binding denoting the location of interest
 * @param javaProject the containing java project, consulted for the actual name of
 *  the annotation used for nullness defaults (default: <code>@NonNullByDefault</code>).
 * @return binding for the effective nullness default annotation
 * 	or null if no nullness default is effective at the context location.
 */
public static IAnnotationBinding findNullnessDefault(IBinding contextBinding, IJavaProject javaProject) {
	if (JavaCore.ENABLED.equals(javaProject.getOption(JavaCore.COMPILER_ANNOTATION_NULL_ANALYSIS, true))) {
		String annotationName= javaProject.getOption(JavaCore.COMPILER_NONNULL_BY_DEFAULT_ANNOTATION_NAME, true);
		while (contextBinding != null) {
			for (IAnnotationBinding annotation : contextBinding.getAnnotations()) {
				ITypeBinding annotationType= annotation.getAnnotationType();
				if (annotationType != null && annotationType.getQualifiedName().equals(annotationName)) {
					return annotation;
				}
			}
			// travel out:
			switch (contextBinding.getKind()) {
			case IBinding.METHOD:
				IMethodBinding methodBinding= (IMethodBinding) contextBinding;
				contextBinding= methodBinding.getDeclaringMember();
				if (contextBinding == null) {
					contextBinding= methodBinding.getDeclaringClass();
				}
				break;
			case IBinding.VARIABLE:
				IVariableBinding variableBinding= (IVariableBinding) contextBinding;
				contextBinding= variableBinding.getDeclaringMethod();
				if (contextBinding == null) {
					contextBinding= variableBinding.getDeclaringClass();
				}
				break;
			case IBinding.TYPE:
				ITypeBinding currentClass= (ITypeBinding) contextBinding;
				contextBinding= currentClass.getDeclaringMember();
				if (contextBinding == null) {
					contextBinding= currentClass.getDeclaringMethod();
					if (contextBinding == null) {
						contextBinding= currentClass.getDeclaringClass();
						if (contextBinding == null) {
							contextBinding= currentClass.getPackage();
						}
					}
				}
				break;
			default:
				contextBinding= null;
				break;
			}
		}
	}
	return null;
} 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:57,代码来源:Bindings.java

示例8: SelfEncapsulateFieldProposal

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
public SelfEncapsulateFieldProposal(String label, ICompilationUnit targetCU, ASTNode invocationNode, IVariableBinding binding, IField field, int relevance) {
	super(label, targetCU, null, relevance);

	this.fField = field;
	this.fVariableBinding = binding;
	this.fSenderBinding = binding.getDeclaringClass();
	this.fNode = invocationNode;
} 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:9,代码来源:SelfEncapsulateFieldProposal.java

示例9: getEnclosingFieldType

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
private Type getEnclosingFieldType(IVariableBinding typeBindingFeild) {

		Type declaringType = null;
		if (typeBindingFeild != null) {
			enclosingTypeField = typeBindingFeild.getDeclaringClass();
			if (enclosingTypeField != null) {
				declaringType = typeInfo.getType(enclosingTypeField.getQualifiedName());

			}
		}
		return declaringType;
	} 
开发者ID:aroog,项目名称:code,代码行数:13,代码来源:C_AllMetrics.java

示例10: apply

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
@Override
public boolean apply(TM tm, TMSolutionType solIndex){
	boolean isHeuristicApplied = false;
	boolean isPublicParam = false;
	Set<Entry<Variable, Set<OType>>> entrySet = tm.entrySet();
	Set<OType> newSourceTyping = new HashSet<OType>();
	// XXX. Can we replace iteration with just 1 lookup: entrySet.get()?
	for (Entry<Variable, Set<OType>> entry : entrySet) {
		Variable var = entry.getKey();	
		if(var.equals(this.changedVar) /*au.isTypeEqual(auType) && au.isEnclosingTypeEqual(auEnclosingType)*/){
			ITypeBinding declaringClassTypeBinding = null;
			if(var instanceof TACVariable || var instanceof SourceVariable){
   				Variable srcVariable = null;
   				IVariableBinding srcVariableBinding = null;
   				if(var instanceof TACVariable){
   					srcVariable = (TACVariable)var;
   					srcVariableBinding = ((TACVariable)srcVariable).getVarDecl();
   					declaringClassTypeBinding = srcVariableBinding.getDeclaringClass();
   				}
   				else{
   					srcVariable = (SourceVariable)var;
   					srcVariableBinding = ((SourceVariable)srcVariable).getBinding();
   					declaringClassTypeBinding = srcVariableBinding.getDeclaringMethod().getDeclaringClass();
   				}
   				boolean isMain = declaringClassTypeBinding.getQualifiedName().equals(Config.MAINCLASS);
   				String solAlpha = SolutionManager.getSolution(solIndex, this.getRefinementType(), isMain);
   				if(solAlpha != null ) {
   					OType newSrcTyping = null;
   					ITypeBinding sourceType = srcVariableBinding.getType();
   					if(sourceType.isParameterizedType()){
   						newSourceTyping = tm.initParametrizedTypeMapping("this.owned",isMain);
   					}
   					else{
   						newSrcTyping = new OType("this.owned", solAlpha);
   						newSourceTyping.add(newSrcTyping);
   					}
   					Set<OType> analysisResult = new HashSet<OType>(newSourceTyping);
   					tm.putTypeMapping(var, analysisResult);

   					// Record the AU being modified directly based on the refinement
   					//this.addAU(au);
   					this.putVariableMap(var, "this.owned");

   					// Record the new set of typings
   					this.setNewTyping(solIndex, newSrcTyping); 

   					isHeuristicApplied = true;
   					break;
   				}
			}
		}
	}

	return isHeuristicApplied;
} 
开发者ID:aroog,项目名称:code,代码行数:56,代码来源:InferOwnedHeuristic.java

示例11: apply

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
@Override
public boolean apply(TM tm, TMSolutionType solIndex){
	boolean isHeuristicApplied = false;
	Set<Entry<Variable, Set<OType>>> entrySet = tm.entrySet();
	Set<OType> newSourceTyping = new HashSet<OType>();
	for (Entry<Variable, Set<OType>> entry : entrySet) {
		Variable au = entry.getKey();
		if(au instanceof SourceVariable || au instanceof TACVariable){
			ITypeBinding declaringClassTypeBinding = null;
			Variable srcVariable = null;
			IVariableBinding srcVariableBinding = null;
			if(au instanceof TACVariable){
				srcVariable = (TACVariable)au;
				srcVariableBinding = ((TACVariable)srcVariable).getVarDecl();
				declaringClassTypeBinding = srcVariableBinding.getDeclaringClass();
			}
			else{
				srcVariable = (SourceVariable)au;
				srcVariableBinding = ((SourceVariable)srcVariable).getBinding();
				declaringClassTypeBinding = srcVariableBinding.getDeclaringMethod().getDeclaringClass();
			}

			if(srcVariable.equals(this.changedVar) ){
				boolean isMain = declaringClassTypeBinding.getQualifiedName().equals(Config.MAINCLASS);
				String solAlpha = SolutionManager.getSolution(solIndex, this.getRefinementType(),isMain);
				if(solAlpha!=null){
					OType newSrcTyping = null;
					ITypeBinding sourceType = srcVariableBinding.getType();
					if(sourceType.isParameterizedType()){
						newSourceTyping = tm.initParametrizedTypeMapping("this.PD",isMain);
					}
					else{
						newSrcTyping = new OType("this.PD", solAlpha);
						newSourceTyping.add(newSrcTyping);
					}
					Set<OType> analysisResult = new HashSet<OType>(newSourceTyping);
					tm.putTypeMapping(srcVariable, analysisResult);

					// Record the AU being modified directly based on the refinement
					this.putVariableMap(srcVariable, "this.PD");

					// Record the new set of typings
					this.setNewTyping(solIndex,newSrcTyping); 

					isHeuristicApplied = true;
				}
			}
		}
	}

	return isHeuristicApplied;

} 
开发者ID:aroog,项目名称:code,代码行数:54,代码来源:InferPDHeuristic.java

示例12: apply

import org.eclipse.jdt.core.dom.IVariableBinding; //导入方法依赖的package包/类
@Override
public boolean apply(TM tm, TMSolutionType solIndex){
	boolean isHeuristicApplied = false;
	boolean isPublicParam = false;
	Set<Entry<Variable, Set<OType>>> entrySet = tm.entrySet();
	Set<OType> newSourceTyping = new HashSet<OType>();
	// XXX. Can we replace iteration with just 1 lookup: entrySet.get()?
	for (Entry<Variable, Set<OType>> entry : entrySet) {
		ITypeBinding declaringClassTypeBinding = null;
		Variable var = entry.getKey();	
		if(var.equals(this.changedVar) /*au.isTypeEqual(auType) && au.isEnclosingTypeEqual(auEnclosingType)*/){
			
			if(var instanceof TACVariable || var instanceof SourceVariable){
   				Variable srcVariable = null;
   				IVariableBinding srcVariableBinding = null;
   				if(var instanceof TACVariable){
   					srcVariable = (TACVariable)var;
   					srcVariableBinding = ((TACVariable)srcVariable).getVarDecl();
   					declaringClassTypeBinding = srcVariableBinding.getDeclaringClass();
   				}
   				else{
   					srcVariable = (SourceVariable)var;
   					srcVariableBinding = ((SourceVariable)srcVariable).getBinding();
   					declaringClassTypeBinding = srcVariableBinding.getDeclaringMethod().getDeclaringClass();
   				}
   				boolean isMain = declaringClassTypeBinding.getQualifiedName().equals(Config.MAINCLASS);
   				String solAlpha = SolutionManager.getSolution(solIndex, this.getRefinementType(), isMain);
   				if(solAlpha != null ) {
   					OType newSrcTyping = null;
   					ITypeBinding sourceType = srcVariableBinding.getType();
   					if(sourceType.isParameterizedType()){
   						newSourceTyping = tm.initParametrizedTypeMapping("owner",isMain);
   					}
   					else{
   						newSrcTyping = new OType("owner", solAlpha);
   						newSourceTyping.add(newSrcTyping);
   					}
   					Set<OType> analysisResult = new HashSet<OType>(newSourceTyping);
   					tm.putTypeMapping(var, analysisResult);

   					// Record the AU being modified directly based on the refinement
   					//this.addAU(au);
   					this.putVariableMap(var, "owner");

   					// Record the new set of typings
   					this.setNewTyping(solIndex, newSrcTyping); 

   					isHeuristicApplied = true;
   					break;
   				}
			}
		}
	}

	return isHeuristicApplied;
} 
开发者ID:aroog,项目名称:code,代码行数:57,代码来源:InferOwnerHeuristic.java

本文标签属性:

示例:示例英文

代码:代码大全可复制

java:javascript18岁

IVariableBinding:IVariableBinding

getDeclaringClass:getDeclaringClass

上一篇:PHP Http::sendHttpRequestBy方法代码示例(php中piwik\u005chttp10个代码示例汇总)
下一篇:呼伦贝尔现大量飞虫(呼伦贝尔 飞虫)(呼伦贝尔旅游需要注意什么?)

为您推荐