@Test public void testComments() { Tree parent = converter.parse("#! Shebang comment\n\nfun function1(a: Int, b: String): Boolean { assertTree(parent).isInstanceOf(TopLevelTree.class); assertThat(parent.children()).hasSize(1); TopLevelTree topLevelTree = (TopLevelTree) parent; List<Comment> comments = topLevelTree.allComments(); assertThat(comments).hasSize(4); Comment comment = comments.get(1); assertRange(comment.textRange()).hasRange(2, 0, 3, 2); assertRange(comment.contentRange()).hasRange(2, 3, 3, 0); assertThat(comment.contentText()).isEqualTo(" Doc comment \n"); assertThat(comment.text()).isEqualTo(""); FunctionDeclarationTree tree = (FunctionDeclarationTree) topLevelTree.declarations().get(0); List<Comment> commentsInsideFunction = tree.metaData().commentsInside(); assertThat(commentsInsideFunction).hasSize(3); comment = commentsInsideFunction.get(2); assertRange(comment.textRange()).hasRange(4, 63, 4, 77); assertRange(comment.contentRange()).hasRange(4, 65, 4, 77); assertThat(comment.text()).isEqualTo(" }
@Override public Tree parse(String content) { KotlinTree kotlinTree = new KotlinTree(content); KotlinTreeVisitor kotlinTreeVisitor = new KotlinTreeVisitor(kotlinTree.psiFile, kotlinTree.metaDataProvider); return kotlinTreeVisitor.getSLangAST(); }
KotlinConverter implements ASTConverter { @Override public Tree parse(String content) { KotlinTree kotlinTree = new KotlinTree(content); KotlinTreeVisitor kotlinTreeVisitor = new KotlinTreeVisitor(kotlinTree.psiFile, kotlinTree.metaDataProvider); return kotlinTreeVisitor.getSLangAST(); } }
KotlinConverter implements ASTConverter { @Override public Tree parse(String content) { KotlinTree kotlinTree = new KotlinTree(content); KotlinTreeVisitor kotlinTreeVisitor = new KotlinTreeVisitor(kotlinTree.psiFile, kotlinTree.metaDataProvider); return kotlinTreeVisitor.getSLangAST(); }  }
KotlinConverter implements ASTConverter { @Override public Tree parse(String content) { KotlinTree kotlinTree = new KotlinTree(content); KotlinTreeVisitor kotlinTreeVisitor = new KotlinTreeVisitor(kotlinTree.psiFile, kotlinTree.metaDataProvider); return kotlinTreeVisitor.getSLangAST(); }  @Override Tree parse(String content); }
KotlinConverter implements ASTConverter { @Override public Tree parse(String content) { KotlinTree kotlinTree = new KotlinTree(content); KotlinTreeVisitor kotlinTreeVisitor = new KotlinTreeVisitor(kotlinTree.psiFile, kotlinTree.metaDataProvider); return kotlinTreeVisitor.getSLangAST(); }  @Override Tree parse(String content);  }