com.sun.tools.javac.tree.EndPosTable Java Examples

The following examples show how to use com.sun.tools.javac.tree.EndPosTable. 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: TreeAnalyzer.java    From meghanada-server with GNU General Public License v3.0 6 votes vote down vote up
private static void analyzeAnnotationTree(
    final Source src, final EndPosTable endPosTable, final AnnotationTree at) {
  if (at instanceof JCTree.JCAnnotation) {
    JCTree.JCAnnotation anno = (JCTree.JCAnnotation) at;
    int startPos = anno.getPreferredPosition();
    int endPos = anno.getEndPosition(endPosTable);
    JCTree annotationType = anno.getAnnotationType();
    int annotationTypeEndPosition = annotationType.getEndPosition(endPosTable);
    Range range;
    if (endPos != annotationTypeEndPosition) {
      startPos = annotationTypeEndPosition;
    }
    range = Range.create(src, startPos + 1, endPos);
    Type type = anno.type;
    Annotation annotation;
    if (nonNull(type)) {
      annotation = new Annotation(type.toString(), startPos, range);
    } else {
      annotation = new Annotation(annotationType.toString(), startPos, range);
    }
    src.annotationMap.put(range.begin.line, annotation);
  }
}
 
Example #2
Source File: TreePosTest.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #3
Source File: CheckAttributedTree.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #4
Source File: TreePosTest.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #5
Source File: TreePosTest.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #6
Source File: CheckAttributedTree.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #7
Source File: CheckAttributedTree.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #8
Source File: TreePosTest.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #9
Source File: TreePosTest.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #10
Source File: TreePosTest.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #11
Source File: CheckAttributedTree.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #12
Source File: TreeAnalyzer.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
private static void analyzeAnnotations(
    final SourceContext sc, final List<JCTree.JCAnnotation> annotations, final BlockScope bs) {
  Source src = sc.source;
  EndPosTable endPosTable = sc.endPosTable;
  for (JCTree.JCAnnotation anno : annotations) {
    analyzeAnnotationTree(src, endPosTable, anno);
  }
}
 
Example #13
Source File: TreePosTest.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #14
Source File: TreeAnalyzer.java    From meghanada-server with GNU General Public License v3.0 5 votes vote down vote up
private static void analyzePackageAnnotations(
    final CompilationUnitTree cut, final Source src, final EndPosTable endPosTable) {
  java.util.List<? extends AnnotationTree> annotations = cut.getPackageAnnotations();
  for (final AnnotationTree at : annotations) {
    analyzeAnnotationTree(src, endPosTable, at);
  }
}
 
Example #15
Source File: CheckAttributedTree.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #16
Source File: TranslatePositionsVisitor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TranslatePositionsVisitor (final MethodTree changedMethod, final EndPosTable endPos, final int delta) {
//        assert changedMethod != null;
        assert endPos != null;
        this.changedMethod = changedMethod;
        this.endPos = endPos;
        this.delta = delta;
        
        active = changedMethod == null;//hack
    }
 
Example #17
Source File: TranslatePositionsVisitor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public TranslatePositionsVisitor (final MethodTree changedMethod, final EndPosTable endPos, final int delta) {
    assert changedMethod != null;
    assert endPos != null;
    this.changedMethod = changedMethod;
    this.endPos = endPos;
    this.delta = delta;
}
 
Example #18
Source File: CheckAttributedTree.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
Info(JCTree tree, EndPosTable endPosTable) {
    this.tree = tree;
    tag = tree.getTag();
    start = TreeInfo.getStartPos(tree);
    pos = tree.pos;
    end = TreeInfo.getEndPos(tree, endPosTable);
}
 
Example #19
Source File: DeferredLintHandler.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getEndPosition(EndPosTable endPosTable) {
    Assert.error();
    return -1;
}
 
Example #20
Source File: TreeAnalyzer.java    From meghanada-server with GNU General Public License v3.0 4 votes vote down vote up
private static void analyzeTopLevelClass(SourceContext context, JCTree.JCClassDecl classDecl)
    throws IOException {
  Source src = context.source;
  EndPosTable endPosTable = context.endPosTable;

  Tree.Kind classDeclKind = classDecl.getKind();

  boolean isInterface = classDeclKind.equals(Tree.Kind.INTERFACE);
  boolean isEnum = classDeclKind.equals(Tree.Kind.ENUM);

  int startPos = classDecl.getPreferredPosition();
  int endPos = classDecl.getEndPosition(endPosTable);
  JCTree.JCModifiers modifiers = classDecl.getModifiers();
  List<JCTree.JCAnnotation> annotations = modifiers.getAnnotations();

  final String classModifiers = parseModifiers(context, modifiers);

  analyzeParsedTree(context, classDecl.getExtendsClause());

  analyzeSimpleExpressions(context, classDecl.getImplementsClause());

  Name simpleName = classDecl.getSimpleName();
  Range range = Range.create(src, startPos + 1, endPos);

  int nameStart = startPos + 6;
  if (isInterface) {
    nameStart = startPos + 10;
  } else if (isEnum) {
    nameStart = startPos + 5;
  }
  Range nameRange = Range.create(src, nameStart, nameStart + simpleName.length());

  String fqcn;
  if (src.getPackageName().isEmpty()) {
    fqcn = simpleName.toString();
  } else {
    fqcn = src.getPackageName() + '.' + simpleName.toString();
  }
  ClassScope classScope = new ClassScope(fqcn, nameRange, startPos, range);
  classScope.isEnum = isEnum;
  classScope.isInterface = isInterface;
  log.trace("class={}", classScope);
  analyzeAnnotations(context, annotations, classScope);

  src.startClass(classScope);

  for (JCTree tree : classDecl.getMembers()) {
    analyzeParsedTree(context, tree);
  }
  addClassNameIndex(
      src, classScope.range.begin.line, classScope.range.begin.column, classScope.getFQCN());
  Optional<ClassScope> endClass = src.endClass();
  log.trace("class={}", endClass);
}
 
Example #21
Source File: DeferredLintHandler.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getEndPosition(EndPosTable endPosTable) {
    Assert.error();
    return -1;
}
 
Example #22
Source File: Log.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
public void setEndPosTable(JavaFileObject name, EndPosTable endPosTable) {
    name.getClass(); // null check
    getSource(name).setEndPosTable(endPosTable);
}
 
Example #23
Source File: DeferredLintHandler.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
@Override
public int getEndPosition(EndPosTable endPosTable) {
    Assert.error();
    return -1;
}
 
Example #24
Source File: TestLog.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
LogTester(Log log, EndPosTable endPosTable) {
    this.log = log;
    this.endPosTable = endPosTable;
}
 
Example #25
Source File: DiagnosticSource.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
public EndPosTable getEndPosTable() {
    return endPosTable;
}
 
Example #26
Source File: SourceContext.java    From meghanada-server with GNU General Public License v3.0 4 votes vote down vote up
SourceContext(final Source source, final EndPosTable endPosTable) {
  this.source = source;
  this.endPosTable = endPosTable;
}
 
Example #27
Source File: DiagnosticSource.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public EndPosTable getEndPosTable() {
    return endPosTable;
}
 
Example #28
Source File: DiagnosticSource.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void setEndPosTable(EndPosTable t) {
    if (endPosTable != null && endPosTable != t)
        throw new IllegalStateException("endPosTable already set");
    endPosTable = t;
}
 
Example #29
Source File: DiagnosticSource.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
public void setEndPosTable(EndPosTable t) {
    if (endPosTable != null && endPosTable != t)
        throw new IllegalStateException("endPosTable already set");
    endPosTable = t;
}
 
Example #30
Source File: Log.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
public void setEndPosTable(JavaFileObject name, EndPosTable endPosTable) {
    name.getClass(); // null check
    getSource(name).setEndPosTable(endPosTable);
}