当前位置: 首页>>代码示例>>Java>>正文


Java SimpleName类代码示例

本文整理汇总了Java中org.eclipse.jdt.core.dom.SimpleName的典型用法代码示例。如果您正苦于以下问题:Java SimpleName类的具体用法?Java SimpleName怎么用?Java SimpleName使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SimpleName类属于org.eclipse.jdt.core.dom包,在下文中一共展示了SimpleName类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getLeftMostSimpleName

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
public static SimpleName getLeftMostSimpleName(Name name) {
	if (name instanceof SimpleName) {
		return (SimpleName)name;
	} else {
		final SimpleName[] result= new SimpleName[1];
		ASTVisitor visitor= new ASTVisitor() {
			@Override
			public boolean visit(QualifiedName qualifiedName) {
				Name left= qualifiedName.getQualifier();
				if (left instanceof SimpleName) {
					result[0]= (SimpleName)left;
				} else {
					left.accept(this);
				}
				return false;
			}
		};
		name.accept(visitor);
		return result[0];
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:ASTNodes.java

示例2: createDeclaration

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
private VariableDeclarationStatement createDeclaration(IVariableBinding binding, Expression intilizer) {
	VariableDeclaration original = ASTNodes.findVariableDeclaration(binding, fAnalyzer.getEnclosingBodyDeclaration());
	VariableDeclarationFragment fragment = fAST.newVariableDeclarationFragment();
	fragment.setName((SimpleName) ASTNode.copySubtree(fAST, original.getName()));
	fragment.setInitializer(intilizer);
	VariableDeclarationStatement result = fAST.newVariableDeclarationStatement(fragment);
	result.modifiers().addAll(ASTNode.copySubtrees(fAST, ASTNodes.getModifiers(original)));
	result.setType(ASTNodeFactory.newType(fAST, original, fImportRewriter, new ContextSensitiveImportRewriteContext(original, fImportRewriter)));
	return result;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:11,代码来源:ExtractMethodRefactoring.java

示例3: visit

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
public boolean visit(SimpleName node) {
	if (mtbStack.isEmpty() && !itbStack.isEmpty()) { // not part of a method
		return false;
		/*
		 * try { return visitName(node.resolveBinding(),
		 * anonClassName.equals("")?getQualifiedName(itb):anonClassName); }
		 * catch (Exception e) {
		 * System.err.println("Cannot resolve simple name \""
		 * +node.getFullyQualifiedName().toString()+"\""); return false; }
		 */
	} else if (!mtbStack.isEmpty()) {
		if (node.getIdentifier().equals("length"))
			return false;
		try {
			return visitName(node.resolveBinding(), mtbStack.peek());
		} catch (Exception e) {
			System.err.println("Cannot resolve simple name \""
					+ node.getFullyQualifiedName().toString() + "\"");
			return false;
		}
	}
	return false;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:24,代码来源:ASTVisitorAtomicChange.java

示例4: handleVarDeclaration

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
private void handleVarDeclaration(VariableDeclarationFragment var, boolean isField) {
	String varName = var.getName().getIdentifier();
	VariableInfo varInfo = current.addVar(varName, isField);
	Expression init = var.getInitializer();
	if(init instanceof SimpleName) {
		String initVar = ((SimpleName) init).getIdentifier();
		varInfo.addOperation(new VariableOperation(varName, VariableOperation.Type.INIT, initVar));
	}

}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:11,代码来源:VarParser.java

示例5: visit

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
@Override
public boolean visit(PostfixExpression exp) {
	if(exp.getOperand() instanceof SimpleName) {
		String varName = exp.getOperand().toString(); 
		VariableOperation op = null;
		if(exp.getOperator() == PostfixExpression.Operator.INCREMENT)
			op = new VariableOperation(varName, VariableOperation.Type.INC);

		else if(exp.getOperator() == PostfixExpression.Operator.DECREMENT)
			op = new VariableOperation(varName, VariableOperation.Type.DEC);

		if(op != null)
			current.addOperation(op);
	}
	return true;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:17,代码来源:VarParser.java

示例6: accessExpressions

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
private Object[] accessExpressions(ArrayAccess node) {
	Object[] exp = new Object[indexDepth(node)+1];
	ArrayAccess a = node;
	int i = exp.length-1;
	do {
		Expression indexExp = a.getIndex();
		if(!(indexExp instanceof SimpleName)) // TODO no modifiers
			return null;

		exp[i] = indexExp.toString();
		Expression temp = a.getArray();
		a = temp instanceof ArrayAccess ? (ArrayAccess) temp : null;
		i--;			
	}
	while(i >= 0);
	return exp;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:18,代码来源:VarParser.java

示例7: isAcumulationAssign

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
private static boolean isAcumulationAssign(Assignment assignment, InfixExpression.Operator op, Predicate<Expression> acceptExpression) {
	if(!(
			assignment.getRightHandSide() instanceof InfixExpression && 
			assignment.getLeftHandSide() instanceof SimpleName &&
			assignment.getOperator() == Assignment.Operator.ASSIGN))
		return false;

	InfixExpression exp = (InfixExpression) assignment.getRightHandSide();
	if(exp.getOperator() != op)
		return false;

	String assignVar = assignment.getLeftHandSide().toString();
	if(	exp.getLeftOperand() instanceof SimpleName &&
			exp.getLeftOperand().toString().equals(assignVar) &&
			acceptExpression.test(exp.getRightOperand()))
		return true;

	if(	exp.getRightOperand() instanceof SimpleName && 
			exp.getRightOperand().toString().equals(assignVar) &&
			acceptExpression.test(exp.getLeftOperand()))
		return true;

	return false;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:25,代码来源:VarParser.java

示例8: getNumberOfIndirectConnections

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
/**
 * Method to get the number of methods with indirect connections.
 * @author Mariana Azevedo
 * @since 13/07/2014
 * @param methodsWithDirectConn
 * @param itMethods
 */
private void getNumberOfIndirectConnections(List<MethodDeclaration> methodsWithDirectConn,
		Iterator<MethodDeclaration> itMethods){
	
	int i=0;
	while (itMethods.hasNext()){
	
		MethodDeclaration firstMethod = itMethods.next();
		if (firstMethod != null){
			Block firstMethodBody = firstMethod.getBody();
		
			if (firstMethodBody != null){
				SimpleName methodDeclaration = methodsWithDirectConn.get(i).getName();
				
				if (firstMethodBody.toString().contains(methodDeclaration.toString())){
					numIndirectConnections++;
				}
			}
		}
	}
}
 
开发者ID:mariazevedo88,项目名称:o3smeasures-tool,代码行数:28,代码来源:LooseClassCohesionVisitor.java

示例9: createStaticMethodInvocation

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
public MethodInvocation createStaticMethodInvocation(AST ast, String className, String methodName) {
    SimpleName typeName = ast.newSimpleName(className);

    MethodInvocation methodInvocation = ast.newMethodInvocation();
    methodInvocation.setName(ast.newSimpleName(methodName));
    methodInvocation.setExpression(typeName);

    return methodInvocation;
}
 
开发者ID:helospark,项目名称:SparkBuilderGenerator,代码行数:10,代码来源:StaticMethodInvocationFragment.java

示例10: getAssignedVariable

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
/**
 * Returns the binding of the variable written in an Assignment.
 * @param assignment The assignment
 * @return The binding or <code>null</code> if no bindings are available.
 */
public static IVariableBinding getAssignedVariable(Assignment assignment) {
	Expression leftHand = assignment.getLeftHandSide();
	switch (leftHand.getNodeType()) {
	case ASTNode.SIMPLE_NAME:
		return (IVariableBinding) ((SimpleName) leftHand).resolveBinding();
	case ASTNode.QUALIFIED_NAME:
		return (IVariableBinding) ((QualifiedName) leftHand).getName().resolveBinding();
	case ASTNode.FIELD_ACCESS:
		return ((FieldAccess) leftHand).resolveFieldBinding();
	case ASTNode.SUPER_FIELD_ACCESS:
		return ((SuperFieldAccess) leftHand).resolveFieldBinding();
	default:
		return null;
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:21,代码来源:Bindings.java

示例11: getLeftHandSideVarBinding

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
/**
 * for an assignment x = y returns the variable binding of x
 * 
 * @param varBinding
 * @param assignment
 * @return
 */
private static IVariableBinding getLeftHandSideVarBinding(Assignment assignment) {
	Expression leftHnsd = assignment.getLeftHandSide();
	if (leftHnsd instanceof SimpleName) {
		IBinding bind = ((SimpleName) leftHnsd).resolveBinding();
		if (bind instanceof IVariableBinding) {
			return ((IVariableBinding) bind).getVariableDeclaration();
		}
	}
	if (leftHnsd instanceof FieldAccess) {
		FieldAccess fa = (FieldAccess) leftHnsd;
		return fa.resolveFieldBinding();
	}
	// Leave it null - cannot determine actual domains for arrays
	// workaround for bugs related to objects created in complex expression
	// if (leftHnsd instanceof ArrayAccess) {
	// ArrayAccess aa = (ArrayAccess) leftHnsd;
	// return getArrayAccessVarBinding(aa);
	// }
	return null;
}
 
开发者ID:aroog,项目名称:code,代码行数:28,代码来源:Utils.java

示例12: visit

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
@Override
public boolean visit(MethodInvocation node) {
	Expression receiver = node.getExpression();
	if (receiver == null) {
		SimpleName name = node.getName();
		if (fIgnoreBinding == null || !Bindings.equals(fIgnoreBinding, name.resolveBinding())) {
			node.getName().accept(this);
		}
	} else {
		receiver.accept(this);
	}
	accept(node.arguments());
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:15,代码来源:CodeScopeBuilder.java

示例13: visit

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
@Override
public boolean visit(SimpleName node) {
	IBinding binding= node.resolveBinding();
	if (binding == null) {
		return false;
	}
	binding= getDeclaration(binding);

	if (fBinding == binding) {
		fResult.add(node);
	} else if (binding.getKind() != fBinding.getKind()) {
		return false;
	} else if (binding.getKind() == IBinding.METHOD) {
		IMethodBinding curr= (IMethodBinding) binding;
		IMethodBinding methodBinding= (IMethodBinding) fBinding;
		if (methodBinding.overrides(curr) || curr.overrides(methodBinding)) {
			fResult.add(node);
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:22,代码来源:LinkedNodeFinder.java

示例14: addStaticImports

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的package包/类
private void addStaticImports(
		Collection<SimpleName> staticReferences,
		ImportRewrite importRewrite,
		UnresolvableImportMatcher unresolvableImportMatcher) {
	for (SimpleName name : staticReferences) {
		IBinding binding= name.resolveBinding();
		if (binding != null) {
			importRewrite.addStaticImport(binding);
		} else {
			// This could be an unresolvable reference to a static member.
			String identifier= name.getIdentifier();
			Set<String> unresolvableImports= unresolvableImportMatcher.matchStaticImports(identifier);
			for (String unresolvableImport : unresolvableImports) {
				int lastDotIndex= unresolvableImport.lastIndexOf('.');
				// It's OK to skip invalid imports.
				if (lastDotIndex != -1) {
					String declaringTypeName= unresolvableImport.substring(0, lastDotIndex);
					String simpleName= unresolvableImport.substring(lastDotIndex + 1);
					// Whether name refers to a field or to a method is unknown.
					boolean isField= false;
					importRewrite.addStaticImport(declaringTypeName, simpleName, isField, UNRESOLVABLE_IMPORT_CONTEXT);
				}
			}
		}
	}
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:27,代码来源:OrganizeImportsOperation.java

示例15: visit

import org.eclipse.jdt.core.dom.SimpleName; //导入依赖的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


注:本文中的org.eclipse.jdt.core.dom.SimpleName类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。