Skip to content

Commit

Permalink
chore: reformat code and remove debug code
Browse files Browse the repository at this point in the history
  • Loading branch information
kunli2 committed Nov 28, 2023
1 parent e1178ec commit c3b4f50
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
12 changes: 0 additions & 12 deletions src/main/java/org/openrewrite/javascript/JavaScriptParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,12 @@ public Stream<SourceFile> parseInputs(Iterable<Input> sources, @Nullable Path re
sourceTextsForTSC.put(relativePath, sourceText.sourceText);
});

// Debug purpose only, Turn this to ture locally to help debug when developing parser
boolean debug = false;

//noinspection resource
runtime().parseSourceTexts(
sourceTextsForTSC,
(node, context) -> {
SourceWrapper source = sourcesByRelativePath.get(context.getRelativeSourcePath());

if (debug) {
System.out.println(TsTreePrinter.print(source.input));
System.out.println(TsTreePrinter.print(node, context, true));
}

parsingListener.startedParsing(source.getInput());
TypeScriptParserVisitor fileMapper = new TypeScriptParserVisitor(
node,
Expand All @@ -151,10 +143,6 @@ public Stream<SourceFile> parseInputs(Iterable<Input> sources, @Nullable Path re
cu = ParseError.build(JavaScriptParser.builder().build(), source.getInput(), relativeTo, pctx, t);
}

if (debug) {
System.out.println(TsTreePrinter.print(cu));
}

compilationUnits.add(cu);
}
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,23 @@ private static String printType(Tree tree) {

private static String printTreeElement(Tree tree) {
// skip some specific types printed in the output to make the output looks clean
if (tree instanceof J.CompilationUnit
|| tree instanceof J.ClassDeclaration
|| tree instanceof J.Block
|| tree instanceof J.Empty
|| tree instanceof J.Try
|| tree instanceof J.Try.Catch
|| tree instanceof J.ForLoop
|| tree instanceof J.WhileLoop
|| tree instanceof J.DoWhileLoop
|| tree instanceof J.Lambda
|| tree instanceof J.Lambda.Parameters
|| tree instanceof J.If
|| tree instanceof J.If.Else
|| tree instanceof J.EnumValueSet
|| tree instanceof J.TypeParameter
|| tree instanceof J.Package
|| tree instanceof J.ForEachLoop
if (tree instanceof J.CompilationUnit ||
tree instanceof J.ClassDeclaration ||
tree instanceof J.Block ||
tree instanceof J.Empty ||
tree instanceof J.Try ||
tree instanceof J.Try.Catch ||
tree instanceof J.ForLoop ||
tree instanceof J.WhileLoop ||
tree instanceof J.DoWhileLoop ||
tree instanceof J.Lambda ||
tree instanceof J.Lambda.Parameters ||
tree instanceof J.If ||
tree instanceof J.If.Else ||
tree instanceof J.EnumValueSet ||
tree instanceof J.TypeParameter ||
tree instanceof J.Package ||
tree instanceof J.ForEachLoop
) {
return "";
}
Expand Down

0 comments on commit c3b4f50

Please sign in to comment.