Package com.sun.source.tree

Examples of com.sun.source.tree.CompilationUnitTree


        .contains(twoWayDiffContextStr());
  }

  @Test
  public void getDiffReport_emptyElementContext() {
    CompilationUnitTree modifiersPresent =
      MoreTrees.parseLinesToTree("package test;",
          "final class TestClass {",
          "   TestClass() {}",
          "}");
    CompilationUnitTree modifiersAbsent =
      MoreTrees.parseLinesToTree("package test;",
          "class TestClass {",
          "   TestClass() {}",
          "}");
    TreeDifference diff =
View Full Code Here


*/
@RunWith(JUnit4.class)
public class TypeEnumeratorTest {
  @Test
  public void getTopLevelTypes_singleQualifiedType() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "package path.to.test;",
        "import java.util.List;",
        "",
        "public class HelloWorld {",
        "  public static void main(String[] args) {",
View Full Code Here

        "path.to.test.HelloWorld");
  }

  @Test
  public void getTopLevelTypes_manyQualifiedTypes() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "package path.to.test;",
        "import java.util.List;",
        "",
        "public class HelloWorld {",
        "  public static void main(String[] args) {",
View Full Code Here

        "path.to.test.HelloWorld", "path.to.test.HelperWorld");
  }

  @Test
  public void getTopLevelTypes_singleSimpleTypes() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "import java.util.List;",
        "",
        "public class HelloWorld {",
        "  public static void main(String[] args) {",
        "    System.out.println(\"Hello World!\");",
View Full Code Here

        "HelloWorld");
  }

  @Test
  public void getTopLevelTypes_manySimpleTypes() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "import java.util.List;",
        "",
        "public class HelloWorld {",
        "  public static void main(String[] args) {",
        "    System.out.println(\"Hello World!\");",
View Full Code Here

        "HelloWorld", "HelperWorld");
  }

  @Test
  public void getTopLevelTypes_worksForAnnotationTypes() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "package path.to.test;",
        "import java.util.List;",
        "",
        "public @interface HelloWorld {}");
View Full Code Here

        "path.to.test.HelloWorld");
  }

  @Test
  public void getTopLevelTypes_worksForEnums() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "package path.to.test;",
        "import java.util.List;",
        "",
        "public enum HelloWorld {",
        "  HELLO,",
View Full Code Here

        "path.to.test.HelloWorld");
  }

  @Test
  public void getTopLevelTypes_worksForInterfaces() {
    CompilationUnitTree compilation = MoreTrees.parseLinesToTree(
        "package path.to.test;",
        "import java.util.List;",
        "",
        "public interface HelloWorld {",
        "  public String getSalutation();",
View Full Code Here

                if (treePath == null)
                    return name + " (Unknown Source)";
                // just like stack trace, we just print the file name and
                // not the whole path. The idea is that the package name should
                // provide enough clue on which directory it lives.
                CompilationUnitTree compilationUnit = treePath.getCompilationUnit();
                Trees trees = Trees.instance(env);
                long startPosition = trees.getSourcePositions().getStartPosition(compilationUnit, treePath.getLeaf());
                return name + "(" +
                        compilationUnit.getSourceFile().getName() + ":" + compilationUnit.getLineMap().getLineNumber(startPosition) +
                        ")";
            }
        };
    }
View Full Code Here

            int idx = binaryName.lastIndexOf('$');
            String name = "~"+binaryName.substring(idx); // #$1 is ambiguous between field and anonyous type, so use '~' as the prefix for type
            return combine(getEnclosingTypeOrPackage(t).accept(this,null)).append(name);
        case TOP_LEVEL:
            // check if this class is the 'primary type' of the compilation unit
            CompilationUnitTree owner = pss.getTreePathByClass().get(ct).getCompilationUnit();
            String primaryTypeName = TreeUtil.getPrimaryTypeName(owner);
            String simpleName = ct.getSimpleName().toString();

            StringBuilder buf = new StringBuilder();
            if(!primaryTypeName.equals(simpleName)) {
View Full Code Here

TOP

Related Classes of com.sun.source.tree.CompilationUnitTree

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.