Refine search
@Override public ConstructorDeclaration doMerge(ConstructorDeclaration first, ConstructorDeclaration second) { ConstructorDeclaration cd = new ConstructorDeclaration(); cd.setName(first.getName()); cd.setJavaDoc(mergeSingle(first.getJavaDoc(), second.getJavaDoc())); cd.setModifiers(mergeModifiers(first.getModifiers(), second.getModifiers())); cd.setAnnotations(mergeCollections(first.getAnnotations(), second.getAnnotations())); cd.setParameters(mergeCollectionsInOrder(first.getParameters(), second.getParameters())); cd.setTypeParameters(mergeCollectionsInOrder(first.getTypeParameters(), second.getTypeParameters())); cd.setThrows(mergeListNoDuplicate(first.getThrows(), second.getThrows(), false)); cd.setBlock(mergeSingle(first.getBlock(), second.getBlock())); return cd; }
@Override public int getNumberOfSpecifiedExceptions() { return wrappedNode.getThrownExceptions().size(); }
@Override public List<Parameter> parametersExposedToChild(Node child) { if (child == wrappedNode.getBody()) { return wrappedNode.getParameters(); } return Collections.emptyList(); }
@Override public boolean doIsEquals(ConstructorDeclaration first, ConstructorDeclaration second) { if (!StringUtils.equals(first.getName(), second.getName())) return false; if (!isParametersEquals(first.getParameters(), second.getParameters())) return false; if (!isTypeParameterEquals(first.getTypeParameters(), second.getTypeParameters())) return false; return true; } }
@Override public int getNumberOfParams() { return this.wrappedNode.getParameters().size(); }
public void index(ConstructorDeclaration constructorDeclaration, int typeId) { List<Parameter> parameters = constructorDeclaration.getParameters(); String name = constructorDeclaration.getNameAsString(); int methodId = methodDao.save(new Method(name, constructorDeclaration.isPublic(), constructorDeclaration.isStatic(), constructorDeclaration.isFinal(), constructorDeclaration.isAbstract(), true, typeId)); for (Parameter parameter : parameters) { parameterIndexer.index(parameter, methodId); } }
@Override public void visit(ConstructorDeclaration n, A arg) { HashSet<String> blockVariables = newHashSet(); this.localVariables.addLast(blockVariables); try { for (Parameter parameter : emptyIfNull(n.getParameters())) { blockVariables.add(parameter.getId().getName()); } for (AnnotationExpr annotationExpr : emptyIfNull(n.getAnnotations())) { annotationExpr.accept(this, arg); } BlockStmt body = n.getBlock(); if (body != null) { visit(body, arg); } } finally { this.localVariables.removeLast(); } }
&& ctx.kind.equals(SearchKind.METHOD)) { final ConstructorDeclaration declaration = (ConstructorDeclaration) member; final SimpleName simpleName = declaration.getName(); final String name = simpleName.getIdentifier(); final Optional<Position> begin = simpleName.getBegin(); if (name.equals(ctx.name) && begin.isPresent()) { final Position position = begin.get(); final List<Parameter> parameters = declaration.getParameters(); final Position pos = constructor.getName().getBegin().get(); return new Location(targetFile.getCanonicalPath(), pos.line, pos.column);
@Override public List<ResolvedTypeParameterDeclaration> getTypeParameters() { return this.wrappedNode.getTypeParameters().stream().map((astTp) -> new JavaParserTypeParameter(astTp, typeSolver)).collect(Collectors.toList()); }
return NameRole.REFERENCE; if (whenParentIs(ConstructorDeclaration.class, name, (p, c) -> p.getName() == c)) { return NameRole.REFERENCE; return NameRole.REFERENCE; if (whenParentIs(ConstructorDeclaration.class, name, (p, c) -> p.getName() == c || p.getThrownExceptions().contains(c))) { return NameRole.REFERENCE;
@Test public void constructorDeclarationResolve() throws IOException { File f = adaptPath(new File("src/test/resources/javaparser_new_src/javaparser-core/com/github/javaparser/ast/CompilationUnit.java")); CompilationUnit cu = parseWithSymbolResolution(f); ClassOrInterfaceDeclaration classOrInterfaceDeclaration = (ClassOrInterfaceDeclaration)cu.getType(0); ConstructorDeclaration constructorDeclaration = classOrInterfaceDeclaration.getDefaultConstructor().get(); ResolvedConstructorDeclaration resolvedConstructorDeclaration = constructorDeclaration.resolve(); } @Test
CompilationUnit cu = JavaParser.parse(file); List<TypeDeclaration> typeDeclarations = cu.getTypes(); for (TypeDeclaration typeDec : typeDeclarations) { List<BodyDeclaration> members = typeDec.getMembers(); if(members != null) { for (BodyDeclaration member : members) { if (member instanceof ConstructorDeclaration) { ConstructorDeclaration constructor = (ConstructorDeclaration) member; //Put your code here //The constructor instance contains all the information about it. constructor.getBeginLine(); //begin line constructor.getBlock(); //constructor body } } } }
@Override public AccessSpecifier accessSpecifier() { return Helper.toAccessLevel(wrappedNode.getModifiers()); }
@Override public int getNumberOfParams() { return this.wrappedNode.getParameters().size(); }
ConstructorDeclaration cdOne = (ConstructorDeclaration) outer; ConstructorDeclaration cdTwo = (ConstructorDeclaration) inner; if (cdOne.getName().equals(cdTwo.getName()) && isParametersEquals(cdOne.getParameters(), cdTwo.getParameters()) && isListEquals(cdOne.getTypeParameters(), cdTwo.getTypeParameters())) {
return; List<Parameter> ps = n.getParameters(); NodeList<Statement> stmts = n.getBody().getStatements(); if (!(stmts.get(0) instanceof ExplicitConstructorInvocationStmt)) { recordBadConstructor("missing super call");
@Override public void visit(ConstructorDeclaration n, A arg) { this.definedTypeParameters.addLast(getTypeParameterNames(n.getTypeParameters())); try { super.visit(n, arg); } finally { this.definedTypeParameters.removeLast(); } }
if (whenParentIs(ConstructorDeclaration.class, name, (p, c) -> p.getName() == name)) { return true; p.getThrownExceptions().contains(c))) { return true;
ResolvedMethodLikeDeclaration resolvedMethodLikeDeclaration; if (callableDeclaration.isConstructorDeclaration()) { resolvedMethodLikeDeclaration = callableDeclaration.asConstructorDeclaration().resolve(); } else { resolvedMethodLikeDeclaration = callableDeclaration.asMethodDeclaration().resolve();