Package lombok.ast

Examples of lombok.ast.Position


 
  private lombok.ast.Modifiers toModifiers(int modifiers, Annotation[] annotations, int start, int end) {
    lombok.ast.Modifiers m = new lombok.ast.Modifiers();
    for (KeywordModifier mod : KeywordModifier.fromReflectModifiers(modifiers)) m.astKeywords().addToEnd(mod);
    fillList(annotations, m.rawAnnotations());
    m.setPosition(new Position(start, end));
    return m;
  }
View Full Code Here


    if (node == null) return Position.UNPLACED;
    int start = node.pos;
    Integer end_ = null;
    if (endPosTable != null) end_ = endPosTable.get(node);
    int end = end_ == null ? node.getEndPosition(endPosTable) : end_;
    return new Position(start, end);
  }
View Full Code Here

    }
   
    VariableDefinition def = new VariableDefinition();
    def.astModifiers((Modifiers) toTree(first.mods));
    setPos(decls.get(decls.size()-1), def);
    if (decls.size() > 1) def.setPosition(new Position(startPosFirst, def.getPosition().getEnd()));
    int baseDims = countDims(baseType);
    if ((first.mods.flags & Flags.VARARGS) != 0) {
      def.astVarargs(true);
      setConversionPositionInfo(def, "...", getPosition(baseType));
      if (baseType instanceof JCArrayTypeTree) baseType = ((JCArrayTypeTree) baseType).elemtype;
View Full Code Here

  private void attachJavadocToNode(CommentInfo javadoc, JavadocContainer node) {
    String content = javadoc.content;
    if (content.startsWith("/*") && content.endsWith("*/")) content = content.substring(2, content.length() - 2);
   
    Comment comment = new Comment().astBlockComment(true).astContent(content);
    comment.setPosition(new Position(javadoc.pos, javadoc.endPos));
    node.astJavadoc(comment);
    if (!node.getPosition().isUnplaced()) {
      int oldStart = node.getPosition().getStart();
      if (oldStart == -1 || comment.getPosition().getStart() < oldStart) {
        node.setPosition(new Position(comment.getPosition().getStart(), node.getPosition().getEnd()));
      }
    }
  }
View Full Code Here

      int start = node.pos;
      Integer end_ = endPosTable.get(node);
      if (node instanceof JCUnary) end_ = node.getEndPosition(endPosTable);
      int end = end_ == null ? node.getEndPosition(endPosTable) : end_;
      if (start != com.sun.tools.javac.util.Position.NOPOS && end != com.sun.tools.javac.util.Position.NOPOS) {
        astNode.setPosition(new Position(start, end));
      }
    }
    return astNode;
  }
View Full Code Here

 
  private void postProcess() {
    for (ParseError error : parsingResult.parseErrors) {
      int errStart = error.getStartIndex();
      int errEnd = error.getEndIndex();
      problems.add(new ParseProblem(new Position(mapPosition(errStart), mapPosition(errEnd)), error.toString()));
    }
   
    if (parsingResult.parseTreeRoot != null) {
      nodes.add(parsingResult.parseTreeRoot.getValue());
      gatherComments(parsingResult.parseTreeRoot);
View Full Code Here

   
    Map<Node, Collection<SourceStructure>> result = map.asMap();
   
    for (Collection<SourceStructure> structures : result.values()) {
      for (SourceStructure structure : structures) {
        structure.setPosition(new Position(
            mapPosition(structure.getPosition().getStart()),
            mapPosition(structure.getPosition().getEnd())));
      }
    }
   
View Full Code Here

    Node target = registeredStructures.remove(pNode);
    if (target != null || pNode.getChildren().isEmpty()) {
      int start = pNode.getStartIndex();
      int end = pNode.getEndIndex();
      String text = preprocessed.substring(start, end);
      SourceStructure structure = new SourceStructure(new Position(start, end), text);
      if (target != null) addSourceStructure(map, target, structure);
      else if (pNode.getValue() != null && !(pNode.getValue() instanceof TemporaryNode)) addSourceStructure(map, pNode.getValue(), structure);
      else if (owner != null) addSourceStructure(map, owner, structure);
    } else {
      Node possibleOwner = pNode.getValue();
View Full Code Here

   * We also adjust all positions to conform with the raw input (undoing any positional shifts caused by preprocessing).
   */
  private void rtrimPositions(List<Node> nodes, List<Comment> comments) {
    final boolean[] whitespace = new boolean[preprocessed.length()];
    for (Comment comment : comments) {
      Position p = comment.getPosition();
      if (!p.isUnplaced()) {
        for (int i = p.getStart(); i < p.getEnd(); i++) whitespace[i] = true;
      }
    }
   
    /* Process actual whitespace in preprocessed source data */ {
      char[] chars = preprocessed.toCharArray();
      for (int i = 0; i < chars.length; i++) if (Character.isWhitespace(chars[i])) whitespace[i] = true;
    }
   
    for (Node node : nodes) node.accept(new ForwardingAstVisitor() {
      @Override public boolean visitNode(Node node) {
        Position p = node.getPosition();
        if (p.isUnplaced()) return false;
       
        int trimmed = Math.min(whitespace.length, p.getEnd());
        while (trimmed > 0 && whitespace[trimmed-1]) trimmed--;
       
        int start, end;
       
        if (p.getEnd() - p.getStart() == 0) {
          if (node.getParent() != null) {
            start = Math.min(node.getParent().getPosition().getEnd(), Math.max(node.getParent().getPosition().getStart(), p.getStart()));
            end = start;
          } else {
            start = p.getStart();
            end = start;
          }
        } else {
          start = p.getStart();
          end = Math.max(trimmed, start);
        }
       
        node.setPosition(new Position(start, end));
       
        return false;
      }
    });
  }
View Full Code Here

  }
 
  private void fixPositions(List<? extends Node> nodes) {
    for (Node node : nodes) node.accept(new ForwardingAstVisitor() {
      @Override public boolean visitNode(Node node) {
        Position p = node.getPosition();
        if (!p.isUnplaced()) {
          node.setPosition(new Position(mapPosition(p.getStart()), mapPosition(p.getEnd())));
        }
        if (node instanceof Expression) {
          List<Position> list = ((Expression)node).astParensPositions();
          if (list != null) {
            ListIterator<Position> li = list.listIterator();
            while (li.hasNext()) {
              Position parenPos = li.next();
              if (!parenPos.isUnplaced()) {
                parenPos = new Position(mapPosition(parenPos.getStart()), mapPosition(parenPos.getEnd()));
                li.set(parenPos);
              }
            }
          }
        }
View Full Code Here

TOP

Related Classes of lombok.ast.Position

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.