From a35061ee79ad3f3a141a2eb511f73d349e8437fb Mon Sep 17 00:00:00 2001 From: Asger F Date: Wed, 14 Nov 2018 17:33:48 +0000 Subject: [PATCH] TS: dont create JSON nodes in convertJsxSelfClosingElement --- .../js/parser/TypeScriptASTConverter.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/javascript/extractor/src/com/semmle/js/parser/TypeScriptASTConverter.java b/javascript/extractor/src/com/semmle/js/parser/TypeScriptASTConverter.java index 59fcb87a75c..8cb4f2b2594 100644 --- a/javascript/extractor/src/com/semmle/js/parser/TypeScriptASTConverter.java +++ b/javascript/extractor/src/com/semmle/js/parser/TypeScriptASTConverter.java @@ -1385,7 +1385,7 @@ public class TypeScriptASTConverter { return new JSXClosingElement(loc, null); } - private Node convertJsxOpeningElement(JsonObject node, SourceLocation loc) throws ParseError { + private List convertJsxAttributes(JsonObject node) throws ParseError { JsonElement attributes = node.get("attributes"); List convertedAttributes; if (attributes.isJsonArray()) { @@ -1393,15 +1393,18 @@ public class TypeScriptASTConverter { } else { convertedAttributes = convertChildren(attributes.getAsJsonObject(), "properties"); } + return convertedAttributes; + } + + private Node convertJsxOpeningElement(JsonObject node, SourceLocation loc) throws ParseError { + List convertedAttributes = convertJsxAttributes(node); return new JSXOpeningElement(loc, convertJSXName(convertChild(node, "tagName")), convertedAttributes, hasChild(node, "selfClosing")); } - private Node convertJsxSelfClosingElement(JsonObject node, - SourceLocation loc) throws ParseError { - node.remove("kind"); - node.add("kind", syntaxKinds.get("JsxOpeningElement")); - node.add("selfClosing", new JsonPrimitive(true)); - return new JSXElement(loc, (JSXOpeningElement) convertNode(node), new ArrayList<>(), null); + private Node convertJsxSelfClosingElement(JsonObject node, SourceLocation loc) throws ParseError { + List convertedAttributes = convertJsxAttributes(node); + JSXOpeningElement opening = new JSXOpeningElement(loc, convertJSXName(convertChild(node, "tagName")), convertedAttributes, true); + return new JSXElement(loc, opening, new ArrayList<>(), null); } private Node convertJsxSpreadAttribute(JsonObject node,