當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。