From 8b206c9e6aa2fb4a0a7d7636315e1af01ed837cb Mon Sep 17 00:00:00 2001 From: giraud Date: Mon, 7 May 2018 17:11:37 +0200 Subject: [PATCH] parse tag names with dot (#52) --- .../com/reason/lang/reason/RmlParser.java | 6 ++++- tests/com/reason/reason/JsxParsingTest.java | 23 ++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/reason/lang/reason/RmlParser.java b/src/main/java/com/reason/lang/reason/RmlParser.java index 4227c9359..944a1e7ac 100644 --- a/src/main/java/com/reason/lang/reason/RmlParser.java +++ b/src/main/java/com/reason/lang/reason/RmlParser.java @@ -343,6 +343,7 @@ private void parseLt(PsiBuilder builder, ParserState state) { if (state.isInScopeExpression()) { state.addStart(tagScope); } + state.dontMove = advance(builder); builder.remapCurrentToken(m_types.TAG_NAME); @@ -356,8 +357,11 @@ private void parseLtSlash(PsiBuilder builder, ParserState state) { // A closing tag builder.remapCurrentToken(m_types.TAG_LT); state.add(markCompleteScope(builder, closeTag, m_types.TAG_CLOSE, groupExpression, m_types.TAG_LT)); + state.dontMove = advance(builder); + builder.remapCurrentToken(m_types.TAG_NAME); + state.dontMove = wrapWith(nextTokenType == m_types.UIDENT ? m_types.UPPER_SYMBOL : m_types.LOWER_SYMBOL, builder); } } @@ -537,7 +541,7 @@ private void parseUIdent(PsiBuilder builder, ParserState state) { state.setComplete(); } else if (state.isResolution(module)) { state.setResolution(moduleNamed); - } else if (state.isResolution(startTag) && state.previousTokenType == m_types.DOT) { + } else if ((state.isResolution(startTag) || state.isResolution(closeTag)) && state.previousTokenType == m_types.DOT) { // a namespaced custom component builder.remapCurrentToken(m_types.TAG_NAME); } else if (state.isResolution(typeNamedEqVariant) && state.previousTokenType == m_types.PIPE) { diff --git a/tests/com/reason/reason/JsxParsingTest.java b/tests/com/reason/reason/JsxParsingTest.java index edd8d5ed3..26d161296 100644 --- a/tests/com/reason/reason/JsxParsingTest.java +++ b/tests/com/reason/reason/JsxParsingTest.java @@ -1,10 +1,13 @@ package com.reason.reason; +import com.intellij.psi.PsiElement; import com.intellij.psi.util.PsiTreeUtil; import com.reason.BaseParsingTestCase; import com.reason.lang.core.psi.PsiLet; +import com.reason.lang.core.psi.PsiTagClose; import com.reason.lang.core.psi.PsiTagStart; import com.reason.lang.reason.RmlParserDefinition; +import com.reason.lang.reason.RmlTypes; public class JsxParsingTest extends BaseParsingTestCase { public JsxParsingTest() { @@ -13,9 +16,27 @@ public JsxParsingTest() { public void testOptionAsTag() { // option here is not a ReasonML keyword - PsiLet let = first(parseCode("let _ =