Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.AST


      ASTTools.annotation(declaration, getAnnotationUnqualifiedName());
    if (annotation != null) {
      return;
    }
   
    AST ast = declaration.getAST();
   
    annotation = AstUtils.createMarkerAnnotation(
      ast, getAnnotationFullyQualifiedName());
    annotation.setSourceRange(
        AstUtils.calculateOffset(declaration).offset,
View Full Code Here


      BodyDeclaration declaration, Object value) throws MalformedTreeException, BadLocationException, CoreException {

    if (annotationExists(declaration)) {
      return;
    }
    AST ast = declaration.getAST();
    Annotation annotation = AstUtils.createSingleMemberAnnotation(
            ast, getAnnotationFullyQualifiedName(), value);
    annotation.setSourceRange(
        AstUtils.calculateOffset(declaration, true).offset,
        annotation.getLength());
View Full Code Here

      SingleVariableDeclaration declaration, Object value) throws MalformedTreeException, BadLocationException, CoreException {

    if (annotationExists(declaration)) {
      return;
    }
    AST ast = declaration.getAST();
    Annotation annotation = AstUtils.createSingleMemberAnnotation(
            ast, getAnnotationFullyQualifiedName(), value);
    annotation.setSourceRange(
        AstUtils.calculateOffset(declaration).offset,
        annotation.getLength());
View Full Code Here

      BodyDeclaration declaration, Object value) throws JavaModelException, MalformedTreeException, BadLocationException {
   
    SingleMemberAnnotation singleMemberAnnotation =
      annotation(declaration, SingleMemberAnnotation.class);
    if (singleMemberAnnotation != null) {
            AST ast = singleMemberAnnotation.getAST();
            if (value != QualifiedNameValue.DEFAULT_VALUE) {
                Expression replacement = 
                    value != null? AstUtils.createExpression(
                            ast, value): null;
       
                AstUtils.rewriteReplace(
                    compilationUnit, singleMemberAnnotation.getValue(), replacement);
                return;
            } else {
                MarkerAnnotation replacementAnnotation = ast.newMarkerAnnotation();
                replacementAnnotation.setTypeName(ast.newName(singleMemberAnnotation.getTypeName().getFullyQualifiedName()));
                AstUtils.rewriteReplace(
                    compilationUnit, singleMemberAnnotation, replacementAnnotation);
                return;
            }
        }
        MarkerAnnotation markerAnnotation =
            annotation(declaration, MarkerAnnotation.class);
        if (markerAnnotation != null) {
            AST ast = markerAnnotation.getAST();
            if (value != QualifiedNameValue.DEFAULT_VALUE) {
                SingleMemberAnnotation replacementAnnotation = ast.newSingleMemberAnnotation();
                replacementAnnotation.setTypeName(ast.newName(markerAnnotation.getTypeName().getFullyQualifiedName()));
                Expression memberValueExpression = 
                    value != null? AstUtils.createExpression(
                            ast, value): null;
                replacementAnnotation.setValue(memberValueExpression);
                AstUtils.rewriteReplace(
View Full Code Here

    if (annotationExists(declaration)) {
      return;
    }

    AST ast = declaration.getAST();
   
    NormalAnnotation normalAnnotation = AstUtils.createNormalAnnotation(
            ast, getAnnotationFullyQualifiedName(), memberValues);
    normalAnnotation.setSourceRange(
        AstUtils.calculateOffset(declaration, true).offset,
View Full Code Here

    if (annotationExists(declaration)) {
      return;
    }

    AST ast = declaration.getAST();
   
    NormalAnnotation normalAnnotation = AstUtils.createNormalAnnotation(
            ast, getAnnotationFullyQualifiedName(), memberValues);
    normalAnnotation.setSourceRange(
        AstUtils.calculateOffset(declaration).offset,
View Full Code Here

    Document document= new Document(source);
   
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(compilationUnit);

    AST ast = normalAnnotation.getAST();

    ASTRewrite rewrite = ASTRewrite.create(ast);

    maintainValuesProperty(normalAnnotation, memberValues, ast, rewrite);
   
View Full Code Here

    Document document= new Document(source);
   
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(compilationUnit);

    AST ast = normalAnnotation.getAST();

    ASTRewrite rewrite = ASTRewrite.create(ast);

    maintainValuesProperty(normalAnnotation, memberValues, ast, rewrite);
   
View Full Code Here

        new UniqueEList<Generalization>());
  }

  @Test
  public void testGenerateClassCheckedExceptionWithNoInheritance() {
    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    TypeDeclaration typeDeclaration = exceptionGenerator.generateClass(
        clazz, ast, cu);

    assertEquals(typeDeclaration.toString(),
View Full Code Here

    when(generalization.getGeneral()).thenReturn(clazzGeneralization);
    when(clazzGeneralization.getQualifiedName()).thenReturn(
        "de::test::SuperCompanyException");
    when(clazz.getGeneralizations()).thenReturn(generalizations);

    AST ast = AST.newAST(AST.JLS3);
    CompilationUnit cu = ast.newCompilationUnit();

    TypeDeclaration typeDeclaration = exceptionGenerator.generateClass(
        clazz, ast, cu);

    assertEquals(typeDeclaration.toString(),
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.AST

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.