| 49 | import com.google.common.collect.Maps; |
| 50 | |
| 51 | public class Source { |
| 52 | @Getter private final String name; |
| 53 | @Getter private final String rawInput; |
| 54 | private List<Node> nodes; |
| 55 | private List<ParseProblem> problems; |
| 56 | private List<Comment> comments; |
| 57 | private boolean parsed; |
| 58 | private ParsingResult<Node> parsingResult; |
| 59 | |
| 60 | private TreeMap<Integer, Integer> positionDeltas; |
| 61 | private Map<org.parboiled.Node<Node>, Node> registeredStructures; |
| 62 | private Map<org.parboiled.Node<Node>, List<Comment>> registeredComments; |
| 63 | private String preprocessed; |
| 64 | private Map<Node, Collection<SourceStructure>> cachedSourceStructures; |
| 65 | private List<Integer> lineEndings; |
| 66 | |
| 67 | public Source(String rawInput, String name) { |
| 68 | this.rawInput = rawInput; |
| 69 | this.name = name; |
| 70 | clear(); |
| 71 | } |
| 72 | |
| 73 | public List<Node> getNodes() { |
| 74 | parseCompilationUnit(); |
| 75 | if (!parsed) throw new IllegalStateException("Code hasn't been parsed yet."); |
| 76 | return nodes; |
| 77 | } |
| 78 | |
| 79 | public List<ParseProblem> getProblems() { |
| 80 | parseCompilationUnit(); |
| 81 | return problems; |
| 82 | } |
| 83 | |
| 84 | public void clear() { |
| 85 | nodes = Lists.newArrayList(); |
| 86 | problems = Lists.newArrayList(); |
| 87 | comments = Lists.newArrayList(); |
| 88 | lineEndings = ImmutableList.of(); |
| 89 | parsed = false; |
| 90 | parsingResult = null; |
| 91 | positionDeltas = Maps.newTreeMap(); |
| 92 | registeredComments = new MapMaker().weakKeys().makeMap(); |
| 93 | registeredStructures = new MapMaker().weakKeys().makeMap(); |
| 94 | cachedSourceStructures = null; |
| 95 | } |
| 96 | |
| 97 | public String getOverviewProfileInformation() { |
| 98 | clear(); |
| 99 | preProcess(); |
| 100 | ParserGroup group = new ParserGroup(this); |
| 101 | ProfilerParseRunner<Node> runner = new ProfilerParseRunner<Node>(group.structures.compilationUnitEoi(), preprocessed); |
| 102 | this.parsingResult = runner.run(); |
| 103 | StringBuilder out = new StringBuilder(); |
| 104 | out.append(runner.getOverviewReport()); |
| 105 | postProcess(); |
| 106 | return out.toString(); |
| 107 | } |
| 108 |
nothing calls this directly
no outgoing calls
no test coverage detected