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


Java MethodDeclaration.isConstructor方法代码示例

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


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

示例1: createMethod

import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
public RastNode createMethod(String methodSignature, HasChildrenNodes parent, String sourceFilePath, boolean constructor, MethodDeclaration ast) {
	String methodName = ast.isConstructor() ? "" : ast.getName().getIdentifier();
	RastNode rastNode = new RastNode(++nodeCounter);
	rastNode.setType(ast.getClass().getSimpleName());
	
	Block body = ast.getBody();
	int bodyStart;
	int bodyLength;
       if (body == null) {
           rastNode.addStereotypes(Stereotype.ABSTRACT);
           bodyStart = ast.getStartPosition() + ast.getLength();
           bodyLength = 0;
       } else {
       	bodyStart = body.getStartPosition();
           bodyLength = body.getLength();
       }
       rastNode.setLocation(new Location(sourceFilePath, ast.getStartPosition(), ast.getStartPosition() + ast.getLength(), bodyStart, bodyStart + bodyLength));
	rastNode.setLocalName(methodSignature);
	rastNode.setSimpleName(methodName);
	parent.addNode(rastNode);
	keyMap.put(JavaParser.getKey(rastNode), rastNode);
	return rastNode;
}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:24,代码来源:SDModel.java

示例2: getSignatureFromMethodDeclaration

import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
public static String getSignatureFromMethodDeclaration(MethodDeclaration methodDeclaration) {
		String methodName = methodDeclaration.isConstructor() ? "" : methodDeclaration.getName().getIdentifier();
//		if (methodName.equals("allObjectsSorted")) {
//			System.out.println();
//		}
		StringBuilder sb = new StringBuilder();
		sb.append(methodName);
		sb.append('(');
		@SuppressWarnings("unchecked")
        Iterator<SingleVariableDeclaration> parameters = methodDeclaration.parameters().iterator();
		while (parameters.hasNext()) {
			SingleVariableDeclaration parameter = parameters.next();
			Type parameterType = parameter.getType();
			String typeName = normalizeTypeName(parameterType, parameter.getExtraDimensions(), parameter.isVarargs());
			sb.append(typeName);
			if (parameters.hasNext()) {
				sb.append(", ");
			}
		}
		sb.append(')');
		String methodSignature = sb.toString();
		return methodSignature;
	}
 
开发者ID:aserg-ufmg,项目名称:RefDiff,代码行数:24,代码来源:AstUtils.java

示例3: visit

import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration node) {
	boolean instanceMember = !node.isConstructor() && !Modifier.isStatic(node.getModifiers());
	if(((TypeDeclaration) node.getParent()).isPackageMemberTypeDeclaration()) {
		AssignmentVisitor v = new AssignmentVisitor();
		node.accept(v);
		if(instanceMember) {
			MethodInfo m = new MethodInfo(
					node.getName().getIdentifier(), 
					VisibilityInfo.from(node), 
					node.getReturnType2().resolveBinding().isParameterizedType() ? Object.class.toString() : node.getReturnType2().resolveBinding().getQualifiedName(), 
							v.params,
							v.containsFieldAssignments);
			info.addMethod(m);
		}
	}
	return false;
}
 
开发者ID:andre-santos-pt,项目名称:pandionj,代码行数:19,代码来源:Visitor.java

示例4: hasConstructor

import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
public static boolean hasConstructor(TypeDeclaration typeDecl, Map<ast.Type, TypeDeclaration> types,
		QualifiedClassName cThis) {
	boolean hasConstr = false;
	if (!hasFieldInitializers(typeDecl))
		hasConstr = true;
	else {
		for (MethodDeclaration md : typeDecl.getMethods()) {
			if (md.isConstructor())
				hasConstr = true;
		}
	}
	Type superclassType = typeDecl.getSuperclassType();
	if (superclassType == null)
		return hasConstr;
	if (superclassType.resolveBinding().getQualifiedName().equals(Utils.JAVA_LANG_OBJECT))
		return hasConstr;
	TypeDeclaration superTypeDecl = types.get(new QualifiedClassName(superclassType.resolveBinding(), cThis)
			.getType());
	if (superTypeDecl != null) {
		hasConstr = hasConstr && hasConstructor(superTypeDecl, types, cThis);
	}
	return hasConstr;

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

示例5: visit

import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration node) {
	if (!isAffected(node)) {
		return false;
	}
	doVisitNode(node.getJavadoc());

	doVisitChildren(node.modifiers());
	doVisitChildren(node.typeParameters());

	if (!node.isConstructor()) {
		doVisitNode(node.getReturnType2());
	}
	// name not visited

	int apiLevel= node.getAST().apiLevel();
	if (apiLevel >= AST.JLS8) {
		doVisitNode(node.getReceiverType());
	}
	// receiverQualifier not visited:
	//   Enclosing class names cannot be shadowed by an import (qualification is always redundant).
	doVisitChildren(node.parameters());
	if (apiLevel >= AST.JLS8) {
		doVisitChildren(node.extraDimensions());
		doVisitChildren(node.thrownExceptionTypes());
	} else {
		Iterator<Name> iter= getThrownExceptions(node).iterator();
		while (iter.hasNext()) {
			typeRefFound(iter.next());
		}
	}
	if (!fSkipMethodBodies) {
		doVisitNode(node.getBody());
	}
	return false;
}
 
开发者ID:eclipse,项目名称:eclipse.jdt.ls,代码行数:37,代码来源:ImportReferencesCollector.java

示例6: visit

import org.eclipse.jdt.core.dom.MethodDeclaration; //导入方法依赖的package包/类
@Override
public boolean visit(MethodDeclaration methodDecl) {

	int modifiers = methodDecl.getModifiers();
	if(Modifier.isPublic(modifiers) && !methodDecl.isConstructor() && !methodDecl.getReturnType2().isPrimitiveType()){
		Block body = methodDecl.getBody();
		if(body!=null){
			List<Statement> statements = body.statements();
			for (Statement stmnt : statements) {
				if(stmnt instanceof ReturnStatement){
					ReturnStatement retStmnt = (ReturnStatement)stmnt;
					Expression expression = retStmnt.getExpression();
					if(expression instanceof SimpleName){
						SimpleName simpleExpr = (SimpleName)expression;
						IBinding resolveBinding = simpleExpr.resolveBinding();
						Variable variable = context.getAllBindingKeyToVariableMap(resolveBinding.getKey());
						if(variable!=null){
							context.removeEncapsulatedVariable(variable);
						}
					}
				}
			}
		}

	}

	return super.visit(methodDecl);
	 
}
 
开发者ID:aroog,项目名称:code,代码行数:30,代码来源:HeuristicOwnedLocalsVisitor.java


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