@SuppressWarnings("unchecked") @Override ASTNode clone0(AST target) { ModuleDeclaration result = new ModuleDeclaration(target); result.setSourceRange(getStartPosition(), getLength()); result.setJavadoc((Javadoc) ASTNode.copySubtree(target, getJavadoc())); result.setOpen(isOpen()); result.annotations().addAll(ASTNode.copySubtrees(target, annotations())); result.setName((SimpleName) getName().clone(target)); result.moduleStatements().addAll(ASTNode.copySubtrees(target, moduleStatements())); return result; }
@Override void accept0(ASTVisitor visitor) { boolean visitChildren = visitor.visit(this); if (visitChildren) { // visit children in normal left to right reading order acceptChild(visitor, getJavadoc()); acceptChildren(visitor, this.annotations); acceptChild(visitor, getName()); acceptChildren(visitor, this.moduleStatements); } visitor.endVisit(this); } /**
@Override public boolean visit(ModuleDeclaration node) { if (found(node, node.getName()) && this.resolveBinding) { this.foundBinding = node.resolveBinding(); } return true; } @Override
/** * Returns whether the given node and the other object match. * <p> * The default implementation provided by this class tests whether the * other object is a node of the same type with structurally isomorphic * child subtrees. Subclasses may override this method as needed. * </p> * * @param node the node * @param other the other object, or <code>null</code> * @return <code>true</code> if the subtree matches, or * <code>false</code> if they do not match or the other object has a * different node type or is <code>null</code> * @since 3.14 */ public boolean match(ModuleDeclaration node, Object other) { if (!(other instanceof ModuleDeclaration)) { return false; } ModuleDeclaration o = (ModuleDeclaration) other; return (safeSubtreeMatch(node.getJavadoc(), o.getJavadoc()) && safeSubtreeListMatch(node.annotations(), o.annotations()) && node.isOpen() == o.isOpen() && safeSubtreeMatch(node.getName(), o.getName()) && safeSubtreeListMatch(node.moduleStatements(), o.moduleStatements())); }
moduleDecl.setOpen(moduleDeclaration.isOpen()); Name moduleName = getName(moduleDeclaration, CharOperation.splitOn('.', moduleDeclaration.moduleName), moduleDeclaration.sourcePositions); moduleDecl.setName(moduleName); List<ModuleDirective> stmts = moduleDecl.moduleStatements(); TreeSet<ModuleDirective> tSet = new TreeSet<> (new Comparator() { @Override recordNodes(moduleDecl, moduleDeclaration); recordNodes(moduleName, moduleDeclaration); moduleDecl.resolveBinding(); moduleDecl.setSourceRange(moduleDeclaration.declarationSourceStart, end - moduleDeclaration.declarationSourceStart + 1); return moduleDecl;
@Override public void endVisit(ModuleDeclaration node) { tryKeepOnOneLine(node, node.getName(), node.moduleStatements(), this.options.keep_type_declaration_on_one_line); }
final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == JAVADOC_PROPERTY) { if (get) { return getJavadoc(); } else { setJavadoc((Javadoc) child); return null; } } if (property == NAME_PROPERTY) { if (get) { return getName(); } else { setName((Name) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
@Override int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + this.annotations.listSize() + (this.name == null ? 0 : getName().treeSize()) + this.moduleStatements.listSize(); } }
@Override final List internalGetChildListProperty(ChildListPropertyDescriptor property) { if (property == ANNOTATIONS_PROPERTY) { return annotations(); } if (property == MODULE_DIRECTIVES_PROPERTY) { return moduleStatements(); } // allow default implementation to flag the error return super.internalGetChildListProperty(property); }
final boolean internalGetSetBooleanProperty(SimplePropertyDescriptor property, boolean get, boolean value) { if (property == OPEN_PROPERTY) { if (get) { return isOpen(); } else { setOpen(value); return false; } } // allow default implementation to flag the error return super.internalGetSetBooleanProperty(property, get, value); } /* (omit javadoc for this method)
ListRewrite listRewrite= rewrite.getListRewrite(moduleDecl, ModuleDeclaration.MODULE_DIRECTIVES_PROPERTY); boolean requiresAlreadyPresent= false; List<ModuleDirective> moduleStatements= moduleDecl.moduleStatements(); ModuleDirective lastModuleRequiresDirective= null; if (moduleStatements != null) {
@Override public boolean visit(ModuleDeclaration node) { handleToken(node.getName(), TokenNameLBRACE, this.options.insert_space_before_opening_brace_in_type_declaration, false); return true; }
public boolean visit(CompilationUnit node) { if (node.getAST().apiLevel() >= JLS9) { if (node.getModule() != null) { node.getModule().accept(this); } } if (node.getPackage() != null) { node.getPackage().accept(this); } for (Iterator it = node.imports().iterator(); it.hasNext(); ) { ImportDeclaration d = (ImportDeclaration) it.next(); d.accept(this); } for (Iterator it = node.types().iterator(); it.hasNext(); ) { AbstractTypeDeclaration d = (AbstractTypeDeclaration) it.next(); d.accept(this); } return false; }
protected void setAnnotations(ModuleDeclaration moduleDecl, org.eclipse.jdt.internal.compiler.ast.ModuleDeclaration moduleDeclaration) { this.scanner.resetTo(moduleDeclaration.declarationSourceStart, moduleDeclaration.sourceStart); List<IExtendedModifier> modifiers = new ArrayList<>(); this.setModifiers(modifiers, moduleDeclaration.annotations, moduleDeclaration.sourceStart); for (IExtendedModifier ie : modifiers) { if (!ie.isAnnotation()) { continue; // not setting to malformed. } moduleDecl.annotations().add(ie); } } /**
/** * Creates and returns a new unparented module declaration * node for an unspecified, but legal, name; no modifiers; no javadoc; * and an empty list of statements. * * @return a new unparented module declaration node * @exception UnsupportedOperationException if this operation is used in an AST with level less than JLS9 * @since 3.14 */ public ModuleDeclaration newModuleDeclaration() { ModuleDeclaration result = new ModuleDeclaration(this); return result; }
/** * Returns whether the given node and the other object match. * <p> * The default implementation provided by this class tests whether the * other object is a node of the same type with structurally isomorphic * child subtrees. Subclasses may override this method as needed. * </p> * * @param node the node * @param other the other object, or <code>null</code> * @return <code>true</code> if the subtree matches, or * <code>false</code> if they do not match or the other object has a * different node type or is <code>null</code> * @since 3.14 */ public boolean match(ModuleDeclaration node, Object other) { if (!(other instanceof ModuleDeclaration)) { return false; } ModuleDeclaration o = (ModuleDeclaration) other; return (safeSubtreeMatch(node.getJavadoc(), o.getJavadoc()) && safeSubtreeListMatch(node.annotations(), o.annotations()) && node.isOpen() == o.isOpen() && safeSubtreeMatch(node.getName(), o.getName()) && safeSubtreeListMatch(node.moduleStatements(), o.moduleStatements())); }
moduleDecl.setOpen(moduleDeclaration.isOpen()); Name moduleName = getName(moduleDeclaration, CharOperation.splitOn('.', moduleDeclaration.moduleName), moduleDeclaration.sourcePositions); moduleDecl.setName(moduleName); List<ModuleDirective> stmts = moduleDecl.moduleStatements(); TreeSet<ModuleDirective> tSet = new TreeSet<> (new Comparator() { public int compare(Object o1, Object o2) { recordNodes(moduleDecl, moduleDeclaration); recordNodes(moduleName, moduleDeclaration); moduleDecl.resolveBinding(); moduleDecl.setSourceRange(moduleDeclaration.declarationSourceStart, end - moduleDeclaration.declarationSourceStart + 1); return moduleDecl;
@Override public boolean visit(ModuleDeclaration node) { // using settings for type declaration and fields for now, add new settings if necessary breakLineBefore(node); handleBracedCode(node, node.getName(), this.options.brace_position_for_type_declaration, this.options.indent_body_declarations_compare_to_type_header, this.options.insert_new_line_in_empty_type_declaration); List<ModuleDirective> statements = node.moduleStatements(); ModuleDirective previous = null; for (ModuleDirective statement : statements) { int blankLines = previous == null ? this.options.blank_lines_before_first_class_body_declaration : previous.getClass().equals(statement.getClass()) ? this.options.blank_lines_before_field : this.options.blank_lines_before_new_chunk; putBlankLinesBefore(statement, blankLines); previous = statement; } this.declarationModifierVisited = false; return true; }
@Override final ASTNode internalGetSetChildProperty(ChildPropertyDescriptor property, boolean get, ASTNode child) { if (property == JAVADOC_PROPERTY) { if (get) { return getJavadoc(); } else { setJavadoc((Javadoc) child); return null; } } if (property == NAME_PROPERTY) { if (get) { return getName(); } else { setName((Name) child); return null; } } // allow default implementation to flag the error return super.internalGetSetChildProperty(property, get, child); }
@Override int treeSize() { return memSize() + (this.optionalDocComment == null ? 0 : getJavadoc().treeSize()) + this.annotations.listSize() + (this.name == null ? 0 : getName().treeSize()) + this.moduleStatements.listSize(); } }