Java Code Examples for com.github.javaparser.ast.body.ClassOrInterfaceDeclaration#getName()
The following examples show how to use
com.github.javaparser.ast.body.ClassOrInterfaceDeclaration#getName() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MethodBoundaryExtractor.java From scott with MIT License | 6 votes |
private boolean isInTheCorrectClass(MethodDeclaration methodDeclaration) { Node n = methodDeclaration; String containingClassName = ""; while (n != null) { if (n instanceof ClassOrInterfaceDeclaration) { ClassOrInterfaceDeclaration c = (ClassOrInterfaceDeclaration) n; containingClassName = c.getName() + "$" + containingClassName; } Optional<Node> no = n.getParentNode(); if (no.isEmpty()) { n = null; } else { n = no.get(); } } containingClassName = containingClassName.substring(0, containingClassName.length() - 1); return containingClassName.equals(className); }
Example 2
Source File: ParameterNameVisitor.java From meghanada-server with GNU General Public License v3.0 | 5 votes |
@Override public void visit(ClassOrInterfaceDeclaration n, Object arg) { super.visit(n, arg); NodeList<Modifier> modifiers = n.getModifiers(); if (!modifiers.contains(Modifier.privateModifier())) { final List<BodyDeclaration<?>> members = n.getMembers(); final SimpleName simpleName = n.getName(); final String clazz = simpleName.getId(); // String clazz = n.getName(); this.className = this.pkg + '.' + clazz; log.debug("class {}", this.className); int i = 0; for (final BodyDeclaration<?> body : members) { if (body instanceof MethodDeclaration) { MethodDeclaration methodDeclaration = (MethodDeclaration) body; this.getParameterNames(methodDeclaration, n.isInterface()); i++; } else if (body instanceof ConstructorDeclaration) { // Constructor } else if (body instanceof ClassOrInterfaceDeclaration) { final ClassOrInterfaceDeclaration classOrInterfaceDeclaration = (ClassOrInterfaceDeclaration) body; String name = classOrInterfaceDeclaration.getName().getIdentifier(); String key = this.pkg + '.' + name; name = this.originClassName + '.' + name; for (MethodParameterNames mpn : this.parameterNamesList) { if (mpn != null && mpn.className != null && mpn.className.equals(key)) { mpn.className = name; } } } } if (i > 0 && this.names.className != null) { this.parameterNamesList.add(this.names); this.names = new MethodParameterNames(); } } }