Search in sources :

Example 61 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project AutoRefactor by JnRouvignac.

the class CommentsCleanUp method getNextNode.

private ASTNode getNextNode(final Comment node) {
    int nodeEndPosition = node.getStartPosition() + node.getLength();
    ASTNode coveringNode = getCoveringNode(node);
    int parentNodeEndPosition = coveringNode.getStartPosition() + coveringNode.getLength();
    NodeFinder finder = new NodeFinder(coveringNode, nodeEndPosition, parentNodeEndPosition - nodeEndPosition);
    if (node instanceof Javadoc) {
        return finder.getCoveringNode();
    }
    return finder.getCoveredNode();
}
Also used : ASTNode(org.eclipse.jdt.core.dom.ASTNode) Javadoc(org.eclipse.jdt.core.dom.Javadoc) NodeFinder(org.eclipse.jdt.core.dom.NodeFinder)

Example 62 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project xtext-xtend by eclipse.

the class JavaASTFlattener method visit.

@Override
public boolean visit(final PackageDeclaration it) {
    Javadoc _javadoc = it.getJavadoc();
    boolean _tripleNotEquals = (_javadoc != null);
    if (_tripleNotEquals) {
        it.getJavadoc().accept(this);
    }
    this.visitAll(it.annotations(), " ");
    this.appendToBuffer("package ");
    it.getName().accept(this);
    this.appendLineWrapToBuffer();
    return false;
}
Also used : Javadoc(org.eclipse.jdt.core.dom.Javadoc)

Example 63 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project xtext-xtend by eclipse.

the class JavaASTFlattener method visit.

@Override
public boolean visit(final Initializer it) {
    Javadoc _javadoc = it.getJavadoc();
    boolean _tripleNotEquals = (_javadoc != null);
    if (_tripleNotEquals) {
        it.getJavadoc().accept(this);
    }
    this.appendModifiers(it, it.modifiers());
    boolean _isStatic = this._aSTFlattenerUtils.isStatic(it.modifiers());
    if (_isStatic) {
        if (((it.getParent() instanceof TypeDeclaration) && IterableExtensions.<FieldDeclaration>forall(IterableExtensions.<FieldDeclaration>filter(((Iterable<FieldDeclaration>) Conversions.doWrapArray(((TypeDeclaration) it.getParent()).getFields())), ((Function1<FieldDeclaration, Boolean>) (FieldDeclaration it_1) -> {
            return Boolean.valueOf((this._aSTFlattenerUtils.isStatic(it_1.modifiers()) && this._aSTFlattenerUtils.isFinal(it_1.modifiers())));
        })), ((Function1<FieldDeclaration, Boolean>) (FieldDeclaration f) -> {
            final Function1<VariableDeclarationFragment, Boolean> _function = (VariableDeclarationFragment fragment) -> {
                Boolean _isAssignedInBody = this._aSTFlattenerUtils.isAssignedInBody(it.getBody(), fragment);
                return Boolean.valueOf((!(_isAssignedInBody).booleanValue()));
            };
            return Boolean.valueOf(IterableExtensions.<VariableDeclarationFragment>forall(f.fragments(), _function));
        })))) {
            this.appendToBuffer(" final Void static_initializer = {");
            this.appendLineWrapToBuffer();
            it.getBody().accept(this);
            this.appendToBuffer("null }");
            this.appendLineWrapToBuffer();
        } else {
            this.addProblem(it, "Static initializer is not fully supported");
            this.appendToBuffer("{/*FIXME ");
            it.getBody().accept(this);
            this.appendToBuffer("*/}");
        }
    } else {
        ASTNode _parent = it.getParent();
        if ((_parent instanceof AnonymousClassDeclaration)) {
            StringConcatenation _builder = new StringConcatenation();
            _builder.append("Initializer is not supported in ");
            String _simpleName = ASTNode.nodeClassForType(it.getParent().getNodeType()).getSimpleName();
            _builder.append(_simpleName);
            this.addProblem(it, _builder.toString());
        }
        it.getBody().accept(this);
    }
    return false;
}
Also used : VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) ASTNode(org.eclipse.jdt.core.dom.ASTNode) AnonymousClassDeclaration(org.eclipse.jdt.core.dom.AnonymousClassDeclaration) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Javadoc(org.eclipse.jdt.core.dom.Javadoc) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration) AnnotationTypeDeclaration(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration) FieldDeclaration(org.eclipse.jdt.core.dom.FieldDeclaration)

Example 64 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project xtext-xtend by eclipse.

the class JavaASTFlattener method visit.

@Override
public boolean visit(final FieldDeclaration it) {
    Javadoc _javadoc = it.getJavadoc();
    boolean _tripleNotEquals = (_javadoc != null);
    if (_tripleNotEquals) {
        it.getJavadoc().accept(this);
    }
    final Consumer<VariableDeclarationFragment> _function = (VariableDeclarationFragment frag) -> {
        this.appendModifiers(it, it.modifiers());
        boolean _isPackageVisibility = this._aSTFlattenerUtils.isPackageVisibility(Iterables.<Modifier>filter(it.modifiers(), Modifier.class));
        if (_isPackageVisibility) {
            ASTNode _parent = it.getParent();
            if ((_parent instanceof TypeDeclaration)) {
                ASTNode _parent_1 = it.getParent();
                boolean _isInterface = ((TypeDeclaration) _parent_1).isInterface();
                boolean _not = (!_isInterface);
                if (_not) {
                    this.appendToBuffer("package ");
                }
            }
        }
        it.getType().accept(this);
        this.appendExtraDimensions(frag.getExtraDimensions());
        this.appendSpaceToBuffer();
        frag.accept(this);
    };
    it.fragments().forEach(_function);
    return false;
}
Also used : VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment) ASTNode(org.eclipse.jdt.core.dom.ASTNode) Javadoc(org.eclipse.jdt.core.dom.Javadoc) Modifier(org.eclipse.jdt.core.dom.Modifier) IExtendedModifier(org.eclipse.jdt.core.dom.IExtendedModifier) TypeDeclaration(org.eclipse.jdt.core.dom.TypeDeclaration) AbstractTypeDeclaration(org.eclipse.jdt.core.dom.AbstractTypeDeclaration) AnnotationTypeDeclaration(org.eclipse.jdt.core.dom.AnnotationTypeDeclaration)

Example 65 with Javadoc

use of org.eclipse.jdt.core.dom.Javadoc in project xtext-xtend by eclipse.

the class JavaASTFlattener method visit.

@Override
public boolean visit(final TypeDeclaration it) {
    boolean _isDummyType = this._aSTFlattenerUtils.isDummyType(it);
    if (_isDummyType) {
        this.visitAll(it.bodyDeclarations(), this.nl());
        return false;
    }
    boolean _isNotSupportedInnerType = this._aSTFlattenerUtils.isNotSupportedInnerType(it);
    if (_isNotSupportedInnerType) {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("/* FIXME Non-static inner classes are not supported.*/");
        this.appendToBuffer(_builder.toString());
        this.addProblem(it, "Non-static inner classes are not supported.");
    }
    Javadoc _javadoc = it.getJavadoc();
    boolean _tripleNotEquals = (_javadoc != null);
    if (_tripleNotEquals) {
        it.getJavadoc().accept(this);
    }
    this.appendModifiers(it, it.modifiers());
    boolean _isInterface = it.isInterface();
    if (_isInterface) {
        this.appendToBuffer("interface ");
    } else {
        boolean _isPackageVisibility = this._aSTFlattenerUtils.isPackageVisibility(Iterables.<Modifier>filter(it.modifiers(), Modifier.class));
        if (_isPackageVisibility) {
            this.appendToBuffer("package ");
        }
        this.appendToBuffer("class ");
    }
    it.getName().accept(this);
    boolean _isEmpty = it.typeParameters().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
        this.appendTypeParameters(it.typeParameters());
    }
    this.appendSpaceToBuffer();
    Type _superclassType = it.getSuperclassType();
    boolean _tripleNotEquals_1 = (_superclassType != null);
    if (_tripleNotEquals_1) {
        this.appendToBuffer("extends ");
        it.getSuperclassType().accept(this);
        this.appendSpaceToBuffer();
    }
    boolean _isEmpty_1 = it.superInterfaceTypes().isEmpty();
    boolean _not_1 = (!_isEmpty_1);
    if (_not_1) {
        boolean _isInterface_1 = it.isInterface();
        if (_isInterface_1) {
            this.appendToBuffer("extends ");
        } else {
            this.appendToBuffer("implements ");
        }
        this.visitAllSeparatedByComma(it.superInterfaceTypes());
    }
    this.appendToBuffer("{");
    this.increaseIndent();
    BodyDeclaration prev = null;
    List _bodyDeclarations = it.bodyDeclarations();
    for (final BodyDeclaration body : ((Iterable<BodyDeclaration>) _bodyDeclarations)) {
        {
            if ((prev instanceof EnumConstantDeclaration)) {
                if ((body instanceof EnumConstantDeclaration)) {
                    this.appendToBuffer(", ");
                } else {
                    this.appendToBuffer("; ");
                }
            }
            this.appendLineWrapToBuffer();
            body.accept(this);
            prev = body;
        }
    }
    ASTNode _root = it.getRoot();
    if ((_root instanceof CompilationUnit)) {
        ASTNode _root_1 = it.getRoot();
        final CompilationUnit cu = ((CompilationUnit) _root_1);
        final Consumer<Comment> _function = (Comment it_1) -> {
            it_1.accept(this);
            this.assignedComments.add(it_1);
        };
        this.unAssignedComments(cu).forEach(_function);
    }
    this.decreaseIndent();
    this.appendLineWrapToBuffer();
    this.appendToBuffer("}");
    return false;
}
Also used : CompilationUnit(org.eclipse.jdt.core.dom.CompilationUnit) EnumConstantDeclaration(org.eclipse.jdt.core.dom.EnumConstantDeclaration) Comment(org.eclipse.jdt.core.dom.Comment) BlockComment(org.eclipse.jdt.core.dom.BlockComment) LineComment(org.eclipse.jdt.core.dom.LineComment) ParameterizedType(org.eclipse.jdt.core.dom.ParameterizedType) WildcardType(org.eclipse.jdt.core.dom.WildcardType) QualifiedType(org.eclipse.jdt.core.dom.QualifiedType) PrimitiveType(org.eclipse.jdt.core.dom.PrimitiveType) ArrayType(org.eclipse.jdt.core.dom.ArrayType) SimpleType(org.eclipse.jdt.core.dom.SimpleType) Type(org.eclipse.jdt.core.dom.Type) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) ASTNode(org.eclipse.jdt.core.dom.ASTNode) Javadoc(org.eclipse.jdt.core.dom.Javadoc) BodyDeclaration(org.eclipse.jdt.core.dom.BodyDeclaration) ArrayList(java.util.ArrayList) List(java.util.List) Modifier(org.eclipse.jdt.core.dom.Modifier) IExtendedModifier(org.eclipse.jdt.core.dom.IExtendedModifier)

Aggregations

Javadoc (org.eclipse.jdt.core.dom.Javadoc)68 AST (org.eclipse.jdt.core.dom.AST)33 MethodDeclaration (org.eclipse.jdt.core.dom.MethodDeclaration)31 ASTNode (org.eclipse.jdt.core.dom.ASTNode)30 TagElement (org.eclipse.jdt.core.dom.TagElement)25 Type (org.eclipse.jdt.core.dom.Type)25 ASTRewrite (org.eclipse.jdt.core.dom.rewrite.ASTRewrite)20 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)17 SingleVariableDeclaration (org.eclipse.jdt.core.dom.SingleVariableDeclaration)16 ImportRewriteContext (org.eclipse.jdt.core.dom.rewrite.ImportRewrite.ImportRewriteContext)16 AbstractTypeDeclaration (org.eclipse.jdt.core.dom.AbstractTypeDeclaration)15 Block (org.eclipse.jdt.core.dom.Block)15 ITypeBinding (org.eclipse.jdt.core.dom.ITypeBinding)14 PrimitiveType (org.eclipse.jdt.core.dom.PrimitiveType)14 ImportRewrite (org.eclipse.jdt.core.dom.rewrite.ImportRewrite)14 ListRewrite (org.eclipse.jdt.core.dom.rewrite.ListRewrite)14 BodyDeclaration (org.eclipse.jdt.core.dom.BodyDeclaration)12 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)12 ReturnStatement (org.eclipse.jdt.core.dom.ReturnStatement)12 TextElement (org.eclipse.jdt.core.dom.TextElement)11