本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}