com.sun.source.tree.LiteralTree Java Examples

The following examples show how to use com.sun.source.tree.LiteralTree. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JSEmbeddingProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@Override
public Void visitMethod(
        final MethodTree m,
        final List<? super LiteralTree> p) {
    for (AnnotationTree a : m.getModifiers().getAnnotations()) {
        final TypeElement ae = (TypeElement) trees.getElement(TreePath.getPath(cu, a.getAnnotationType()));
        if (ae != null && JS_ANNOTATION.contentEquals(ae.getQualifiedName())) {
            final List<? extends ExpressionTree> args =  a.getArguments();
            for (ExpressionTree kvp : args) {
                if (kvp instanceof AssignmentTree) {
                    final AssignmentTree assignemt = (AssignmentTree) kvp;
                    if (BODY.equals(assignemt.getVariable().toString())) {
                        inEmbedding = true;
                        try {
                            scan(assignemt.getExpression(), p);
                        } finally {
                            inEmbedding = false;
                        }
                    }
                }
            }
        }
    }
    return null;
}
 
Example #2
Source File: Utilities.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public static ExpressionTree findValue(AnnotationTree m, String name) {
    for (ExpressionTree et : m.getArguments()) {
        if (et.getKind() == Kind.ASSIGNMENT) {
            AssignmentTree at = (AssignmentTree) et;
            String varName = ((IdentifierTree) at.getVariable()).getName().toString();

            if (varName.equals(name)) {
                return at.getExpression();
            }
        }

        if (et instanceof LiteralTree/*XXX*/ && "value".equals(name)) {
            return et;
        }
    }

    return null;
}
 
Example #3
Source File: ResourceStringFoldProvider.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private String getBundleName(MethodInvocationTree n, int index, String bfn) {
    if (n.getArguments().size() <= index) {
        return null;
    }
    ExpressionTree t = n.getArguments().get(index);
    // recognize just string literals + .class references
    if (t.getKind() == Tree.Kind.STRING_LITERAL) {
        Object o = ((LiteralTree)t).getValue();
        return o == null ? null : o.toString();
    } else if (t.getKind() == Tree.Kind.MEMBER_SELECT) {
        MemberSelectTree mst = (MemberSelectTree)t;
        if (!mst.getIdentifier().contentEquals("class")) {
            return null;
        }
        return bundleFileFromClass(new TreePath(getCurrentPath(), mst.getExpression()), bfn);
    }
    return null;
}
 
Example #4
Source File: ConvertTextBlockToString.java    From netbeans with Apache License 2.0 6 votes vote down vote up
@TriggerTreeKind(Tree.Kind.STRING_LITERAL)
@Messages("ERR_ConvertTextBlockToString=Text block may not be supported")//NOI18N
public static ErrorDescription computeWarning(HintContext ctx) {
    TokenSequence<?> ts = ctx.getInfo().getTokenHierarchy().tokenSequence();
    if (ts == null) {
        return null;
    }
    int textBlockIndex = (int) ctx.getInfo().getTrees().getSourcePositions().getStartPosition(ctx.getPath().getCompilationUnit(), ctx.getPath().getLeaf());
    if (textBlockIndex == -1) {
        return null;
    }
    ts.move(textBlockIndex);

    if (!ts.moveNext() || ts.token().id() != JavaTokenId.MULTILINE_STRING_LITERAL) {
        return null;
    }

    String orignalString = (String) ((LiteralTree) ctx.getPath().getLeaf()).getValue();
    String orignalStringArr[] = textBlockToStringArr(orignalString);
    Fix fix = new FixImpl(ctx.getInfo(), ctx.getPath(), orignalStringArr).toEditorFix();
    return ErrorDescriptionFactory.forName(ctx, ctx.getPath(), Bundle.ERR_ConvertTextBlockToString(), fix);
}
 
Example #5
Source File: ConvertToTextBlock.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private static String getTextOrNull(TreePath tp) {
    StringBuilder text = new StringBuilder();
    Tree current = tp.getLeaf();
    while (current.getKind() == Kind.PLUS) {
        BinaryTree bt = (BinaryTree) current;
        if (bt.getRightOperand().getKind() == Kind.STRING_LITERAL) {
            text.insert(0, ((LiteralTree) bt.getRightOperand()).getValue());
        } else {
            return null;
        }
        current = bt.getLeftOperand();
    }
    if (current.getKind() == Kind.STRING_LITERAL) {
        text.insert(0, ((LiteralTree) current).getValue());
    } else {
        return null;
    }
    String textString = text.toString();
    if (!textString.contains("\n")) {
        return null;
    }
    return textString;
}
 
Example #6
Source File: Refactorer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private List<ProspectiveOperation> getIfListRepresentation( StatementTree tree, boolean last) {
    IfTree ifTree = (IfTree) tree;
    List<ProspectiveOperation> ls = new ArrayList<ProspectiveOperation>();
    if (ifTree.getElseStatement() == null) {

        StatementTree then = ifTree.getThenStatement();
        if (isOneStatementBlock(then)) {
            then = ((BlockTree) then).getStatements().get(0);
        }
        if (then.getKind() == Tree.Kind.RETURN) {
            ReturnTree returnTree = (ReturnTree) then;
            ExpressionTree returnExpression = returnTree.getExpression();
            if (returnExpression.getKind() == Tree.Kind.BOOLEAN_LITERAL && ((LiteralTree) returnExpression).getValue().equals(true)) {
                ls.addAll(ProspectiveOperation.createOperator(ifTree, ProspectiveOperation.OperationType.ANYMATCH, this.preconditionsChecker, this.workingCopy));
            } else if (returnExpression.getKind() == Tree.Kind.BOOLEAN_LITERAL && ((LiteralTree) returnExpression).getValue().equals(false)) {
                ls.addAll(ProspectiveOperation.createOperator(ifTree, ProspectiveOperation.OperationType.NONEMATCH, this.preconditionsChecker, this.workingCopy));
            }
        } else {
            ls.addAll(ProspectiveOperation.createOperator(ifTree, ProspectiveOperation.OperationType.FILTER, this.preconditionsChecker, this.workingCopy));
            ls.addAll(getListRepresentation(ifTree.getThenStatement(), last));
        }
    } else {

        ls.addAll(ProspectiveOperation.createOperator(ifTree, ProspectiveOperation.OperationType.MAP, this.preconditionsChecker, this.workingCopy));
    }
    return ls;
}
 
Example #7
Source File: LiteralTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testNoExtraEscapesInStringLiteral() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile,
        "package hierbas.del.litoral;\n" +
        "\n" +
        "public class Test {\n" +
        "    public static final String C;\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n" +
        "\n" +
        "public class Test {\n" +
        "    public static final String C = \"'\";\n" +
        "}\n";
    JavaSource testSource = JavaSource.forFileObject(FileUtil.toFileObject(testFile));
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(WorkingCopy workingCopy) throws java.io.IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            TreeMaker make = workingCopy.getTreeMaker();

            ClassTree clazz = (ClassTree) workingCopy.getCompilationUnit().getTypeDecls().get(0);
            VariableTree var = (VariableTree) clazz.getMembers().get(1);
            LiteralTree val = make.Literal("'");
            VariableTree nue = make.setInitialValue(var, val);
            workingCopy.rewrite(var, nue);
        }

    };
    testSource.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    //System.err.println(res);
    assertEquals(golden, res);
}
 
Example #8
Source File: AbstractTestGenerator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 */
private StatementTree generateSystemOutPrintln(TreeMaker maker,
                                               String arg) {
    MethodInvocationTree methodInvocation = maker.MethodInvocation(
            Collections.<ExpressionTree>emptyList(),        //type args
            maker.MemberSelect(
                    maker.MemberSelect(
                            maker.Identifier("System"), "out"), "println"),//NOI18N
            Collections.<LiteralTree>singletonList(
                    maker.Literal(arg)));                   //args.
    return maker.ExpressionStatement(methodInvocation);
}
 
Example #9
Source File: AbstractTestGenerator.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 */
private StatementTree generateSystemOutPrintln(TreeMaker maker,
                                               String arg) {
    MethodInvocationTree methodInvocation = maker.MethodInvocation(
            Collections.<ExpressionTree>emptyList(),        //type args
            maker.MemberSelect(
                    maker.MemberSelect(
                            maker.Identifier("System"), "out"), "println"),//NOI18N
            Collections.<LiteralTree>singletonList(
                    maker.Literal(arg)));                   //args.
    return maker.ExpressionStatement(methodInvocation);
}
 
Example #10
Source File: CopyFinder.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public Boolean visitLiteral(LiteralTree node, TreePath p) {
    if (p == null)
        return super.visitLiteral(node, p);

    LiteralTree lt = (LiteralTree) p.getLeaf();
    Object nodeValue = node.getValue();
    Object ltValue = lt.getValue();

    if (nodeValue == ltValue)
        return true;

    if (nodeValue == null || ltValue == null)
        return false;
    return nodeValue.equals(ltValue);
}
 
Example #11
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testPrintMemberReference() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = null;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitLiteral(LiteralTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                    return super.visitLiteral(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    //System.err.println(res);
    assertEquals(golden, res);
}
 
Example #12
Source File: TreeNode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitLiteral(LiteralTree tree, List<Node> d) {
    List<Node> below = new ArrayList<Node>();
    
    addCorrespondingType(below);
    addCorrespondingComments(below);
    super.visitLiteral(tree, below);
    
    d.add(new TreeNode(info, getCurrentPath(), below));
    return null;
}
 
Example #13
Source File: JSEmbeddingProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void colorizeJSB(final CompilationInfo ci) {
    final CompilationUnitTree cu = ci.getCompilationUnit();
    final Trees trees = ci.getTrees();
    final SourcePositions sp = trees.getSourcePositions();
    final Finder f = new Finder(trees);
    final List<LiteralTree> result = new ArrayList<>();
    f.scan(cu, result);
    if (!result.isEmpty()) {
        try {
            final TokenHierarchy<Document> tk = TokenHierarchy.get(ci.getDocument());
            final Language<?> java = Language.find(JAVA_MIME_TYPE);
            final Language<?> javaScript = Language.find(JAVASCRIPT_MIME_TYPE);
            if (java != null && javaScript != null) {
                final TokenSequence<?> seq = tk.tokenSequence(java);
                if (seq != null) {
                    for (LiteralTree lt : result) {
                        final int start = (int) sp.getStartPosition(cu, lt);
                        final int end = (int) sp.getEndPosition(cu, lt);
                        seq.move(start);
                        while (seq.moveNext() && seq.offset() < end) {
                            if (
                                seq.embedded() != null &&
                                seq.embedded().language() != null &&
                                "text/x-java-string".equals(seq.embedded().language().mimeType())
                            ) {
                                seq.removeEmbedding(seq.embedded().language());
                            }
                            seq.createEmbedding(javaScript, 1, 1, true);
                        }
                    }
                }
            }
        } catch (IOException ioe) {
            LOG.log(Level.WARNING, null, ioe);
        }
    }
}
 
Example #14
Source File: JSEmbeddingProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitCompilationUnit(
        final CompilationUnitTree unit,
        final List<? super LiteralTree> p) {
    this.cu = unit;
    return super.visitCompilationUnit(unit, p);
}
 
Example #15
Source File: JSEmbeddingProvider.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitLiteral(LiteralTree node, List<? super LiteralTree> p) {
    if (inEmbedding) {
        p.add(node);
    }
    return super.visitLiteral(node, p);
}
 
Example #16
Source File: ArithmeticUtilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Object visitLiteral(LiteralTree node, Void p) {
    if (node.getKind() == NULL_LITERAL) {
        return enhanceProcessing ? NULL : null;
    } 
    return node.getValue();
}
 
Example #17
Source File: BreadcrumbsTest.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
private LiteralTree literalTree() {
   // Checked implicitly in CompilationTestUtils by Tree.Kind parameter
  @SuppressWarnings("unchecked")
  LiteralTree ret =
      (LiteralTree) MoreTrees.findSubtree(baseTree(), Tree.Kind.STRING_LITERAL, "literal");
  return ret;
}
 
Example #18
Source File: Flow.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean visitLiteral(LiteralTree node, ConstructorData p) {
    Object val = node.getValue();

    if (val instanceof Boolean) {
        return (Boolean) val;
    } else {
        return null;
    }
}
 
Example #19
Source File: Utilities.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public String visitLiteral(LiteralTree node, Void p) {
    if (node.getValue() instanceof String)
        return "...";

    int start = (int) info.getTrees().getSourcePositions().getStartPosition(info.getCompilationUnit(), node);
    int end   = (int) info.getTrees().getSourcePositions().getEndPosition(info.getCompilationUnit(), node);

    if (start < 0 || end < 0 || end < start) {
        return node.toString();
    }
    
    return info.getText().substring(start, end);
}
 
Example #20
Source File: LambdaTest.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testPrintMemberReference() throws Exception {
    testFile = new File(getWorkDir(), "Test.java");
    TestUtilities.copyStringToFile(testFile, 
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = null;\n" + 
        "    }\n" +
        "}\n"
        );
    String golden =
        "package hierbas.del.litoral;\n\n" +
        "public class Test {\n" +
        "    public static void taragui() {\n" +
        "        Runnable r = Test::taragui;\n" + 
        "    }\n" +
        "}\n";
    JavaSource src = getJavaSource(testFile);
    
    Task<WorkingCopy> task = new Task<WorkingCopy>() {

        public void run(final WorkingCopy workingCopy) throws IOException {
            workingCopy.toPhase(Phase.RESOLVED);
            CompilationUnitTree cut = workingCopy.getCompilationUnit();
            final TreeMaker make = workingCopy.getTreeMaker();
            new ErrorAwareTreeScanner<Void, Void>() {
                @Override public Void visitLiteral(LiteralTree node, Void p) {
                    workingCopy.rewrite(node, make.MemberReference(ReferenceMode.INVOKE, make.Identifier("Test"), "taragui", Collections.<ExpressionTree>emptyList()));
                    return super.visitLiteral(node, p);
                }
            }.scan(workingCopy.getCompilationUnit(), null);
        }

    };
    src.runModificationTask(task).commit();
    String res = TestUtilities.copyFileToString(testFile);
    System.err.println(res);
    assertEquals(golden, res);
}
 
Example #21
Source File: StreamNullabilityPropagator.java    From NullAway with MIT License 5 votes vote down vote up
private boolean canBooleanExpressionEvalToTrue(ExpressionTree expressionTree) {
  if (expressionTree instanceof LiteralTree) {
    LiteralTree expressionAsLiteral = (LiteralTree) expressionTree;
    if (expressionAsLiteral.getValue() instanceof Boolean) {
      return (boolean) expressionAsLiteral.getValue();
    } else {
      throw new RuntimeException("not a boolean expression!");
    }
  }
  // We are fairly conservative, anything other than 'return false;' is assumed to potentially be
  // true.
  // No SAT-solving or any other funny business.
  return true;
}
 
Example #22
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
@Override
public Void visitLiteral(LiteralTree node, Void unused) {
    sync(node);
    String sourceForNode = getSourceForNode(node, getCurrentPath());
    // A negative numeric literal -n is usually represented as unary minus on n,
    // but that doesn't work for integer or long MIN_VALUE. The parser works
    // around that by representing it directly as a singed literal (with no
    // unary minus), but the lexer still expects two tokens.
    if (sourceForNode.startsWith("-")) {
        token("-");
        sourceForNode = sourceForNode.substring(1).trim();
    }
    token(sourceForNode);
    return null;
}
 
Example #23
Source File: JavaInputAstVisitor.java    From javaide with GNU General Public License v3.0 5 votes vote down vote up
private boolean isStringConcat(ExpressionTree first) {
    final boolean[] stringLiteral = {true};
    final boolean[] formatString = {false};
    new TreeScanner() {
        @Override
        public void scan(JCTree tree) {
            if (tree == null) {
                return;
            }
            switch (tree.getKind()) {
                case STRING_LITERAL:
                    break;
                case PLUS:
                    super.scan(tree);
                    break;
                default:
                    stringLiteral[0] = false;
                    break;
            }
            if (tree.getKind() == STRING_LITERAL) {
                Object value = ((LiteralTree) tree).getValue();
                if (value instanceof String && FORMAT_SPECIFIER.matcher(value.toString()).find()) {
                    formatString[0] = true;
                }
            }
        }
    }.scan((JCTree) first);
    return stringLiteral[0] && formatString[0];
}
 
Example #24
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitLiteral(LiteralTree node, Void unused) {
  sync(node);
  String sourceForNode = getSourceForNode(node, getCurrentPath());
  // A negative numeric literal -n is usually represented as unary minus on n,
  // but that doesn't work for integer or long MIN_VALUE. The parser works
  // around that by representing it directly as a signed literal (with no
  // unary minus), but the lexer still expects two tokens.
  if (sourceForNode.startsWith("-")) {
    token("-");
    sourceForNode = sourceForNode.substring(1).trim();
  }
  token(sourceForNode);
  return null;
}
 
Example #25
Source File: JavaInputAstVisitor.java    From google-java-format with Apache License 2.0 5 votes vote down vote up
private boolean isStringConcat(ExpressionTree first) {
  final boolean[] stringLiteral = {true};
  final boolean[] formatString = {false};
  new TreeScanner() {
    @Override
    public void scan(JCTree tree) {
      if (tree == null) {
        return;
      }
      switch (tree.getKind()) {
        case STRING_LITERAL:
          break;
        case PLUS:
          super.scan(tree);
          break;
        default:
          stringLiteral[0] = false;
          break;
      }
      if (tree.getKind() == STRING_LITERAL) {
        Object value = ((LiteralTree) tree).getValue();
        if (value instanceof String && FORMAT_SPECIFIER.matcher(value.toString()).find()) {
          formatString[0] = true;
        }
      }
    }
  }.scan((JCTree) first);
  return stringLiteral[0] && formatString[0];
}
 
Example #26
Source File: ModelBuilder.java    From vertx-codetrans with Apache License 2.0 5 votes vote down vote up
@Override
public ExpressionModel visitLiteral(LiteralTree node, VisitContext context) {
  switch (node.getKind()) {
    case NULL_LITERAL:
      return new NullLiteralModel(context.builder);
    case STRING_LITERAL:
      return new StringLiteralModel(context.builder, node.getValue().toString());
    case BOOLEAN_LITERAL:
      return context.builder.render(writer -> {
        writer.renderBooleanLiteral(node.getValue().toString());
      });
    case INT_LITERAL:
      return context.builder.render(writer -> {
        writer.renderIntegerLiteral(node.getValue().toString());
      });
    case LONG_LITERAL:
      return context.builder.render(writer -> {
        writer.renderLongLiteral(node.getValue().toString());
      });
    case CHAR_LITERAL:
      return context.builder.render(writer -> {
        writer.renderCharLiteral(node.getValue().toString().charAt(0));
      });
    case FLOAT_LITERAL:
      return context.builder.render(writer -> {
        writer.renderFloatLiteral(node.getValue().toString());
      });
    case DOUBLE_LITERAL:
      return context.builder.render(writer -> {
        writer.renderDoubleLiteral(node.getValue().toString());
      });
    default:
      throw new UnsupportedOperationException("Literal " + node.getKind().name() + " not yet implemented");
  }
}
 
Example #27
Source File: TreePruner.java    From bazel with Apache License 2.0 5 votes vote down vote up
@Override
public Boolean visitLiteral(LiteralTree node, Void unused) {
  switch (node.getKind()) {
    case STRING_LITERAL:
    case INT_LITERAL:
    case LONG_LITERAL:
    case FLOAT_LITERAL:
    case DOUBLE_LITERAL:
    case BOOLEAN_LITERAL:
    case CHAR_LITERAL:
      return true;
    default:
      return false;
  }
}
 
Example #28
Source File: TreeDiffer.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitLiteral(LiteralTree expected, Tree actual) {
  Optional<LiteralTree> other = checkTypeAndCast(expected, actual);
  if (!other.isPresent()) {
    addTypeMismatch(expected, actual);
    return null;
  }

  checkForDiff(Objects.equal(expected.getValue(), other.get().getValue()),
      "Expected literal value to be <%s> but was <%s>.",
      expected.getValue(), other.get().getValue());
  return null;
}
 
Example #29
Source File: MoreTrees.java    From compile-testing with Apache License 2.0 5 votes vote down vote up
@Override
public Optional<TreePath> visitLiteral(@Nullable LiteralTree node, Void v) {
  if (node == null) {
    return Optional.absent();
  } else if (isMatch(node, node.getValue())) {
    return currentPathPlus(node);
  }

  return super.visitLiteral(node, v);
}
 
Example #30
Source File: JavaInputAstVisitor.java    From java-n-IDE-for-Android with Apache License 2.0 5 votes vote down vote up
@Override
public Void visitLiteral(LiteralTree node, Void unused) {
    sync(node);
    String sourceForNode = getSourceForNode(node, getCurrentPath());
    // A negative numeric literal -n is usually represented as unary minus on n,
    // but that doesn't work for integer or long MIN_VALUE. The parser works
    // around that by representing it directly as a singed literal (with no
    // unary minus), but the lexer still expects two tokens.
    if (sourceForNode.startsWith("-")) {
        token("-");
        sourceForNode = sourceForNode.substring(1).trim();
    }
    token(sourceForNode);
    return null;
}