diff --git a/src/main/java/com/reason/lang/ParserScopeEnum.java b/src/main/java/com/reason/lang/ParserScopeEnum.java index 292056af8..3d94b76f5 100644 --- a/src/main/java/com/reason/lang/ParserScopeEnum.java +++ b/src/main/java/com/reason/lang/ParserScopeEnum.java @@ -102,5 +102,5 @@ public enum ParserScopeEnum { executable, maybeLetFunction, maybeLetFunctionParameters, - valNamedSymbol, struct, matchException, beginScope, ifElseStatement, bracketGt, moduleDeclaration, moduleInstanciation, tryWith, moduleNamedColonWith, moduleNamedWithType, doLoop, tryWithScope, letBinding, scope, moduleNamedSignatureEq, array, signature, objectScope, clazzDeclaration, clazz, clazzNamed, clazzNamedEq, clazzBody, clazzBodyScope, clazzConstructor, clazzField, clazzFieldNamed, clazzMethod, clazzMethodNamed, clazzNamedParameters, clazzNamedConstructor, record, mixin, name + valNamedSymbol, struct, matchException, beginScope, ifElseStatement, bracketGt, moduleDeclaration, moduleInstanciation, tryWith, moduleNamedColonWith, moduleNamedWithType, doLoop, tryWithScope, letBinding, scope, moduleNamedSignatureEq, array, signature, objectScope, clazzDeclaration, clazz, clazzNamed, clazzNamedEq, clazzBody, clazzBodyScope, clazzConstructor, clazzField, clazzFieldNamed, clazzMethod, clazzMethodNamed, clazzNamedParameters, clazzNamedConstructor, record, mixin, functionCallParams, name } diff --git a/src/main/java/com/reason/lang/PsiElementFactory.java b/src/main/java/com/reason/lang/PsiElementFactory.java index 5e589dac5..035197f5a 100644 --- a/src/main/java/com/reason/lang/PsiElementFactory.java +++ b/src/main/java/com/reason/lang/PsiElementFactory.java @@ -58,6 +58,8 @@ public static PsiElement createElement(MlTypes types, ASTNode node) { return new PsiLetBinding(node); } else if (type == types.FUN_PARAMS) { return new PsiParametersImpl(types, node); + } else if (type == types.FUN_CALL_PARAMS) { + return new PsiFunctionCallParams(node); } else if (type == types.MACRO_NAME) { return new PsiMacroName(node); } else if (type == types.SCOPED_EXPR) { diff --git a/src/main/java/com/reason/lang/core/psi/PsiFunctionCallParams.java b/src/main/java/com/reason/lang/core/psi/PsiFunctionCallParams.java new file mode 100644 index 000000000..5f6f4c14c --- /dev/null +++ b/src/main/java/com/reason/lang/core/psi/PsiFunctionCallParams.java @@ -0,0 +1,21 @@ +package com.reason.lang.core.psi; + +import com.intellij.extapi.psi.ASTWrapperPsiElement; +import com.intellij.lang.ASTNode; + +public class PsiFunctionCallParams extends ASTWrapperPsiElement { + + public PsiFunctionCallParams(ASTNode node) { + super(node); + } + + @Override + public boolean canNavigate() { + return false; + } + + @Override + public String toString() { + return "function call params"; + } +} diff --git a/src/main/java/com/reason/lang/core/psi/type/MlTypes.java b/src/main/java/com/reason/lang/core/psi/type/MlTypes.java index deef02d0f..231a0e8ff 100644 --- a/src/main/java/com/reason/lang/core/psi/type/MlTypes.java +++ b/src/main/java/com/reason/lang/core/psi/type/MlTypes.java @@ -23,6 +23,7 @@ public abstract class MlTypes { public IElementType GENERIC_EXPR; public IElementType MACRO_EXPR; public IElementType MACRO_NAME; + public IElementType MIXIN_FIELD; public IElementType MODULE_PATH; public IElementType ASSERT_STMT; public IElementType SCOPED_EXPR; @@ -39,6 +40,7 @@ public abstract class MlTypes { public IElementType FUN_EXPR; public IElementType FUN_PARAMS; public IElementType FUN_BODY; + public IElementType FUN_CALL_PARAMS; public IElementType RECORD_EXPR; public IElementType RECORD_FIELD; public IElementType SWITCH_EXPR; @@ -89,7 +91,6 @@ public abstract class MlTypes { public MlTokenElementType INITIALIZER; public MlTokenElementType LAZY; public MlTokenElementType LET; - public MlTokenElementType MIXIN_FIELD; public MlTokenElementType MODULE; public MlTokenElementType MUTABLE; public MlTokenElementType NEW; diff --git a/src/main/java/com/reason/lang/ocaml/OclTypes.java b/src/main/java/com/reason/lang/ocaml/OclTypes.java index f27526caf..1759a7ad0 100644 --- a/src/main/java/com/reason/lang/ocaml/OclTypes.java +++ b/src/main/java/com/reason/lang/ocaml/OclTypes.java @@ -33,6 +33,7 @@ private OclTypes() { FUN_EXPR = new MlCompositeElementType("FUN_EXPR", OclLanguage.INSTANCE); FUN_PARAMS = new MlCompositeElementType("FUN_PARAMS", OclLanguage.INSTANCE); FUN_BODY = new MlCompositeElementType("FUN_BODY", OclLanguage.INSTANCE); + FUN_CALL_PARAMS = new MlCompositeElementType("FUN_CALL_PARAMS", OclLanguage.INSTANCE); IF_STMT = new MlCompositeElementType("IF_STMT", OclLanguage.INSTANCE); LET_BINDING = new MlCompositeElementType("LET_BINDING", OclLanguage.INSTANCE); TYPE_CONSTR_NAME = new MlCompositeElementType("TYPE_CONSTR_NAME", OclLanguage.INSTANCE); @@ -56,6 +57,7 @@ private OclTypes() { UPPER_SYMBOL = new MlCompositeElementType("UPPER_SYMBOL", OclLanguage.INSTANCE); LOWER_SYMBOL = new MlCompositeElementType("LOWER_SYMBOL", OclLanguage.INSTANCE); STRUCT_EXPR = new MlCompositeElementType("STRUCT_EXPR", OclLanguage.INSTANCE); + MIXIN_FIELD = new MlCompositeElementType("MIXIN_FIELD", OclLanguage.INSTANCE); // Token element types @@ -126,7 +128,6 @@ private OclTypes() { MATCH = new MlTokenElementType("MATCH", OclLanguage.INSTANCE); MINUS = new MlTokenElementType("MINUS", OclLanguage.INSTANCE); MINUSDOT = new MlTokenElementType("MINUSDOT", OclLanguage.INSTANCE); - MIXIN_FIELD = new MlTokenElementType("MIXIN_FIELD", OclLanguage.INSTANCE); MODULE = new MlTokenElementType("MODULE", OclLanguage.INSTANCE); MUTABLE = new MlTokenElementType("MUTABLE", OclLanguage.INSTANCE); NONE = new MlTokenElementType("NONE", OclLanguage.INSTANCE); diff --git a/src/main/java/com/reason/lang/reason/RmlParser.java b/src/main/java/com/reason/lang/reason/RmlParser.java index 352a132b1..10c071e53 100644 --- a/src/main/java/com/reason/lang/reason/RmlParser.java +++ b/src/main/java/com/reason/lang/reason/RmlParser.java @@ -626,7 +626,11 @@ private void parseLParen(PsiBuilder builder, ParserState state) { state.add(mark(builder, genericExpression, m_types.LPAREN)); } - state.add(markScope(builder, paren, m_types.SCOPED_EXPR, m_types.LPAREN)); + if (state.previousTokenElementType == m_types.LIDENT) { + state.add(markScope(builder, paren, functionCallParams, m_types.FUN_CALL_PARAMS, m_types.LPAREN)); + } else { + state.add(markScope(builder, paren, m_types.SCOPED_EXPR, m_types.LPAREN)); + } } } diff --git a/src/main/java/com/reason/lang/reason/RmlTypes.java b/src/main/java/com/reason/lang/reason/RmlTypes.java index b3d94fbba..0b55c0005 100644 --- a/src/main/java/com/reason/lang/reason/RmlTypes.java +++ b/src/main/java/com/reason/lang/reason/RmlTypes.java @@ -20,6 +20,7 @@ private RmlTypes() { EXCEPTION_EXPR = new MlCompositeElementType("EXCEPTION_EXPRESSION", RmlLanguage.INSTANCE); INCLUDE_STMT = new MlCompositeElementType("INCLUDE_STMT", RmlLanguage.INSTANCE); MACRO_NAME = new MlCompositeElementType("MACRO_NAME", RmlLanguage.INSTANCE); + MIXIN_FIELD = new MlCompositeElementType("MIXIN_FIELD", RmlLanguage.INSTANCE); MODULE_STMT = new PsiModuleStubElementType("MODULE_STMT", RmlLanguage.INSTANCE); MODULE_PATH = new MlCompositeElementType("MODULE_PATH", RmlLanguage.INSTANCE); CLASS_STMT = new MlCompositeElementType("CLASS_STMT", RmlLanguage.INSTANCE); @@ -34,6 +35,7 @@ private RmlTypes() { FUN_EXPR = new MlCompositeElementType("FUN_EXPR", RmlLanguage.INSTANCE); FUN_PARAMS = new MlCompositeElementType("FUN_PARAMS", RmlLanguage.INSTANCE); FUN_BODY = new MlCompositeElementType("FUN_BODY", RmlLanguage.INSTANCE); + FUN_CALL_PARAMS = new MlCompositeElementType("FUN_CALL_PARAMS", RmlLanguage.INSTANCE); LET_BINDING = new MlCompositeElementType("LET_BINDING", RmlLanguage.INSTANCE); TYPE_CONSTR_NAME = new MlCompositeElementType("TYPE_CONSTR_NAME", RmlLanguage.INSTANCE); TYPE_BINDING = new MlCompositeElementType("TYPE_BINDING", RmlLanguage.INSTANCE); @@ -123,7 +125,6 @@ private RmlTypes() { MATCH = new MlTokenElementType("MATCH", RmlLanguage.INSTANCE); MINUS = new MlTokenElementType("MINUS", RmlLanguage.INSTANCE); MINUSDOT = new MlTokenElementType("MINUSDOT", RmlLanguage.INSTANCE); - MIXIN_FIELD = new MlTokenElementType("MIXIN_FIELD", RmlLanguage.INSTANCE); MODULE = new MlTokenElementType("MODULE", RmlLanguage.INSTANCE); MUTABLE = new MlTokenElementType("MUTABLE", RmlLanguage.INSTANCE); NONE = new MlTokenElementType("NONE", RmlLanguage.INSTANCE); diff --git a/tests/com/reason/lang/ocaml/FunctionCallTest.java b/tests/com/reason/lang/ocaml/FunctionCallTest.java new file mode 100644 index 000000000..60ade20a9 --- /dev/null +++ b/tests/com/reason/lang/ocaml/FunctionCallTest.java @@ -0,0 +1,17 @@ +package com.reason.lang.ocaml; + +import com.reason.lang.BaseParsingTestCase; +import com.reason.lang.reason.RmlParserDefinition; + +public class FunctionCallTest extends BaseParsingTestCase { + public FunctionCallTest() { + super("", "re", new RmlParserDefinition()); + } + + public void testCall() { + //PsiLet e = first(letExpressions(parseCode("let t = string_of_int 1"))); + // + //assertNotNull(first(PsiTreeUtil.findChildrenOfType(e, PsiFunctionCallParams.class))); + } + +} diff --git a/tests/com/reason/lang/reason/FunctionCallTest.java b/tests/com/reason/lang/reason/FunctionCallTest.java new file mode 100644 index 000000000..afeadaef9 --- /dev/null +++ b/tests/com/reason/lang/reason/FunctionCallTest.java @@ -0,0 +1,19 @@ +package com.reason.lang.reason; + +import com.intellij.psi.util.PsiTreeUtil; +import com.reason.lang.BaseParsingTestCase; +import com.reason.lang.core.psi.PsiFunctionCallParams; +import com.reason.lang.core.psi.PsiLet; + +public class FunctionCallTest extends BaseParsingTestCase { + public FunctionCallTest() { + super("", "re", new RmlParserDefinition()); + } + + public void testCall() { + PsiLet e = first(letExpressions(parseCode("let t = string_of_int(1);"))); + + assertNotNull(first(PsiTreeUtil.findChildrenOfType(e, PsiFunctionCallParams.class))); + } + +}