Package lombok.ast

Examples of lombok.ast.ForwardingAstVisitor


      }
    });
  }
 
  private static void deleteEmptyDeclarations(Node node) {
    node.accept(new ForwardingAstVisitor() {
      @Override public boolean visitEmptyDeclaration(EmptyDeclaration node) {
        node.unparent();
        return true;
      }
    });
View Full Code Here


      }
    });
  }
 
  private static void foldStringConcats(Node tree) {
    tree.accept(new ForwardingAstVisitor() {
      @Override public boolean visitBinaryExpression(BinaryExpression node) {
        if (node.rawLeft() != null) node.rawLeft().accept(this);
        if (node.rawRight() != null) node.rawRight().accept(this);
        String left = null, right = null;
        if (node.astOperator() != BinaryOperator.PLUS || node.getParent() == null) return true;
View Full Code Here

  @Test
  public void testBasicTypesMatch() {
    final AtomicInteger hit = new AtomicInteger();
    Source s = new Source(SIMPLE_SOURCE, "SimpleTypesMatchTest.java");
    s.parseCompilationUnit();
    s.getNodes().get(0).accept(new ForwardingAstVisitor() {
      @Override public boolean visitMethodDeclaration(MethodDeclaration node) {
        assertTrue("typesMatch with star import should match but fails:" + node.astReturnTypeReference(),
            new Resolver().typesMatch("java.util.List", node.astReturnTypeReference()));
        assertFalse("typesMatch with no relevant imports should fail but matches",
            new Resolver().typesMatch("java.awt.List", node.astReturnTypeReference()));
View Full Code Here

  public void testMethodLocalMaskingTypesMatch() {
    Source s = new Source(METHOD_LOCAL_MASKING_SOURCE, "MaskingTypesMatchTest.java");
    s.parseCompilationUnit();
    final AtomicInteger hit1 = new AtomicInteger();
    final AtomicInteger hit2 = new AtomicInteger();
    s.getNodes().get(0).accept(new ForwardingAstVisitor() {
      @Override public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
        if ("thisIsAUtilList".equals(node.astName().astValue())) {
          assertTrue("thisIsAUtilList isn't matched to java.util.List, but should.",
              new Resolver().typesMatch("java.util.List<?>", node.upToVariableDefinition().astTypeReference()));
          hit1.incrementAndGet();
View Full Code Here

  @Test
  public void testInnerMaskingTypesMatch() {
    Source s = new Source(INNER_MASKING_SOURCE, "MaskingTypesMatchTest.java");
    s.parseCompilationUnit();
    final AtomicInteger hit = new AtomicInteger();
    s.getNodes().get(0).accept(new ForwardingAstVisitor() {
      @Override public boolean visitMethodDeclaration(MethodDeclaration node) {
        assertFalse("typesMatch with star import but should fail due to inner masking, yet succeeds.",
            new Resolver().typesMatch("java.util.List", node.astReturnTypeReference()));
        hit.incrementAndGet();
        return true;
View Full Code Here

  @Test
  public void testTopLevelMaskingTypesMatch() {
    Source s = new Source(TOP_LEVEL_MASKING_SOURCE, "MaskingTypesMatchTest.java");
    s.parseCompilationUnit();
    final AtomicInteger hit = new AtomicInteger();
    s.getNodes().get(0).accept(new ForwardingAstVisitor() {
      @Override public boolean visitMethodDeclaration(MethodDeclaration node) {
        assertFalse("typesMatch with star import but should fail due to top level masking, yet succeeds.",
            new Resolver().typesMatch("java.util.List", node.astReturnTypeReference()));
        hit.incrementAndGet();
        return true;
View Full Code Here

  @Test
  public void testArrayTypesMatch() {
    Source s = new Source(ARRAYS_SOURCE, "ArrayTypesMatchTest.java");
    s.parseCompilationUnit();
    final AtomicInteger hit = new AtomicInteger();
    s.getNodes().get(0).accept(new ForwardingAstVisitor() {
      @Override public boolean visitMethodDeclaration(MethodDeclaration node) {
        assertTrue("typesMatch with String[] should match java.lang.String[] but doesn't.",
            new Resolver().typesMatch("java.lang.String[]", node.astReturnTypeReference()));
        assertFalse("typesMatch with String[] should NOT match java.lang.String[][] but does.",
            new Resolver().typesMatch("java.lang.String[][]", node.astReturnTypeReference()));
View Full Code Here

  @Test
  public void testImportedTypesMatch() {
    Source s = new Source(IMPORTS_SOURCE, "ImportsTest.java");
    s.parseCompilationUnit();
    final AtomicInteger hit = new AtomicInteger();
    s.getNodes().get(0).accept(new ForwardingAstVisitor() {
      @Override public boolean visitMethodDeclaration(MethodDeclaration node) {
        assertFalse("typesMatch with java.awt.List+java.util.* imported should NOT match java.util.List",
            new Resolver().typesMatch("java.util.List", node.astReturnTypeReference()));
        assertTrue("typesMatch with java.awt.List+java.util.* imported SHOULD match java.awt.List",
            new Resolver().typesMatch("java.awt.List", node.astReturnTypeReference()));
View Full Code Here

TOP

Related Classes of lombok.ast.ForwardingAstVisitor

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.