Package org.eclipse.jdt.core.dom

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


  public static List<IVariableBinding> getWicketModelTypes(final IFile javaFile) {
    Assert.isNotNull(javaFile);
    final List<IVariableBinding> list = new ArrayList<IVariableBinding>();

    final ASTParser parser = ASTParser.newParser(AST.JLS4);
    parser.setResolveBindings(true);
    parser.setSource(JavaCore.createCompilationUnitFrom(javaFile));
    final CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.accept(new ASTVisitor() {

      @Override
      public boolean visit(final ClassInstanceCreation node) {
        ITypeBinding ntb = node.resolveTypeBinding();
View Full Code Here


        ICompilationUnit asyncContents = (ICompilationUnit) JavaCore.create(aRemoteServiceFile);
        String source = asyncContents.getBuffer().getContents();
        Document document = new Document(source);

        ASTParser parser = ASTParser.newParser(AST.JLS3);
        parser.setSource(asyncContents);
        CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
        AST ast = astRoot.getAST();

        astRoot.recordModifications();

        // Modify imports (+AsyncCallback, -RemoteService, -*Exception)
 
View Full Code Here

       
        ICompilationUnit asyncContents = (ICompilationUnit) JavaCore.create(aRemoteServiceFile);
        String source = asyncContents.getBuffer().getContents();
        Document document = new Document(source);

        ASTParser parser = ASTParser.newParser(AST.JLS3);
        parser.setSource(asyncContents);
        CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
        AST ast = astRoot.getAST();

        astRoot.recordModifications();

        // Modify imports (+AsyncCallback, -RemoteService, -*Exception)
View Full Code Here

       * Find or create types in the compilation unit
       */
      IFile file;
      try {
        ICompilationUnit original = (ICompilationUnit)item;
        ASTParser astParser = ASTParser.newParser(AST.JLS3);
        astParser.setSource(original);
        CompilationUnit compilationUnit = parse(original);
       
        IProject project = original.getResource().getProject();
       
        IPackageFragment parentPackage = (IPackageFragment) original.getParent();
View Full Code Here

   
   
  }

  private static CompilationUnit parse(ICompilationUnit unit) {
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    parser.setSource(unit);
    parser.setResolveBindings(true);
    return (CompilationUnit) parser.createAST(null); // parse
  }
View Full Code Here

       
        ICompilationUnit asyncContents = (ICompilationUnit) JavaCore.create(aRemoteServiceFile);
        String source = asyncContents.getBuffer().getContents();
        Document document = new Document(source);

        ASTParser parser = ASTParser.newParser(AST.JLS3);
        parser.setSource(asyncContents);
        CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
        AST ast = astRoot.getAST();

        astRoot.recordModifications();

        // Modify imports (+AsyncCallback, -RemoteService, -*Exception)
View Full Code Here

    ICompilationUnit asyncContents = (ICompilationUnit) JavaCore.create(aRemoteServiceFile);
    String source = asyncContents.getBuffer().getContents();
    Document document = new Document(source);

    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(asyncContents);
    CompilationUnit astRoot = (CompilationUnit) parser.createAST(null);
    AST ast = astRoot.getAST();

    astRoot.recordModifications();

    // Modify imports (+AsyncCallback, -RemoteService, -*Exception)
 
View Full Code Here

      @SuppressWarnings("restriction")
      Annotation a = (Annotation) ia;
      ICompilationUnit ic = a.getCompilationUnit();
      CompilationUnit cu = (CompilationUnit) ic;

      ASTParser astParser = ASTParser.newParser(AST.JLS3);
      astParser.setSource(cu.getContents());
      ASTNode node = astParser.createAST(new NullProgressMonitor());

      ASTNode aNode = a
          .findNode((org.eclipse.jdt.core.dom.CompilationUnit) node);
      if (aNode instanceof NormalAnnotation) {
        NormalAnnotation aA = (NormalAnnotation) aNode;
View Full Code Here

            Annotation a = (Annotation) ia;

            ICompilationUnit ic = a.getCompilationUnit();
            CompilationUnit cu = (CompilationUnit) ic;

            ASTParser astParser = ASTParser.newParser(AST.JLS3);
            astParser.setSource(cu.getContents());
            ASTNode node = astParser
                .createAST(new NullProgressMonitor());

            ASTNode aNode = a
                .findNode((org.eclipse.jdt.core.dom.CompilationUnit) node);
            if (aNode instanceof NormalAnnotation) {
              NormalAnnotation na = (NormalAnnotation) aNode;
              Expression exp = getAnnotationElement(na, "members");
              parseAnnotationListElement(elems, annotationName,
                  nameProp, colProp, exp);
            }
          }
        }
      } catch (JavaModelException e) {
        e.printStackTrace();
      }
    } else {
      try {
        ias = f.getAnnotations();
        String annotationSetName = "AttributeOverrides";
        String annotationName = "AttributeOverride";
        String nameProp = "name";
        String colProp = "column";

        for (IAnnotation ia : ias) {
          if (ia.getElementName().equals(annotationSetName)) {
            if (ia instanceof Annotation) {
              Annotation a = (Annotation) ia;

              ICompilationUnit ic = a.getCompilationUnit();
              CompilationUnit cu = (CompilationUnit) ic;

              ASTParser astParser = ASTParser.newParser(AST.JLS3);
              astParser.setSource(cu.getContents());
              ASTNode node = astParser
                  .createAST(new NullProgressMonitor());

              ASTNode aNode = a
                  .findNode((org.eclipse.jdt.core.dom.CompilationUnit) node);

              if (aNode instanceof SingleMemberAnnotation) {
                SingleMemberAnnotation sma = (SingleMemberAnnotation) aNode;
                Expression val = sma.getValue();
                parseAnnotationListElement(elems,
                    annotationName, nameProp, colProp, val);
              }
            }
          } else if (ia.getElementName().equals(annotationName)) {
            Annotation a = (Annotation) ia;

            ICompilationUnit ic = a.getCompilationUnit();
            CompilationUnit cu = (CompilationUnit) ic;

            ASTParser astParser = ASTParser.newParser(AST.JLS3);
            astParser.setSource(cu.getContents());
            ASTNode node = astParser
                .createAST(new NullProgressMonitor());

            ASTNode aNode = a
                .findNode((org.eclipse.jdt.core.dom.CompilationUnit) node);
            if (aNode instanceof NormalAnnotation) {
View Full Code Here

    }
  }
 
  private String goThroughClass(String ClassContent) {
    attributeList = "";
    ASTParser parser = ASTParser.newParser(AST.JLS3);
    parser.setSource(ClassContent.toCharArray());
    parser.setKind(ASTParser.K_COMPILATION_UNIT);
    CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.accept(new ASTVisitor() {
      public boolean visit(FieldDeclaration node) {
        String attr_name = "";
        List list = node.fragments();
        for(int i=0; i<list.size(); i++){
View Full Code Here

TOP

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

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.