@Test public void comments() { TopLevelTree tree = (TopLevelTree) converter.parse("#start comment\n" + "require 'stuff'\n" + "a = 2 && 1\n" + "def method()\n" + " a += 2 # line comment\n" + "end\n" + "result = obj.methodcall(argument) ; result\n" + "=begin\n" + "First line\n" + "End multiline comment\n" + "=end\n"); assertThat(tree.allComments()).extracting(Comment::text).containsExactly( "#start comment", "# line comment", "=begin\nFirst line\nEnd multiline comment\n=end"); assertThat(tree.allComments()).extracting(Comment::contentText).containsExactly( "start comment", " line comment", "First line\nEnd multiline comment"); assertRange(tree.allComments().get(0).textRange()).hasRange(1, 0, 1, 14); assertRange(tree.allComments().get(1).textRange()).hasRange(5, 9, 5, 23); assertRange(tree.allComments().get(2).textRange()).hasRange(8, 0, 11, 4); assertRange(tree.allComments().get(0).contentRange()).hasRange(1, 1, 1, 14); assertRange(tree.allComments().get(1).contentRange()).hasRange(5, 10, 5, 23); assertRange(tree.allComments().get(2).contentRange()).hasRange(9, 0, 10, 21); assertThat(tree.children().get(0).children().get(0).metaData().commentsInside()).isEmpty(); assertThat(tree.children().get(0).children().get(2).metaData().commentsInside()).hasSize(1); }
@Override public Tree parse(String content) { try { return parseContent(content); } catch (StandardError e) { throw new ParseException(e.getMessage(), getErrorLocation(e), e); } catch (Exception e) { throw new ParseException(e.getMessage(), null, e); } }
RubyConverter implements ASTConverter { @Override public Tree parse(String content) { try { return parseContent(content); } catch (StandardError e) { throw new ParseException(e.getMessage(), getErrorLocation(e), e); } catch (Exception e) { throw new ParseException(e.getMessage(), null, e); } } }
RubyConverter implements ASTConverter { @Override public Tree parse(String content) { try { return parseContent(content); } catch (StandardError e) { throw new ParseException(e.getMessage(), getErrorLocation(e), e); } catch (Exception e) { throw new ParseException(e.getMessage(), null, e); } } RubyConverter(RubyRuntimeAdapter rubyRuntimeAdapter);  RubyConverter(); }
RubyConverter implements ASTConverter { @Override public Tree parse(String content) { try { return parseContent(content); } catch (StandardError e) { throw new ParseException(e.getMessage(), getErrorLocation(e), e); } catch (Exception e) { throw new ParseException(e.getMessage(), null, e); } } RubyConverter(RubyRuntimeAdapter rubyRuntimeAdapter);  RubyConverter(); @Override void terminate(); @Override Tree parse(String content); }
RubyConverter implements ASTConverter { @Override public Tree parse(String content) { try { return parseContent(content); } catch (StandardError e) { throw new ParseException(e.getMessage(), getErrorLocation(e), e); } catch (Exception e) { throw new ParseException(e.getMessage(), null, e); } } RubyConverter(RubyRuntimeAdapter rubyRuntimeAdapter);  RubyConverter(); @Override void terminate(); @Override Tree parse(String content);  }