From 649f67cccf907a1b25aa88ee3f21c18bd7116626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Giraud?= Date: Mon, 10 May 2021 08:44:13 +0200 Subject: [PATCH] #303 - redesign reference resolution --- CHANGELOG.md | 3 + build.gradle | 18 +- jps-plugin/src/com/reason/Joiner.java | 91 +- jps-plugin/src/com/reason/Log.java | 15 +- .../lang/core/psi/PsiQualifiedElement.java | 12 - resources/META-INF/plugin.xml | 5 + .../ide/docs/ORDocumentationProvider.java | 63 +- src/com/reason/ide/files/FileBase.java | 179 ++- src/com/reason/ide/files/OclFile.java | 32 +- .../ide/go/ModuleDelegatePresentation.java | 21 +- .../reason/ide/go/ORDelegatePsiElement.java | 21 +- .../ide/go/ORGotoDeclarationHandler.java | 34 +- .../reason/ide/go/ORLineMarkerProvider.java | 2 +- .../reason/ide/go/ORModuleContributor.java | 137 +-- .../ide/highlight/ORSyntaxHighlighter.java | 3 - .../DuneProjectImportBuilder.java | 61 +- .../DotExpressionCompletionProvider.java | 288 +++-- .../FreeExpressionCompletionProvider.java | 2 +- .../provider/JsxNameCompletionProvider.java | 2 +- .../provider/ObjectCompletionProvider.java | 2 +- .../ide/search/FileModuleIndexService.java | 32 +- .../ide/search/ORFindUsagesProvider.java | 98 +- src/com/reason/ide/search/PsiFinder.java | 130 +- .../ide/search/index/ExceptionFqnIndex.java | 18 +- .../ide/search/index/ExceptionIndex.java | 22 +- .../ide/search/index/ExternalIndex.java | 16 +- .../reason/ide/search/index/IncludeIndex.java | 26 + .../reason/ide/search/index/IndexKeys.java | 4 + .../reason/ide/search/index/LetFqnIndex.java | 17 +- src/com/reason/ide/search/index/LetIndex.java | 16 +- .../ide/search/index/ModuleAliasedIndex.java | 26 + .../ide/search/index/ModuleAliasesIndex.java | 26 + .../search/index/ModuleComponentFqnIndex.java | 18 +- .../search/index/ModuleComponentIndex.java | 12 +- .../ide/search/index/ModuleFqnIndex.java | 21 +- .../reason/ide/search/index/ModuleIndex.java | 22 +- .../ide/search/index/ModuleTopLevelIndex.java | 21 +- .../reason/ide/search/index/OpenIndex.java | 26 + .../ide/search/index/ParameterFqnIndex.java | 17 +- .../ide/search/index/ParameterIndex.java | 13 +- .../ide/search/index/RecordFieldIndex.java | 13 +- .../reason/ide/search/index/TypeFqnIndex.java | 17 +- .../reason/ide/search/index/TypeIndex.java | 13 +- .../reason/ide/search/index/ValFqnIndex.java | 17 +- src/com/reason/ide/search/index/ValIndex.java | 13 +- .../ide/search/index/VariantFqnIndex.java | 22 +- .../reason/ide/search/index/VariantIndex.java | 18 +- .../ide/structure/StructureViewElement.java | 2 +- src/com/reason/lang/PsiFileHelper.java | 2 +- src/com/reason/lang/core/ORCodeFactory.java | 3 +- src/com/reason/lang/core/ORUtil.java | 54 +- src/com/reason/lang/core/psi/PsiClass.java | 34 +- .../reason/lang/core/psi/PsiException.java | 17 +- src/com/reason/lang/core/psi/PsiExternal.java | 14 +- src/com/reason/lang/core/psi/PsiInclude.java | 14 +- .../reason/lang/core/psi/PsiInnerModule.java | 23 +- src/com/reason/lang/core/psi/PsiLet.java | 7 +- src/com/reason/lang/core/psi/PsiModule.java | 6 +- src/com/reason/lang/core/psi/PsiOpen.java | 5 +- .../reason/lang/core/psi/PsiParameter.java | 2 +- .../core/psi/PsiQualifiedPathElement.java | 12 + .../reason/lang/core/psi/PsiRecordField.java | 14 +- src/com/reason/lang/core/psi/PsiType.java | 26 +- src/com/reason/lang/core/psi/PsiVal.java | 14 +- .../lang/core/psi/PsiVariantDeclaration.java | 29 +- .../lang/core/psi/impl/ORASTFactory.java | 6 - .../lang/core/psi/impl/PsiClassImpl.java | 209 ++-- .../lang/core/psi/impl/PsiExceptionImpl.java | 54 +- .../lang/core/psi/impl/PsiExternalImpl.java | 53 +- .../lang/core/psi/impl/PsiFakeModule.java | 82 +- .../lang/core/psi/impl/PsiFunctorCall.java | 51 +- .../lang/core/psi/impl/PsiFunctorImpl.java | 69 +- .../lang/core/psi/impl/PsiIncludeImpl.java | 72 +- .../core/psi/impl/PsiInnerModuleImpl.java | 713 +++++------ .../core/psi/impl/PsiLeafPropertyName.java | 33 +- .../reason/lang/core/psi/impl/PsiLetImpl.java | 100 +- .../lang/core/psi/impl/PsiOpenImpl.java | 27 +- .../lang/core/psi/impl/PsiParameterImpl.java | 63 +- .../reason/lang/core/psi/impl/PsiRecord.java | 57 +- .../core/psi/impl/PsiRecordFieldImpl.java | 41 +- .../lang/core/psi/impl/PsiTypeImpl.java | 109 +- .../reason/lang/core/psi/impl/PsiValImpl.java | 49 +- .../core/psi/reference/CodeInstruction.java | 44 + .../core/psi/reference/ORElementResolver.java | 368 ++++++ .../psi/reference/ORFakeResolvedElement.java | 63 +- .../psi/reference/ORReferenceAnalyzer.java | 243 ++++ .../reference/PsiLowerSymbolReference.java | 422 ++----- .../reference/PsiPropertyNameReference.java | 154 ++- .../reference/PsiUpperSymbolReference.java | 200 +-- .../lang/core/psi/reference/Resolution.java | 228 ++++ .../core/stub/OclStubBasedElementTypes.java | 49 +- .../lang/core/stub/PsiExceptionStub.java | 55 +- .../lang/core/stub/PsiExternalStub.java | 69 +- .../reason/lang/core/stub/PsiIncludeStub.java | 46 + src/com/reason/lang/core/stub/PsiLetStub.java | 100 +- .../reason/lang/core/stub/PsiModuleStub.java | 93 +- .../reason/lang/core/stub/PsiOpenStub.java | 17 + .../lang/core/stub/PsiParameterStub.java | 43 +- .../lang/core/stub/PsiRecordFieldStub.java | 49 +- .../reason/lang/core/stub/PsiTypeStub.java | 76 +- src/com/reason/lang/core/stub/PsiValStub.java | 59 +- .../core/stub/PsiVariantDeclarationStub.java | 49 +- .../stub/RescriptStubBasedElementTypes.java | 49 +- .../core/stub/RmlStubBasedElementTypes.java | 49 +- .../core/stub/type/NsFileStubElementType.java | 2 +- .../stub/type/OclFileStubElementType.java | 2 +- .../type/PsiExceptionStubElementType.java | 105 +- .../stub/type/PsiExternalStubElementType.java | 96 +- .../type/PsiFakeModuleStubElementType.java | 100 +- .../stub/type/PsiIncludeStubElementType.java | 59 + .../core/stub/type/PsiLetStubElementType.java | 205 ++-- .../stub/type/PsiModuleStubElementType.java | 70 +- .../stub/type/PsiOpenStubElementType.java | 57 + .../type/PsiParameterStubElementType.java | 18 +- .../type/PsiRecordFieldStubElementType.java | 99 +- .../stub/type/PsiTypeStubElementType.java | 75 +- .../core/stub/type/PsiValStubElementType.java | 101 +- .../stub/type/PsiVariantStubElementType.java | 23 +- .../stub/type/RmlFileStubElementType.java | 25 +- .../lang/core/stub/type/SerializerUtil.java | 31 + src/com/reason/lang/core/type/ORTypes.java | 5 +- src/com/reason/lang/napkin/ResFlexLexer.java | 1007 ++++++++-------- .../reason/lang/napkin/ResQNameFinder.java | 4 +- src/com/reason/lang/napkin/ResTypes.java | 8 +- src/com/reason/lang/napkin/Rescript.flex | 1 - src/com/reason/lang/ocaml/OCaml.flex | 1 - src/com/reason/lang/ocaml/OCamlLexer.java | 1047 ++++++++-------- src/com/reason/lang/ocaml/OclParser.java | 5 +- src/com/reason/lang/ocaml/OclQNameFinder.java | 2 +- src/com/reason/lang/ocaml/OclTypes.java | 5 +- src/com/reason/lang/reason/ReasonML.flex | 1 - src/com/reason/lang/reason/ReasonMLLexer.java | 1073 ++++++++--------- src/com/reason/lang/reason/RmlParser.java | 12 +- .../reason/lang/reason/RmlQNameFinder.java | 4 +- src/com/reason/lang/reason/RmlTypes.java | 522 ++++---- tests/com/reason/bs/BsPlatformTest.java | 68 -- .../reason/ide/ORBasePlatformTestCase.java | 32 +- tests/com/reason/ide/ORFileUtilsTest.java | 79 -- .../com/reason/ide/ORProjectManagerTest.java | 224 ---- tests/com/reason/ide/PsiFinderTest.java | 325 ++--- .../FunctionBracesIntentionTest.java | 74 +- .../reference/FindLIdentUsagesOCLTest.java | 27 + .../reference/FindLIdentUsagesRMLTest.java | 39 + .../ide/reference/FindLIdentUsagesTest.java | 26 - .../reference/FindUIdentUsagesOCLTest.java | 17 + .../reference/FindUIdentUsagesRMLTest.java | 17 + .../ide/reference/FindUIdentUsagesTest.java | 17 - .../reference/ResolveDeconstructionTest.java | 23 - .../ResolveExternalElementRMLTest.java | 32 - .../ide/reference/ResolveInFunctorTest.java | 41 - .../ResolveJsxPropertyElementRMLTest.java | 100 +- .../ResolveJsxPropertyElementRSTest.java | 76 -- .../ResolveJsxTagElementRMLTest.java | 45 + .../ide/reference/ResolveLetElementTest.java | 101 -- .../reference/ResolveLowerElementOCLTest.java | 231 ++++ .../reference/ResolveLowerElementRMLTest.java | 373 ++++++ .../reference/ResolveModuleElementTest.java | 67 - .../ResolveParameterElementOCLTest.java | 15 - .../ResolveParameterElementRMLTest.java | 15 - .../ResolveParameterElementRSTest.java | 15 - .../reference/ResolveRecordFieldsTest.java | 22 - .../ide/reference/ResolveTypeElementTest.java | 39 - .../reference/ResolveUpperElementOCLTest.java | 175 +++ .../reference/ResolveUpperElementRMLTest.java | 225 ++++ .../reference/ResolveVariantElementTest.java | 91 -- .../ide/structure/StructureOCLTest.java | 103 ++ .../reason/ide/structure/StructureTest.java | 104 -- tests/com/reason/lang/core/ORUtilTest.java | 76 +- .../core/psi/reference/ResolutionTest.java | 63 + .../lang/napkin/IncludeParsingTest.java | 6 +- .../reason/lang/napkin/LetParsingTest.java | 3 +- .../reason/lang/ocaml/FunctorParsingTest.java | 206 ++-- .../reason/lang/ocaml/IncludeParsingTest.java | 10 +- .../com/reason/lang/ocaml/LetParsingTest.java | 2 +- .../lang/reason/FunctionParsingTest.java | 389 +++--- .../lang/reason/FunctorCallParsingTest.java | 41 +- .../lang/reason/IncludeParsingTest.java | 6 +- .../reason/lang/reason/LetParsingTest.java | 2 +- .../lang/reason/SignatureParsingTest.java | 11 +- 179 files changed, 8003 insertions(+), 6691 deletions(-) delete mode 100644 jps-plugin/src/com/reason/lang/core/psi/PsiQualifiedElement.java create mode 100644 src/com/reason/ide/search/index/IncludeIndex.java create mode 100644 src/com/reason/ide/search/index/ModuleAliasedIndex.java create mode 100644 src/com/reason/ide/search/index/ModuleAliasesIndex.java create mode 100644 src/com/reason/ide/search/index/OpenIndex.java create mode 100644 src/com/reason/lang/core/psi/PsiQualifiedPathElement.java create mode 100644 src/com/reason/lang/core/psi/reference/CodeInstruction.java create mode 100644 src/com/reason/lang/core/psi/reference/ORElementResolver.java create mode 100644 src/com/reason/lang/core/psi/reference/ORReferenceAnalyzer.java create mode 100644 src/com/reason/lang/core/psi/reference/Resolution.java create mode 100644 src/com/reason/lang/core/stub/PsiIncludeStub.java create mode 100644 src/com/reason/lang/core/stub/PsiOpenStub.java create mode 100644 src/com/reason/lang/core/stub/type/PsiIncludeStubElementType.java create mode 100644 src/com/reason/lang/core/stub/type/PsiOpenStubElementType.java create mode 100644 src/com/reason/lang/core/stub/type/SerializerUtil.java delete mode 100644 tests/com/reason/bs/BsPlatformTest.java delete mode 100644 tests/com/reason/ide/ORFileUtilsTest.java delete mode 100644 tests/com/reason/ide/ORProjectManagerTest.java create mode 100644 tests/com/reason/ide/reference/FindLIdentUsagesOCLTest.java create mode 100644 tests/com/reason/ide/reference/FindLIdentUsagesRMLTest.java delete mode 100644 tests/com/reason/ide/reference/FindLIdentUsagesTest.java create mode 100644 tests/com/reason/ide/reference/FindUIdentUsagesOCLTest.java create mode 100644 tests/com/reason/ide/reference/FindUIdentUsagesRMLTest.java delete mode 100644 tests/com/reason/ide/reference/FindUIdentUsagesTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveDeconstructionTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveExternalElementRMLTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveInFunctorTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveJsxPropertyElementRSTest.java create mode 100644 tests/com/reason/ide/reference/ResolveJsxTagElementRMLTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveLetElementTest.java create mode 100644 tests/com/reason/ide/reference/ResolveLowerElementOCLTest.java create mode 100644 tests/com/reason/ide/reference/ResolveLowerElementRMLTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveModuleElementTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveParameterElementOCLTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveParameterElementRMLTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveParameterElementRSTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveRecordFieldsTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveTypeElementTest.java create mode 100644 tests/com/reason/ide/reference/ResolveUpperElementOCLTest.java create mode 100644 tests/com/reason/ide/reference/ResolveUpperElementRMLTest.java delete mode 100644 tests/com/reason/ide/reference/ResolveVariantElementTest.java create mode 100644 tests/com/reason/ide/structure/StructureOCLTest.java delete mode 100644 tests/com/reason/ide/structure/StructureTest.java create mode 100644 tests/com/reason/lang/core/psi/reference/ResolutionTest.java diff --git a/CHANGELOG.md b/CHANGELOG.md index dc797208e..4245c3e8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,9 @@ are solved. ## Unreleased +- :bug: [#303](https://github.com/reasonml-editor/reasonml-idea-plugin/issues/303) Incorrect resolution for record field +- :house: Reference resolution algorithm has been totally redesigned + ## 0.100 - 2021/05/05 - :house: move to jfrog, bintray is no more available diff --git a/build.gradle b/build.gradle index 53f41cf7f..8b1e9d085 100644 --- a/build.gradle +++ b/build.gradle @@ -1,26 +1,24 @@ plugins { - id 'org.jetbrains.intellij' version '0.7.2' // https://github.com/JetBrains/gradle-intellij-plugin + id 'java' + id 'org.jetbrains.intellij' version '0.7.3' // https://github.com/JetBrains/gradle-intellij-plugin } allprojects { repositories { - jcenter() mavenCentral() } apply plugin: 'java' apply plugin: 'org.jetbrains.intellij' - sourceCompatibility = '1.8' + group 'com.reason' version = pluginVersion + '-' + platformVersion + sourceCompatibility = '1.8' + compileJava.options.encoding = 'UTF-8' - group 'com.reason' dependencies { - def powerMockVersion = '2.0.2' - testImplementation 'org.mockito:mockito-core:3.3.3' - testImplementation "org.powermock:powermock-module-junit4:${powerMockVersion}" - testImplementation "org.powermock:powermock-api-mockito2:${powerMockVersion}" + testImplementation 'junit:junit:4.12' } sourceSets { @@ -59,6 +57,10 @@ allprojects { } } + runIde { + systemProperty 'idea.is.internal', true + } + verifyPlugin { pluginDirectory 'resources' } diff --git a/jps-plugin/src/com/reason/Joiner.java b/jps-plugin/src/com/reason/Joiner.java index 379de04a5..abb897b2b 100644 --- a/jps-plugin/src/com/reason/Joiner.java +++ b/jps-plugin/src/com/reason/Joiner.java @@ -1,52 +1,69 @@ package com.reason; +import org.jetbrains.annotations.*; + import java.util.function.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; public class Joiner { - private Joiner() {} - - @NotNull - public static String join(@NotNull String separator, @Nullable Iterable items) { - return join(separator, items, Object::toString); - } + private Joiner() { + } - @NotNull - public static String join( - @NotNull String separator, @Nullable Iterable items, @NotNull Function fn) { - if (items == null) { - return ""; + @NotNull + public static String join(@NotNull String separator, @Nullable Iterable items) { + return join(separator, items, Object::toString); } - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (T item : items) { - if (!first) { - sb.append(separator); - } - sb.append(fn.apply(item)); - first = false; + @NotNull + public static String join( + @NotNull String separator, @Nullable Iterable items, @NotNull Function fn) { + if (items == null) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + boolean first = true; + for (T item : items) { + if (!first) { + sb.append(separator); + } + sb.append(fn.apply(item)); + first = false; + } + return sb.toString(); } - return sb.toString(); - } - @NotNull - public static String join(@NotNull String separator, @Nullable Object[] items) { - if (items == null) { - return ""; + @NotNull + public static String join(@NotNull String separator, @Nullable Object[] items) { + if (items == null) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + boolean first = true; + for (Object item : items) { + if (!first) { + sb.append(separator); + } + sb.append(item); + first = false; + } + return sb.toString(); } - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (Object item : items) { - if (!first) { - sb.append(separator); - } - sb.append(item); - first = false; + @NotNull + public static String joinFrom(@NotNull String separator, @Nullable Object[] items, int from) { + if (items == null) { + return ""; + } + + StringBuilder sb = new StringBuilder(); + for (int i = from; i < items.length; i++) { + if (i != from) { + sb.append(separator); + } + sb.append(items[i]); + } + return sb.toString(); } - return sb.toString(); - } } diff --git a/jps-plugin/src/com/reason/Log.java b/jps-plugin/src/com/reason/Log.java index aa2e45aff..6f2e2fbed 100644 --- a/jps-plugin/src/com/reason/Log.java +++ b/jps-plugin/src/com/reason/Log.java @@ -7,7 +7,6 @@ import com.intellij.openapi.project.*; import com.intellij.openapi.vfs.*; import com.intellij.psi.*; -import com.reason.lang.core.psi.*; import org.jetbrains.annotations.*; import java.io.*; @@ -160,7 +159,7 @@ public void trace(String comment, @Nullable Collection t) { } } - public void debug(String comment, @NotNull PsiQualifiedElement element) { + public void debug(String comment, @NotNull PsiQualifiedNamedElement element) { if (m_log.isDebugEnabled()) { m_log.debug( comment @@ -172,7 +171,7 @@ public void debug(String comment, @NotNull PsiQualifiedElement element) { } } - public void debug(String comment, @NotNull PsiQualifiedElement element, int position) { + public void debug(String comment, @NotNull PsiQualifiedNamedElement element, int position) { if (m_log.isDebugEnabled()) { m_log.debug( comment @@ -220,15 +219,7 @@ public void debug(String msg, VirtualFile[] files) { public void debug(String msg, PsiElement element) { if (m_log.isDebugEnabled()) { - m_log.debug( - msg - + SEP - + " " - + element - + SEP - + (element instanceof PsiNamedElement - ? " [" + ((PsiNamedElement) element).getName() + "]" - : "")); + m_log.debug(msg + SEP + element + (element instanceof PsiNamedElement ? ", name=[" + ((PsiNamedElement) element).getName() + "]" : "")); } } diff --git a/jps-plugin/src/com/reason/lang/core/psi/PsiQualifiedElement.java b/jps-plugin/src/com/reason/lang/core/psi/PsiQualifiedElement.java deleted file mode 100644 index c43aa4009..000000000 --- a/jps-plugin/src/com/reason/lang/core/psi/PsiQualifiedElement.java +++ /dev/null @@ -1,12 +0,0 @@ -package com.reason.lang.core.psi; - -import com.intellij.psi.PsiNamedElement; -import org.jetbrains.annotations.NotNull; - -public interface PsiQualifiedElement extends PsiNamedElement { - @NotNull - String getPath(); - - @NotNull - String getQualifiedName(); -} diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml index 8fe445abd..e9f127be3 100644 --- a/resources/META-INF/plugin.xml +++ b/resources/META-INF/plugin.xml @@ -238,6 +238,8 @@ + + @@ -252,12 +254,15 @@ + + + ) ==> functionName() if (contextElement != null @@ -254,8 +243,8 @@ private String getInferredSignature(@NotNull PsiElement element, @NotNull PsiFil } @NotNull - private String createQuickDocTemplate(@NotNull String qPath, @Nullable String type, @Nullable String name, @Nullable String signature) { - return qPath + private String createQuickDocTemplate(@Nullable String[] path, @Nullable String type, @Nullable String name, @Nullable String signature) { + return Joiner.join(".", path) + "
" + (type == null ? "" : type) + (" " + name + "") diff --git a/src/com/reason/ide/files/FileBase.java b/src/com/reason/ide/files/FileBase.java index e1317278b..051cc526e 100644 --- a/src/com/reason/ide/files/FileBase.java +++ b/src/com/reason/ide/files/FileBase.java @@ -1,59 +1,50 @@ package com.reason.ide.files; -import com.intellij.extapi.psi.PsiFileBase; -import com.intellij.lang.Language; -import com.intellij.openapi.project.Project; -import com.intellij.psi.FileViewProvider; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.lang.ModuleHelper; -import com.reason.lang.PsiFileHelper; -import com.reason.lang.core.ORUtil; -import com.reason.lang.core.psi.PsiQualifiedElement; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.Objects; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public abstract class FileBase extends PsiFileBase implements PsiQualifiedElement { - - @NotNull private final String m_moduleName; - - FileBase(@NotNull FileViewProvider viewProvider, @NotNull Language language) { - super(viewProvider, language); - m_moduleName = ORUtil.fileNameToModuleName(getName()); - } - - @NotNull - public String getModuleName() { - return m_moduleName; - } - - @NotNull - @Override - public String getPath() { - return getModuleName(); - } - - @NotNull - @Override - public String getQualifiedName() { - return getModuleName(); - } - - public boolean isComponent() { - if (FileHelper.isOCaml(getFileType())) { - return false; +import com.intellij.extapi.psi.*; +import com.intellij.lang.*; +import com.intellij.psi.*; +import com.intellij.psi.util.*; +import com.reason.lang.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +public abstract class FileBase extends PsiFileBase implements PsiQualifiedPathElement { + private final @NotNull String m_moduleName; + + FileBase(@NotNull FileViewProvider viewProvider, @NotNull Language language) { + super(viewProvider, language); + m_moduleName = ORUtil.fileNameToModuleName(getName()); } - return ModuleHelper.isComponent(this); - } + public @NotNull String getModuleName() { + return m_moduleName; + } + + //region PsiQualifiedName + @Override + public @Nullable String[] getPath() { + return null; + } - @Override - public PsiElement getNavigationElement() { + @Override + public @NotNull String getQualifiedName() { + return getModuleName(); + } + //endregion + + public boolean isComponent() { + if (FileHelper.isOCaml(getFileType())) { + return false; + } + + return ModuleHelper.isComponent(this); + } + + @Override + public PsiElement getNavigationElement() { /* ClassCastException ?? if (isComponent()) { PsiLet make = getLetExpression("make"); @@ -62,55 +53,51 @@ public PsiElement getNavigationElement() { } } */ - return super.getNavigationElement(); - } - - @NotNull - public String shortLocation(@NotNull Project project) { - return FileHelper.shortLocation(this); - } - - @NotNull - public Collection getExpressions(@Nullable String name) { - return PsiFileHelper.getExpressions(this, name); - } - - @SafeVarargs - @NotNull - public final List getQualifiedExpressions( - @Nullable String name, @NotNull Class... clazz) { - List result = new ArrayList<>(); - - if (name != null) { - Collection children = PsiTreeUtil.findChildrenOfAnyType(this, clazz); - for (T child : children) { - if (name.equals(child.getQualifiedName())) { - result.add(child); - } - } + return super.getNavigationElement(); } - return result; - } + public @NotNull String shortLocation() { + return FileHelper.shortLocation(this); + } - public boolean isInterface() { - return FileHelper.isInterface(getFileType()); - } + public @NotNull Collection getExpressions(@Nullable String name) { + return PsiFileHelper.getExpressions(this, name); + } + + @SafeVarargs + public @NotNull final List getQualifiedExpressions(@Nullable String name, @NotNull Class... clazz) { + List result = new ArrayList<>(); + + if (name != null) { + Collection children = PsiTreeUtil.findChildrenOfAnyType(this, clazz); + for (T child : children) { + if (name.equals(child.getQualifiedName())) { + result.add(child); + } + } + } + + return result; + } - @Override - public boolean equals(@Nullable Object o) { - if (this == o) { - return true; + public boolean isInterface() { + return FileHelper.isInterface(getFileType()); } - if (o == null || getClass() != o.getClass()) { - return false; + + @Override + public boolean equals(@Nullable Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + FileBase fileBase = (FileBase) o; + return m_moduleName.equals(fileBase.m_moduleName) && isInterface() == fileBase.isInterface(); + } + + @Override + public int hashCode() { + return Objects.hash(m_moduleName, isInterface()); } - FileBase fileBase = (FileBase) o; - return m_moduleName.equals(fileBase.m_moduleName) && isInterface() == fileBase.isInterface(); - } - - @Override - public int hashCode() { - return Objects.hash(m_moduleName, isInterface()); - } } diff --git a/src/com/reason/ide/files/OclFile.java b/src/com/reason/ide/files/OclFile.java index cad079786..8beb86372 100644 --- a/src/com/reason/ide/files/OclFile.java +++ b/src/com/reason/ide/files/OclFile.java @@ -1,24 +1,22 @@ package com.reason.ide.files; -import com.intellij.openapi.fileTypes.FileType; -import com.intellij.psi.FileViewProvider; -import com.reason.lang.ocaml.OclLanguage; -import org.jetbrains.annotations.NotNull; +import com.intellij.openapi.fileTypes.*; +import com.intellij.psi.*; +import com.reason.lang.ocaml.*; +import org.jetbrains.annotations.*; public class OclFile extends FileBase { - public OclFile(@NotNull FileViewProvider viewProvider) { - super(viewProvider, OclLanguage.INSTANCE); - } + public OclFile(@NotNull FileViewProvider viewProvider) { + super(viewProvider, OclLanguage.INSTANCE); + } - @NotNull - @Override - public FileType getFileType() { - return OclFileType.INSTANCE; - } + @Override + public @NotNull FileType getFileType() { + return OclFileType.INSTANCE; + } - @NotNull - @Override - public String toString() { - return getName(); - } + @Override + public @NotNull String toString() { + return getName(); + } } diff --git a/src/com/reason/ide/go/ModuleDelegatePresentation.java b/src/com/reason/ide/go/ModuleDelegatePresentation.java index 2688b8197..ae0a2bc55 100644 --- a/src/com/reason/ide/go/ModuleDelegatePresentation.java +++ b/src/com/reason/ide/go/ModuleDelegatePresentation.java @@ -3,35 +3,34 @@ import com.intellij.navigation.*; import com.intellij.psi.*; import com.intellij.util.*; -import com.reason.lang.core.*; import com.reason.lang.core.psi.*; import org.jetbrains.annotations.*; import javax.swing.*; -class ModuleDelegatePresentation extends ORDelegatePsiElement - implements NavigationItem, PsiQualifiedElement { +class ModuleDelegatePresentation extends ORDelegatePsiElement implements NavigationItem, PsiQualifiedPathElement { private final @NotNull ItemPresentation m_presentation; - public ModuleDelegatePresentation( - @NotNull PsiQualifiedElement source, @NotNull ItemPresentation presentation) { + public ModuleDelegatePresentation(@NotNull PsiQualifiedPathElement source, @NotNull ItemPresentation presentation) { super(source); m_presentation = presentation; } + //region PsiQualifiedPathElement @Override - public @NotNull String getPath() { - return ORUtil.getQualifiedPath(m_source); + public @Nullable String[] getPath() { + return m_source.getPath(); } @Override - public @Nullable PsiElement setName(@NotNull String name) throws IncorrectOperationException { - return null; + public @Nullable String getQualifiedName() { + return m_source.getQualifiedName(); } + //endregion @Override - public @NotNull String getQualifiedName() { - return m_source.getQualifiedName(); + public @Nullable PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return null; } @Override diff --git a/src/com/reason/ide/go/ORDelegatePsiElement.java b/src/com/reason/ide/go/ORDelegatePsiElement.java index 7d167bd43..071205111 100644 --- a/src/com/reason/ide/go/ORDelegatePsiElement.java +++ b/src/com/reason/ide/go/ORDelegatePsiElement.java @@ -1,23 +1,18 @@ package com.reason.ide.go; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiManager; -import com.intellij.psi.impl.PsiElementBase; -import com.reason.lang.core.psi.PsiQualifiedElement; +import com.intellij.lang.*; +import com.intellij.openapi.util.*; +import com.intellij.psi.*; +import com.intellij.psi.impl.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; import javax.swing.*; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - public abstract class ORDelegatePsiElement extends PsiElementBase { - protected final @NotNull PsiQualifiedElement m_source; + protected final @NotNull PsiQualifiedPathElement m_source; - protected ORDelegatePsiElement(@NotNull PsiQualifiedElement source) { + protected ORDelegatePsiElement(@NotNull PsiQualifiedPathElement source) { m_source = source; } diff --git a/src/com/reason/ide/go/ORGotoDeclarationHandler.java b/src/com/reason/ide/go/ORGotoDeclarationHandler.java index a757a5996..0243b10c3 100644 --- a/src/com/reason/ide/go/ORGotoDeclarationHandler.java +++ b/src/com/reason/ide/go/ORGotoDeclarationHandler.java @@ -3,7 +3,6 @@ import com.intellij.codeInsight.navigation.actions.*; import com.intellij.openapi.editor.*; import com.intellij.psi.*; -import com.intellij.psi.util.*; import com.reason.ide.files.*; import com.reason.lang.core.psi.*; import org.jetbrains.annotations.*; @@ -21,32 +20,19 @@ public class ORGotoDeclarationHandler extends GotoDeclarationHandlerBase { public @Nullable static PsiElement resolveInterface(@Nullable PsiReference reference) { if (reference instanceof PsiPolyVariantReference) { ResolveResult[] resolveResults = ((PsiPolyVariantReference) reference).multiResolve(false); - if (resolveResults.length > 0) { - PsiElement resolvedElement = resolveResults[0].getElement(); - FileBase resolvedFile = resolvedElement == null ? null : (FileBase) resolvedElement.getContainingFile(); - - if (resolvedFile != null && !resolvedFile.isInterface()) { - PsiQualifiedElement qualifiedResolvedElement = PsiTreeUtil.getParentOfType(resolvedElement, PsiQualifiedElement.class); - if (qualifiedResolvedElement != null) { - // Look into other resolved elements to find an equivalent interface if one exist - for (ResolveResult resolved : resolveResults) { - PsiElement element = resolved.getElement(); - if (element == resolvedElement) { - continue; - } - - PsiQualifiedElement qualifiedElement = PsiTreeUtil.getParentOfType(element, PsiQualifiedElement.class); - if (qualifiedElement != null && qualifiedElement.getQualifiedName().equals(qualifiedResolvedElement.getQualifiedName())) { - FileBase file = (FileBase) qualifiedElement.getContainingFile(); - if (file.isInterface()) { - return element; - } - } - } + if (resolveResults.length == 1) { + return resolveResults[0].getElement(); + } else if (resolveResults.length > 1) { + // Look into other resolved elements to find an equivalent interface if one exist + for (ResolveResult resolved : resolveResults) { + PsiElement element = resolved.getElement(); + FileBase file = element == null ? null : (FileBase) element.getContainingFile(); + if (file != null && file.isInterface()) { + return element; } } - return resolvedElement; + return resolveResults[0].getElement(); } } diff --git a/src/com/reason/ide/go/ORLineMarkerProvider.java b/src/com/reason/ide/go/ORLineMarkerProvider.java index 33d0f9513..99f37318c 100644 --- a/src/com/reason/ide/go/ORLineMarkerProvider.java +++ b/src/com/reason/ide/go/ORLineMarkerProvider.java @@ -78,7 +78,7 @@ protected void collectNavigationMarkers(@NotNull PsiElement element, @NotNull Co } } - @SafeVarargs private final void extractRelatedExpressions( + @SafeVarargs private final void extractRelatedExpressions( @Nullable PsiElement element, @Nullable String qname, @NotNull Collection> result, diff --git a/src/com/reason/ide/go/ORModuleContributor.java b/src/com/reason/ide/go/ORModuleContributor.java index e60155666..5db45cb17 100644 --- a/src/com/reason/ide/go/ORModuleContributor.java +++ b/src/com/reason/ide/go/ORModuleContributor.java @@ -1,94 +1,79 @@ package com.reason.ide.go; -import com.intellij.navigation.ChooseByNameContributorEx; -import com.intellij.navigation.GotoClassContributor; -import com.intellij.navigation.ItemPresentation; -import com.intellij.navigation.NavigationItem; -import com.intellij.openapi.project.Project; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.Processor; -import com.intellij.util.indexing.FindSymbolParameters; -import com.intellij.util.indexing.IdFilter; -import com.reason.ide.files.FileBase; -import com.reason.ide.search.PsiFinder; -import com.reason.ide.search.index.ModuleIndex; -import com.reason.lang.core.ORFileType; -import com.reason.lang.core.ORUtil; -import com.reason.lang.core.psi.PsiInnerModule; -import com.reason.lang.core.psi.PsiModule; -import com.reason.lang.core.psi.PsiQualifiedElement; -import icons.ORIcons; +import com.intellij.navigation.*; +import com.intellij.openapi.project.*; +import com.intellij.psi.*; +import com.intellij.psi.search.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.*; +import com.intellij.util.indexing.*; +import com.reason.*; +import com.reason.ide.files.*; +import com.reason.ide.search.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.*; +import icons.*; +import org.jetbrains.annotations.*; + import javax.swing.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; // Implements the goto class public class ORModuleContributor implements GotoClassContributor, ChooseByNameContributorEx { - - @Override - public void processNames( - @NotNull Processor processor, - @NotNull GlobalSearchScope scope, - @Nullable IdFilter filter) { - Project project = scope.getProject(); - if (project != null) { - ModuleIndex.getInstance().processAllKeys(project, processor); + @Override + public void processNames(@NotNull Processor processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { + Project project = scope.getProject(); + if (project != null) { + StubIndex.getInstance().processAllKeys(IndexKeys.MODULES, project, processor); + } } - } - @Override - public void processElementsWithName( - @NotNull String name, - @NotNull Processor processor, - @NotNull FindSymbolParameters parameters) { - Project project = parameters.getProject(); - GlobalSearchScope scope = parameters.getSearchScope(); + @Override + public void processElementsWithName(@NotNull String name, @NotNull Processor processor, @NotNull FindSymbolParameters parameters) { + Project project = parameters.getProject(); + GlobalSearchScope scope = parameters.getSearchScope(); - for (PsiModule psiModule : - PsiFinder.getInstance(project).findModulesbyName(name, ORFileType.both, null, scope)) { + for (PsiModule psiModule : PsiFinder.getInstance(project).findModulesbyName(name, ORFileType.both, null, scope)) { + NavigationItem element = psiModule; + if (psiModule instanceof PsiInnerModule) { + Icon icon = psiModule.isInterface() ? ORIcons.INNER_MODULE_INTF : ORIcons.INNER_MODULE; - NavigationItem element = psiModule; - if (psiModule instanceof PsiInnerModule) { - Icon icon = psiModule.isInterface() ? ORIcons.INNER_MODULE_INTF : ORIcons.INNER_MODULE; + element = new ModuleDelegatePresentation( + psiModule, + new ItemPresentation() { + @Override + public @Nullable String getPresentableText() { + return psiModule.getName(); + } - element = - new ModuleDelegatePresentation( - psiModule, - new ItemPresentation() { - @Override - public @Nullable String getPresentableText() { - return psiModule.getName(); - } + @Override + public String getLocationString() { + return Joiner.join(".", psiModule.getPath()); + } - @Override - public String getLocationString() { - return ORUtil.getQualifiedPath(psiModule); - } + @Override + public Icon getIcon(boolean unused) { + return icon; + } + }); + } - @Override - public Icon getIcon(boolean unused) { - return icon; - } - }); - } - - processor.process(element); + processor.process(element); + } } - } - @Nullable - @Override - public String getQualifiedName(NavigationItem item) { - if (item instanceof FileBase) { - return ((FileBase) item).getModuleName(); - } else if (item instanceof PsiQualifiedElement) { - return ((PsiQualifiedElement) item).getQualifiedName(); + @Override + public @Nullable String getQualifiedName(NavigationItem item) { + if (item instanceof FileBase) { + return ((FileBase) item).getModuleName(); + } else if (item instanceof PsiQualifiedNamedElement) { + return ((PsiQualifiedNamedElement) item).getQualifiedName(); + } + return null; } - return null; - } - @Override - public @Nullable String getQualifiedNameSeparator() { - return null; - } + @Override + public @Nullable String getQualifiedNameSeparator() { + return null; + } } diff --git a/src/com/reason/ide/highlight/ORSyntaxHighlighter.java b/src/com/reason/ide/highlight/ORSyntaxHighlighter.java index 19e30fad8..5da097708 100644 --- a/src/com/reason/ide/highlight/ORSyntaxHighlighter.java +++ b/src/com/reason/ide/highlight/ORSyntaxHighlighter.java @@ -86,7 +86,6 @@ public class ORSyntaxHighlighter extends SyntaxHighlighterBase { RmlTypes.INSTANCE.L_OR, RmlTypes.INSTANCE.SHORTCUT, RmlTypes.INSTANCE.ARROW, - RmlTypes.INSTANCE.PIPE_FIRST, RmlTypes.INSTANCE.PIPE_FORWARD, RmlTypes.INSTANCE.EQEQEQ, RmlTypes.INSTANCE.EQEQ, @@ -194,7 +193,6 @@ public class ORSyntaxHighlighter extends SyntaxHighlighterBase { ResTypes.INSTANCE.L_OR, ResTypes.INSTANCE.SHORTCUT, ResTypes.INSTANCE.ARROW, - ResTypes.INSTANCE.PIPE_FIRST, ResTypes.INSTANCE.PIPE_FORWARD, ResTypes.INSTANCE.EQEQEQ, ResTypes.INSTANCE.EQEQ, @@ -315,7 +313,6 @@ public class ORSyntaxHighlighter extends SyntaxHighlighterBase { OclTypes.INSTANCE.L_OR, OclTypes.INSTANCE.SHORTCUT, OclTypes.INSTANCE.ARROW, - OclTypes.INSTANCE.PIPE_FIRST, OclTypes.INSTANCE.PIPE_FORWARD, OclTypes.INSTANCE.EQEQEQ, OclTypes.INSTANCE.EQEQ, diff --git a/src/com/reason/ide/importWizard/DuneProjectImportBuilder.java b/src/com/reason/ide/importWizard/DuneProjectImportBuilder.java index b75e64bc9..f25bef79c 100644 --- a/src/com/reason/ide/importWizard/DuneProjectImportBuilder.java +++ b/src/com/reason/ide/importWizard/DuneProjectImportBuilder.java @@ -1,39 +1,25 @@ package com.reason.ide.importWizard; -import com.intellij.openapi.application.Application; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.module.ModifiableModuleModel; -import com.intellij.openapi.module.Module; -import com.intellij.openapi.module.ModuleManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.projectRoots.Sdk; -import com.intellij.openapi.projectRoots.SdkTypeId; -import com.intellij.openapi.roots.ContentEntry; -import com.intellij.openapi.roots.ModifiableRootModel; -import com.intellij.openapi.roots.ModuleRootManager; -import com.intellij.openapi.roots.ex.ProjectRootManagerEx; -import com.intellij.openapi.roots.ui.configuration.ModulesProvider; -import com.intellij.openapi.vfs.LocalFileSystem; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.packaging.artifacts.ModifiableArtifactModel; -import com.intellij.projectImport.ProjectImportBuilder; -import com.reason.module.OCamlModuleType; -import com.reason.sdk.OCamlSdkType; -import icons.ORIcons; - -import java.io.File; -import java.io.IOException; -import java.nio.file.FileVisitResult; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.SimpleFileVisitor; -import java.nio.file.attribute.BasicFileAttributes; -import java.util.ArrayList; -import java.util.List; -import javax.swing.*; +import com.intellij.openapi.application.*; +import com.intellij.openapi.module.*; +import com.intellij.openapi.project.*; +import com.intellij.openapi.projectRoots.*; +import com.intellij.openapi.roots.*; +import com.intellij.openapi.roots.ex.*; +import com.intellij.openapi.roots.ui.configuration.*; +import com.intellij.openapi.vfs.*; +import com.intellij.packaging.artifacts.*; +import com.intellij.projectImport.*; +import com.reason.module.*; +import com.reason.sdk.*; +import icons.*; +import org.jetbrains.annotations.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import javax.swing.*; +import java.io.*; +import java.nio.file.*; +import java.nio.file.attribute.*; +import java.util.*; public class DuneProjectImportBuilder extends ProjectImportBuilder { @@ -76,11 +62,7 @@ public void setOpenProjectSettingsAfter(boolean on) { @Nullable @Override - public List commit( - @NotNull Project project, - @Nullable ModifiableModuleModel moduleModel, - ModulesProvider modulesProvider, - ModifiableArtifactModel artifactModel) { + public List commit(@NotNull Project project, @Nullable ModifiableModuleModel moduleModel, ModulesProvider modulesProvider, ModifiableArtifactModel artifactModel) { List createdModules = new ArrayList<>(); String ideaModuleDirPath = project.getBasePath(); @@ -115,8 +97,7 @@ public List commit( @Override public @NotNull FileVisitResult visitFile(@NotNull Path path, BasicFileAttributes basicFileAttributes) { if ("dune".equals(path.getFileName().toString())) { - VirtualFile file = - LocalFileSystem.getInstance().findFileByPath(path.toString()); + VirtualFile file = LocalFileSystem.getInstance().findFileByPath(path.toString()); VirtualFile dir = file == null ? null : file.getParent(); if (dir != null) { content.addSourceFolder(dir, false); diff --git a/src/com/reason/ide/insight/provider/DotExpressionCompletionProvider.java b/src/com/reason/ide/insight/provider/DotExpressionCompletionProvider.java index c65595d38..1521d28d5 100644 --- a/src/com/reason/ide/insight/provider/DotExpressionCompletionProvider.java +++ b/src/com/reason/ide/insight/provider/DotExpressionCompletionProvider.java @@ -30,171 +30,167 @@ import static com.reason.lang.core.psi.ExpressionScope.*; public class DotExpressionCompletionProvider { + private static final Log LOG = Log.create("insight.dot"); - private static final Log LOG = Log.create("insight.dot"); - - private DotExpressionCompletionProvider() { - } + private DotExpressionCompletionProvider() { + } - public static void addCompletions( - @NotNull QNameFinder qnameFinder, - @NotNull PsiElement element, - @NotNull CompletionResultSet resultSet) { - LOG.debug("DOT expression completion"); + public static void addCompletions(@NotNull QNameFinder qnameFinder, @NotNull PsiElement element, @NotNull CompletionResultSet resultSet) { + LOG.debug("DOT expression completion"); - Project project = element.getProject(); - PsiElement dotLeaf = PsiTreeUtil.prevVisibleLeaf(element); - PsiElement previousElement = dotLeaf == null ? null : dotLeaf.getPrevSibling(); + Project project = element.getProject(); + PsiElement dotLeaf = PsiTreeUtil.prevVisibleLeaf(element); + PsiElement previousElement = dotLeaf == null ? null : dotLeaf.getPrevSibling(); - if (previousElement instanceof PsiUpperSymbol) { - String upperName = previousElement.getText(); - if (upperName != null) { - LOG.debug(" -> symbol", upperName); - PsiFinder psiFinder = PsiFinder.getInstance(project); - GlobalSearchScope scope = GlobalSearchScope.allScope(project); + if (previousElement instanceof PsiUpperSymbol) { + String upperName = previousElement.getText(); + if (upperName != null) { + LOG.debug(" -> symbol", upperName); + PsiFinder psiFinder = PsiFinder.getInstance(project); + GlobalSearchScope scope = GlobalSearchScope.allScope(project); - // Find potential module paths, and filter the result - Set potentialPaths = qnameFinder.extractPotentialPaths(element); - if (LOG.isTraceEnabled()) { - LOG.debug(" -> paths", potentialPaths); - } + // Find potential module paths, and filter the result + Set potentialPaths = qnameFinder.extractPotentialPaths(element); + if (LOG.isTraceEnabled()) { + LOG.debug(" -> paths", potentialPaths); + } - Set resolvedModules = new ArrayListSet<>(); - for (String qname : potentialPaths) { - Set modulesFromQn = - psiFinder.findModulesFromQn(qname, true, interfaceOrImplementation, scope); - for (PsiModule module : modulesFromQn) { - PsiFunctorCall functorCall = module.getFunctorCall(); - if (functorCall != null) { - // resolve functor definition - String functorName = functorCall.getFunctorName(); - potentialPaths = qnameFinder.extractPotentialPaths(module); - for (String qnameFunctorPath : potentialPaths) { - Set functorsFromQn = - psiFinder.findModulesFromQn( - qnameFunctorPath + "." + functorName, - true, - interfaceOrImplementation, - scope); - for (PsiModule functorModule : functorsFromQn) { - PsiFunctor functor = (PsiFunctor) functorModule; - PsiElement returnType = functor.getReturnType(); - if (returnType == null) { - resolvedModules.add(functor); - } else { - // resolve return type - Set interfacesFromQn = - psiFinder.findModulesFromQn( - qnameFunctorPath + "." + returnType.getText(), - true, - interfaceOrImplementation, - scope); - resolvedModules.addAll(interfacesFromQn); - } + Set resolvedModules = new ArrayListSet<>(); + for (String qname : potentialPaths) { + Set modulesFromQn = + psiFinder.findModulesFromQn(qname, true, interfaceOrImplementation, scope); + for (PsiModule module : modulesFromQn) { + PsiFunctorCall functorCall = module.getFunctorCall(); + if (functorCall != null) { + // resolve functor definition + String functorName = functorCall.getFunctorName(); + potentialPaths = qnameFinder.extractPotentialPaths(module); + for (String qnameFunctorPath : potentialPaths) { + Set functorsFromQn = + psiFinder.findModulesFromQn( + qnameFunctorPath + "." + functorName, + true, + interfaceOrImplementation, + scope); + for (PsiModule functorModule : functorsFromQn) { + PsiFunctor functor = (PsiFunctor) functorModule; + PsiElement returnType = functor.getReturnType(); + if (returnType == null) { + resolvedModules.add(functor); + } else { + // resolve return type + Set interfacesFromQn = + psiFinder.findModulesFromQn( + qnameFunctorPath + "." + returnType.getText(), + true, + interfaceOrImplementation, + scope); + resolvedModules.addAll(interfacesFromQn); + } + } + } + } else { + resolvedModules.add(module); + } + } } - } - } else { - resolvedModules.add(module); - } - } - } - LOG.debug(" -> resolved modules from path", resolvedModules); + LOG.debug(" -> resolved modules from path", resolvedModules); - // Might be a virtual namespace + // Might be a virtual namespace - Collection modulesForNamespace = psiFinder.findModulesForNamespace(upperName, scope); - if (!modulesForNamespace.isEmpty()) { - LOG.debug(" found namespace files", modulesForNamespace); + Collection modulesForNamespace = psiFinder.findModulesForNamespace(upperName, scope); + if (!modulesForNamespace.isEmpty()) { + LOG.debug(" found namespace files", modulesForNamespace); - VirtualFileManager vFileManager = VirtualFileManager.getInstance(); - PsiManager psiManager = PsiManager.getInstance(project); + VirtualFileManager vFileManager = VirtualFileManager.getInstance(); + PsiManager psiManager = PsiManager.getInstance(project); - for (IndexedFileModule file : modulesForNamespace) { - VirtualFile fileByNioPath = vFileManager.findFileByNioPath(new File(file.getPath()).toPath()); - PsiFile psiFile = fileByNioPath == null ? null : psiManager.findFile(fileByNioPath); - resultSet.addElement( - LookupElementBuilder.create(file.getModuleName()) - .withTypeText(psiFile == null ? file.getPath() : FileHelper.shortLocation(psiFile)) - .withIcon(IconProvider.getFileModuleIcon(file.isOCaml(), file.isInterface()))); - } + for (IndexedFileModule file : modulesForNamespace) { + VirtualFile fileByNioPath = vFileManager.findFileByNioPath(new File(file.getPath()).toPath()); + PsiFile psiFile = fileByNioPath == null ? null : psiManager.findFile(fileByNioPath); + resultSet.addElement( + LookupElementBuilder.create(file.getModuleName()) + .withTypeText(psiFile == null ? file.getPath() : FileHelper.shortLocation(psiFile)) + .withIcon(IconProvider.getFileModuleIcon(file.isOCaml(), file.isInterface()))); + } - return; - } + return; + } - // Use first resolved module + // Use first resolved module - if (!resolvedModules.isEmpty()) { - Collection expressions = - resolvedModules.iterator().next().getExpressions(pub, NO_FILTER); - LOG.trace(" -> expressions", expressions); - addExpressions(resultSet, expressions, element.getLanguage()); - } - } - } else if (previousElement instanceof PsiLowerSymbol) { - // Expression of let/val/external/type - String lowerName = previousElement.getText(); - if (lowerName != null) { - LOG.debug(" symbol", lowerName); - PsiFinder psiFinder = PsiFinder.getInstance(project); - - // try let - Collection lets = psiFinder.findLets(lowerName, interfaceOrImplementation); - if (LOG.isDebugEnabled()) { - LOG.debug( - " lets", - lets.size(), - lets.size() == 1 - ? " (" + lets.iterator().next().getName() + ")" - : "[" + Joiner.join(", ", lets) + "]"); - } + if (!resolvedModules.isEmpty()) { + Collection expressions = + resolvedModules.iterator().next().getExpressions(pub, NO_FILTER); + LOG.trace(" -> expressions", expressions); + addExpressions(resultSet, expressions, element.getLanguage()); + } + } + } else if (previousElement instanceof PsiLowerSymbol) { + // Expression of let/val/external/type + String lowerName = previousElement.getText(); + if (lowerName != null) { + LOG.debug(" symbol", lowerName); + PsiFinder psiFinder = PsiFinder.getInstance(project); + + // try let + Collection lets = psiFinder.findLets(lowerName, interfaceOrImplementation); + if (LOG.isDebugEnabled()) { + LOG.debug( + " lets", + lets.size(), + lets.size() == 1 + ? " (" + lets.iterator().next().getName() + ")" + : "[" + Joiner.join(", ", lets) + "]"); + } - // need filtering + // need filtering - for (PsiLet expression : lets) { - for (PsiRecordField recordField : expression.getRecordFields()) { - resultSet.addElement( - LookupElementBuilder.create(recordField) - .withTypeText(PsiSignatureUtil.getSignature(recordField, element.getLanguage())) - .withIcon(PsiIconUtil.getProvidersIcon(recordField, 0))); - } + for (PsiLet expression : lets) { + for (PsiRecordField recordField : expression.getRecordFields()) { + resultSet.addElement( + LookupElementBuilder.create(recordField) + .withTypeText(PsiSignatureUtil.getSignature(recordField, element.getLanguage())) + .withIcon(PsiIconUtil.getProvidersIcon(recordField, 0))); + } + } + } } - } } - } - - private static void addExpressions( - @NotNull CompletionResultSet resultSet, - @NotNull Collection expressions, - @NotNull Language language) { - for (PsiNamedElement expression : expressions) { - if (!(expression instanceof PsiOpen) - && !(expression instanceof PsiInclude) - && !(expression instanceof PsiAnnotation)) { - // TODO: if include => include - String name = expression.getName(); - if (name != null) { - String signature = PsiSignatureUtil.getSignature(expression, language); - resultSet.addElement( - LookupElementBuilder.create(name) - .withTypeText(signature) - .withIcon(PsiIconUtil.getProvidersIcon(expression, 0))); - } - if (expression instanceof PsiType) { - PsiType eType = (PsiType) expression; - Collection variants = eType.getVariants(); - if (!variants.isEmpty()) { - for (PsiVariantDeclaration variant : variants) { - String variantName = variant.getName(); - if (variantName != null) { - resultSet.addElement( - LookupElementBuilder.create(variantName) - .withTypeText(eType.getName()) - .withIcon(PsiIconUtil.getProvidersIcon(variant, 0))); - } + + private static void addExpressions( + @NotNull CompletionResultSet resultSet, + @NotNull Collection expressions, + @NotNull Language language) { + for (PsiNamedElement expression : expressions) { + if (!(expression instanceof PsiOpen) + && !(expression instanceof PsiInclude) + && !(expression instanceof PsiAnnotation)) { + // TODO: if include => include + String name = expression.getName(); + if (name != null) { + String signature = PsiSignatureUtil.getSignature(expression, language); + resultSet.addElement( + LookupElementBuilder.create(name) + .withTypeText(signature) + .withIcon(PsiIconUtil.getProvidersIcon(expression, 0))); + } + if (expression instanceof PsiType) { + PsiType eType = (PsiType) expression; + Collection variants = eType.getVariants(); + if (!variants.isEmpty()) { + for (PsiVariantDeclaration variant : variants) { + String variantName = variant.getName(); + if (variantName != null) { + resultSet.addElement( + LookupElementBuilder.create(variantName) + .withTypeText(eType.getName()) + .withIcon(PsiIconUtil.getProvidersIcon(variant, 0))); + } + } + } + } } - } } - } } - } } diff --git a/src/com/reason/ide/insight/provider/FreeExpressionCompletionProvider.java b/src/com/reason/ide/insight/provider/FreeExpressionCompletionProvider.java index 6bc34ba0d..430a92349 100644 --- a/src/com/reason/ide/insight/provider/FreeExpressionCompletionProvider.java +++ b/src/com/reason/ide/insight/provider/FreeExpressionCompletionProvider.java @@ -112,7 +112,7 @@ public static void addCompletions(@NotNull QNameFinder qnameFinder, @NotNull Psi || item instanceof PsiExternal || item instanceof PsiException || item instanceof PsiVal) { - if (item instanceof PsiLet && ((PsiLet) item).isDeconsruction()) { + if (item instanceof PsiLet && ((PsiLet) item).isDeconstruction()) { for (PsiElement deconstructedElement : ((PsiLet) item).getDeconstructedElements()) { resultSet.addElement( LookupElementBuilder.create(deconstructedElement.getText()) diff --git a/src/com/reason/ide/insight/provider/JsxNameCompletionProvider.java b/src/com/reason/ide/insight/provider/JsxNameCompletionProvider.java index b8733c9ce..3fa98a508 100644 --- a/src/com/reason/ide/insight/provider/JsxNameCompletionProvider.java +++ b/src/com/reason/ide/insight/provider/JsxNameCompletionProvider.java @@ -46,7 +46,7 @@ public static void addCompletions(@NotNull PsiElement element, @NotNull Completi .withTypeText( module instanceof PsiInnerModule ? containingFile.getModuleName() - : containingFile.shortLocation(project)) + : containingFile.shortLocation()) .withInsertHandler( (context, item) -> insertTagNameHandler(project, context, moduleName))); } diff --git a/src/com/reason/ide/insight/provider/ObjectCompletionProvider.java b/src/com/reason/ide/insight/provider/ObjectCompletionProvider.java index 49e2df233..391320b6e 100644 --- a/src/com/reason/ide/insight/provider/ObjectCompletionProvider.java +++ b/src/com/reason/ide/insight/provider/ObjectCompletionProvider.java @@ -168,7 +168,7 @@ public static void addCompletions(@NotNull ORTypes types, @NotNull PsiElement el GlobalSearchScope scope = GlobalSearchScope.allScope(let.getProject()); String signatureName = "." + letSignature.getText(); for (String path : paths) { - PsiType type = psiFinder.findTypeFromQn(path + signatureName, scope); + PsiType type = psiFinder.findTypeFromQn(path + signatureName); if (type != null) { LOG.debug(" -> Found", type); return type; diff --git a/src/com/reason/ide/search/FileModuleIndexService.java b/src/com/reason/ide/search/FileModuleIndexService.java index af11af217..e59688b05 100644 --- a/src/com/reason/ide/search/FileModuleIndexService.java +++ b/src/com/reason/ide/search/FileModuleIndexService.java @@ -1,24 +1,16 @@ package com.reason.ide.search; -import com.intellij.openapi.components.ServiceManager; -import com.intellij.openapi.project.Project; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.indexing.FileBasedIndex; -import com.intellij.util.indexing.ID; -import com.reason.Joiner; -import com.reason.Log; -import com.reason.ide.files.FileBase; -import com.reason.ide.search.index.FileModuleIndex; -import com.reason.ide.search.index.ModuleIndex; -import com.reason.ide.search.index.NamespaceIndex; -import com.reason.lang.core.psi.PsiModule; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.openapi.components.*; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; +import com.intellij.util.indexing.*; +import com.reason.*; +import com.reason.ide.files.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; public class FileModuleIndexService { private static final Log LOG = Log.create("index.fileservice"); @@ -56,7 +48,7 @@ public List getFiles(@NotNull Project project, @NotNull GlobalSearchSc LOG.debug("all keys (" + allKeys.size() + "): " + Joiner.join(", ", allKeys)); for (String key : allKeys) { if (!"Pervasives".equals(key)) { - Collection psiModules = ModuleIndex.getInstance().get(key, project, scope); + Collection psiModules = ModuleIndex.getElements(key, project, null); for (PsiModule psiModule : psiModules) { result.add((FileBase) psiModule.getContainingFile()); } diff --git a/src/com/reason/ide/search/ORFindUsagesProvider.java b/src/com/reason/ide/search/ORFindUsagesProvider.java index 33f028d45..5f56d3f00 100644 --- a/src/com/reason/ide/search/ORFindUsagesProvider.java +++ b/src/com/reason/ide/search/ORFindUsagesProvider.java @@ -1,62 +1,54 @@ package com.reason.ide.search; -import com.intellij.lang.HelpID; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import com.reason.lang.core.psi.PsiModule; -import com.reason.lang.core.psi.PsiQualifiedElement; -import com.reason.lang.core.psi.impl.PsiLowerIdentifier; -import com.reason.lang.core.psi.impl.PsiUpperIdentifier; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - -public abstract class ORFindUsagesProvider - implements com.intellij.lang.findUsages.FindUsagesProvider { - - @Override - public boolean canFindUsagesFor(@NotNull PsiElement element) { - return element instanceof PsiUpperIdentifier || element instanceof PsiLowerIdentifier; - } - - @Nullable - @Override - public String getHelpId(@NotNull PsiElement psiElement) { - return HelpID.FIND_OTHER_USAGES; - } - - @NotNull - @Override - public String getType(@NotNull PsiElement element) { - String type = PsiTypeElementProvider.getType(element); - return type == null ? "unknown type" : type; - } - - @NotNull - @Override - public String getDescriptiveName(@NotNull PsiElement element) { - if (element instanceof PsiModule) { - return "Module " + ((PsiModule) element).getName(); - } else if (element instanceof PsiNamedElement) { - String name = ((PsiNamedElement) element).getName(); - return name == null ? "" : name; +import com.intellij.lang.*; +import com.intellij.psi.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import org.jetbrains.annotations.*; + +public abstract class ORFindUsagesProvider implements com.intellij.lang.findUsages.FindUsagesProvider { + @Override + public boolean canFindUsagesFor(@NotNull PsiElement element) { + return element instanceof PsiUpperIdentifier || element instanceof PsiLowerIdentifier; } - return ""; - } - @NotNull - @Override - public String getNodeText(@NotNull PsiElement element, boolean useFullName) { - if (element instanceof PsiQualifiedElement) { - return ((PsiQualifiedElement) element).getQualifiedName(); + @Override + public @Nullable String getHelpId(@NotNull PsiElement psiElement) { + return HelpID.FIND_OTHER_USAGES; } - if (element instanceof PsiNamedElement) { - String name = ((PsiNamedElement) element).getName(); - if (name != null) { - return name; - } + + @Override + public @NotNull String getType(@NotNull PsiElement element) { + String type = PsiTypeElementProvider.getType(element); + return type == null ? "unknown type" : type; } - return element.getText(); - } + @Override + public @NotNull String getDescriptiveName(@NotNull PsiElement element) { + if (element instanceof PsiModule) { + return "Module " + ((PsiModule) element).getName(); + } else if (element instanceof PsiNamedElement) { + String name = ((PsiNamedElement) element).getName(); + return name == null ? "" : name; + } + + return ""; + } + + @Override + public @NotNull String getNodeText(@NotNull PsiElement element, boolean useFullName) { + if (element instanceof PsiQualifiedNamedElement) { + String qName = ((PsiQualifiedNamedElement) element).getQualifiedName(); + return qName == null ? "" : qName; + } + if (element instanceof PsiNamedElement) { + String name = ((PsiNamedElement) element).getName(); + if (name != null) { + return name; + } + } + + return element.getText(); + } } diff --git a/src/com/reason/ide/search/PsiFinder.java b/src/com/reason/ide/search/PsiFinder.java index 8b94b9234..0e8ff3a88 100644 --- a/src/com/reason/ide/search/PsiFinder.java +++ b/src/com/reason/ide/search/PsiFinder.java @@ -26,6 +26,7 @@ import java.util.HashSet; import java.util.*; +import java.util.regex.*; import java.util.stream.*; import static com.intellij.psi.search.GlobalSearchScope.*; @@ -36,6 +37,60 @@ public final class PsiFinder { private static final Log LOG = Log.create("finder"); + public @Nullable PsiQualifiedPathElement findModuleBack(@Nullable PsiElement root, @Nullable String path) { + if (root != null && path != null) { + PsiElement prev = ORUtil.prevSibling(root); + PsiElement item = prev == null ? root.getParent() : prev; + while (item != null) { + if (item instanceof PsiInnerModule) { + PsiInnerModule module = (PsiInnerModule) item; + String name = module.getModuleName(); + String alias = module.getAlias(); + if (alias != null) { + // This is a local module alias, we'll need to replace it in final paths + Pattern compile = Pattern.compile("(\\.?)(" + name + ")(\\.?)"); + String replace = "$1" + alias + "$3"; + path = compile.matcher(path).replaceFirst(replace); + } else if (path.equals(name)) { + return module; + } else if (name != null && path.startsWith(name)) { + // Follow module from top to bottom to find real module + path = path.substring(name.length() + 1); + return findModuleForward(module.getBody(), path); + } + } + prev = ORUtil.prevSibling(item); + item = prev == null ? item.getParent() : prev; + } + } + + return null; + } + + private @Nullable PsiQualifiedPathElement findModuleForward(@Nullable PsiElement root, @Nullable String path) { + if (root != null && path != null) { + PsiElement next = ORUtil.nextSibling(root); + PsiElement item = next == null ? root.getFirstChild() : next; + while (item != null) { + if (item instanceof PsiInnerModule) { + PsiInnerModule module = (PsiInnerModule) item; + String name = module.getModuleName(); + if (path.equals(name)) { + return module; + } else if (name != null && path.startsWith(name)) { + // Go deeper + path = path.substring(name.length() + 1); + return findModuleForward(module.getBody(), path); + } + } + next = ORUtil.nextSibling(item); + item = next == null ? item.getFirstChild() : next; + } + } + + return null; + } + @FunctionalInterface public interface ModuleFilter { boolean accepts(T module); @@ -130,14 +185,13 @@ public boolean hasInterfaces() { public @NotNull Set findModulesbyName(@NotNull String name, @NotNull ORFileType fileType, ModuleFilter filter, @NotNull GlobalSearchScope scope) { Set result = new HashSet<>(); - ModuleIndex moduleIndex = ModuleIndex.getInstance(); - moduleIndex.processAllKeys( + StubIndex.getInstance().processAllKeys(IndexKeys.MODULES, m_project, CommonProcessors.processAll( moduleName -> { if (name.equals(moduleName)) { - Collection modules = moduleIndex.get(moduleName, m_project, scope); + Collection modules = ModuleIndex.getElements(moduleName, m_project, null); PartitionedModules partitionedModules = new PartitionedModules(m_project, modules, filter); @@ -172,7 +226,7 @@ public boolean hasInterfaces() { } public @Nullable PsiModule findComponentFromQName(@Nullable String fqn, @NotNull GlobalSearchScope scope) { - Collection modules = fqn == null ? emptyList() : ModuleComponentFqnIndex.getInstance().get(fqn.hashCode(), m_project, scope); + Collection modules = fqn == null ? emptyList() : ModuleComponentFqnIndex.getElements(fqn, m_project); if (!modules.isEmpty()) { PsiModule module = modules.iterator().next(); return ServiceManager.getService(m_project, BsCompiler.class) @@ -194,13 +248,12 @@ public boolean hasInterfaces() { BsCompiler bucklescript = ServiceManager.getService(m_project, BsCompiler.class); - ModuleComponentIndex componentIndex = ModuleComponentIndex.getInstance(); - ModuleIndex moduleIndex = ModuleIndex.getInstance(); - componentIndex.processAllKeys( + StubIndex.getInstance().processAllKeys( + IndexKeys.MODULES_COMP, project, CommonProcessors.processAll( moduleName -> { - for (PsiModule module : moduleIndex.get(moduleName, project, scope)) { + for (PsiModule module : ModuleIndex.getElements(moduleName, project, null)) { FileBase file = (FileBase) module.getContainingFile(); if (!module.isInterface() && bucklescript.isDependency(file.getVirtualFile())) { result.add(module); @@ -248,13 +301,8 @@ public Set findExternals(@NotNull String name, @NotNull ORFileType } @NotNull - private Set findLowerSymbols( - @NotNull String debugName, - @NotNull String name, - @NotNull ORFileType fileType, - @NotNull StubIndexKey indexKey, - @NotNull Class clazz, - @NotNull GlobalSearchScope scope) { + private Set findLowerSymbols(@NotNull String debugName, @NotNull String name, @NotNull ORFileType fileType, @NotNull StubIndexKey indexKey, @NotNull Class clazz, + @NotNull GlobalSearchScope scope) { Map implNames = new THashMap<>(); Map intfNames = new THashMap<>(); @@ -319,23 +367,13 @@ private Set findLowerSymbols( return result; } - @Nullable - public PsiVariantDeclaration findVariant(@Nullable String qname, @NotNull GlobalSearchScope scope) { - if (qname == null) { - return null; - } - - Collection variants = VariantFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); - return variants.isEmpty() ? null : variants.iterator().next(); - } - @NotNull public Collection findVariantByName(@Nullable String path, @Nullable String name, @NotNull GlobalSearchScope scope) { if (name == null) { return emptyList(); } - Collection variants = VariantIndex.getInstance().get(name, m_project, scope); + Collection variants = VariantIndex.getElements(name, m_project, null); if (!variants.isEmpty() && path != null) { // Keep variants that have correct path return variants @@ -347,15 +385,12 @@ public Collection findVariantByName(@Nullable String path return variants; } - @Nullable - public PsiException findException( - @Nullable String qname, ORFileType fileType, @NotNull GlobalSearchScope scope) { + public @Nullable PsiException findException(@Nullable String qname, ORFileType fileType, @NotNull GlobalSearchScope scope) { if (qname == null) { return null; } - Collection items = - ExceptionFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); + Collection items = ExceptionFqnIndex.getElements(qname, m_project); if (items.isEmpty()) { return null; } @@ -380,17 +415,12 @@ public PsiException findException( return null; } - @NotNull - public Set findTopModules( - boolean excludeNamespaces, @NotNull GlobalSearchScope scope) { + public @NotNull Set findTopModules(boolean excludeNamespaces, @NotNull GlobalSearchScope scope) { Set result = new HashSet<>(); - ModuleTopLevelIndex index = ModuleTopLevelIndex.getInstance(); - - index.processAllKeys( - m_project, + StubIndex.getInstance().processAllKeys(IndexKeys.MODULES_TOP_LEVEL, m_project, name -> { - Collection collection = index.get(name, m_project, scope); + Collection collection = ModuleTopLevelIndex.getElements(name, m_project); for (PsiFakeModule psiFakeModule : collection) { if (!(excludeNamespaces && psiFakeModule.hasNamespace())) { result.add(psiFakeModule); @@ -411,13 +441,11 @@ public Set findModuleAlias(@Nullable String qname, @NotNull GlobalSea Set result = new HashSet<>(); - Collection psiModules = - ModuleFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); + Collection psiModules = ModuleFqnIndex.getElements(qname, m_project); for (PsiModule module : psiModules) { String alias = module.getAlias(); if (alias != null) { - Collection aliasModules = - ModuleFqnIndex.getInstance().get(alias.hashCode(), m_project, scope); + Collection aliasModules = ModuleFqnIndex.getElements(alias, m_project); if (!aliasModules.isEmpty()) { for (PsiModule aliasModule : aliasModules) { Set nextModuleAlias = findModuleAlias(aliasModule.getQualifiedName(), scope); @@ -443,7 +471,7 @@ public Set findModulesFromQn(@Nullable String qname, boolean resolveA Set result = new HashSet<>(); // Try qn directly - Collection modules = ModuleFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); + Collection modules = ModuleFqnIndex.getElements(qname, m_project); if (modules.isEmpty()) { // Qn not working, maybe because of aliases... try to navigate to each module @@ -523,8 +551,7 @@ public PsiParameter findParameterFromQn( } // Try qn directly - Collection parameters = - ParameterFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); + Collection parameters = ParameterFqnIndex.getElements(qname, m_project); if (!parameters.isEmpty()) { return parameters.iterator().next(); } @@ -541,7 +568,7 @@ public PsiLet findLetFromQn(@Nullable String qname) { GlobalSearchScope scope = allScope(m_project); // Try qn directly - Collection lets = LetFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); + Collection lets = LetFqnIndex.getElements(qname.hashCode(), m_project); if (!lets.isEmpty()) { return lets.iterator().next(); } @@ -592,7 +619,7 @@ public PsiVal findValFromQn(@Nullable String qname) { GlobalSearchScope scope = allScope(m_project); // Try qn directly - Collection vals = ValFqnIndex.getInstance().get(qname.hashCode(), m_project, scope); + Collection vals = ValFqnIndex.getElements(qname.hashCode(), m_project); if (!vals.isEmpty()) { return vals.iterator().next(); } @@ -641,8 +668,7 @@ public PsiVal findValFromQn(@Nullable String qname) { GlobalSearchScope scope = allScope(m_project); // Try qn directly - Collection parameters = - ParameterFqnIndex.getInstance().get(qName.hashCode(), m_project, scope); + Collection parameters = ParameterFqnIndex.getElements(qName, m_project); if (!parameters.isEmpty()) { if (parameters.size() == 1) { return parameters.iterator().next(); @@ -652,10 +678,10 @@ public PsiVal findValFromQn(@Nullable String qname) { return null; } - public @Nullable PsiType findTypeFromQn(@Nullable String qName, @NotNull GlobalSearchScope scope) { + public @Nullable PsiType findTypeFromQn(@Nullable String qName) { if (qName != null) { // Try qn directly - Collection types = TypeFqnIndex.getInstance().get(qName.hashCode(), m_project, scope); + Collection types = TypeFqnIndex.getElements(qName.hashCode(), m_project); if (!types.isEmpty()) { return types.iterator().next(); } diff --git a/src/com/reason/ide/search/index/ExceptionFqnIndex.java b/src/com/reason/ide/search/index/ExceptionFqnIndex.java index f77a5521d..8e1f37d48 100644 --- a/src/com/reason/ide/search/index/ExceptionFqnIndex.java +++ b/src/com/reason/ide/search/index/ExceptionFqnIndex.java @@ -1,25 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ExceptionFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 3; - private static final ExceptionFqnIndex INSTANCE = new ExceptionFqnIndex(); - - @NotNull - public static ExceptionFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ExceptionFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiExceptionStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.EXCEPTIONS_FQN; } + + public static @NotNull Collection getElements(String key, Project project) { + return StubIndex.getElements(IndexKeys.EXCEPTIONS_FQN, key.hashCode(), project, null, PsiException.class); + } } diff --git a/src/com/reason/ide/search/index/ExceptionIndex.java b/src/com/reason/ide/search/index/ExceptionIndex.java index 07c30b5a1..e6a904441 100644 --- a/src/com/reason/ide/search/index/ExceptionIndex.java +++ b/src/com/reason/ide/search/index/ExceptionIndex.java @@ -1,26 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ExceptionIndex extends StringStubIndexExtension { - private static final int VERSION = 4; - private static final ExceptionIndex INSTANCE = new ExceptionIndex(); - - @NotNull - public static ExceptionIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ExceptionIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiExceptionStubElementType.VERSION; } - @NotNull @Override - public StubIndexKey getKey() { + public @NotNull StubIndexKey getKey() { return IndexKeys.EXCEPTIONS; } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.EXCEPTIONS, key, project, scope, PsiException.class); + } } diff --git a/src/com/reason/ide/search/index/ExternalIndex.java b/src/com/reason/ide/search/index/ExternalIndex.java index e800f54cf..4b4e780ae 100644 --- a/src/com/reason/ide/search/index/ExternalIndex.java +++ b/src/com/reason/ide/search/index/ExternalIndex.java @@ -1,20 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ExternalIndex extends StringStubIndexExtension { - private static final int VERSION = 7; +import java.util.*; +public class ExternalIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiExternalStubElementType.VERSION; } - @NotNull @Override - public StubIndexKey getKey() { + public @NotNull StubIndexKey getKey() { return IndexKeys.EXTERNALS; } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.EXTERNALS, key, project, scope, PsiExternal.class); + } } diff --git a/src/com/reason/ide/search/index/IncludeIndex.java b/src/com/reason/ide/search/index/IncludeIndex.java new file mode 100644 index 000000000..248a0a147 --- /dev/null +++ b/src/com/reason/ide/search/index/IncludeIndex.java @@ -0,0 +1,26 @@ +package com.reason.ide.search.index; + +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; +import com.intellij.psi.stubs.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +public class IncludeIndex extends StringStubIndexExtension { + @Override + public int getVersion() { + return super.getVersion() + PsiIncludeStubElementType.VERSION; + } + + @Override + public @NotNull StubIndexKey getKey() { + return IndexKeys.INCLUDES; + } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.INCLUDES, key, project, scope, PsiInclude.class); + } +} diff --git a/src/com/reason/ide/search/index/IndexKeys.java b/src/com/reason/ide/search/index/IndexKeys.java index 117cded6c..43f060f60 100644 --- a/src/com/reason/ide/search/index/IndexKeys.java +++ b/src/com/reason/ide/search/index/IndexKeys.java @@ -14,6 +14,8 @@ public class IndexKeys { public static final StubIndexKey MODULES_COMP = StubIndexKey.createIndexKey("reason.module.comp"); public static final StubIndexKey MODULES_COMP_FQN = StubIndexKey.createIndexKey("reason.module.comp.fqn"); public static final StubIndexKey MODULES = StubIndexKey.createIndexKey("reason.module"); + public static final StubIndexKey MODULES_ALIASED = StubIndexKey.createIndexKey("reason.module.aliased"); + public static final StubIndexKey MODULES_ALIASES = StubIndexKey.createIndexKey("reason.module.aliases"); public static final StubIndexKey MODULES_FQN = StubIndexKey.createIndexKey("reason.module.fqn"); public static final StubIndexKey VARIANTS = StubIndexKey.createIndexKey("reason.variant"); public static final StubIndexKey VARIANTS_FQN = StubIndexKey.createIndexKey("reason.variant.fqn"); @@ -29,6 +31,8 @@ public class IndexKeys { public static final StubIndexKey EXCEPTIONS_FQN = StubIndexKey.createIndexKey("reason.exception.fqn"); public static final StubIndexKey PARAMETERS = StubIndexKey.createIndexKey("reason.parameter"); public static final StubIndexKey PARAMETERS_FQN = StubIndexKey.createIndexKey("reason.parameter.fqn"); + public static final StubIndexKey INCLUDES = StubIndexKey.createIndexKey("reason.include"); + public static final StubIndexKey OPENS = StubIndexKey.createIndexKey("reason.open"); private IndexKeys() { } diff --git a/src/com/reason/ide/search/index/LetFqnIndex.java b/src/com/reason/ide/search/index/LetFqnIndex.java index 2b6ad5192..c909da6c2 100644 --- a/src/com/reason/ide/search/index/LetFqnIndex.java +++ b/src/com/reason/ide/search/index/LetFqnIndex.java @@ -1,24 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class LetFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 4; - private static final LetFqnIndex INSTANCE = new LetFqnIndex(); - - public static @NotNull LetFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class LetFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiLetStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.LETS_FQN; } + + public static @NotNull Collection getElements(int key, @NotNull Project project) { + return StubIndex.getElements(IndexKeys.LETS_FQN, key, project, null, PsiLet.class); + } } diff --git a/src/com/reason/ide/search/index/LetIndex.java b/src/com/reason/ide/search/index/LetIndex.java index 1a2e5c66c..222e18589 100644 --- a/src/com/reason/ide/search/index/LetIndex.java +++ b/src/com/reason/ide/search/index/LetIndex.java @@ -1,20 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class LetIndex extends StringStubIndexExtension { - private static final int VERSION = 10; +import java.util.*; +public class LetIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiLetStubElementType.VERSION; } - @NotNull @Override - public StubIndexKey getKey() { + public @NotNull StubIndexKey getKey() { return IndexKeys.LETS; } + + public static @NotNull Collection getElements(String key, Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.LETS, key, project, scope, PsiLet.class); + } } diff --git a/src/com/reason/ide/search/index/ModuleAliasedIndex.java b/src/com/reason/ide/search/index/ModuleAliasedIndex.java new file mode 100644 index 000000000..867d1be0f --- /dev/null +++ b/src/com/reason/ide/search/index/ModuleAliasedIndex.java @@ -0,0 +1,26 @@ +package com.reason.ide.search.index; + +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; +import com.intellij.psi.stubs.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +public class ModuleAliasedIndex extends StringStubIndexExtension { + @Override + public int getVersion() { + return super.getVersion() + PsiModuleStubElementType.VERSION; + } + + @Override + public @NotNull StubIndexKey getKey() { + return IndexKeys.MODULES_ALIASED; + } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.MODULES_ALIASED, key, project, scope, PsiModule.class); + } +} diff --git a/src/com/reason/ide/search/index/ModuleAliasesIndex.java b/src/com/reason/ide/search/index/ModuleAliasesIndex.java new file mode 100644 index 000000000..6ed57bdce --- /dev/null +++ b/src/com/reason/ide/search/index/ModuleAliasesIndex.java @@ -0,0 +1,26 @@ +package com.reason.ide.search.index; + +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; +import com.intellij.psi.stubs.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +public class ModuleAliasesIndex extends StringStubIndexExtension { + @Override + public int getVersion() { + return super.getVersion() + PsiModuleStubElementType.VERSION; + } + + @Override + public @NotNull StubIndexKey getKey() { + return IndexKeys.MODULES_ALIASES; + } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.MODULES_ALIASES, key, project, scope, PsiModule.class); + } +} diff --git a/src/com/reason/ide/search/index/ModuleComponentFqnIndex.java b/src/com/reason/ide/search/index/ModuleComponentFqnIndex.java index d75cf9581..b10f08bc5 100644 --- a/src/com/reason/ide/search/index/ModuleComponentFqnIndex.java +++ b/src/com/reason/ide/search/index/ModuleComponentFqnIndex.java @@ -1,24 +1,24 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ModuleComponentFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 1; - private static final ModuleComponentFqnIndex INSTANCE = new ModuleComponentFqnIndex(); - - public static @NotNull ModuleComponentFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ModuleComponentFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiModuleStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.MODULES_COMP_FQN; } -} + + public static @NotNull Collection getElements(String key, Project project) { + return StubIndex.getElements(IndexKeys.MODULES_COMP_FQN, key.hashCode(), project, null, PsiModule.class); + }} diff --git a/src/com/reason/ide/search/index/ModuleComponentIndex.java b/src/com/reason/ide/search/index/ModuleComponentIndex.java index 78a9b220e..6a419f7f9 100644 --- a/src/com/reason/ide/search/index/ModuleComponentIndex.java +++ b/src/com/reason/ide/search/index/ModuleComponentIndex.java @@ -2,21 +2,13 @@ import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; public class ModuleComponentIndex extends StringStubIndexExtension { - - private static final int VERSION = 8; - private static final ModuleComponentIndex INSTANCE = new ModuleComponentIndex(); - - @NotNull - public static ModuleComponentIndex getInstance() { - return INSTANCE; - } - @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiModuleStubElementType.VERSION; } @NotNull diff --git a/src/com/reason/ide/search/index/ModuleFqnIndex.java b/src/com/reason/ide/search/index/ModuleFqnIndex.java index 4ea5ad956..b3f0b2555 100644 --- a/src/com/reason/ide/search/index/ModuleFqnIndex.java +++ b/src/com/reason/ide/search/index/ModuleFqnIndex.java @@ -1,26 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ModuleFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 8; - private static final ModuleFqnIndex INSTANCE = new ModuleFqnIndex(); - - @NotNull - public static ModuleFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ModuleFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiModuleStubElementType.VERSION; } - @NotNull @Override - public StubIndexKey getKey() { + public @NotNull StubIndexKey getKey() { return IndexKeys.MODULES_FQN; } + + public static @NotNull Collection getElements(@NotNull String qname, @NotNull Project project) { + return StubIndex.getElements(IndexKeys.MODULES_FQN, qname.hashCode(), project, null, PsiModule.class); + } } diff --git a/src/com/reason/ide/search/index/ModuleIndex.java b/src/com/reason/ide/search/index/ModuleIndex.java index 4a8afcf6d..8b238f8e8 100644 --- a/src/com/reason/ide/search/index/ModuleIndex.java +++ b/src/com/reason/ide/search/index/ModuleIndex.java @@ -1,26 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ModuleIndex extends StringStubIndexExtension { - private static final int VERSION = 17; - private static final ModuleIndex INSTANCE = new ModuleIndex(); - - @NotNull - public static ModuleIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ModuleIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiModuleStubElementType.VERSION; } - @NotNull @Override - public StubIndexKey getKey() { + public @NotNull StubIndexKey getKey() { return IndexKeys.MODULES; } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.MODULES, key, project, scope, PsiModule.class); + } } diff --git a/src/com/reason/ide/search/index/ModuleTopLevelIndex.java b/src/com/reason/ide/search/index/ModuleTopLevelIndex.java index b357548fd..ebdbe59b5 100644 --- a/src/com/reason/ide/search/index/ModuleTopLevelIndex.java +++ b/src/com/reason/ide/search/index/ModuleTopLevelIndex.java @@ -1,26 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ModuleTopLevelIndex extends StringStubIndexExtension { - private static final int VERSION = 2; - private static final ModuleTopLevelIndex INSTANCE = new ModuleTopLevelIndex(); - - @NotNull - public static ModuleTopLevelIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ModuleTopLevelIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiFakeModuleStubElementType.VERSION; } - @NotNull @Override - public StubIndexKey getKey() { + public @NotNull StubIndexKey getKey() { return IndexKeys.MODULES_TOP_LEVEL; } + + public static @NotNull Collection getElements(String key, Project project) { + return StubIndex.getElements(IndexKeys.MODULES_TOP_LEVEL, key, project, null, PsiFakeModule.class); + } } diff --git a/src/com/reason/ide/search/index/OpenIndex.java b/src/com/reason/ide/search/index/OpenIndex.java new file mode 100644 index 000000000..a59374270 --- /dev/null +++ b/src/com/reason/ide/search/index/OpenIndex.java @@ -0,0 +1,26 @@ +package com.reason.ide.search.index; + +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; +import com.intellij.psi.stubs.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +public class OpenIndex extends StringStubIndexExtension { + @Override + public int getVersion() { + return super.getVersion() + PsiOpenStubElementType.VERSION; + } + + @Override + public @NotNull StubIndexKey getKey() { + return IndexKeys.OPENS; + } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.OPENS, key, project, scope, PsiOpen.class); + } +} diff --git a/src/com/reason/ide/search/index/ParameterFqnIndex.java b/src/com/reason/ide/search/index/ParameterFqnIndex.java index 18b24759a..1fa880b1b 100644 --- a/src/com/reason/ide/search/index/ParameterFqnIndex.java +++ b/src/com/reason/ide/search/index/ParameterFqnIndex.java @@ -1,24 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ParameterFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 3; - private static final ParameterFqnIndex INSTANCE = new ParameterFqnIndex(); - - public static @NotNull ParameterFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ParameterFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiParameterStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.PARAMETERS_FQN; } + + public static @NotNull Collection getElements(String key, Project project) { + return StubIndex.getElements(IndexKeys.PARAMETERS_FQN, key.hashCode(), project, null, PsiParameter.class); + } } diff --git a/src/com/reason/ide/search/index/ParameterIndex.java b/src/com/reason/ide/search/index/ParameterIndex.java index d0225f098..7ddfc7336 100644 --- a/src/com/reason/ide/search/index/ParameterIndex.java +++ b/src/com/reason/ide/search/index/ParameterIndex.java @@ -1,19 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ParameterIndex extends StringStubIndexExtension { - private static final int VERSION = 3; +import java.util.*; +public class ParameterIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiParameterStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.PARAMETERS; } + + public static @NotNull Collection getElements(String key, Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.PARAMETERS, key, project, scope, PsiParameter.class); + } } diff --git a/src/com/reason/ide/search/index/RecordFieldIndex.java b/src/com/reason/ide/search/index/RecordFieldIndex.java index afcdce5fd..1d3a27c68 100644 --- a/src/com/reason/ide/search/index/RecordFieldIndex.java +++ b/src/com/reason/ide/search/index/RecordFieldIndex.java @@ -1,19 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class RecordFieldIndex extends StringStubIndexExtension { - private static final int VERSION = 3; +import java.util.*; +public class RecordFieldIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiRecordFieldStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.RECORD_FIELDS; } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.RECORD_FIELDS, key, project, scope, PsiRecordField.class); + } } diff --git a/src/com/reason/ide/search/index/TypeFqnIndex.java b/src/com/reason/ide/search/index/TypeFqnIndex.java index 40a8a9561..a7d267f03 100644 --- a/src/com/reason/ide/search/index/TypeFqnIndex.java +++ b/src/com/reason/ide/search/index/TypeFqnIndex.java @@ -1,24 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class TypeFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 1; - private static final TypeFqnIndex INSTANCE = new TypeFqnIndex(); - - public static @NotNull TypeFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class TypeFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiTypeStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.TYPES_FQN; } + + public static @NotNull Collection getElements(int key, Project project) { + return StubIndex.getElements(IndexKeys.TYPES_FQN, key, project, null, PsiType.class); + } } diff --git a/src/com/reason/ide/search/index/TypeIndex.java b/src/com/reason/ide/search/index/TypeIndex.java index 08fbf5482..ee9c68938 100644 --- a/src/com/reason/ide/search/index/TypeIndex.java +++ b/src/com/reason/ide/search/index/TypeIndex.java @@ -1,19 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class TypeIndex extends StringStubIndexExtension { - private static final int VERSION = 9; +import java.util.*; +public class TypeIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiTypeStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.TYPES; } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.TYPES, key, project, scope, PsiType.class); + } } diff --git a/src/com/reason/ide/search/index/ValFqnIndex.java b/src/com/reason/ide/search/index/ValFqnIndex.java index cb3717ad5..27c1bbd72 100644 --- a/src/com/reason/ide/search/index/ValFqnIndex.java +++ b/src/com/reason/ide/search/index/ValFqnIndex.java @@ -1,24 +1,25 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ValFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 3; - private static final ValFqnIndex INSTANCE = new ValFqnIndex(); - - public static @NotNull ValFqnIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class ValFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiValStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.VALS_FQN; } + + public static @NotNull Collection getElements(int key, @NotNull Project project) { + return StubIndex.getElements(IndexKeys.VALS_FQN, key, project, null, PsiVal.class); + } } diff --git a/src/com/reason/ide/search/index/ValIndex.java b/src/com/reason/ide/search/index/ValIndex.java index 61a0792bd..6651ec219 100644 --- a/src/com/reason/ide/search/index/ValIndex.java +++ b/src/com/reason/ide/search/index/ValIndex.java @@ -1,19 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class ValIndex extends StringStubIndexExtension { - private static final int VERSION = 10; +import java.util.*; +public class ValIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiValStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.VALS; } + + public static @NotNull Collection getElements(String key, Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.VALS, key, project, scope, PsiVal.class); + } } diff --git a/src/com/reason/ide/search/index/VariantFqnIndex.java b/src/com/reason/ide/search/index/VariantFqnIndex.java index 23a5d3fc2..70e1816fa 100644 --- a/src/com/reason/ide/search/index/VariantFqnIndex.java +++ b/src/com/reason/ide/search/index/VariantFqnIndex.java @@ -1,24 +1,32 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class VariantFqnIndex extends IntStubIndexExtension { - private static final int VERSION = 4; - private static final VariantFqnIndex INSTANCE = new VariantFqnIndex(); +import java.util.*; - public static @NotNull VariantFqnIndex getInstance() { - return INSTANCE; - } +import static java.util.Collections.*; +public class VariantFqnIndex extends IntStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiVariantStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.VARIANTS_FQN; } + + public static @NotNull Collection getElements(String key, Project project) { + return StubIndex.getElements(IndexKeys.VARIANTS_FQN, key.hashCode(), project, null, PsiVariantDeclaration.class); + } + + public static PsiVariantDeclaration getElement(@Nullable String qname, @NotNull Project m_project) { + Collection variants = qname == null ? emptyList() : VariantFqnIndex.getElements(qname, m_project); + return variants.isEmpty() ? null : variants.iterator().next(); + } } diff --git a/src/com/reason/ide/search/index/VariantIndex.java b/src/com/reason/ide/search/index/VariantIndex.java index d341039ff..3beacf9b2 100644 --- a/src/com/reason/ide/search/index/VariantIndex.java +++ b/src/com/reason/ide/search/index/VariantIndex.java @@ -1,24 +1,26 @@ package com.reason.ide.search.index; +import com.intellij.openapi.project.*; +import com.intellij.psi.search.*; import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.type.*; import org.jetbrains.annotations.*; -public class VariantIndex extends StringStubIndexExtension { - private static final int VERSION = 3; - private static final VariantIndex INSTANCE = new VariantIndex(); - - public static @NotNull VariantIndex getInstance() { - return INSTANCE; - } +import java.util.*; +public class VariantIndex extends StringStubIndexExtension { @Override public int getVersion() { - return super.getVersion() + VERSION; + return super.getVersion() + PsiVariantStubElementType.VERSION; } @Override public @NotNull StubIndexKey getKey() { return IndexKeys.VARIANTS; } + + public static @NotNull Collection getElements(@NotNull String key, @NotNull Project project, @Nullable GlobalSearchScope scope) { + return StubIndex.getElements(IndexKeys.VARIANTS, key, project, scope, PsiVariantDeclaration.class); + } } diff --git a/src/com/reason/ide/structure/StructureViewElement.java b/src/com/reason/ide/structure/StructureViewElement.java index 3dd2cb3fc..81edbfc1e 100644 --- a/src/com/reason/ide/structure/StructureViewElement.java +++ b/src/com/reason/ide/structure/StructureViewElement.java @@ -72,7 +72,7 @@ public boolean canNavigateToSource() { if (element instanceof PsiNamedElement) { name = ((PsiNamedElement) element).getName(); } else if (element instanceof PsiInclude) { - name = ((PsiInclude) element).getPath(); + name = ((PsiInclude) element).getIncludePath(); } else if (element instanceof PsiOpen) { name = ((PsiOpen) element).getPath(); } diff --git a/src/com/reason/lang/PsiFileHelper.java b/src/com/reason/lang/PsiFileHelper.java index 71c67d6aa..e66682ff8 100644 --- a/src/com/reason/lang/PsiFileHelper.java +++ b/src/com/reason/lang/PsiFileHelper.java @@ -43,7 +43,7 @@ private static void processSiblingExpressions(@Nullable PsiFinder psiFinder, @No PsiModule includedModule = null; - String includedPath = include.getPath(); + String includedPath = include.getIncludePath(); for (String path : qnameFinder.extractPotentialPaths(include)) { Set modulesFromQn = psiFinder.findModulesFromQn(path + "." + includedPath, true, interfaceOrImplementation, scope); if (!modulesFromQn.isEmpty()) { diff --git a/src/com/reason/lang/core/ORCodeFactory.java b/src/com/reason/lang/core/ORCodeFactory.java index e1a450fe1..8679d0041 100644 --- a/src/com/reason/lang/core/ORCodeFactory.java +++ b/src/com/reason/lang/core/ORCodeFactory.java @@ -19,8 +19,7 @@ public class ORCodeFactory { private ORCodeFactory() {} @Nullable - public static PsiUpperIdentifier createModuleName( - @NotNull Project project, @NotNull String name) { + public static PsiUpperIdentifier createModuleName(@NotNull Project project, @NotNull String name) { FileBase file = createFileFromText(project, RmlLanguage.INSTANCE, "module " + name + " = {};"); PsiInnerModule module = ORUtil.findImmediateFirstChildOfClass(file, PsiInnerModule.class); return ORUtil.findImmediateFirstChildOfClass(module, PsiUpperIdentifier.class); diff --git a/src/com/reason/lang/core/ORUtil.java b/src/com/reason/lang/core/ORUtil.java index 8d855b0be..fef4c0591 100644 --- a/src/com/reason/lang/core/ORUtil.java +++ b/src/com/reason/lang/core/ORUtil.java @@ -5,6 +5,7 @@ import com.intellij.psi.*; import com.intellij.psi.tree.*; import com.intellij.psi.util.*; +import com.reason.*; import com.reason.ide.files.*; import com.reason.lang.core.psi.PsiAnnotation; import com.reason.lang.core.psi.*; @@ -43,7 +44,11 @@ public static String fileNameToModuleName(@NotNull String filename) { public static PsiElement prevSibling(@NotNull PsiElement element) { // previous sibling without considering whitespace PsiElement prevSibling = element.getPrevSibling(); - while (prevSibling != null && prevSibling.getNode().getElementType() == TokenType.WHITE_SPACE) { + while (prevSibling != null) { + ASTNode prevNode = prevSibling.getNode(); + if (prevNode == null || prevNode.getElementType() != TokenType.WHITE_SPACE) { + break; + } prevSibling = prevSibling.getPrevSibling(); } return prevSibling; @@ -278,19 +283,16 @@ public static T findImmediateFirstChildOfClass(@Nullable return null; } - @NotNull - public static String getQualifiedPath(@NotNull PsiNamedElement element) { + public static @Nullable String[] getQualifiedPath(@NotNull PsiElement element) { String path = ""; PsiElement parent = element.getParent(); while (parent != null) { - if (parent instanceof PsiQualifiedElement) { - if (parent instanceof PsiNameIdentifierOwner - && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { - return ((PsiQualifiedElement) parent).getPath(); + if (parent instanceof PsiQualifiedPathElement) { + if (parent instanceof PsiNameIdentifierOwner && ((PsiNameIdentifierOwner) parent).getNameIdentifier() == element) { + return ((PsiQualifiedPathElement) parent).getPath(); } - return ((PsiQualifiedElement) parent).getQualifiedName() - + (path.isEmpty() ? "" : "." + path); + return (((PsiQualifiedNamedElement) parent).getQualifiedName() + (path.isEmpty() ? "" : "." + path)).split("\\."); } else { if (parent instanceof PsiNameIdentifierOwner) { String parentName = ((PsiNamedElement) parent).getName(); @@ -304,16 +306,16 @@ public static String getQualifiedPath(@NotNull PsiNamedElement element) { try { PsiFile containingFile = element.getContainingFile(); // Fail in 2019.2... ? - return ((FileBase) containingFile).getModuleName() + (path.isEmpty() ? "" : "." + path); + return (((FileBase) containingFile).getModuleName() + (path.isEmpty() ? "" : "." + path)).split("\\."); } catch (PsiInvalidElementAccessException e) { - return path; + return path.split("\\."); } } @NotNull public static String getQualifiedName(@NotNull PsiNamedElement element) { String name = element.getName(); - String qualifiedPath = getQualifiedPath(element); + String qualifiedPath = Joiner.join(".", getQualifiedPath(element)); return name == null ? qualifiedPath + ".UNKNOWN" : qualifiedPath + "." + name; } @@ -331,16 +333,11 @@ public static String computeAlias(@Nullable PsiElement rootElement, @NotNull Lan PsiElement currentElement = rootElement; ORTypes types = getTypes(language); StringBuilder aliasName = new StringBuilder(); - IElementType elementType = - currentElement == null ? null : currentElement.getNode().getElementType(); + IElementType elementType = currentElement == null ? null : currentElement.getNode().getElementType(); while (elementType != null && elementType != types.SEMI) { - if (elementType != TokenType.WHITE_SPACE - && elementType != types.C_UPPER_SYMBOL - && elementType != types.DOT) { + if (elementType != TokenType.WHITE_SPACE && elementType != types.C_UPPER_SYMBOL && elementType != types.DOT) { // if last term is lower symbol, and we accept lower symbol, then it's an alias - if (elementType != types.C_LOWER_SYMBOL - || currentElement.getNextSibling() != null - || !lowerAccepted) { + if (elementType != types.C_LOWER_SYMBOL || currentElement.getNextSibling() != null || !lowerAccepted) { isALias = false; break; } @@ -356,4 +353,21 @@ public static String computeAlias(@Nullable PsiElement rootElement, @NotNull Lan return isALias ? aliasName.toString() : null; } + + public static String[] getQualifiedNameAsPath(PsiQualifiedPathElement element) { + String[] path = element.getPath(); + if (path == null) { + return null; + } + + String name = element.getName(); + if (name == null) { + return path; + } + + String[] qpath = new String[path.length + 1]; + System.arraycopy(path, 0, qpath, 0, path.length); + qpath[qpath.length - 1] = name; + return qpath; + } } diff --git a/src/com/reason/lang/core/psi/PsiClass.java b/src/com/reason/lang/core/psi/PsiClass.java index cc8904a77..cd7b65418 100644 --- a/src/com/reason/lang/core/psi/PsiClass.java +++ b/src/com/reason/lang/core/psi/PsiClass.java @@ -1,28 +1,24 @@ package com.reason.lang.core.psi; -import com.intellij.psi.NavigatablePsiElement; -import com.intellij.psi.PsiElement; -import com.reason.lang.core.psi.impl.PsiClassConstructor; -import com.reason.lang.core.psi.impl.PsiClassField; -import com.reason.lang.core.psi.impl.PsiClassMethod; -import com.reason.lang.core.psi.impl.PsiClassParameters; +import com.intellij.psi.*; +import com.reason.lang.core.psi.impl.*; +import org.jetbrains.annotations.*; + import java.util.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public interface PsiClass extends PsiQualifiedElement, NavigatablePsiElement, PsiStructuredElement { - @Nullable - PsiElement getClassBody(); +public interface PsiClass extends PsiQualifiedPathElement, NavigatablePsiElement, PsiStructuredElement { + @Nullable + PsiElement getClassBody(); - @NotNull - Collection getFields(); + @NotNull + Collection getFields(); - @NotNull - Collection getMethods(); + @NotNull + Collection getMethods(); - @NotNull - Collection getParameters(); + @NotNull + Collection getParameters(); - @Nullable - PsiClassConstructor getConstructor(); + @Nullable + PsiClassConstructor getConstructor(); } diff --git a/src/com/reason/lang/core/psi/PsiException.java b/src/com/reason/lang/core/psi/PsiException.java index be4d1b997..21222a636 100644 --- a/src/com/reason/lang/core/psi/PsiException.java +++ b/src/com/reason/lang/core/psi/PsiException.java @@ -1,15 +1,10 @@ package com.reason.lang.core.psi; -import com.intellij.psi.NavigatablePsiElement; -import com.intellij.psi.StubBasedPsiElement; -import com.reason.lang.core.stub.PsiExceptionStub; -import org.jetbrains.annotations.Nullable; +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; +import org.jetbrains.annotations.*; -public interface PsiException - extends NavigatablePsiElement, - PsiStructuredElement, - PsiQualifiedElement, - StubBasedPsiElement { - @Nullable - String getAlias(); +public interface PsiException extends NavigatablePsiElement, PsiStructuredElement, PsiNameIdentifierOwner, PsiQualifiedPathElement, StubBasedPsiElement { + @Nullable + String getAlias(); } diff --git a/src/com/reason/lang/core/psi/PsiExternal.java b/src/com/reason/lang/core/psi/PsiExternal.java index 7e8cf3b0e..36ac233c6 100644 --- a/src/com/reason/lang/core/psi/PsiExternal.java +++ b/src/com/reason/lang/core/psi/PsiExternal.java @@ -1,12 +1,12 @@ package com.reason.lang.core.psi; -import com.intellij.psi.StubBasedPsiElement; -import com.reason.lang.core.stub.PsiExternalStub; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; +import org.jetbrains.annotations.*; -public interface PsiExternal extends PsiQualifiedElement, PsiSignatureElement, PsiStructuredElement, StubBasedPsiElement { - boolean isFunction(); +public interface PsiExternal extends PsiQualifiedPathElement, PsiSignatureElement, PsiStructuredElement, StubBasedPsiElement { + boolean isFunction(); - @NotNull - String getExternalName(); + @NotNull + String getExternalName(); } diff --git a/src/com/reason/lang/core/psi/PsiInclude.java b/src/com/reason/lang/core/psi/PsiInclude.java index 52b63139c..219c5c8f6 100644 --- a/src/com/reason/lang/core/psi/PsiInclude.java +++ b/src/com/reason/lang/core/psi/PsiInclude.java @@ -1,7 +1,17 @@ package com.reason.lang.core.psi; -public interface PsiInclude extends PsiStructuredElement { - String getPath(); +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; +import org.jetbrains.annotations.*; + +public interface PsiInclude extends PsiStructuredElement, StubBasedPsiElement { + String[] getQualifiedPath(); + + @Nullable String[] getResolvedPath(); + + String getIncludePath(); + + @Nullable PsiModule getModule(); boolean useFunctor(); } diff --git a/src/com/reason/lang/core/psi/PsiInnerModule.java b/src/com/reason/lang/core/psi/PsiInnerModule.java index 78599c7b6..b724b36ef 100644 --- a/src/com/reason/lang/core/psi/PsiInnerModule.java +++ b/src/com/reason/lang/core/psi/PsiInnerModule.java @@ -1,19 +1,20 @@ package com.reason.lang.core.psi; -import com.intellij.psi.PsiElement; -import com.intellij.psi.StubBasedPsiElement; -import com.reason.lang.core.psi.impl.PsiModuleType; -import com.reason.lang.core.stub.PsiModuleStub; -import org.jetbrains.annotations.Nullable; +import com.intellij.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import org.jetbrains.annotations.*; public interface PsiInnerModule extends PsiModule, StubBasedPsiElement { - @Nullable - PsiModuleType getModuleType(); - - @Nullable - PsiElement getBody(); - boolean isComponent(); boolean isModuleType(); + + boolean isFunctorCall(); + + @Nullable + PsiModuleType getModuleType(); + + @Nullable + PsiElement getBody(); } diff --git a/src/com/reason/lang/core/psi/PsiLet.java b/src/com/reason/lang/core/psi/PsiLet.java index 35cdb59cb..c55da1a7f 100644 --- a/src/com/reason/lang/core/psi/PsiLet.java +++ b/src/com/reason/lang/core/psi/PsiLet.java @@ -6,7 +6,7 @@ import java.util.*; -public interface PsiLet extends PsiVar, PsiSignatureElement, PsiInferredType, PsiQualifiedElement, NavigatablePsiElement, PsiStructuredElement, StubBasedPsiElement { +public interface PsiLet extends PsiVar, PsiSignatureElement, PsiInferredType, PsiQualifiedPathElement, NavigatablePsiElement, PsiStructuredElement, StubBasedPsiElement { @Nullable PsiLetBinding getBinding(); @@ -28,10 +28,7 @@ public interface PsiLet extends PsiVar, PsiSignatureElement, PsiInferredType, Ps @NotNull Collection getScopeChildren(); - @NotNull - String getPath(); - - boolean isDeconsruction(); + boolean isDeconstruction(); @NotNull List getDeconstructedElements(); diff --git a/src/com/reason/lang/core/psi/PsiModule.java b/src/com/reason/lang/core/psi/PsiModule.java index d0f93673e..af2e487cd 100644 --- a/src/com/reason/lang/core/psi/PsiModule.java +++ b/src/com/reason/lang/core/psi/PsiModule.java @@ -10,8 +10,7 @@ /** * Common interface to file-based modules and inner modules */ -public interface PsiModule - extends PsiQualifiedElement, NavigatablePsiElement, PsiStructuredElement { +public interface PsiModule extends PsiQualifiedPathElement, NavigatablePsiElement, PsiStructuredElement { boolean isInterface(); @@ -23,6 +22,9 @@ public interface PsiModule @Nullable String getModuleName(); + @Nullable + String[] getQualifiedNameAsPath(); + @Nullable PsiFunctorCall getFunctorCall(); diff --git a/src/com/reason/lang/core/psi/PsiOpen.java b/src/com/reason/lang/core/psi/PsiOpen.java index ea2208373..000f0deb8 100644 --- a/src/com/reason/lang/core/psi/PsiOpen.java +++ b/src/com/reason/lang/core/psi/PsiOpen.java @@ -1,6 +1,9 @@ package com.reason.lang.core.psi; -public interface PsiOpen extends PsiStructuredElement { +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; + +public interface PsiOpen extends PsiStructuredElement, StubBasedPsiElement { String getPath(); boolean useFunctor(); diff --git a/src/com/reason/lang/core/psi/PsiParameter.java b/src/com/reason/lang/core/psi/PsiParameter.java index 778b4e012..4fc8a53e0 100644 --- a/src/com/reason/lang/core/psi/PsiParameter.java +++ b/src/com/reason/lang/core/psi/PsiParameter.java @@ -4,7 +4,7 @@ import com.reason.lang.core.stub.*; import org.jetbrains.annotations.*; -public interface PsiParameter extends PsiNameIdentifierOwner, PsiQualifiedElement, PsiSignatureElement, StubBasedPsiElement { +public interface PsiParameter extends PsiNameIdentifierOwner, PsiQualifiedPathElement, PsiSignatureElement, StubBasedPsiElement { @Nullable PsiDefaultValue getDefaultValue(); diff --git a/src/com/reason/lang/core/psi/PsiQualifiedPathElement.java b/src/com/reason/lang/core/psi/PsiQualifiedPathElement.java new file mode 100644 index 000000000..1f0b9dd10 --- /dev/null +++ b/src/com/reason/lang/core/psi/PsiQualifiedPathElement.java @@ -0,0 +1,12 @@ +package com.reason.lang.core.psi; + +import com.intellij.psi.*; +import org.jetbrains.annotations.*; + +/** + * A {@link PsiQualifiedNamedElement} with an extra access to the element path as array of strings. + */ +public interface PsiQualifiedPathElement extends PsiQualifiedNamedElement { + @Nullable + String[] getPath(); +} diff --git a/src/com/reason/lang/core/psi/PsiRecordField.java b/src/com/reason/lang/core/psi/PsiRecordField.java index c92983f2b..4423a5df6 100644 --- a/src/com/reason/lang/core/psi/PsiRecordField.java +++ b/src/com/reason/lang/core/psi/PsiRecordField.java @@ -1,13 +1,7 @@ package com.reason.lang.core.psi; -import com.intellij.psi.NavigatablePsiElement; -import com.intellij.psi.PsiNameIdentifierOwner; -import com.intellij.psi.StubBasedPsiElement; -import com.reason.lang.core.stub.PsiRecordFieldStub; +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; -public interface PsiRecordField - extends PsiNameIdentifierOwner, - PsiQualifiedElement, - NavigatablePsiElement, - PsiSignatureElement, - StubBasedPsiElement {} +public interface PsiRecordField extends PsiNameIdentifierOwner, PsiQualifiedPathElement, NavigatablePsiElement, PsiSignatureElement, StubBasedPsiElement { +} diff --git a/src/com/reason/lang/core/psi/PsiType.java b/src/com/reason/lang/core/psi/PsiType.java index de225fff7..daa767991 100644 --- a/src/com/reason/lang/core/psi/PsiType.java +++ b/src/com/reason/lang/core/psi/PsiType.java @@ -1,21 +1,21 @@ package com.reason.lang.core.psi; -import com.intellij.psi.NavigatablePsiElement; -import com.intellij.psi.PsiElement; -import com.intellij.psi.StubBasedPsiElement; -import com.reason.lang.core.stub.PsiTypeStub; +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; +import org.jetbrains.annotations.*; + import java.util.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -public interface PsiType extends PsiQualifiedElement, NavigatablePsiElement, PsiStructuredElement, StubBasedPsiElement { - @Nullable - PsiElement getBinding(); +public interface PsiType extends PsiNameIdentifierOwner, PsiQualifiedPathElement, NavigatablePsiElement, PsiStructuredElement, StubBasedPsiElement { + @Nullable + PsiElement getBinding(); + + @NotNull + Collection getVariants(); - @NotNull - Collection getVariants(); + boolean isJsObject(); - boolean isJsObject(); + boolean isRecord(); - boolean isAbstract(); + boolean isAbstract(); } diff --git a/src/com/reason/lang/core/psi/PsiVal.java b/src/com/reason/lang/core/psi/PsiVal.java index 66cc8aba2..0a82b0f58 100644 --- a/src/com/reason/lang/core/psi/PsiVal.java +++ b/src/com/reason/lang/core/psi/PsiVal.java @@ -1,13 +1,7 @@ package com.reason.lang.core.psi; -import com.intellij.psi.NavigatablePsiElement; -import com.intellij.psi.StubBasedPsiElement; -import com.reason.lang.core.stub.PsiValStub; +import com.intellij.psi.*; +import com.reason.lang.core.stub.*; -public interface PsiVal - extends PsiVar, - PsiQualifiedElement, - PsiSignatureElement, - NavigatablePsiElement, - PsiStructuredElement, - StubBasedPsiElement {} +public interface PsiVal extends PsiVar, PsiQualifiedPathElement, PsiSignatureElement, NavigatablePsiElement, PsiStructuredElement, StubBasedPsiElement { +} diff --git a/src/com/reason/lang/core/psi/PsiVariantDeclaration.java b/src/com/reason/lang/core/psi/PsiVariantDeclaration.java index cb7d8d2e9..fb957b039 100644 --- a/src/com/reason/lang/core/psi/PsiVariantDeclaration.java +++ b/src/com/reason/lang/core/psi/PsiVariantDeclaration.java @@ -14,7 +14,7 @@ import static java.util.Collections.*; -public class PsiVariantDeclaration extends PsiTokenStub implements PsiQualifiedElement, StubBasedPsiElement { +public class PsiVariantDeclaration extends PsiTokenStub implements PsiQualifiedPathElement, StubBasedPsiElement { // region Constructors public PsiVariantDeclaration(@NotNull ORTypes types, @NotNull ASTNode node) { super(types, node); @@ -25,8 +25,14 @@ public PsiVariantDeclaration(@NotNull ORTypes types, @NotNull PsiVariantDeclarat } // endregion + //region PsiNamedElement @Override public String getName() { + PsiVariantDeclarationStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + PsiElement nameIdentifier = getFirstChild(); return nameIdentifier == null ? "" : nameIdentifier.getText(); } @@ -35,16 +41,11 @@ public String getName() { public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { return this; } + //endregion + //region PsiQualifiedName @Override - public @NotNull PsiElement getNavigationElement() { - PsiUpperIdentifier id = ORUtil.findImmediateFirstChildOfClass(this, PsiUpperIdentifier.class); - return id == null ? this : id; - } - - @NotNull - @Override - public String getPath() { + public @NotNull String[] getPath() { PsiVariantDeclarationStub stub = getGreenStub(); if (stub != null) { return stub.getPath(); @@ -53,9 +54,8 @@ public String getPath() { return ORUtil.getQualifiedPath(this); } - @NotNull @Override - public String getQualifiedName() { + public @NotNull String getQualifiedName() { PsiVariantDeclarationStub stub = getGreenStub(); if (stub != null) { return stub.getQualifiedName(); @@ -63,6 +63,13 @@ public String getQualifiedName() { return ORUtil.getQualifiedName(this); } + //endregion + + @Override + public @NotNull PsiElement getNavigationElement() { + PsiUpperIdentifier id = ORUtil.findImmediateFirstChildOfClass(this, PsiUpperIdentifier.class); + return id == null ? this : id; + } @Nullable public PsiNameIdentifierOwner getVariant() { diff --git a/src/com/reason/lang/core/psi/impl/ORASTFactory.java b/src/com/reason/lang/core/psi/impl/ORASTFactory.java index 436248c9b..f8186bec8 100644 --- a/src/com/reason/lang/core/psi/impl/ORASTFactory.java +++ b/src/com/reason/lang/core/psi/impl/ORASTFactory.java @@ -120,12 +120,6 @@ public ORASTFactory(T types) { if (type == m_types.C_IF) { return new PsiIfStatement(m_types, type); } - if (type == m_types.C_OPEN) { - return new PsiOpenImpl(m_types, type); - } - if (type == m_types.C_INCLUDE) { - return new PsiIncludeImpl(m_types, type); - } if (type == m_types.C_OBJECT) { return new PsiObject(type); } diff --git a/src/com/reason/lang/core/psi/impl/PsiClassImpl.java b/src/com/reason/lang/core/psi/impl/PsiClassImpl.java index 2173c1b64..93e6121fb 100644 --- a/src/com/reason/lang/core/psi/impl/PsiClassImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiClassImpl.java @@ -1,116 +1,105 @@ package com.reason.lang.core.psi.impl; -import com.intellij.navigation.ItemPresentation; -import com.intellij.psi.PsiElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.IncorrectOperationException; -import com.reason.lang.core.CompositeTypePsiElement; -import com.reason.lang.core.ORUtil; -import com.reason.lang.core.psi.*; -import com.reason.lang.core.type.ORTypes; -import icons.ORIcons; -import java.util.Collection; +import com.intellij.navigation.*; +import com.intellij.psi.*; +import com.intellij.psi.tree.*; +import com.intellij.psi.util.*; +import com.intellij.util.*; +import com.reason.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.PsiClass; +import com.reason.lang.core.type.*; +import icons.*; +import org.jetbrains.annotations.*; + import javax.swing.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import java.util.*; public class PsiClassImpl extends CompositeTypePsiElement implements PsiClass { - - // region Constructors - protected PsiClassImpl(@NotNull ORTypes types, @NotNull IElementType elementType) { - super(types, elementType); - } - // endregion - - // region NamedElement - @Nullable - public PsiElement getNameIdentifier() { - return findChildByClass(PsiLowerIdentifier.class); - } - - @Nullable - @Override - public String getName() { - PsiElement nameIdentifier = getNameIdentifier(); - return nameIdentifier == null ? "" : nameIdentifier.getText(); - } - - @NotNull - @Override - public PsiElement setName(@NotNull String name) throws IncorrectOperationException { - return this; - } - // endregion - - @NotNull - @Override - public String getPath() { - return ORUtil.getQualifiedPath(this); - } - - @NotNull - @Override - public String getQualifiedName() { - String name = getName(); - return name == null ? "" : name; - } - - @Nullable - @Override - public PsiElement getClassBody() { - return PsiTreeUtil.findChildOfType(this, PsiObject.class); - } - - @NotNull - @Override - public Collection getFields() { - return PsiTreeUtil.findChildrenOfType(getClassBody(), PsiClassField.class); - } - - @NotNull - @Override - public Collection getMethods() { - return PsiTreeUtil.findChildrenOfType(getClassBody(), PsiClassMethod.class); - } - - @NotNull - @Override - public Collection getParameters() { - return PsiTreeUtil.findChildrenOfType(this, PsiClassParameters.class); - } - - @Nullable - @Override - public PsiClassConstructor getConstructor() { - return findChildByClass(PsiClassConstructor.class); - } - - public ItemPresentation getPresentation() { - return new ItemPresentation() { - @Nullable - @Override - public String getPresentableText() { - return getName(); - } - - @Nullable - @Override - public String getLocationString() { - return null; - } - - @NotNull - @Override - public Icon getIcon(boolean unused) { - return ORIcons.CLASS; - } - }; - } - - @Nullable - @Override - public String toString() { - return "Class " + getQualifiedName(); - } + // region Constructors + protected PsiClassImpl(@NotNull ORTypes types, @NotNull IElementType elementType) { + super(types, elementType); + } + // endregion + + // region PsiNamedElement + public @Nullable PsiElement getNameIdentifier() { + return findChildByClass(PsiLowerIdentifier.class); + } + + @Override + public @Nullable String getName() { + PsiElement nameIdentifier = getNameIdentifier(); + return nameIdentifier == null ? "" : nameIdentifier.getText(); + } + + @Override + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return this; + } + // endregion + + + //region PsiQualifiedName + @Override + public @Nullable String[] getPath() { // zzz stub + return ORUtil.getQualifiedPath(this); + } + + @Override + public @NotNull String getQualifiedName() { + String[] path = getPath(); + String name = getName(); + return name == null ? "" : Joiner.join(".", path) + "." + name; + } + //endregion + + @Override + public @Nullable PsiElement getClassBody() { + return PsiTreeUtil.findChildOfType(this, PsiObject.class); + } + + @Override + public @NotNull Collection getFields() { + return PsiTreeUtil.findChildrenOfType(getClassBody(), PsiClassField.class); + } + + @Override + public @NotNull Collection getMethods() { + return PsiTreeUtil.findChildrenOfType(getClassBody(), PsiClassMethod.class); + } + + @Override + public @NotNull Collection getParameters() { + return PsiTreeUtil.findChildrenOfType(this, PsiClassParameters.class); + } + + @Override + public @Nullable PsiClassConstructor getConstructor() { + return findChildByClass(PsiClassConstructor.class); + } + + public ItemPresentation getPresentation() { + return new ItemPresentation() { + @Override + public @Nullable String getPresentableText() { + return getName(); + } + + @Override + public @Nullable String getLocationString() { + return null; + } + + @Override + public @NotNull Icon getIcon(boolean unused) { + return ORIcons.CLASS; + } + }; + } + + @Override + public @Nullable String toString() { + return "Class " + getQualifiedName(); + } } diff --git a/src/com/reason/lang/core/psi/impl/PsiExceptionImpl.java b/src/com/reason/lang/core/psi/impl/PsiExceptionImpl.java index c246ddf32..c0913fe46 100644 --- a/src/com/reason/lang/core/psi/impl/PsiExceptionImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiExceptionImpl.java @@ -1,21 +1,19 @@ package com.reason.lang.core.psi.impl; -import com.intellij.lang.ASTNode; -import com.intellij.navigation.ItemPresentation; -import com.intellij.psi.PsiElement; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.util.IncorrectOperationException; -import com.reason.lang.core.ORUtil; -import com.reason.lang.core.psi.PsiException; -import com.reason.lang.core.stub.PsiExceptionStub; -import com.reason.lang.core.type.ORTypes; -import icons.ORIcons; +import com.intellij.lang.*; +import com.intellij.navigation.*; +import com.intellij.psi.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import icons.*; +import org.jetbrains.annotations.*; import javax.swing.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; - public class PsiExceptionImpl extends PsiTokenStub implements PsiException { // region Constructors public PsiExceptionImpl(@NotNull ORTypes types, @NotNull ASTNode node) { @@ -27,19 +25,31 @@ public PsiExceptionImpl(@NotNull ORTypes types, @NotNull PsiExceptionStub stub, } // endregion + //region PsiNamedElement + @Override public @Nullable PsiElement getNameIdentifier() { + return ORUtil.findImmediateFirstChildOfClass(this, PsiUpperIdentifier.class); + } + @Override public @Nullable String getName() { - PsiElement nameIdentifier = ORUtil.findImmediateFirstChildOfClass(this, PsiUpperIdentifier.class); + PsiExceptionStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + + PsiElement nameIdentifier = getNameIdentifier(); return nameIdentifier == null ? null : nameIdentifier.getText(); } @Override public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { - throw new IncorrectOperationException("Not implemented"); + return this; } + //endregion + //region PsiQualifiedPathName @Override - public @NotNull String getPath() { + public @Nullable String[] getPath() { PsiExceptionStub stub = getGreenStub(); if (stub != null) { return stub.getPath(); @@ -57,15 +67,17 @@ public PsiExceptionImpl(@NotNull ORTypes types, @NotNull PsiExceptionStub stub, return ORUtil.getQualifiedName(this); } + //endregion @Override public @Nullable String getAlias() { - PsiElement eq = findChildByType(m_types.EQ); - if (eq != null) { - return ORUtil.computeAlias(eq.getNextSibling(), getLanguage(), false); + PsiExceptionStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); } - return null; + PsiElement eq = findChildByType(m_types.EQ); + return eq == null ? null : ORUtil.computeAlias(eq.getNextSibling(), getLanguage(), false); } @Override @@ -89,7 +101,7 @@ public ItemPresentation getPresentation() { } @Override - public @Nullable String toString() { + public @NotNull String toString() { return "Exception " + getName(); } } diff --git a/src/com/reason/lang/core/psi/impl/PsiExternalImpl.java b/src/com/reason/lang/core/psi/impl/PsiExternalImpl.java index 8064451d3..9eaefee3a 100644 --- a/src/com/reason/lang/core/psi/impl/PsiExternalImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiExternalImpl.java @@ -37,52 +37,55 @@ public PsiExternalImpl(@NotNull ORTypes types, @NotNull PsiExternalStub stub, @N return findChildByClass(PsiLowerIdentifier.class); } - @NotNull @Override - public String getPath() { + public String getName() { PsiExternalStub stub = getGreenStub(); if (stub != null) { - return stub.getPath(); + return stub.getName(); } - return ORUtil.getQualifiedPath(this); + PsiElement nameIdentifier = getNameIdentifier(); + if (nameIdentifier == null) { + return "unknown"; + } + + return nameIdentifier.getText(); + } + + @Override + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return this; } + // endregion - @NotNull + //region PsiQualifiedName @Override - public String getQualifiedName() { + public @NotNull String[] getPath() { PsiExternalStub stub = getGreenStub(); if (stub != null) { - return stub.getQualifiedName(); + return stub.getPath(); } - return ORUtil.getQualifiedName(this); + return ORUtil.getQualifiedPath(this); } @Override - public String getName() { - PsiElement nameIdentifier = getNameIdentifier(); - if (nameIdentifier == null) { - return "unknown"; + public @NotNull String getQualifiedName() { + PsiExternalStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); } - return nameIdentifier.getText(); - } - - @NotNull - @Override - public PsiElement setName(@NotNull String name) throws IncorrectOperationException { - return this; + return ORUtil.getQualifiedName(this); } - // endregion + //endregion @Override public @Nullable PsiSignature getSignature() { return findChildByClass(PsiSignature.class); } - @NotNull - private String getRealName() { + private @NotNull String getRealName() { PsiElement name = findChildByType(m_types.STRING_VALUE); return name == null ? "" : name.getText(); } @@ -114,9 +117,8 @@ public boolean isFunction() { @Override public ItemPresentation getPresentation() { return new ItemPresentation() { - @Nullable @Override - public String getPresentableText() { + public @Nullable String getPresentableText() { String aliasName = getName(); String realName = getRealName(); @@ -143,9 +145,8 @@ public Icon getIcon(boolean unused) { }; } - @Nullable @Override - public String toString() { + public @Nullable String toString() { return "external " + getQualifiedName(); } } diff --git a/src/com/reason/lang/core/psi/impl/PsiFakeModule.java b/src/com/reason/lang/core/psi/impl/PsiFakeModule.java index fe86bb12b..3024eee74 100644 --- a/src/com/reason/lang/core/psi/impl/PsiFakeModule.java +++ b/src/com/reason/lang/core/psi/impl/PsiFakeModule.java @@ -29,14 +29,42 @@ public PsiFakeModule(@NotNull ORTypes types, @NotNull PsiModuleStub stub, @NotNu // endregion @Override - public @NotNull String getPath() { + public @NotNull String getModuleName() { PsiFile file = getContainingFile(); - return file instanceof FileBase ? ((FileBase) file).getModuleName() : ""; + assert file instanceof FileBase; + return ((FileBase) file).getModuleName(); + } + + //region PsiNamedElement + @Override + public @Nullable String getName() { + PsiModuleStub greenStub = getGreenStub(); + if (greenStub != null) { + return greenStub.getName(); + } + + return getModuleName(); } - @NotNull @Override - public String getQualifiedName() { + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + throw new RuntimeException("Not implemented, use FileBase"); + } + //endregion + + //region PsiQualifiedPath + @Override + public @Nullable String[] getPath() { + PsiModuleStub greenStub = getGreenStub(); + if (greenStub != null) { + return greenStub.getPath(); + } + + return null; + } + + @Override + public @NotNull String getQualifiedName() { PsiModuleStub greenStub = getGreenStub(); if (greenStub != null) { String name = greenStub.getName(); @@ -46,6 +74,11 @@ public String getQualifiedName() { // ?? Namespace ?? return getModuleName(); } + //endregion + + @Override public @Nullable String[] getQualifiedNameAsPath() { + return ORUtil.getQualifiedNameAsPath(this); + } @Override public void navigate(boolean requestFocus) { @@ -62,9 +95,8 @@ public boolean isInterface() { return ((FileBase) getContainingFile()).isInterface(); } - @Nullable @Override - public PsiFunctorCall getFunctorCall() { + public @Nullable PsiFunctorCall getFunctorCall() { return null; } @@ -76,31 +108,11 @@ public boolean isComponent() { return ((FileBase) getContainingFile()).isComponent(); } - @Nullable @Override - public String getAlias() { + public @Nullable String getAlias() { return null; } - @Override - @Nullable - public String getName() { - return getModuleName(); - } - - @NotNull - @Override - public String getModuleName() { - PsiFile file = getContainingFile(); - assert file instanceof FileBase; - return ((FileBase) file).getModuleName(); - } - - @Override - public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { - throw new RuntimeException("Not implemented, use FileBase"); - } - @Override public @NotNull Collection getExpressions(@NotNull ExpressionScope eScope, @Nullable ExpressionFilter filter) { return PsiFileHelper.getExpressions(getContainingFile(), eScope, filter); @@ -123,30 +135,27 @@ public String getModuleName() { return null; } - @Nullable @Override - public PsiLet getLetExpression(@Nullable String name) { + public @Nullable PsiLet getLetExpression(@Nullable String name) { Collection expressions = getExpressions(name, PsiLet.class); return expressions.isEmpty() ? null : expressions.iterator().next(); } - @Nullable @Override - public PsiVal getValExpression(@Nullable String name) { + public @Nullable PsiVal getValExpression(@Nullable String name) { Collection expressions = getExpressions(name, PsiVal.class); return expressions.isEmpty() ? null : expressions.iterator().next(); } - @Nullable + @Override - public PsiType getTypeExpression(@Nullable String name) { + public @Nullable PsiType getTypeExpression(@Nullable String name) { List expressions = getExpressions(name, PsiType.class); return expressions.isEmpty() ? null : expressions.iterator().next(); } @NotNull - private List getExpressions( - @Nullable String name, @NotNull Class clazz) { + private List getExpressions(@Nullable String name, @NotNull Class clazz) { List result = new ArrayList<>(); if (name != null) { @@ -161,8 +170,7 @@ private List getExpressions( return result; } - @Nullable - public ItemPresentation getPresentation() { + public @Nullable ItemPresentation getPresentation() { // FileBase presentation should be used return null; } diff --git a/src/com/reason/lang/core/psi/impl/PsiFunctorCall.java b/src/com/reason/lang/core/psi/impl/PsiFunctorCall.java index db00e8a37..878f40a9b 100644 --- a/src/com/reason/lang/core/psi/impl/PsiFunctorCall.java +++ b/src/com/reason/lang/core/psi/impl/PsiFunctorCall.java @@ -1,33 +1,40 @@ package com.reason.lang.core.psi.impl; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.lang.core.CompositeTypePsiElement; -import com.reason.lang.core.psi.PsiParameters; -import com.reason.lang.core.type.ORTypes; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.tree.*; +import com.intellij.psi.util.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +import static java.util.Collections.emptyList; public class PsiFunctorCall extends CompositeTypePsiElement { + protected PsiFunctorCall(@NotNull ORTypes types, @NotNull IElementType elementType) { + super(types, elementType); + } - protected PsiFunctorCall(@NotNull ORTypes types, @NotNull IElementType elementType) { - super(types, elementType); - } + @NotNull + public String getFunctorName() { + String text = getText(); - @NotNull - public String getFunctorName() { - String text = getText(); + PsiParameters params = PsiTreeUtil.findChildOfType(this, PsiParameters.class); + if (params == null) { + return text; + } - PsiParameters params = PsiTreeUtil.findChildOfType(this, PsiParameters.class); - if (params == null) { - return text; + return text.substring(0, params.getTextOffset() - getTextOffset()); } - return text.substring(0, params.getTextOffset() - getTextOffset()); - } + public @NotNull Collection getParameters() { + PsiParameters params = PsiTreeUtil.findChildOfType(this, PsiParameters.class); + return params == null ? emptyList() : params.getParametersList(); + } - @NotNull - @Override - public String toString() { - return "Functor call"; - } + @Override + public @NotNull String toString() { + return "Functor call"; + } } diff --git a/src/com/reason/lang/core/psi/impl/PsiFunctorImpl.java b/src/com/reason/lang/core/psi/impl/PsiFunctorImpl.java index 8e492ce84..57d2d84e9 100644 --- a/src/com/reason/lang/core/psi/impl/PsiFunctorImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiFunctorImpl.java @@ -29,29 +29,59 @@ public PsiFunctorImpl(@NotNull ORTypes types, @NotNull ASTNode node) { super(types, node); } - public PsiFunctorImpl( - @NotNull ORTypes types, @NotNull PsiModuleStub stub, @NotNull IStubElementType nodeType) { + public PsiFunctorImpl(@NotNull ORTypes types, @NotNull PsiModuleStub stub, @NotNull IStubElementType nodeType) { super(types, stub, nodeType); } // endregion - // region NamedElement + // region PsiNamedElement + @Override + public @Nullable PsiElement getNameIdentifier() { + return ORUtil.findImmediateFirstChildOfClass(this, PsiUpperIdentifier.class); + } + @Override public @Nullable String getName() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + PsiElement nameIdentifier = getNameIdentifier(); return nameIdentifier == null ? null : nameIdentifier.getText(); } @Override - public @Nullable PsiElement getNameIdentifier() { - return ORUtil.findImmediateFirstChildOfClass(this, PsiUpperIdentifier.class); + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return this; } + // endregion + //region PsiQualifiedName @Override - public @Nullable PsiElement setName(@NotNull String name) throws IncorrectOperationException { - return null; + public @Nullable String[] getPath() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getPath(); + } + + return ORUtil.getQualifiedPath(this); + } + + @Override + public @NotNull String getQualifiedName() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); + } + + return ORUtil.getQualifiedName(this); + } + //endregion + + @Override public @Nullable String[] getQualifiedNameAsPath() { + return ORUtil.getQualifiedNameAsPath(this); } - // endregion @Override public boolean isInterface() { @@ -63,9 +93,8 @@ public boolean isComponent() { return false; } - @Nullable @Override - public String getAlias() { + public @Nullable String getAlias() { return null; } @@ -80,26 +109,6 @@ public String getAlias() { return null; } - @Override - public @NotNull String getPath() { - PsiModuleStub stub = getGreenStub(); - if (stub != null) { - return stub.getPath(); - } - - return ORUtil.getQualifiedPath(this); - } - - @Override - public @NotNull String getQualifiedName() { - PsiModuleStub stub = getGreenStub(); - if (stub != null) { - return stub.getQualifiedName(); - } - - return ORUtil.getQualifiedName(this); - } - @Override public @NotNull Collection getExpressions(@NotNull ExpressionScope eScope, @Nullable ExpressionFilter filter) { Collection result = emptyList(); diff --git a/src/com/reason/lang/core/psi/impl/PsiIncludeImpl.java b/src/com/reason/lang/core/psi/impl/PsiIncludeImpl.java index 29a8e5d4e..c79000bbf 100644 --- a/src/com/reason/lang/core/psi/impl/PsiIncludeImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiIncludeImpl.java @@ -1,25 +1,47 @@ package com.reason.lang.core.psi.impl; +import com.intellij.lang.*; import com.intellij.navigation.*; import com.intellij.psi.*; +import com.intellij.psi.stubs.*; import com.intellij.psi.tree.*; import com.intellij.psi.util.*; import com.intellij.util.xml.model.gotosymbol.*; +import com.reason.ide.search.*; import com.reason.lang.core.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.*; import com.reason.lang.core.type.*; import icons.*; import org.jetbrains.annotations.*; -public class PsiIncludeImpl extends CompositeTypePsiElement implements PsiInclude { +public class PsiIncludeImpl extends PsiTokenStub implements PsiInclude { // region Constructors - protected PsiIncludeImpl(@NotNull ORTypes types, @NotNull IElementType elementType) { - super(types, elementType); + public PsiIncludeImpl(@NotNull ORTypes types, @NotNull ASTNode node) { + super(types, node); + } + + public PsiIncludeImpl(@NotNull ORTypes types, @NotNull PsiIncludeStub stub, @NotNull IStubElementType nodeType) { + super(types, stub, nodeType); } // endregion + @Override public String[] getQualifiedPath() { + PsiIncludeStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedPath(); + } + + return ORUtil.getQualifiedPath(this); + } + @Override - public @NotNull String getPath() { + public @NotNull String getIncludePath() { + PsiIncludeStub stub = getGreenStub(); + if (stub != null) { + return stub.getIncludePath(); + } + PsiElement firstChild = PsiTreeUtil.skipWhitespacesForward(getFirstChild()); if (firstChild instanceof PsiFunctorCall) { return ((PsiFunctorCall) firstChild).getFunctorName(); @@ -27,6 +49,44 @@ protected PsiIncludeImpl(@NotNull ORTypes types, @NotNull IElementType elementTy return firstChild == null ? "" : ORUtil.getTextUntilClass(firstChild, PsiConstraints.class); } + @Override + public @Nullable String[] getResolvedPath() { + PsiIncludeStub stub = getGreenStub(); + if (stub != null) { + return stub.getResolvedPath(); + } + + // Iterate over previous elements, can't use references here because it needs to work during indexing + String includePath = getIncludePath(); + PsiFinder psiFinder = PsiFinder.getInstance(getProject()); + PsiQualifiedPathElement resolvedElement = psiFinder.findModuleBack(this, includePath); + + String path = resolvedElement == null ? includePath : resolvedElement.getQualifiedName(); + return path == null ? null : path.split("\\."); + } + + @Nullable private PsiUpperSymbol getLatestUpperSymbol(PsiElement root) { + // Latest element in path + PsiElement sibling = ORUtil.nextSibling(root); + PsiUpperSymbol last = sibling instanceof PsiUpperSymbol ? (PsiUpperSymbol) sibling : null; + while (sibling != null) { + IElementType elementType = sibling.getNode().getElementType(); + if (elementType == m_types.DOT || elementType == m_types.C_UPPER_SYMBOL) { + sibling = sibling.getNextSibling(); + if (sibling instanceof PsiUpperSymbol) { + last = (PsiUpperSymbol) sibling; + } + } else { + sibling = null; + } + } + return last; + } + + @Override public @Nullable PsiModule getModule() { + return null; // TODO implement method + } + @Override public boolean useFunctor() { PsiElement firstChild = PsiTreeUtil.skipWhitespacesForward(getFirstChild()); @@ -35,7 +95,7 @@ public boolean useFunctor() { @Override public ItemPresentation getPresentation() { - return new GoToSymbolProvider.BaseNavigationItem(this, getPath(), ORIcons.INCLUDE); + return new GoToSymbolProvider.BaseNavigationItem(this, getIncludePath(), ORIcons.INCLUDE); } @Override @@ -45,6 +105,6 @@ public boolean canBeDisplayed() { @Override public @NotNull String toString() { - return "PsiInclude " + getPath(); + return "PsiInclude " + getIncludePath(); } } diff --git a/src/com/reason/lang/core/psi/impl/PsiInnerModuleImpl.java b/src/com/reason/lang/core/psi/impl/PsiInnerModuleImpl.java index 323992aad..981341421 100644 --- a/src/com/reason/lang/core/psi/impl/PsiInnerModuleImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiInnerModuleImpl.java @@ -1,394 +1,407 @@ package com.reason.lang.core.psi.impl; -import static com.reason.lang.core.ORFileType.interfaceOrImplementation; -import static java.util.Collections.emptyList; - -import com.intellij.lang.ASTNode; -import com.intellij.navigation.ItemPresentation; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.PsiReference; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.util.PsiTreeUtil; -import com.intellij.util.IncorrectOperationException; -import com.reason.ide.files.FileBase; -import com.reason.ide.search.PsiFinder; -import com.reason.lang.ModuleHelper; -import com.reason.lang.QNameFinder; -import com.reason.lang.core.ExpressionFilter; -import com.reason.lang.core.ORUtil; +import com.intellij.lang.*; +import com.intellij.navigation.*; +import com.intellij.psi.*; +import com.intellij.psi.search.*; +import com.intellij.psi.stubs.*; +import com.intellij.psi.util.*; +import com.intellij.util.*; +import com.reason.ide.files.*; +import com.reason.ide.search.*; +import com.reason.lang.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.PsiType; import com.reason.lang.core.psi.*; -import com.reason.lang.core.stub.PsiModuleStub; -import com.reason.lang.core.type.ORTypes; -import icons.ORIcons; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Set; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import icons.*; +import org.jetbrains.annotations.*; + import javax.swing.*; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import java.util.*; + +import static com.reason.lang.core.ORFileType.*; +import static java.util.Collections.*; public class PsiInnerModuleImpl extends PsiTokenStub implements PsiInnerModule { - // region Constructors - public PsiInnerModuleImpl(@NotNull ORTypes types, @NotNull ASTNode node) { - super(types, node); - } - - public PsiInnerModuleImpl( - @NotNull ORTypes types, @NotNull PsiModuleStub stub, @NotNull IStubElementType nodeType) { - super(types, stub, nodeType); - } - // endregion - - // region NamedElement - @Nullable - @Override - public String getName() { - PsiElement nameIdentifier = findChildByClass(PsiUpperIdentifier.class); - return nameIdentifier == null ? null : nameIdentifier.getText(); - } - - @NotNull - @Override - public PsiElement setName(@NotNull String newName) throws IncorrectOperationException { - return this; - } - // endregion - - @NotNull - @Override - public String getModuleName() { - String name = getName(); - return name == null ? "" : name; - } - - @Override - public boolean isInterface() { - return ((FileBase) getContainingFile()).isInterface(); - } - - @Nullable - @Override - public PsiFunctorCall getFunctorCall() { - return ORUtil.findImmediateFirstChildOfClass(this, PsiFunctorCall.class); - } - - @NotNull - @Override - public String getPath() { - PsiModuleStub stub = getGreenStub(); - if (stub != null) { - return stub.getPath(); + // region Constructors + public PsiInnerModuleImpl(@NotNull ORTypes types, @NotNull ASTNode node) { + super(types, node); + } + + public PsiInnerModuleImpl(@NotNull ORTypes types, @NotNull PsiModuleStub stub, @NotNull IStubElementType nodeType) { + super(types, stub, nodeType); + } + // endregion + + // region NamedElement + private @Nullable PsiElement getNameIdentifier() { + return findChildByClass(PsiUpperIdentifier.class); + } + + @Override + public @Nullable String getName() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + + PsiElement nameIdentifier = getNameIdentifier(); + return nameIdentifier == null ? null : nameIdentifier.getText(); } - return ORUtil.getQualifiedPath(this); - } + @Override + public @NotNull PsiElement setName(@NotNull String newName) throws IncorrectOperationException { + return this; + } + // endregion + + //region PsiQualifiedPath + @Override + public @Nullable String[] getPath() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getPath(); + } - @NotNull - @Override - public String getQualifiedName() { - PsiModuleStub stub = getGreenStub(); - if (stub != null) { - return stub.getQualifiedName(); + return ORUtil.getQualifiedPath(this); } - return ORUtil.getQualifiedName(this); - } - - @Nullable - public PsiElement getBody() { - return ORUtil.findImmediateFirstChildOfAnyClass(this, PsiScopedExpr.class, PsiStruct.class); - } - - @Nullable - public PsiModuleType getModuleType() { - return ORUtil.findImmediateFirstChildOfClass(this, PsiModuleType.class); - } - - @NotNull - @Override - public Collection getModules() { - PsiElement body = getBody(); - return body == null - ? emptyList() - : PsiTreeUtil.getStubChildrenOfTypeAsList(body, PsiInnerModule.class); - } - - @Nullable - @Override - public PsiModule getModuleExpression(@Nullable String name) { - if (name != null) { - for (PsiModule module : getModules()) { - if (name.equals(module.getName())) { - return module; + @Override + public @NotNull String getQualifiedName() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); } - } + + return ORUtil.getQualifiedName(this); + } + //endregion + + @Override public @Nullable String[] getQualifiedNameAsPath() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedNameAsPath(); + } + + return ORUtil.getQualifiedNameAsPath(this); + } + + @Override + public @NotNull String getModuleName() { + String name = getName(); + return name == null ? "" : name; } - return null; - } - - @NotNull - @Override - public Collection getExpressions( - @NotNull ExpressionScope eScope, @Nullable ExpressionFilter filter) { - Collection result = emptyList(); - - PsiFinder psiFinder = PsiFinder.getInstance(getProject()); - - String alias = getAlias(); - if (alias != null) { - // Open alias and getExpressions on alias - Set modulesByName = - psiFinder.findModulesbyName( - alias, interfaceOrImplementation, null, GlobalSearchScope.allScope(getProject())); - if (!modulesByName.isEmpty()) { - PsiModule moduleAlias = modulesByName.iterator().next(); - if (moduleAlias != null) { - result = moduleAlias.getExpressions(eScope, filter); + @Override + public boolean isInterface() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.isInterface(); } - } - } else { - PsiModuleType moduleType = getModuleType(); - if (moduleType == null) { + + return ((FileBase) getContainingFile()).isInterface(); + } + + @Override + public @Nullable PsiFunctorCall getFunctorCall() { + return ORUtil.findImmediateFirstChildOfClass(this, PsiFunctorCall.class); + } + + public @Nullable PsiElement getBody() { + return ORUtil.findImmediateFirstChildOfAnyClass(this, PsiScopedExpr.class, PsiStruct.class); + } + + public @Nullable PsiModuleType getModuleType() { + return ORUtil.findImmediateFirstChildOfClass(this, PsiModuleType.class); + } + + @Override + public @NotNull Collection getModules() { PsiElement body = getBody(); - if (body == null) { - PsiFunctorCall functorCall = - ORUtil.findImmediateFirstChildOfClass(this, PsiFunctorCall.class); - if (functorCall != null) { - result = new ArrayList<>(); - // Include all expressions from functor - QNameFinder qnameFinder = PsiFinder.getQNameFinder(getLanguage()); - - Set potentialPaths = qnameFinder.extractPotentialPaths(functorCall); - for (String potentialPath : potentialPaths) { - Set modules = - psiFinder.findModulesFromQn( - potentialPath + "." + functorCall.getFunctorName(), - true, - interfaceOrImplementation, - GlobalSearchScope.allScope(getProject())); - for (PsiModule module : modules) { - result.addAll(module.getExpressions(eScope, filter)); - } + return body == null + ? emptyList() + : PsiTreeUtil.getStubChildrenOfTypeAsList(body, PsiInnerModule.class); + } + + @Override + public @Nullable PsiModule getModuleExpression(@Nullable String name) { + if (name != null) { + for (PsiModule module : getModules()) { + if (name.equals(module.getName())) { + return module; + } } + } - Set modules = - psiFinder.findModulesFromQn( - functorCall.getFunctorName(), - true, - interfaceOrImplementation, - GlobalSearchScope.allScope(getProject())); - for (PsiModule module : modules) { - result.addAll(module.getExpressions(eScope, filter)); + return null; + } + + @Override + public @NotNull Collection getExpressions(@NotNull ExpressionScope eScope, @Nullable ExpressionFilter filter) { + Collection result = emptyList(); + + PsiFinder psiFinder = PsiFinder.getInstance(getProject()); + + String alias = getAlias(); + if (alias != null) { + // Open alias and getExpressions on alias + Set modulesByName = + psiFinder.findModulesbyName( + alias, interfaceOrImplementation, null, GlobalSearchScope.allScope(getProject())); + if (!modulesByName.isEmpty()) { + PsiModule moduleAlias = modulesByName.iterator().next(); + if (moduleAlias != null) { + result = moduleAlias.getExpressions(eScope, filter); + } } - } } else { - result = new ArrayList<>(); - PsiElement element = body.getFirstChild(); - while (element != null) { - if (element instanceof PsiNamedElement - && (filter == null || filter.accept((PsiNamedElement) element))) { - result.add((PsiNamedElement) element); + PsiModuleType moduleType = getModuleType(); + if (moduleType == null) { + PsiElement body = getBody(); + if (body == null) { + PsiFunctorCall functorCall = + ORUtil.findImmediateFirstChildOfClass(this, PsiFunctorCall.class); + if (functorCall != null) { + result = new ArrayList<>(); + // Include all expressions from functor + QNameFinder qnameFinder = PsiFinder.getQNameFinder(getLanguage()); + + Set potentialPaths = qnameFinder.extractPotentialPaths(functorCall); + for (String potentialPath : potentialPaths) { + Set modules = + psiFinder.findModulesFromQn( + potentialPath + "." + functorCall.getFunctorName(), + true, + interfaceOrImplementation, + GlobalSearchScope.allScope(getProject())); + for (PsiModule module : modules) { + result.addAll(module.getExpressions(eScope, filter)); + } + } + + Set modules = + psiFinder.findModulesFromQn( + functorCall.getFunctorName(), + true, + interfaceOrImplementation, + GlobalSearchScope.allScope(getProject())); + for (PsiModule module : modules) { + result.addAll(module.getExpressions(eScope, filter)); + } + } + } else { + result = new ArrayList<>(); + PsiElement element = body.getFirstChild(); + while (element != null) { + if (element instanceof PsiNamedElement + && (filter == null || filter.accept((PsiNamedElement) element))) { + result.add((PsiNamedElement) element); + } + element = element.getNextSibling(); + } + } + } else { + result = new ArrayList<>(); + PsiElement element = moduleType.getFirstChild(); + while (element != null) { + if (element instanceof PsiNamedElement + && (filter == null || filter.accept((PsiNamedElement) element))) { + result.add((PsiNamedElement) element); + } + element = element.getNextSibling(); + } } - element = element.getNextSibling(); - } } - } else { - result = new ArrayList<>(); - PsiElement element = moduleType.getFirstChild(); - while (element != null) { - if (element instanceof PsiNamedElement - && (filter == null || filter.accept((PsiNamedElement) element))) { - result.add((PsiNamedElement) element); - } - element = element.getNextSibling(); + + return result; + } + + @Override + public @Nullable PsiType getTypeExpression(@Nullable String name) { + PsiElement body = name == null ? null : getBody(); + if (body != null) { + ExpressionFilter expressionFilter = + element -> element instanceof PsiType && name.equals(element.getName()); + Collection expressions = + getExpressions(ExpressionScope.all, expressionFilter); + if (!expressions.isEmpty()) { + return (PsiType) expressions.iterator().next(); + } } - } + + return null; } - return result; - } - - @Nullable - @Override - public PsiType getTypeExpression(@Nullable String name) { - PsiElement body = name == null ? null : getBody(); - if (body != null) { - ExpressionFilter expressionFilter = - element -> element instanceof PsiType && name.equals(element.getName()); - Collection expressions = - getExpressions(ExpressionScope.all, expressionFilter); - if (!expressions.isEmpty()) { - return (PsiType) expressions.iterator().next(); - } + @Override + public @Nullable PsiLet getLetExpression(@Nullable String name) { + PsiElement body = name == null ? null : getBody(); + if (body != null) { + ExpressionFilter expressionFilter = + element -> element instanceof PsiLet && name.equals(element.getName()); + Collection expressions = + getExpressions(ExpressionScope.all, expressionFilter); + if (!expressions.isEmpty()) { + return (PsiLet) expressions.iterator().next(); + } + } + + return null; } - return null; - } - - @Nullable - @Override - public PsiLet getLetExpression(@Nullable String name) { - PsiElement body = name == null ? null : getBody(); - if (body != null) { - ExpressionFilter expressionFilter = - element -> element instanceof PsiLet && name.equals(element.getName()); - Collection expressions = - getExpressions(ExpressionScope.all, expressionFilter); - if (!expressions.isEmpty()) { - return (PsiLet) expressions.iterator().next(); - } + @Override + public @Nullable PsiVal getValExpression(@Nullable String name) { + PsiElement body = name == null ? null : getBody(); + if (body != null) { + ExpressionFilter expressionFilter = + element -> element instanceof PsiVal && name.equals(element.getName()); + Collection expressions = + getExpressions(ExpressionScope.all, expressionFilter); + if (!expressions.isEmpty()) { + return (PsiVal) expressions.iterator().next(); + } + } + + return null; } - return null; - } - - @Nullable - @Override - public PsiVal getValExpression(@Nullable String name) { - PsiElement body = name == null ? null : getBody(); - if (body != null) { - ExpressionFilter expressionFilter = - element -> element instanceof PsiVal && name.equals(element.getName()); - Collection expressions = - getExpressions(ExpressionScope.all, expressionFilter); - if (!expressions.isEmpty()) { - return (PsiVal) expressions.iterator().next(); - } + private boolean isModuleTypeOf() { + PsiElement nextSibling = ORUtil.nextSibling(getFirstChild()); + PsiElement nextNextSibling = ORUtil.nextSibling(nextSibling); + return nextSibling != null + && nextNextSibling != null + && nextSibling.getNode().getElementType() == m_types.TYPE + && nextNextSibling.getNode().getElementType() == m_types.OF; } - return null; - } - - private boolean isModuleTypeOf() { - PsiElement nextSibling = ORUtil.nextSibling(getFirstChild()); - PsiElement nextNextSibling = ORUtil.nextSibling(nextSibling); - return nextSibling != null - && nextNextSibling != null - && nextSibling.getNode().getElementType() == m_types.TYPE - && nextNextSibling.getNode().getElementType() == m_types.OF; - } - - private @Nullable PsiModule findReferencedModuleTypeOf() { - PsiElement of = ORUtil.findImmediateFirstChildOfType(this, m_types.OF); - - if (of != null) { - // find latest module name - PsiElement module = ORUtil.nextSiblingWithTokenType(of, m_types.C_UPPER_SYMBOL); - PsiElement moduleNextSibling = module == null ? null : module.getNextSibling(); - while (moduleNextSibling != null - && moduleNextSibling.getNode().getElementType() == m_types.DOT) { - PsiElement element = moduleNextSibling.getNextSibling(); - if (element != null && element.getNode().getElementType() == m_types.C_UPPER_SYMBOL) { - module = element; - moduleNextSibling = module.getNextSibling(); - } else { - moduleNextSibling = null; - } - } - - if (module != null) { - PsiReference reference = module.getReference(); - PsiElement resolvedElement = reference == null ? null : reference.resolve(); - if (resolvedElement instanceof PsiUpperIdentifier) { - PsiElement resolvedModule = resolvedElement.getParent(); - if (resolvedModule instanceof PsiModule) { - return (PsiModule) resolvedModule; - } + private @Nullable PsiModule findReferencedModuleTypeOf() { + PsiElement of = ORUtil.findImmediateFirstChildOfType(this, m_types.OF); + + if (of != null) { + // find latest module name + PsiElement module = ORUtil.nextSiblingWithTokenType(of, m_types.C_UPPER_SYMBOL); + PsiElement moduleNextSibling = module == null ? null : module.getNextSibling(); + while (moduleNextSibling != null + && moduleNextSibling.getNode().getElementType() == m_types.DOT) { + PsiElement element = moduleNextSibling.getNextSibling(); + if (element != null && element.getNode().getElementType() == m_types.C_UPPER_SYMBOL) { + module = element; + moduleNextSibling = module.getNextSibling(); + } else { + moduleNextSibling = null; + } + } + + if (module != null) { + PsiReference reference = module.getReference(); + PsiElement resolvedElement = reference == null ? null : reference.resolve(); + if (resolvedElement instanceof PsiUpperIdentifier) { + PsiElement resolvedModule = resolvedElement.getParent(); + if (resolvedModule instanceof PsiModule) { + return (PsiModule) resolvedModule; + } + } + } } - } + + return null; } - return null; - } - - public ItemPresentation getPresentation() { - boolean isModuleTypeOf = isModuleTypeOf(); - PsiModule referencedModuleType = isModuleTypeOf ? findReferencedModuleTypeOf() : null; - - return new ItemPresentation() { - @Nullable - @Override - public String getPresentableText() { - if (isModuleTypeOf) { - if (referencedModuleType == null) { - PsiElement of = - ORUtil.findImmediateFirstChildOfType(PsiInnerModuleImpl.this, m_types.OF); - assert of != null; - return getText().substring(of.getStartOffsetInParent() + 3); - } - return referencedModuleType.getName(); + public ItemPresentation getPresentation() { + boolean isModuleTypeOf = isModuleTypeOf(); + PsiModule referencedModuleType = isModuleTypeOf ? findReferencedModuleTypeOf() : null; + + return new ItemPresentation() { + @Override + public @Nullable String getPresentableText() { + if (isModuleTypeOf) { + if (referencedModuleType == null) { + PsiElement of = + ORUtil.findImmediateFirstChildOfType(PsiInnerModuleImpl.this, m_types.OF); + assert of != null; + return getText().substring(of.getStartOffsetInParent() + 3); + } + return referencedModuleType.getName(); + } + return getName(); + } + + @Override + public @NotNull String getLocationString() { + return referencedModuleType == null + ? "" + : referencedModuleType.getContainingFile().getName(); + } + + @Override + public @NotNull Icon getIcon(boolean unused) { + return isModuleType() + ? ORIcons.MODULE_TYPE + : (isInterface() ? ORIcons.INNER_MODULE_INTF : ORIcons.INNER_MODULE); + } + }; + } + + @Override + public boolean isComponent() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.isComponent(); } - return getName(); - } - - @NotNull - @Override - public String getLocationString() { - return referencedModuleType == null - ? "" - : referencedModuleType.getContainingFile().getName(); - } - - @NotNull - @Override - public Icon getIcon(boolean unused) { - return isModuleType() - ? ORIcons.MODULE_TYPE - : (isInterface() ? ORIcons.INNER_MODULE_INTF : ORIcons.INNER_MODULE); - } - }; - } - - @Override - public boolean isComponent() { - PsiModuleStub stub = getGreenStub(); - if (stub != null) { - return stub.isComponent(); + + return ModuleHelper.isComponent(getBody()); } - return ModuleHelper.isComponent(getBody()); - } - - @Override - public boolean isModuleType() { - PsiElement psiElement = ORUtil.nextSibling(getFirstChild()); - return psiElement != null && psiElement.getNode().getElementType() == m_types.TYPE; - } - - @NotNull - @Override - public PsiElement getNavigationElement() { - if (isComponent()) { - PsiLet make = getLetExpression("make"); - if (make != null) { - return make; - } + @Override + public boolean isModuleType() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.isModuleType(); + } + + PsiElement psiElement = ORUtil.nextSibling(getFirstChild()); + return psiElement != null && psiElement.getNode().getElementType() == m_types.TYPE; } - return super.getNavigationElement(); - } - - @Override - @Nullable - public String getAlias() { - PsiModuleStub stub = getGreenStub(); - if (stub != null) { - return stub.getAlias(); + + @Override + public boolean isFunctorCall() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.isFunctorCall(); + } + + return ORUtil.findImmediateFirstChildOfType(this, m_types.C_FUNCTOR_CALL) != null; } - PsiElement eq = findChildByType(m_types.EQ); - if (eq != null) { - return ORUtil.computeAlias(eq.getNextSibling(), getLanguage(), false); + @Override + public @NotNull PsiElement getNavigationElement() { + if (isComponent()) { + PsiLet make = getLetExpression("make"); + if (make != null) { + return make; + } + } + return super.getNavigationElement(); } - return null; - } + @Override + public @Nullable String getAlias() { + PsiModuleStub stub = getGreenStub(); + if (stub != null) { + return stub.getAlias(); + } + + PsiElement eq = findChildByType(m_types.EQ); + if (eq != null) { + return ORUtil.computeAlias(eq.getNextSibling(), getLanguage(), false); + } + + return null; + } - @Nullable - @Override - public String toString() { - return "Module " + getQualifiedName(); - } + @Override + public String toString() { + return "Module " + getQualifiedName(); + } } diff --git a/src/com/reason/lang/core/psi/impl/PsiLeafPropertyName.java b/src/com/reason/lang/core/psi/impl/PsiLeafPropertyName.java index ec99e7124..7885fa5f5 100644 --- a/src/com/reason/lang/core/psi/impl/PsiLeafPropertyName.java +++ b/src/com/reason/lang/core/psi/impl/PsiLeafPropertyName.java @@ -1,23 +1,24 @@ package com.reason.lang.core.psi.impl; -import com.intellij.psi.PsiReference; -import com.intellij.psi.impl.source.tree.LeafPsiElement; -import com.intellij.psi.tree.IElementType; -import com.reason.lang.core.psi.reference.PsiPropertyNameReference; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.tree.*; +import com.intellij.psi.tree.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.reference.*; +import org.jetbrains.annotations.*; public class PsiLeafPropertyName extends LeafPsiElement { - public PsiLeafPropertyName(@NotNull IElementType type, CharSequence text) { - super(type, text); - } + public PsiLeafPropertyName(@NotNull IElementType type, CharSequence text) { + super(type, text); + } - @Override - public PsiReference getReference() { - return new PsiPropertyNameReference(this); - } + @Override + public PsiReference getReference() { + return new PsiPropertyNameReference(this, ORUtil.getTypes(getLanguage())); + } - @Override - public String toString() { - return "PropertyName:" + getText(); - } + @Override + public String toString() { + return "PropertyName:" + getText(); + } } diff --git a/src/com/reason/lang/core/psi/impl/PsiLetImpl.java b/src/com/reason/lang/core/psi/impl/PsiLetImpl.java index d625dc757..f64184790 100644 --- a/src/com/reason/lang/core/psi/impl/PsiLetImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiLetImpl.java @@ -31,6 +31,53 @@ public PsiLetImpl(@NotNull ORTypes types, @NotNull PsiLetStub stub, @NotNull ISt } // endregion + // region PsiNamedElement + public @Nullable PsiElement getNameIdentifier() { + return ORUtil.findImmediateFirstChildOfAnyClass(this, PsiLowerIdentifier.class, PsiScopedExpr.class, PsiDeconstruction.class); + } + + @Override + public @Nullable String getName() { + PsiLetStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + + PsiElement nameIdentifier = getNameIdentifier(); + return nameIdentifier == null || nameIdentifier.getNode().getElementType() == m_types.UNDERSCORE + ? null + : nameIdentifier.getText(); + } + + @Override + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return this; + } + // endregion + + //region PsiQualifiedName + @Override + public @NotNull String[] getPath() { + PsiLetStub stub = getGreenStub(); + if (stub != null) { + return stub.getPath(); + } + + return ORUtil.getQualifiedPath(this); + } + + @Override + public @NotNull String getQualifiedName() { + PsiLetStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); + } + + return ORUtil.getQualifiedName(this); + } + //endregion + + // zzz not used ? private static @NotNull List getJsObjectFields(@NotNull PsiElement parent, @NotNull Map visited, @NotNull List path, int offset) { List fields = new ArrayList<>(); @@ -114,31 +161,8 @@ else if (element instanceof PsiLowerSymbol) { return fields; } - // region PsiNamedElement - @Nullable - public PsiElement getNameIdentifier() { - return ORUtil.findImmediateFirstChildOfAnyClass(this, PsiLowerIdentifier.class, PsiScopedExpr.class, PsiDeconstruction.class); - } - - @Nullable @Override - public String getName() { - PsiElement nameIdentifier = getNameIdentifier(); - return nameIdentifier == null || nameIdentifier.getNode().getElementType() == m_types.UNDERSCORE - ? null - : nameIdentifier.getText(); - } - // endregion - - @NotNull - @Override - public PsiElement setName(@NotNull String name) throws IncorrectOperationException { - return this; - } - - @Override - @Nullable - public PsiLetBinding getBinding() { + public @Nullable PsiLetBinding getBinding() { return findChildByClass(PsiLetBinding.class); } @@ -147,9 +171,8 @@ public boolean isScopeIdentifier() { return ORUtil.findImmediateFirstChildOfClass(this, PsiDeconstruction.class) != null; } - @NotNull @Override - public Collection getScopeChildren() { + public @NotNull Collection getScopeChildren() { Collection result = new ArrayList<>(); PsiElement scope = ORUtil.findImmediateFirstChildOfClass(this, PsiDeconstruction.class); @@ -164,9 +187,8 @@ public Collection getScopeChildren() { return result; } - @Nullable @Override - public String getAlias() { + public @Nullable String getAlias() { PsiLetStub stub = getGreenStub(); if (stub != null) { return stub.getAlias(); @@ -232,9 +254,9 @@ public boolean isJsObject() { return binding != null && binding.getFirstChild() instanceof PsiJsObject; } - @NotNull + @Override - public Collection getRecordFields() { + public @NotNull Collection getRecordFields() { return PsiTreeUtil.findChildrenOfType(this, PsiRecordField.class); } @@ -267,23 +289,7 @@ public boolean hasInferredType() { // endregion @Override - public @NotNull String getQualifiedName() { - PsiLetStub stub = getGreenStub(); - if (stub != null) { - return stub.getQualifiedName(); - } - - return ORUtil.getQualifiedName(this); - } - - @NotNull - @Override - public String getPath() { - return ORUtil.getQualifiedPath(this); // stub + name using this - } - - @Override - public boolean isDeconsruction() { + public boolean isDeconstruction() { PsiElement nameIdentifier = getNameIdentifier(); return nameIdentifier instanceof PsiDeconstruction; } diff --git a/src/com/reason/lang/core/psi/impl/PsiOpenImpl.java b/src/com/reason/lang/core/psi/impl/PsiOpenImpl.java index 153126be9..63b970b07 100644 --- a/src/com/reason/lang/core/psi/impl/PsiOpenImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiOpenImpl.java @@ -1,25 +1,36 @@ package com.reason.lang.core.psi.impl; +import com.intellij.lang.*; import com.intellij.navigation.*; import com.intellij.psi.*; -import com.intellij.psi.tree.*; +import com.intellij.psi.stubs.*; import com.intellij.psi.util.*; import com.intellij.util.xml.model.gotosymbol.*; import com.reason.lang.core.*; import com.reason.lang.core.psi.*; +import com.reason.lang.core.stub.*; import com.reason.lang.core.type.*; import icons.*; import org.jetbrains.annotations.*; -public class PsiOpenImpl extends CompositeTypePsiElement implements PsiOpen { +public class PsiOpenImpl extends PsiTokenStub implements PsiOpen { // region Constructors - protected PsiOpenImpl(@NotNull ORTypes types, @NotNull IElementType elementType) { - super(types, elementType); + public PsiOpenImpl(@NotNull ORTypes types, @NotNull ASTNode node) { + super(types, node); + } + + public PsiOpenImpl(@NotNull ORTypes types, @NotNull PsiOpenStub stub, @NotNull IStubElementType nodeType) { + super(types, stub, nodeType); } // endregion @NotNull public String getPath() { + PsiOpenStub stub = getGreenStub(); + if (stub != null) { + return stub.getOpenPath(); + } + // Skip `let` and `open` PsiElement firstChild = getFirstChild(); if (firstChild != null && firstChild.getNode().getElementType() == m_types.LET) { // `let open` in OCaml @@ -44,13 +55,13 @@ public boolean useFunctor() { } @Override - public ItemPresentation getPresentation() { - return new GoToSymbolProvider.BaseNavigationItem(this, getPath(), ORIcons.OPEN); + public boolean canBeDisplayed() { + return !(getParent() instanceof PsiFunctionBody); } @Override - public boolean canBeDisplayed() { - return !(getParent() instanceof PsiFunctionBody); + public ItemPresentation getPresentation() { + return new GoToSymbolProvider.BaseNavigationItem(this, getPath(), ORIcons.OPEN); } @Override diff --git a/src/com/reason/lang/core/psi/impl/PsiParameterImpl.java b/src/com/reason/lang/core/psi/impl/PsiParameterImpl.java index e6adec445..afdab1755 100644 --- a/src/com/reason/lang/core/psi/impl/PsiParameterImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiParameterImpl.java @@ -6,6 +6,7 @@ import com.intellij.psi.tree.*; import com.intellij.psi.util.*; import com.intellij.util.*; +import com.reason.*; import com.reason.lang.core.*; import com.reason.lang.core.psi.PsiParameter; import com.reason.lang.core.psi.*; @@ -21,14 +22,13 @@ public PsiParameterImpl(@NotNull ORTypes types, @NotNull ASTNode node) { super(types, node); } - public PsiParameterImpl( - @NotNull ORTypes types, @NotNull PsiParameterStub stub, @NotNull IStubElementType nodeType) { + public PsiParameterImpl(@NotNull ORTypes types, @NotNull PsiParameterStub stub, @NotNull IStubElementType nodeType) { super(types, stub, nodeType); } // endregion - @Nullable - public PsiElement getNameIdentifier() { + //region PsiNamedElement + public @Nullable PsiElement getNameIdentifier() { PsiElement parent = getParent(); PsiElement grandParent = parent == null ? null : parent.getParent(); if (parent instanceof PsiFunctionCallParams || grandParent instanceof PsiFunctorCall) { @@ -48,6 +48,11 @@ public PsiElement getNameIdentifier() { @Override public @Nullable String getName() { + PsiParameterStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + PsiElement identifier = getNameIdentifier(); if (identifier != null) { return identifier.getText(); @@ -63,7 +68,7 @@ public PsiElement getNameIdentifier() { int i = 0; for (PsiParameter parameter : parameters) { if (parameter == this) { - PsiElement prevSibling = /*grandParent instanceof PsiFunctorCall ? null : */ parent.getPrevSibling(); + PsiElement prevSibling = ORUtil.prevSibling(parent); return (prevSibling == null ? "" : prevSibling.getText()) + "[" + i + "]"; } i++; @@ -77,27 +82,19 @@ public PsiElement getNameIdentifier() { public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { return this; } + //endregion + //region PsiQualifiedName @Override - public @Nullable PsiSignature getSignature() { - return PsiTreeUtil.findChildOfType(this, PsiSignature.class); - } - - @Override - public @Nullable PsiDefaultValue getDefaultValue() { - return ORUtil.findImmediateFirstChildOfClass(this, PsiDefaultValue.class); - } - - @Override - public boolean isOptional() { - return getDefaultValue() != null; - } + public @Nullable String[] getPath() { + PsiParameterStub stub = getGreenStub(); + if (stub != null) { + return stub.getPath(); + } - @Override - public @NotNull String getPath() { - PsiQualifiedElement qualifiedParent = PsiTreeUtil.getParentOfType(this, PsiQualifiedElement.class); - String parentQName = qualifiedParent == null ? null : qualifiedParent.getQualifiedName(); - return parentQName == null ? "" : parentQName; + PsiQualifiedNamedElement qualifiedParent = PsiTreeUtil.getParentOfType(this, PsiQualifiedNamedElement.class); + String qName = qualifiedParent == null ? null : qualifiedParent.getQualifiedName(); + return qName == null ? null : qName.split("\\."); } @Override @@ -112,8 +109,24 @@ public boolean isOptional() { boolean isCall = parent instanceof PsiFunctionCallParams || grandParent instanceof PsiFunctorCall; String name = getName(); - String path = getPath(); - return path + (isCall ? "." + name : "[" + name + "]"); + String[] path = getPath(); + return Joiner.join(".", path) + (isCall ? "." + name : "[" + name + "]"); + } + //endregion + + @Override + public @Nullable PsiSignature getSignature() { + return PsiTreeUtil.findChildOfType(this, PsiSignature.class); + } + + @Override + public @Nullable PsiDefaultValue getDefaultValue() { + return ORUtil.findImmediateFirstChildOfClass(this, PsiDefaultValue.class); + } + + @Override + public boolean isOptional() { + return getDefaultValue() != null; } @Override diff --git a/src/com/reason/lang/core/psi/impl/PsiRecord.java b/src/com/reason/lang/core/psi/impl/PsiRecord.java index f710f5c59..fd5983ad2 100644 --- a/src/com/reason/lang/core/psi/impl/PsiRecord.java +++ b/src/com/reason/lang/core/psi/impl/PsiRecord.java @@ -1,40 +1,37 @@ package com.reason.lang.core.psi.impl; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.source.tree.CompositePsiElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.util.containers.ContainerUtil; -import com.reason.lang.core.psi.PsiRecordField; -import java.util.ArrayList; -import java.util.List; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.*; +import com.intellij.psi.impl.source.tree.*; +import com.intellij.psi.tree.*; +import com.intellij.util.containers.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; public class PsiRecord extends CompositePsiElement { + protected PsiRecord(IElementType type) { + super(type); + } - protected PsiRecord(IElementType type) { - super(type); - } + public @NotNull List getFields() { + PsiElement[] children = getChildren(); + if (children.length == 0) { + return ContainerUtil.emptyList(); + } - @NotNull - public List getFields() { - PsiElement[] children = getChildren(); - if (children.length == 0) { - return ContainerUtil.emptyList(); - } + List result = new ArrayList<>(children.length); + for (PsiElement child : children) { + if (child instanceof PsiRecordField) { + result.add((PsiRecordField) child); + } + } - List result = new ArrayList<>(children.length); - for (PsiElement child : children) { - if (child instanceof PsiRecordField) { - result.add((PsiRecordField) child); - } + return result; } - return result; - } - - @NotNull - @Override - public String toString() { - return "Record"; - } + @Override + public @NotNull String toString() { + return "Record"; + } } diff --git a/src/com/reason/lang/core/psi/impl/PsiRecordFieldImpl.java b/src/com/reason/lang/core/psi/impl/PsiRecordFieldImpl.java index 9ed8ee717..38eb70b32 100644 --- a/src/com/reason/lang/core/psi/impl/PsiRecordFieldImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiRecordFieldImpl.java @@ -7,7 +7,6 @@ import com.intellij.psi.util.*; import com.intellij.util.*; import com.reason.lang.core.*; -import com.reason.lang.core.psi.PsiType; import com.reason.lang.core.psi.*; import com.reason.lang.core.stub.*; import com.reason.lang.core.type.*; @@ -27,44 +26,50 @@ public PsiRecordFieldImpl(@NotNull ORTypes types, @NotNull PsiRecordFieldStub st } // endregion + // region PsiNamedElement @Override public @Nullable PsiElement getNameIdentifier() { return getFirstChild(); } @Override - public @NotNull String getPath() { + public @Nullable String getName() { PsiRecordFieldStub stub = getGreenStub(); if (stub != null) { - return stub.getPath(); + return stub.getName(); } - PsiType parent = PsiTreeUtil.getParentOfType(this, PsiType.class); - String name = getName(); - return (parent == null) ? name : (ORUtil.getQualifiedPath(parent) + "." + name); + PsiElement nameElement = getNameIdentifier(); + return nameElement == null ? "" : nameElement.getText().replaceAll("\"", ""); } + @Override + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return this; + } + // endregion + //region PsiQualifiedName @Override - public @NotNull String getQualifiedName() { + public @NotNull String[] getPath() { PsiRecordFieldStub stub = getGreenStub(); if (stub != null) { - return stub.getQualifiedName(); + return stub.getPath(); } - return ORUtil.getQualifiedName(this); + return ORUtil.getQualifiedPath(this); } @Override - public @NotNull String getName() { - PsiElement nameElement = getNameIdentifier(); - return nameElement == null ? "" : nameElement.getText().replaceAll("\"", ""); - } + public @NotNull String getQualifiedName() { + PsiRecordFieldStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); + } - @Override - public @Nullable PsiElement setName(@NotNull String name) throws IncorrectOperationException { - return null; + return ORUtil.getQualifiedName(this); } + //endregion public @Nullable PsiSignature getSignature() { return PsiTreeUtil.findChildOfType(this, PsiSignature.class); @@ -74,7 +79,7 @@ public PsiRecordFieldImpl(@NotNull ORTypes types, @NotNull PsiRecordFieldStub st public ItemPresentation getPresentation() { return new ItemPresentation() { @Override - public @NotNull String getPresentableText() { + public @Nullable String getPresentableText() { return getName(); } @@ -92,7 +97,7 @@ public ItemPresentation getPresentation() { } @Override - public @Nullable String toString() { + public @NotNull String toString() { return "Record field " + getQualifiedName(); } } diff --git a/src/com/reason/lang/core/psi/impl/PsiTypeImpl.java b/src/com/reason/lang/core/psi/impl/PsiTypeImpl.java index a382d18fe..942e05d5d 100644 --- a/src/com/reason/lang/core/psi/impl/PsiTypeImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiTypeImpl.java @@ -31,62 +31,83 @@ public PsiTypeImpl(@NotNull ORTypes types, @NotNull PsiTypeStub stub, @NotNull I // endregion // region PsiNamedElement - @NotNull @Override - public String getName() { + public @Nullable PsiElement getNameIdentifier() { + return findChildByClass(PsiLowerIdentifier.class); + } + + @Override + public @Nullable String getName() { PsiTypeStub stub = getGreenStub(); if (stub != null) { - String name = stub.getName(); - return name == null ? "" : name; - } - - PsiElement constrName = findChildByClass(PsiLowerIdentifier.class); - if (constrName == null) { - return ""; + return stub.getName(); } - /* zzz - PsiParameters parameters = findChildByClass(PsiParameters.class); + PsiElement constrName = getNameIdentifier(); + return constrName == null ? "" : constrName.getText(); - StringBuilder nameBuilder = new StringBuilder(); - boolean first = true; + } - PsiElement element = constrName.getFirstChild(); - while (element != null) { - if (element instanceof PsiLowerIdentifier) { - if (!first) { - nameBuilder.append(" "); - } - nameBuilder.append(element.getText()); - first = false; - } - element = element.getNextSibling(); + @Override + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { + return this; } + // endregion - return nameBuilder.toString(); + //region PsiQualifiedPathName + @Override + public @Nullable String[] getPath() { + PsiTypeStub stub = getGreenStub(); + if (stub != null) { + return stub.getPath(); + } - */ - return constrName.getText(); + return ORUtil.getQualifiedPath(this); } - @NotNull @Override - public PsiElement setName(@NotNull String name) throws IncorrectOperationException { - throw new IncorrectOperationException("use lower identifier"); + public @NotNull String getQualifiedName() { + PsiTypeStub stub = getGreenStub(); + if (stub != null) { + return stub.getQualifiedName(); + } + + return ORUtil.getQualifiedName(this); } - // endregion + //endregion @Override public boolean isAbstract() { + PsiTypeStub stub = getGreenStub(); + if (stub != null) { + return stub.isAbstract(); + } + return getBinding() == null; } @Override public boolean isJsObject() { + PsiTypeStub stub = getGreenStub(); + if (stub != null) { + return stub.isJsObject(); + } + PsiTypeBinding binding = getBinding(); return binding != null && binding.getFirstChild() instanceof PsiJsObject; } + @Override + public boolean isRecord() { + PsiTypeStub stub = getGreenStub(); + if (stub != null) { + return stub.isRecord(); + } + + PsiTypeBinding binding = getBinding(); + return binding != null && binding.getFirstChild() instanceof PsiRecord; + } + @Override public @Nullable PsiTypeBinding getBinding() { return findChildByClass(PsiTypeBinding.class); @@ -101,28 +122,6 @@ public boolean isJsObject() { return emptyList(); } - @NotNull - @Override - public String getPath() { - PsiTypeStub stub = getGreenStub(); - if (stub != null) { - return stub.getPath(); - } - - return ORUtil.getQualifiedPath(this); - } - - @NotNull - @Override - public String getQualifiedName() { - PsiTypeStub stub = getGreenStub(); - if (stub != null) { - return stub.getQualifiedName(); - } - - return ORUtil.getQualifiedName(this); - } - @Override public ItemPresentation getPresentation() { return new ItemPresentation() { @@ -131,9 +130,8 @@ public String getPresentableText() { return getName(); } - @Nullable @Override - public String getLocationString() { + public @Nullable String getLocationString() { return null; } @@ -144,9 +142,8 @@ public Icon getIcon(boolean unused) { }; } - @Nullable @Override - public String toString() { + public @NotNull String toString() { return "Type " + getQualifiedName(); } } diff --git a/src/com/reason/lang/core/psi/impl/PsiValImpl.java b/src/com/reason/lang/core/psi/impl/PsiValImpl.java index c53f751b3..9d410c30d 100644 --- a/src/com/reason/lang/core/psi/impl/PsiValImpl.java +++ b/src/com/reason/lang/core/psi/impl/PsiValImpl.java @@ -26,55 +26,58 @@ public PsiValImpl(@NotNull ORTypes types, @NotNull PsiValStub stub, @NotNull ISt // endregion // region PsiNamedElement - @Nullable - public PsiElement getNameIdentifier() { + public @Nullable PsiElement getNameIdentifier() { return ORUtil.findImmediateFirstChildOfAnyClass(this, PsiLowerIdentifier.class, PsiScopedExpr.class); } - @NotNull @Override - public String getName() { + public @Nullable String getName() { + PsiValStub stub = getGreenStub(); + if (stub != null) { + return stub.getName(); + } + PsiElement nameIdentifier = getNameIdentifier(); return nameIdentifier == null ? "" : nameIdentifier.getText(); } - @NotNull @Override - public PsiElement setName(@NotNull String name) throws IncorrectOperationException { + public @NotNull PsiElement setName(@NotNull String name) throws IncorrectOperationException { return this; } // endregion + //region PsiQualifiedName @Override - public boolean isFunction() { + public @NotNull String[] getPath() { PsiValStub stub = getGreenStub(); if (stub != null) { - return stub.isFunction(); + return stub.getPath(); } - PsiSignature signature = getSignature(); - return signature != null && signature.isFunction(); + return ORUtil.getQualifiedPath(this); } @Override - public @NotNull String getPath() { + public @NotNull String getQualifiedName() { PsiValStub stub = getGreenStub(); if (stub != null) { - return stub.getPath(); + return stub.getQualifiedName(); } - return ORUtil.getQualifiedPath(this); + return ORUtil.getQualifiedName(this); } + //endregion - @NotNull @Override - public String getQualifiedName() { + public boolean isFunction() { PsiValStub stub = getGreenStub(); if (stub != null) { - return stub.getQualifiedName(); + return stub.isFunction(); } - return ORUtil.getQualifiedName(this); + PsiSignature signature = getSignature(); + return signature != null && signature.isFunction(); } @Override @@ -85,30 +88,26 @@ public String getQualifiedName() { @Override public ItemPresentation getPresentation() { return new ItemPresentation() { - @NotNull @Override - public String getPresentableText() { + public @NotNull String getPresentableText() { return getName(); } - @Nullable @Override - public String getLocationString() { + public @Nullable String getLocationString() { PsiSignature signature = getSignature(); return signature == null ? null : signature.asText(getLanguage()); } - @NotNull @Override - public Icon getIcon(boolean unused) { + public @NotNull Icon getIcon(boolean unused) { return ORIcons.VAL; } }; } - @Nullable @Override - public String toString() { + public @Nullable String toString() { return "Val " + getQualifiedName(); } } diff --git a/src/com/reason/lang/core/psi/reference/CodeInstruction.java b/src/com/reason/lang/core/psi/reference/CodeInstruction.java new file mode 100644 index 000000000..f35bbbec5 --- /dev/null +++ b/src/com/reason/lang/core/psi/reference/CodeInstruction.java @@ -0,0 +1,44 @@ +package com.reason.lang.core.psi.reference; + +import com.intellij.psi.*; +import com.intellij.psi.impl.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; +import java.util.stream.*; + +class CodeInstruction { + @NotNull PsiElement mySource; + @Nullable String[] myValues; + @Nullable Set myAlternateValues = null; + + public CodeInstruction(@NotNull PsiElement source, @Nullable String value, @Nullable Collection includes) { + mySource = source; + myValues = value == null ? null : new String[]{value}; + if (includes != null && !includes.isEmpty()) { + myAlternateValues = includes.stream().map(PsiInclude::getIncludePath).collect(Collectors.toSet()); + } + } + + public CodeInstruction(@NotNull PsiElement source, @Nullable String value) { + this(source, value, null); + } + + public CodeInstruction(@NotNull PsiElement source, @NotNull String[] values) { + mySource = source; + myValues = values; + } + + @Nullable public String getFirstValue() { + return myValues == null ? null : myValues[0]; + } + + @Override + public String toString() { + return "[" + mySource.getClass().getSimpleName() + ":" + Joiner.join("/", myValues) + + (myAlternateValues == null ? "" : " (" + Joiner.join(", ", myAlternateValues) + ")") + + "]"; + } +} diff --git a/src/com/reason/lang/core/psi/reference/ORElementResolver.java b/src/com/reason/lang/core/psi/reference/ORElementResolver.java new file mode 100644 index 000000000..916f692ca --- /dev/null +++ b/src/com/reason/lang/core/psi/reference/ORElementResolver.java @@ -0,0 +1,368 @@ +package com.reason.lang.core.psi.reference; + +import com.intellij.openapi.*; +import com.intellij.openapi.project.*; +import com.intellij.openapi.util.*; +import com.intellij.openapi.util.text.*; +import com.intellij.psi.stubs.*; +import com.intellij.psi.util.*; +import com.intellij.util.*; +import com.reason.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +import static java.util.Collections.*; + +public class ORElementResolver implements Disposable { + private static final Log LOG = Log.create("ref"); + + private final Project myProject; + private final CachedValue>> myCachedIncludeDependencies; + + ORElementResolver(@NotNull Project project) { + myProject = project; + CachedValuesManager cachedValuesManager = CachedValuesManager.getManager(project); + + myCachedIncludeDependencies = cachedValuesManager.createCachedValue(() -> { + Map>> topIncludedModules = new HashMap<>(); + Map> dependencies = new HashMap<>(); + + StubIndex stubIndex = StubIndex.getInstance(); + stubIndex.processAllKeys(IndexKeys.INCLUDES, myProject, includePath -> { + stubIndex.processElements(IndexKeys.INCLUDES, includePath, myProject, null, PsiInclude.class, psiInclude -> { + String[] includeQPath = psiInclude.getQualifiedPath(); + String[] resolvedPath = psiInclude.getResolvedPath(); + if (Arrays.equals(resolvedPath, includeQPath)) { + // !? coq ? + LOG.info("Equality with recursion found: " + psiInclude + " [" + Joiner.join(".", includeQPath) + "] in " + psiInclude.getContainingFile().getVirtualFile()); + return true; + } + + Set depPaths = dependencies.computeIfAbsent(includePath, k -> new TreeSet<>(ArrayUtil::lexicographicCompare)); + depPaths.add(includeQPath); + + String includeModuleName = includeQPath[0]; + + Set> alternatePaths = topIncludedModules.get(resolvedPath[0]); + if (alternatePaths != null) { + for (Pair alternatePath : alternatePaths) { + String alternateKey = alternatePath.first; + Set alternateDependencies = dependencies.get(alternateKey); + String[] newPath = new String[alternatePath.second.length]; + System.arraycopy(alternatePath.second, 0, newPath, 0, alternatePath.second.length); + newPath[0] = includeModuleName; + alternateDependencies.add(newPath); + } + } + + Set> topIncludes = topIncludedModules.computeIfAbsent(includeModuleName, k -> new TreeSet<>((o1, o2) -> { + int compare = NaturalComparator.INSTANCE.compare(o1.first, o2.first); + if (compare != 0) { + return compare; + } + + return ArrayUtil.lexicographicCompare(o1.second, o2.second); + })); + topIncludes.add(Pair.create(includePath, includeQPath)); + + return true; + }); + return true; + }); + + return CachedValueProvider.Result.create(dependencies, PsiModificationTracker.MODIFICATION_COUNT); + }); + + } + + Resolutions getComputation() { + return new ResolutionsImpl(); + } + + @Override + public void dispose() { + } + + interface Resolutions { + void add(@NotNull Collection elements, boolean includeSource); + + void addIncludesEquivalence(); + + void updateWeight(@Nullable String value, Set alternateNames); + + void udpateTerminalWeight(@NotNull String value); + + void removeUpper(); + + void removeIfNotFound(String value, @Nullable Set alternateNames); + + void removeIncomplete(); + + Collection resolvedElements(); + } + + /* + Note: performance is extremely important + */ + private class ResolutionsImpl implements Resolutions { + private final Map myWeightPerLevel = new HashMap<>(); + private final Map> myResolutionsPerTopModule = new HashMap<>(); + + @Override + public void add(@NotNull Collection elements, boolean includeSource) { + if (elements.isEmpty()) { + return; + } + + for (PsiQualifiedPathElement source : elements) { + String sourceName = source.getName(); + if (sourceName == null) { + continue; + } + + String sourceQName = source.getQualifiedName(); + String[] sourcePath = source.getPath(); + if (sourcePath != null) { + // Add source name to the path in case of modules + if (includeSource) { + String[] newPath = new String[sourcePath.length + 1]; + System.arraycopy(sourcePath, 0, newPath, 0, sourcePath.length); + newPath[sourcePath.length] = sourceName; + sourcePath = newPath; + } + // Remove type name in case of variants + if (source instanceof PsiVariantDeclaration) { + String[] newPath = new String[sourcePath.length - 1]; + System.arraycopy(sourcePath, 0, newPath, 0, newPath.length); + sourcePath = newPath; + } + + String first = sourcePath[0]; + Map resolutionsPerQName = myResolutionsPerTopModule.get(first); + //noinspection Java8MapApi + if (resolutionsPerQName == null) { + resolutionsPerQName = new HashMap<>(); + myResolutionsPerTopModule.put(first, resolutionsPerQName); + } + + // try to find duplicates + Resolution resolution = resolutionsPerQName.get(sourceQName); + if (resolution == null) { + resolutionsPerQName.put(sourceQName, new Resolution(sourcePath, source)); + } else { + resolution.myElements.add(source); + } + } else if (includeSource) { + Map resolutionsPerQName = myResolutionsPerTopModule.get(sourceName); + //noinspection Java8MapApi + if (resolutionsPerQName == null) { + resolutionsPerQName = new HashMap<>(); + myResolutionsPerTopModule.put(sourceName, resolutionsPerQName); + } + + // try to find duplicates + Resolution resolution = resolutionsPerQName.get(sourceQName); + if (resolution == null) { + resolutionsPerQName.put(sourceQName, new Resolution(new String[]{sourceName}, source)); + } else { + resolution.myElements.add(source); + } + } + } + + Project project = elements.iterator().next().getProject(); + List aliasResolutions = new ArrayList<>(); + for (Map.Entry> entry : myResolutionsPerTopModule.entrySet()) { + String first = entry.getKey(); + Collection resolutions = entry.getValue().values(); + + Collection aliases = ModuleAliasedIndex.getElements(first, project, null); + for (PsiModule alias : aliases) { + String[] aliasPath = alias.getQualifiedNameAsPath(); + for (Resolution resolution : resolutions) { + Resolution aliasResolution = Resolution.createAlternate(resolution, aliasPath); + aliasResolutions.add(aliasResolution); + } + } + } + + for (Resolution aliasResolution : aliasResolutions) { + String topModuleName = aliasResolution.getTopModuleName(); + Map resolutionsPerQName = myResolutionsPerTopModule.get(topModuleName); + //noinspection Java8MapApi + if (resolutionsPerQName == null) { + resolutionsPerQName = new HashMap<>(); + myResolutionsPerTopModule.put(topModuleName, resolutionsPerQName); + } + + PsiQualifiedPathElement aliasElement = aliasResolution.myElements.get(0); + String aliasQName = aliasResolution.joinPath() + (aliasElement instanceof PsiModule ? "" : "." + aliasElement.getName()); + + resolutionsPerQName.put(aliasQName, aliasResolution); + } + } + + @Override + public void addIncludesEquivalence() { + Map> cachedIncludes = myCachedIncludeDependencies.getValue(); + + List includeResolutions = new ArrayList<>(); + + for (Map.Entry> resolutionPerNameEntry : myResolutionsPerTopModule.entrySet()) { + Map resolutions = resolutionPerNameEntry.getValue(); + for (Map.Entry resolutionEntry : resolutions.entrySet()) { + String key = resolutionEntry.getKey(); + int pos = key.lastIndexOf("."); + String keyPath = pos < 0 ? key : key.substring(0, pos); + findResolutionEquivalence(keyPath, resolutionEntry.getValue(), cachedIncludes, includeResolutions, 0); + } + } + + for (Resolution includeResolution : includeResolutions) { + String topModuleName = includeResolution.getTopModuleName(); + Map resolutionsPerQName = myResolutionsPerTopModule.get(topModuleName); + //noinspection Java8MapApi + if (resolutionsPerQName == null) { + resolutionsPerQName = new HashMap<>(); + myResolutionsPerTopModule.put(topModuleName, resolutionsPerQName); + } + + PsiQualifiedPathElement includeElement = includeResolution.myElements.get(0); + String includeQName = includeResolution.joinPath() + (includeElement instanceof PsiModule ? "" : "." + includeElement.getName()); + + // try to find duplicates + Resolution resolution = resolutionsPerQName.get(includeQName); + if (resolution == null) { + resolutionsPerQName.put(includeQName, includeResolution); + } else { + resolution.myElements.add(includeElement); + } + } + } + + private void findResolutionEquivalence(String path, Resolution resolution, Map> cachedIncludes, List result, int guard) { + Set includeDeps = cachedIncludes.get(path); + if (includeDeps != null) { + // A.B.C.t + // A.B.C ==> A :: A.B.C.t => A.t + for (String[] includeDepPath : includeDeps) { + Resolution newResolution = new Resolution(includeDepPath, resolution.myElements); + result.add(newResolution); + String newPath = Joiner.join(".", includeDepPath); + if (20 < guard) { + LOG.warn("Too much recursion for " + path); + return; + } + + if (newPath.equals(path)) { + LOG.info("equivalent path found (#" + guard + "): " + path + ", deps: [" + Joiner.join(",", includeDeps, p -> Joiner.join(".", p)) + "]"); + } else { + findResolutionEquivalence(newPath, newResolution, cachedIncludes, result, guard + 1); + } + } + } else { + includeDeps = cachedIncludes.get(resolution.getTopModuleName()); + if (includeDeps != null) { + // Core.Types.Visibility + // Core ==> Css :: Core.Types.Visibility.t => Css.Types.Visibility.t + for (String[] includeDepPath : includeDeps) { + String[] newPath = resolution.augmentPath(includeDepPath); + Resolution newResolution = new Resolution(newPath, resolution.myElements); + result.add(newResolution); + } + } + } + } + + public void updateWeight(@Nullable String value, Set alternateNames) { + Map newWeights = new HashMap<>(); + + for (Map topModuleEntry : myResolutionsPerTopModule.values()) { + for (com.reason.lang.core.psi.reference.Resolution resolution : topModuleEntry.values()) { + String name = resolution.getCurrentName(); + if (name != null) { + if (value == null || value.equals(name)) { + int level = resolution.myLevel; + Integer weight = myWeightPerLevel.get(level); + int newWeight = weight == null ? 1 : weight + 1; + resolution.updateCurrentWeight(newWeight); + newWeights.put(level, newWeight); + } else if (alternateNames != null) { + for (String alternateName : alternateNames) { + if (alternateName.equals(name)) { + int level = resolution.myLevel; + Integer weight = myWeightPerLevel.get(level); + int newWeight = weight == null ? 1 : weight + 1; + resolution.updateCurrentWeight(newWeight); + newWeights.put(level, newWeight); + break; + } + } + } + } + } + } + + for (Map.Entry weightLevel : newWeights.entrySet()) { + myWeightPerLevel.put(weightLevel.getKey(), weightLevel.getValue()); + } + } + + public void udpateTerminalWeight(@NotNull String value) { + for (Map topModuleEntry : myResolutionsPerTopModule.values()) { + for (com.reason.lang.core.psi.reference.Resolution resolution : topModuleEntry.values()) { + String name = resolution.getCurrentName(); + if (value.equals(name) && resolution.isLastLevel()) { + // terminal + int level = resolution.myLevel; + Integer weight = myWeightPerLevel.get(level); + int newWeight = weight == null ? 1 : weight + 1; + resolution.updateCurrentWeight(newWeight); + myWeightPerLevel.put(level, newWeight); + } + } + } + } + + public void removeUpper() { + for (Map topModuleEntry : myResolutionsPerTopModule.values()) { + topModuleEntry.values().removeIf(resolution -> { + String name = resolution.getCurrentName(); + return name != null && Character.isUpperCase(name.charAt(0)); + }); + } + } + + // all resolutions must be complete + public void removeIfNotFound(String value, @Nullable Set alternateNames) { + for (Map topModuleEntry : myResolutionsPerTopModule.values()) { + topModuleEntry.values().removeIf(resolution -> { + String currentName = resolution.getCurrentName(); + return !value.equals(currentName) && (alternateNames == null || !alternateNames.contains(currentName)); + }); + } + } + + public void removeIncomplete() { + for (Map topModuleEntry : myResolutionsPerTopModule.values()) { + topModuleEntry.values().removeIf(resolution -> !resolution.myIsComplete); + } + } + + public Collection resolvedElements() { + List allResolutions = new ArrayList<>(); + + // flatten elements + for (Map topModuleEntry : myResolutionsPerTopModule.values()) { + allResolutions.addAll(topModuleEntry.values()); + } + + allResolutions.sort(com.reason.lang.core.psi.reference.Resolution::compareTo); + + return allResolutions.isEmpty() ? emptyList() : allResolutions.get(0).myElements; + } + } +} diff --git a/src/com/reason/lang/core/psi/reference/ORFakeResolvedElement.java b/src/com/reason/lang/core/psi/reference/ORFakeResolvedElement.java index 61a381955..f0ca33455 100644 --- a/src/com/reason/lang/core/psi/reference/ORFakeResolvedElement.java +++ b/src/com/reason/lang/core/psi/reference/ORFakeResolvedElement.java @@ -1,39 +1,34 @@ package com.reason.lang.core.psi.reference; -import com.intellij.openapi.util.TextRange; -import com.intellij.psi.PsiElement; -import com.intellij.psi.impl.FakePsiElement; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.openapi.util.*; +import com.intellij.psi.*; +import com.intellij.psi.impl.*; +import org.jetbrains.annotations.*; public class ORFakeResolvedElement extends FakePsiElement { - - private final @NotNull PsiElement m_sourceElement; - - public ORFakeResolvedElement(@NotNull PsiElement element) { - m_sourceElement = element; - } - - @Override - public @NotNull PsiElement getOriginalElement() { - return m_sourceElement; - } - - @Nullable - @Override - public PsiElement getParent() { - return m_sourceElement.getParent(); - } - - @Nullable - @Override - public String getText() { - return m_sourceElement.getText(); - } - - @NotNull - @Override - public TextRange getTextRangeInParent() { - return TextRange.EMPTY_RANGE; - } + private final @NotNull PsiElement mySourceElement; + + public ORFakeResolvedElement(@NotNull PsiElement element) { + mySourceElement = element; + } + + @Override + public @NotNull PsiElement getOriginalElement() { + return mySourceElement; + } + + @Override + public @Nullable PsiElement getParent() { + return mySourceElement.getParent(); + } + + @Override + public @Nullable String getText() { + return mySourceElement.getText(); + } + + @Override + public @NotNull TextRange getTextRangeInParent() { + return TextRange.EMPTY_RANGE; + } } diff --git a/src/com/reason/lang/core/psi/reference/ORReferenceAnalyzer.java b/src/com/reason/lang/core/psi/reference/ORReferenceAnalyzer.java new file mode 100644 index 000000000..3aaed7100 --- /dev/null +++ b/src/com/reason/lang/core/psi/reference/ORReferenceAnalyzer.java @@ -0,0 +1,243 @@ +package com.reason.lang.core.psi.reference; + +import com.intellij.openapi.project.*; +import com.intellij.psi.*; +import com.intellij.psi.tree.*; +import com.reason.ide.files.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.PsiType; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +// @ProjectComponent +public class ORReferenceAnalyzer { + + static class ORUpperSymbolWithResolution extends ORFakeResolvedElement { + public ORUpperSymbolWithResolution(PsiElement element) { + super(element); + } + + @Override public String toString() { + return getOriginalElement().toString(); + } + } + + static class ORUpperResolvedSymbol extends ORFakeResolvedElement { + public ORUpperResolvedSymbol(PsiElement element) { + super(element); + } + + @Override public String toString() { + return getOriginalElement().toString(); + } + } + + static class ORLocalAlias extends ORFakeResolvedElement { + public String myResolvedAlias; + + public ORLocalAlias(@NotNull PsiElement element, @NotNull String resolvedAlias) { + super(element); + myResolvedAlias = resolvedAlias; + } + + public boolean isModuleName(@NotNull String name) { + return name.equals(((PsiModule) getOriginalElement()).getModuleName()); + } + + @Override public String toString() { + return ((PsiModule) getOriginalElement()).getModuleName() + " =~ " + myResolvedAlias; + } + } + + // Walk through the file - from element up to the root - and extract instructions + static @NotNull Deque createInstructions(@NotNull PsiElement sourceElement, @NotNull ORTypes types) { + boolean startPath = true; + PsiElement prevItem = ORUtil.prevSibling(sourceElement); + if ((sourceElement instanceof PsiUpperSymbol || sourceElement instanceof PsiLowerSymbol) && prevItem != null) { + IElementType prevType = prevItem.getNode().getElementType(); + if (prevType == types.RIGHT_ARROW || prevType == types.PIPE_FORWARD || prevType == types.COMMA) { + // -> A.B |> A.B + // we are no more in a path, skip path + prevItem = prevItem.getPrevSibling(); + prevType = prevItem.getNode().getElementType(); + while (prevType != null && (prevType == types.DOT || prevType == types.C_UPPER_SYMBOL || prevType == types.C_VARIANT || prevType == types.C_LOWER_SYMBOL)) { + prevItem = prevItem.getPrevSibling(); + prevType = prevItem == null ? null : prevItem.getNode().getElementType(); + } + + // if LocalOpen found, it is still a path + if (prevType == types.LPAREN) { + PsiElement parent = prevItem.getParent(); + startPath = parent instanceof PsiLocalOpen; + } else { + startPath = false; + } + } + } + PsiElement item = prevItem == null ? sourceElement.getParent() : prevItem; + Deque instructions = new LinkedList<>(); + + while (item != null) { + if (item instanceof PsiUpperSymbol || item instanceof PsiLowerSymbol) { + // only add if it's from a local path + if (item.getNextSibling().getNode().getElementType() == types.DOT && startPath) { + instructions.push(item instanceof PsiUpperSymbol ? new ORUpperSymbolWithResolution(item) : item); + } + } else if (item instanceof PsiInnerModule) { + if (((PsiInnerModule) item).isFunctorCall()) { + PsiFunctorCall functorCall = ORUtil.findImmediateFirstChildOfClass(item, PsiFunctorCall.class); + if (functorCall != null) { + instructions.push(functorCall); + //instructions.push(new ORFakeModuleAlias(item, functorCall.getFunctorName())); + } + } else { + instructions.push(item); + } + } else if (item instanceof PsiOpen) { + instructions.push(item); + } else if (item instanceof PsiLet) { + instructions.push(item); + } else if (item instanceof PsiType) { + instructions.push(item); + } else if (item instanceof PsiTagStart) { + instructions.push(item); + } else if (item instanceof FileBase) { + instructions.push(item); + break; + } + + prevItem = ORUtil.prevSibling(item); + if ((item instanceof PsiUpperSymbol || item instanceof PsiLowerSymbol) && prevItem != null) { + IElementType prevType = prevItem.getNode().getElementType(); + if (prevType == types.RIGHT_ARROW || prevType == types.PIPE_FORWARD || prevType == types.COMMA) { + // -> A.B or |> A.B + // we are no more in a path, skip path + prevItem = prevItem.getPrevSibling(); + prevType = prevItem.getNode().getElementType(); + while (prevType != null && (prevType == types.DOT || prevType == types.C_UPPER_SYMBOL || prevType == types.C_VARIANT || prevType == types.C_LOWER_SYMBOL)) { + prevItem = prevItem.getPrevSibling(); + prevType = prevItem == null ? null : prevItem.getNode().getElementType(); + } + + // if LocalOpen found, it is still a path + if (prevType == types.LPAREN) { + PsiElement parent = prevItem.getParent(); + startPath = parent instanceof PsiLocalOpen; + } else { + startPath = false; + } + } + } else if (prevItem == null && startPath) { + // if LPAREN, we need to analyze context: a localOpen is still part of the path + IElementType itemType = item.getNode().getElementType(); + PsiElement parent = item.getParent(); + startPath = itemType == types.LPAREN && parent instanceof PsiLocalOpen; + } + + item = prevItem == null ? item.getParent() : prevItem; + } + + return instructions; + } + + static @NotNull Deque resolveInstructions(@NotNull Deque instructions, @NotNull Project project) { + Deque resolvedInstructions = new LinkedList<>(); + + while (!instructions.isEmpty()) { + PsiElement psiElement = instructions.removeFirst(); + + if (psiElement instanceof PsiUpperSymbol || psiElement instanceof ORUpperSymbolWithResolution) { + boolean withResolution = psiElement instanceof ORUpperSymbolWithResolution; + PsiElement element = withResolution ? psiElement.getOriginalElement() : psiElement; + String name = element.getText(); + + // Try to resolve the local aliases and deconstruct result path + String[] path = withResolution ? + resolvedInstructions.stream() + .map(codeInstruction -> codeInstruction.mySource instanceof ORLocalAlias ? (ORLocalAlias) codeInstruction.mySource : null) + .filter(item -> item != null && item.isModuleName(name)) + .findFirst() + .map(item -> item.myResolvedAlias.split("\\.")) + .orElse(null) : null; + + if (path != null) { + for (String p : path) { + resolvedInstructions.push(new CodeInstruction(element, p)); + } + } + + // Try to resolve aliases with full path + boolean alreadyReplaced = false; + if (withResolution) { + String qname = name; + Iterator rIt = resolvedInstructions.iterator(); + boolean hasNext = rIt.hasNext(); + while (hasNext) { + CodeInstruction instruction = rIt.next(); + if (instruction.mySource instanceof PsiUpperSymbol) { + qname = instruction.mySource.getText() + "." + qname; + Collection elements = ModuleAliasesIndex.getElements(qname, project, null); + if (elements.isEmpty()) { + hasNext = rIt.hasNext(); + } else { + // Remove all elements until current instruction + CodeInstruction peek = resolvedInstructions.pop(); + while (peek != null && peek.mySource != instruction.mySource) { + peek = resolvedInstructions.pop(); + } + // and replace them with new path + String[] aliasPath = elements.iterator().next().getAlias().split("\\."); + for (String p : aliasPath) { + resolvedInstructions.push(new CodeInstruction(new ORUpperResolvedSymbol(element), p)); + } + hasNext = false; + alreadyReplaced = true; + } + } else { + hasNext = false; + } + } + } + + if (path == null && !alreadyReplaced) { + resolvedInstructions.push(new CodeInstruction(element, name)); + } + } else if (psiElement instanceof PsiLowerSymbol) { + resolvedInstructions.push(new CodeInstruction(psiElement, psiElement.getText())); + } else if (psiElement instanceof PsiInnerModule) { + String alias = ((PsiInnerModule) psiElement).getAlias(); + if (alias == null) { + resolvedInstructions.push(new CodeInstruction(psiElement, ((PsiInnerModule) psiElement).getModuleName())); + } else { + String[] aliasPath = alias.split("\\."); + CodeInstruction localAlias = resolvedInstructions.stream().filter(instruction -> instruction.mySource instanceof ORLocalAlias && ((ORLocalAlias) instruction.mySource).isModuleName(aliasPath[0])).findFirst().orElse(null); + if (localAlias == null) { + PsiElement local = new ORLocalAlias(psiElement, alias); + resolvedInstructions.push(new CodeInstruction(local, (String) null)); + } else { + int pos = alias.indexOf("."); + String newAlias = ((ORLocalAlias) localAlias.mySource).myResolvedAlias + alias.substring(pos); + PsiElement local = new ORLocalAlias(psiElement, newAlias); + resolvedInstructions.push(new CodeInstruction(local, (String) null)); + } + } + } else if (psiElement instanceof PsiOpen) { + String[] tokens = ((PsiOpen) psiElement).getPath().split("\\."); + for (String token : tokens) { + resolvedInstructions.push(new CodeInstruction(psiElement, token)); + } + } else if (psiElement instanceof FileBase) { + resolvedInstructions.push(new CodeInstruction(psiElement, ((FileBase) psiElement).getModuleName())); + } else if (psiElement instanceof PsiNamedElement) { + resolvedInstructions.push(new CodeInstruction(psiElement, ((PsiNamedElement) psiElement).getName())); + } + } + + return resolvedInstructions; + } +} diff --git a/src/com/reason/lang/core/psi/reference/PsiLowerSymbolReference.java b/src/com/reason/lang/core/psi/reference/PsiLowerSymbolReference.java index c974419a6..008c217e7 100644 --- a/src/com/reason/lang/core/psi/reference/PsiLowerSymbolReference.java +++ b/src/com/reason/lang/core/psi/reference/PsiLowerSymbolReference.java @@ -1,15 +1,14 @@ package com.reason.lang.core.psi.reference; import com.intellij.lang.*; +import com.intellij.openapi.project.*; import com.intellij.openapi.util.*; import com.intellij.psi.*; import com.intellij.psi.search.*; -import com.intellij.psi.util.*; import com.intellij.util.*; import com.reason.*; import com.reason.ide.files.*; -import com.reason.ide.search.*; -import com.reason.lang.*; +import com.reason.ide.search.index.*; import com.reason.lang.core.*; import com.reason.lang.core.psi.PsiParameter; import com.reason.lang.core.psi.PsiType; @@ -19,287 +18,156 @@ import org.jetbrains.annotations.*; import java.util.*; -import java.util.function.*; - -import static com.reason.lang.core.ORFileType.*; -import static java.util.stream.Collectors.*; public class PsiLowerSymbolReference extends PsiPolyVariantReferenceBase { + private static final Log LOG = Log.create("ref.lower"); + private static final Log LOG_PERF = Log.create("ref.perf.lower"); - private final Log LOG = Log.create("ref.lower"); - - @Nullable - private final String m_referenceName; + private final @Nullable String myReferenceName; + private final @NotNull ORTypes myTypes; - public PsiLowerSymbolReference(@NotNull PsiLowerSymbol element, @NotNull ORTypes _types) { + public PsiLowerSymbolReference(@NotNull PsiLowerSymbol element, @NotNull ORTypes types) { super(element, TextRange.create(0, element.getTextLength())); - m_referenceName = element.getText(); + myReferenceName = element.getText(); + myTypes = types; } @Override - @NotNull - public ResolveResult[] multiResolve(boolean incompleteCode) { - if (m_referenceName == null) { + public @NotNull ResolveResult[] multiResolve(boolean incompleteCode) { + if (myReferenceName == null) { return ResolveResult.EMPTY_ARRAY; } // If name is used in a definition, it's a declaration not a usage: ie, it's not a reference // http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi_references.html - PsiLowerIdentifier parent = PsiTreeUtil.getParentOfType(myElement, PsiLowerIdentifier.class); - if (parent != null && parent.getNameIdentifier() == myElement) { + if (myElement instanceof PsiLowerIdentifier) { return ResolveResult.EMPTY_ARRAY; } - PsiFinder psiFinder = PsiFinder.getInstance(myElement.getProject()); - LOG.debug("Resolving", m_referenceName); - - List result = new ArrayList<>(); - int resultPosition = Integer.MAX_VALUE; - - // Find potential paths of current element - OrderedPaths potentialPaths = getPotentialPaths(); - LOG.debug(" potential paths", potentialPaths.getValues()); + long startAll = System.currentTimeMillis(); - // Try to find val items + LOG.debug("Find reference for lower symbol", myReferenceName); - Collection vals = psiFinder.findVals(m_referenceName, both); - LOG.debug(" vals", vals); - if (!vals.isEmpty()) { - // Filter the vals, keep the ones with the same qualified name - List filteredVals = - vals.stream().filter(getPathPredicate(potentialPaths)).collect(toList()); - LOG.debug(" filtered vals", filteredVals); + // Gather instructions from element up to the file root + Deque instructions = ORReferenceAnalyzer.createInstructions(myElement, myTypes); - for (PsiVal valResult : filteredVals) { - int valPosition = potentialPaths.getPosition(valResult.getQualifiedName()); - if (-1 < valPosition && valPosition <= resultPosition) { - if (valPosition < resultPosition) { - result.clear(); - resultPosition = valPosition; - } - result.add(valResult); - LOG.debug(" Found intermediate result", valResult, resultPosition); - } else { - LOG.debug(" skip intermediate result", valResult, valPosition); - } - } + if (LOG.isTraceEnabled()) { + LOG.trace(" Instructions: ", Joiner.join(" -> ", instructions)); } - // Try to find let items - - Collection lets = psiFinder.findLets(m_referenceName, both); - LOG.debug(" lets", lets); - - if (!lets.isEmpty()) { - // Filter the lets, keep the ones with the same qualified name - List filteredLets = - lets.stream().filter(getPathPredicate(potentialPaths)).collect(toList()); - LOG.debug(" filtered lets", filteredLets); - - for (PsiLet letResult : filteredLets) { - PsiElement letIdentifier = null; - int letPosition = -1; - if (letResult.isDeconsruction()) { - for (PsiElement deconstructedElement : letResult.getDeconstructedElements()) { - String qname = letResult.getPath() + "." + deconstructedElement.getText(); - letPosition = potentialPaths.getPosition(qname); - if (letPosition != -1) { - letIdentifier = deconstructedElement; - break; - } - } - } else { - letIdentifier = letResult; - letPosition = potentialPaths.getPosition(letResult.getQualifiedName()); - } + long endInstructions = System.currentTimeMillis(); - if (-1 < letPosition && letPosition <= resultPosition) { - if (letPosition < resultPosition) { - result.clear(); - resultPosition = letPosition; - } - result.add(letResult); - LOG.debug(" Found intermediate result", letResult, resultPosition); - } else { - LOG.debug(" skip intermediate result", letResult, letPosition); - } - } + // Resolve aliases in the stack of instructions, this time from file down to element + Deque resolvedInstructions = ORReferenceAnalyzer.resolveInstructions(instructions, myElement.getProject()); + + if (LOG.isTraceEnabled()) { + LOG.trace(" Resolved instructions: " + Joiner.join(" -> ", resolvedInstructions)); } - // Try to find parameter items + long endResolvedInstructions = System.currentTimeMillis(); - Collection parameters = psiFinder.findParameters(m_referenceName, both); - LOG.debug(" parameters", parameters); + // Find all elements by name and create a list of paths + Project project = myElement.getProject(); + ORElementResolver.Resolutions resolutions = project.getService(ORElementResolver.class).getComputation(); + //Module module = Platform.getModule(project, myElement.getContainingFile().getVirtualFile()); + //GlobalSearchScope scope = module == null ? GlobalSearchScope.projectScope(project) : GlobalSearchScope.moduleScope(module); + GlobalSearchScope scope = GlobalSearchScope.allScope(project); - if (!parameters.isEmpty()) { - // Filter the parameters, keep the ones with the same qualified name - List filteredParameters = parameters.stream() - .filter(getPathPredicate(potentialPaths)) - .collect(toList()); - LOG.debug(" filtered parameters", filteredParameters); + Collection types = TypeIndex.getElements(myReferenceName, project, scope); + Collection vals = ValIndex.getElements(myReferenceName, project, scope); + Collection lets = LetIndex.getElements(myReferenceName, project, scope); + Collection externals = ExternalIndex.getElements(myReferenceName, project, scope); + Collection recordFields = RecordFieldIndex.getElements(myReferenceName, project, scope); + Collection parameters = ParameterIndex.getElements(myReferenceName, project, scope); - for (PsiParameter parameter : filteredParameters) { - int parameterPosition = potentialPaths.getPosition(parameter.getQualifiedName()); - if (-1 < parameterPosition && parameterPosition <= resultPosition) { - if (parameterPosition < resultPosition) { - result.clear(); - resultPosition = parameterPosition; - } - result.add(parameter); - LOG.debug(" Found intermediate result", parameter, resultPosition); - } else { - LOG.debug(" skip intermediate result", parameter, parameterPosition); - } - } + if (LOG.isTraceEnabled()) { + LOG.trace(" indexes: types=" + types.size() + ", vals=" + vals.size() + ", lets=" + lets.size() + + ", externals=" + externals.size() + ", fieds=" + recordFields.size() + ", params=" + parameters.size()); } - // Try to find external items + long endIndexes = System.currentTimeMillis(); - Collection externals = psiFinder.findExternals(m_referenceName, both); - LOG.debug(" externals", externals); + resolutions.add(types, false); + resolutions.add(vals, false); + resolutions.add(lets, false); + resolutions.add(externals, false); + resolutions.add(recordFields, false); + resolutions.add(parameters, false); - if (!externals.isEmpty()) { - // Filter the externals, keep the ones with the same qualified name - List filteredExternals = - externals.stream().filter(getPathPredicate(potentialPaths)).collect(toList()); - LOG.debug(" filtered externals", filteredExternals); + long endAddResolutions = System.currentTimeMillis(); - for (PsiQualifiedElement qualifiedElement : filteredExternals) { - int externalPosition = potentialPaths.getPosition(qualifiedElement.getQualifiedName()); - if (-1 < externalPosition && externalPosition <= resultPosition) { - if (externalPosition < resultPosition) { - result.clear(); - resultPosition = externalPosition; - } - result.add(qualifiedElement); - LOG.debug(" Found intermediate result", qualifiedElement, resultPosition); - } else { - LOG.debug(" skip intermediate result", qualifiedElement, externalPosition); - } - } - } + resolutions.addIncludesEquivalence(); - // Try to find type items + long endIncludes = System.currentTimeMillis(); - Collection types = psiFinder.findTypes(m_referenceName, both); - LOG.debug(" types", types); + // Now that everything is resolved, we can use the stack of instructions to add weight to the paths - if (!types.isEmpty()) { - // Filter the types, keep the ones with the same qualified name - List filteredTypes = - types.stream().filter(getPathPredicate(potentialPaths)).collect(toList()); - LOG.debug(" filtered types", filteredTypes); - - for (PsiQualifiedElement qElement : filteredTypes) { - int qPosition = potentialPaths.getPosition(qElement.getQualifiedName()); - if (-1 < qPosition && qPosition <= resultPosition) { - if (qPosition < resultPosition) { - result.clear(); - resultPosition = qPosition; - } - result.add(qElement); - LOG.debug(" Found intermediate result", qElement, resultPosition); - } else { - LOG.debug(" skip intermediate result", qElement, qPosition); + for (CodeInstruction instruction : resolvedInstructions) { + if (instruction.mySource instanceof FileBase) { + resolutions.udpateTerminalWeight(((FileBase) instruction.mySource).getModuleName()); + } else if (instruction.mySource instanceof PsiLowerSymbol) { + resolutions.removeUpper(); + resolutions.updateWeight(null, instruction.myAlternateValues); + } else if (instruction.mySource instanceof PsiUpperSymbol) { + // We're in a path, must be exact + String value = instruction.getFirstValue(); + resolutions.removeIfNotFound(value, instruction.myAlternateValues); + resolutions.updateWeight(value, instruction.myAlternateValues); + } else if (instruction.myValues != null) { + for (String value : instruction.myValues) { + resolutions.updateWeight(value, instruction.myAlternateValues); } } } - // Try to find type fields ! - - Collection recordFields = psiFinder.findRecordFields(m_referenceName, both); - LOG.debug(" record fields", recordFields); - - if (!recordFields.isEmpty()) { - // Filter the fields, keep the ones with the same qualified name - List filteredFields = - recordFields - .stream() - .filter( - element -> { - String qp = element.getPath(); - return m_referenceName.equals(qp) || potentialPaths.contains(qp); - }) - .collect(toList()); - LOG.debug(" filtered fields", filteredFields); - - for (PsiQualifiedElement qElement : filteredFields) { - int qPosition = potentialPaths.getPosition(qElement.getPath()); - if (-1 < qPosition && qPosition <= resultPosition) { - if (qPosition < resultPosition) { - result.clear(); - resultPosition = qPosition; - } - result.add(qElement); - LOG.debug(" Found intermediate result", qElement, resultPosition); - } else { - LOG.debug(" skip intermediate result", qElement, qPosition); - } - } - } + long endUpdateResolutions = System.currentTimeMillis(); - // If module and inclusion is used, try to resolve included expressions from module - List resolvedElements = potentialPaths.getResolvedElements(); - for (int i = 0; i < resolvedElements.size(); i++) { - PsiQualifiedElement resolvedElement = resolvedElements.get(i); - if (i < resultPosition && resolvedElement instanceof PsiModule) { - Collection expressions = - ((PsiModule) resolvedElement) - .getExpressions( - ExpressionScope.pub, element -> m_referenceName.equals(element.getName())); - if (!expressions.isEmpty()) { - result.clear(); - result.add(expressions.iterator().next()); - resultPosition = i; - } - } - } - - // return implementation if an interface file exists - result.sort( - (item1, item2) -> - FileHelper.isInterface(item1.getContainingFile().getFileType()) - ? 1 - : (FileHelper.isInterface(item2.getContainingFile().getFileType()) ? -1 : 0)); + resolutions.removeIncomplete(); + Collection sortedResult = resolutions.resolvedElements(); if (LOG.isDebugEnabled()) { - LOG.debug( - " => found", - Joiner.join( - ", ", - result, - item -> - ((PsiQualifiedElement) item).getQualifiedName() - + " [" - + Platform.getRelativePathToModule(item.getContainingFile()) - + "]")); + LOG.debug(" => found", Joiner.join(", ", sortedResult, + element -> element.getQualifiedName() + + " [" + Platform.getRelativePathToModule(element.getContainingFile()) + "]")); } - ResolveResult[] resolveResults = new ResolveResult[result.size()]; + long endSort = System.currentTimeMillis(); + + ResolveResult[] resolveResults = new ResolveResult[sortedResult.size()]; int i = 0; - for (PsiElement element : result) { - resolveResults[i] = new LowerResolveResult(element, m_referenceName); + for (PsiElement element : sortedResult) { + resolveResults[i] = new LowerResolveResult(element, myReferenceName); i++; } + long endAll = System.currentTimeMillis(); + if (LOG_PERF.isDebugEnabled()) { + LOG_PERF.debug("Resolution of " + myReferenceName + " in " + (endAll - startAll) + "ms => " + + " i:" + (endInstructions - startAll) + "," + + " rI:" + (endResolvedInstructions - endInstructions) + "," + + " id:" + (endIndexes - endResolvedInstructions) + "," + + " aR:" + (endAddResolutions - endIndexes) + "," + + " aI:" + (endIncludes - endAddResolutions) + "," + + " uR:" + (endUpdateResolutions - endIncludes) + "," + + " sort: " + (endSort - endUpdateResolutions) + "" + ); + } + return resolveResults; } - @Nullable @Override - public PsiElement resolve() { + public @Nullable PsiElement resolve() { ResolveResult[] resolveResults = multiResolve(false); return 0 < resolveResults.length ? resolveResults[0].getElement() : null; } @Override - public PsiElement handleElementRename(@NotNull String newName) - throws IncorrectOperationException { + public PsiElement handleElementRename(@NotNull String newName) throws IncorrectOperationException { PsiElement newNameIdentifier = ORCodeFactory.createLetName(myElement.getProject(), newName); - ASTNode newNameNode = - newNameIdentifier == null ? null : newNameIdentifier.getFirstChild().getNode(); + ASTNode newNameNode = newNameIdentifier == null ? null : newNameIdentifier.getFirstChild().getNode(); if (newNameNode != null) { PsiElement nameIdentifier = myElement.getFirstChild(); if (nameIdentifier == null) { @@ -313,107 +181,13 @@ public PsiElement handleElementRename(@NotNull String newName) return myElement; } - @NotNull - private Predicate getPathPredicate(@NotNull OrderedPaths paths) { - return element -> { - if (element instanceof PsiLet && ((PsiLet) element).isDeconsruction()) { - for (PsiElement deconstructedElement : ((PsiLet) element).getDeconstructedElements()) { - String qn = element.getPath() + "." + deconstructedElement.getText(); - if ((m_referenceName != null && m_referenceName.equals(qn)) || paths.contains(qn)) { - return true; - } - } - return false; - } - - String qn = element.getQualifiedName(); - return (m_referenceName != null && m_referenceName.equals(qn)) || paths.contains(qn); - }; - } - - @NotNull - private OrderedPaths getPotentialPaths() { - QNameFinder qnameFinder = PsiFinder.getQNameFinder(myElement.getLanguage()); - GlobalSearchScope scope = GlobalSearchScope.allScope(myElement.getProject()); // in api - - PsiFinder psiFinder = PsiFinder.getInstance(myElement.getProject()); - - OrderedPaths result = new OrderedPaths(); - - List resolvedPaths = new ArrayList<>(); - Set potentialPaths = qnameFinder.extractPotentialPaths(myElement); - for (String pathName : potentialPaths) { - Set moduleAlias = psiFinder.findModuleAlias(pathName, scope); - if (moduleAlias.isEmpty()) { - Set modulesFromQn = psiFinder.findModulesFromQn(pathName, true, both, scope); - if (modulesFromQn.isEmpty()) { - // Not a module but maybe a let or a parameter - PsiLet let = psiFinder.findLetFromQn(pathName); - resolvedPaths.add(let == null ? psiFinder.findParamFromQn(pathName) : let); - } else { - resolvedPaths.addAll(modulesFromQn); - } - } else { - resolvedPaths.addAll(moduleAlias); - } - } - - for (PsiQualifiedElement element : resolvedPaths) { - if (element != null && m_referenceName != null) { - result.add(element, m_referenceName); - } - } - - return result; - } - - static class OrderedPaths { - final List m_elements = new ArrayList<>(); - final List m_paths = new ArrayList<>(); - final Map m_elementIndices = new HashMap<>(); - final Map m_pathIndices = new HashMap<>(); - - void add(@NotNull PsiQualifiedElement element, @NotNull String name) { - String value = - element.getQualifiedName() + (element instanceof PsiParameter ? "" : "." + name); - - if (!m_paths.contains(value)) { - m_paths.add(value); - m_elements.add(element); - m_elementIndices.put(value, m_elements.size() - 1); - m_pathIndices.put(value, m_paths.size() - 1); - } - } - - @NotNull - public List getResolvedElements() { - return m_elements; - } - - @NotNull - public List getValues() { - return m_paths; - } - - public boolean contains(@Nullable String value) { - return value != null && m_pathIndices.containsKey(value); - } - - public int getPosition(@NotNull String value) { - Integer pos = m_pathIndices.get(value); - return pos == null ? -1 : pos; - } - } - public static class LowerResolveResult implements ResolveResult { - private final @NotNull - PsiElement m_referencedIdentifier; + private final @NotNull PsiElement m_referencedIdentifier; public LowerResolveResult(@NotNull PsiElement referencedElement, String sourceName) { - if (referencedElement instanceof PsiLet && ((PsiLet) referencedElement).isDeconsruction()) { + if (referencedElement instanceof PsiLet && ((PsiLet) referencedElement).isDeconstruction()) { PsiElement identifierElement = referencedElement; - for (PsiElement deconstructedElement : - ((PsiLet) referencedElement).getDeconstructedElements()) { + for (PsiElement deconstructedElement : ((PsiLet) referencedElement).getDeconstructedElements()) { if (deconstructedElement.getText().equals(sourceName)) { identifierElement = deconstructedElement; break; @@ -421,15 +195,13 @@ public LowerResolveResult(@NotNull PsiElement referencedElement, String sourceNa } m_referencedIdentifier = identifierElement; } else { - PsiLowerIdentifier identifier = - ORUtil.findImmediateFirstChildOfClass(referencedElement, PsiLowerIdentifier.class); + PsiLowerIdentifier identifier = ORUtil.findImmediateFirstChildOfClass(referencedElement, PsiLowerIdentifier.class); m_referencedIdentifier = identifier == null ? referencedElement : identifier; } } - @Nullable @Override - public PsiElement getElement() { + public @Nullable PsiElement getElement() { return m_referencedIdentifier; } diff --git a/src/com/reason/lang/core/psi/reference/PsiPropertyNameReference.java b/src/com/reason/lang/core/psi/reference/PsiPropertyNameReference.java index f1b0c6a67..ff2342959 100644 --- a/src/com/reason/lang/core/psi/reference/PsiPropertyNameReference.java +++ b/src/com/reason/lang/core/psi/reference/PsiPropertyNameReference.java @@ -3,78 +3,124 @@ import com.intellij.openapi.project.*; import com.intellij.openapi.util.*; import com.intellij.psi.*; -import com.intellij.psi.search.*; import com.reason.*; -import com.reason.ide.search.*; -import com.reason.lang.*; +import com.reason.ide.files.*; +import com.reason.ide.search.index.*; import com.reason.lang.core.psi.PsiParameter; import com.reason.lang.core.psi.*; import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.type.*; import org.jetbrains.annotations.*; import java.util.*; -public class PsiPropertyNameReference extends PsiReferenceBase { - private final Log LOG = Log.create("ref.params"); +public class PsiPropertyNameReference extends PsiPolyVariantReferenceBase { + private static final Log LOG = Log.create("ref.params"); - @Nullable - private final String m_referenceName; + private final @Nullable String myReferenceName; + private final @NotNull ORTypes myTypes; - public PsiPropertyNameReference(@NotNull PsiLeafPropertyName element) { - super(element, TextRange.from(0, element.getTextLength())); - m_referenceName = element.getText(); - } - - @Override - public @Nullable PsiElement resolve() { - if (m_referenceName == null) { - return null; + public PsiPropertyNameReference(@NotNull PsiLeafPropertyName element, @NotNull ORTypes types) { + super(element, TextRange.from(0, element.getTextLength())); + myReferenceName = element.getText(); + myTypes = types; } - Project project = myElement.getProject(); - GlobalSearchScope scope = GlobalSearchScope.allScope(project); + @Override + public @NotNull ResolveResult[] multiResolve(boolean incompleteCode) { + if (myReferenceName == null) { + return ResolveResult.EMPTY_ARRAY; + } - PsiFinder psiFinder = PsiFinder.getInstance(project); + LOG.debug("Find reference for propertyLeaf", myReferenceName); - // Find potential paths of current element - List potentialPaths = getPotentialPaths(psiFinder); - LOG.debug(" potential paths", potentialPaths); + Project project = myElement.getProject(); + ORElementResolver.Resolutions resolutions = project.getService(ORElementResolver.class).getComputation(); - for (String path : potentialPaths) { - PsiParameter parameter = psiFinder.findParameterFromQn(path, scope); - if (parameter != null) { - LOG.debug(" -> Found", parameter); - return parameter.getNameIdentifier(); - } - } + // Comp.make function from module + // Find all elements by name and create a list of paths + resolutions.add(LetIndex.getElements("make", project, null), false); + + // Gather instructions from element up to the file root + Deque instructions = ORReferenceAnalyzer.createInstructions(myElement, myTypes); + + if (LOG.isTraceEnabled()) { + LOG.trace(" Instructions: ", Joiner.join(" -> ", instructions)); + } + + // Resolve aliases in the stack of instructions, this time from file down to element + Deque resolvedInstructions = ORReferenceAnalyzer.resolveInstructions(instructions, myElement.getProject()); + + if (LOG.isTraceEnabled()) { + LOG.trace(" Resolved instructions: " + Joiner.join(" -> ", resolvedInstructions)); + } + + // Now that everything is resolved, we can use the stack of instructions to add weight to the paths + + for (CodeInstruction instruction : resolvedInstructions) { + if (instruction.mySource instanceof FileBase) { + resolutions.udpateTerminalWeight(((FileBase) instruction.mySource).getModuleName()); + } else if (instruction.mySource instanceof PsiLowerSymbol) { + resolutions.removeUpper(); + resolutions.updateWeight(null, instruction.myAlternateValues); + } else if (instruction.myValues != null) { + for (String value : instruction.myValues) { + resolutions.updateWeight(value, instruction.myAlternateValues); + } + } + } - return null; // new ORFakeResolvedElement(myElement); - } - - private List getPotentialPaths(@NotNull PsiFinder psiFinder) { - List result = new ArrayList<>(); - - QNameFinder qnameFinder = PsiFinder.getQNameFinder(myElement.getLanguage()); - PsiElement parent = myElement.getParent(); - PsiElement grandParent = parent == null ? null : parent.getParent(); - PsiElement nameIdentifier = grandParent == null ? null : ((PsiTagStart) grandParent).getNameIdentifier(); - if (nameIdentifier != null) { - Set potentialPaths = qnameFinder.extractPotentialPaths(nameIdentifier); - - List resolvedPaths = new ArrayList<>(); - for (String pathName : potentialPaths) { - PsiLet let = - psiFinder.findLetFromQn(pathName + (pathName.isEmpty() ? "" : ".") + "make"); - if (let != null) { - resolvedPaths.add(let); + resolutions.removeIncomplete(); + Collection sortedResult = resolutions.resolvedElements(); + + if (LOG.isDebugEnabled()) { + LOG.debug(" => found", Joiner.join(", ", sortedResult, + element -> element.getQualifiedName() + + " [" + Platform.getRelativePathToModule(element.getContainingFile()) + "]")); + } + + ResolveResult[] resolveResults = new ResolveResult[sortedResult.size()]; + int i = 0; + for (PsiElement element : sortedResult) { + resolveResults[i] = new JsxTagResolveResult(element, myReferenceName); + i++; } - } - for (PsiQualifiedElement resolvedPath : resolvedPaths) { - result.add(resolvedPath.getQualifiedName() + "[" + m_referenceName + "]"); - } + return resolveResults; } - return result; - } + @Override + public @Nullable PsiElement resolve() { + ResolveResult[] resolveResults = multiResolve(false); + return 0 < resolveResults.length ? resolveResults[0].getElement() : null; + } + + public static class JsxTagResolveResult implements ResolveResult { + private @Nullable PsiElement myReferencedIdentifier = null; + + public JsxTagResolveResult(@NotNull PsiElement referencedElement, String propertyName) { + if (referencedElement instanceof PsiLet) { + PsiFunction function = ((PsiLet) referencedElement).getFunction(); + if (function != null) { + List parameters = function.getParameters(); + for (PsiParameter parameter : parameters) { + if (propertyName.equals(parameter.getName())) { + myReferencedIdentifier = parameter; + break; + } + } + } + } + } + + @Override + public @Nullable PsiElement getElement() { + return myReferencedIdentifier; + } + + @Override + public boolean isValidResult() { + return myReferencedIdentifier != null; + } + } } diff --git a/src/com/reason/lang/core/psi/reference/PsiUpperSymbolReference.java b/src/com/reason/lang/core/psi/reference/PsiUpperSymbolReference.java index 00388b042..d96067b82 100644 --- a/src/com/reason/lang/core/psi/reference/PsiUpperSymbolReference.java +++ b/src/com/reason/lang/core/psi/reference/PsiUpperSymbolReference.java @@ -5,13 +5,10 @@ import com.intellij.openapi.util.*; import com.intellij.psi.*; import com.intellij.psi.search.*; -import com.intellij.psi.util.*; import com.intellij.util.*; -import com.intellij.util.containers.*; import com.reason.*; import com.reason.ide.files.*; -import com.reason.ide.search.*; -import com.reason.lang.*; +import com.reason.ide.search.index.*; import com.reason.lang.core.*; import com.reason.lang.core.psi.*; import com.reason.lang.core.psi.impl.*; @@ -20,57 +17,129 @@ import java.util.*; -import static com.reason.lang.core.ORFileType.*; - public class PsiUpperSymbolReference extends PsiPolyVariantReferenceBase { private static final Log LOG = Log.create("ref.upper"); + private static final Log LOG_PERF = Log.create("ref.perf.upper"); - private final @Nullable String m_referenceName; - private final @NotNull ORTypes m_types; + private final @Nullable String myReferenceName; + private final @NotNull ORTypes myTypes; public PsiUpperSymbolReference(@NotNull PsiUpperSymbol element, @NotNull ORTypes types) { super(element, TextRange.create(0, element.getTextLength())); - m_referenceName = element.getText(); - m_types = types; + myReferenceName = element.getText(); + myTypes = types; } @Override public @NotNull ResolveResult[] multiResolve(boolean incompleteCode) { - if (m_referenceName == null) { + if (myReferenceName == null) { return ResolveResult.EMPTY_ARRAY; } // If name is used in a definition, it's a declaration not a usage: ie, it's not a reference // http://www.jetbrains.org/intellij/sdk/docs/basics/architectural_overview/psi_references.html - PsiUpperIdentifier parent = PsiTreeUtil.getParentOfType(myElement, PsiUpperIdentifier.class); - if (parent != null && parent.getNameIdentifier() == myElement) { + if (myElement instanceof PsiUpperIdentifier) { return ResolveResult.EMPTY_ARRAY; } - LOG.debug("Find reference for upper symbol", m_referenceName); + long startAll = System.currentTimeMillis(); - // Find potential paths of current element - List referencedElements = new ArrayList<>(resolveElementsFromPaths()); - if (referencedElements.isEmpty()) { - LOG.debug(" -> No resolved elements found from paths"); - } else { - if (LOG.isDebugEnabled()) { - LOG.debug(" => found", Joiner.join(", ", referencedElements, item -> item.getQualifiedName() + " [" + Platform.getRelativePathToModule(item.getContainingFile()) + "]")); - } + LOG.debug("Find reference for upper symbol", myReferenceName); - ResolveResult[] resolveResults = new ResolveResult[referencedElements.size()]; + // Gather instructions from element up to the file root + Deque instructions = ORReferenceAnalyzer.createInstructions(myElement, myTypes); + instructions.addLast(myElement); - int i = 0; - for (PsiQualifiedElement referencedElement : referencedElements) { - // A fake module resolve to its file - resolveResults[i] = new UpperResolveResult(referencedElement instanceof PsiFakeModule ? (FileBase) referencedElement.getContainingFile() : referencedElement); - i++; + if (LOG.isTraceEnabled()) { + LOG.trace(" Instructions", Joiner.join(" -> ", instructions)); + } + + long endInstructions = System.currentTimeMillis(); + + // Resolve aliases in the stack of instructions, this time from file down to element + Deque resolvedInstructions = ORReferenceAnalyzer.resolveInstructions(instructions, myElement.getProject()); + + if (LOG.isTraceEnabled()) { + LOG.trace(" Resolved instructions: " + Joiner.join(" -> ", resolvedInstructions)); + } + + long endResolvedInstructions = System.currentTimeMillis(); + + // Find all elements by name and create a list of paths + Project project = myElement.getProject(); + //Module module = Platform.getModule(project, myElement.getContainingFile().getVirtualFile()); + //GlobalSearchScope scope = module == null ? GlobalSearchScope.projectScope(project) : GlobalSearchScope.moduleScope(module); + GlobalSearchScope scope = GlobalSearchScope.allScope(project); + + Collection modules = ModuleIndex.getElements(myReferenceName, project, scope); + Collection variants = VariantIndex.getElements(myReferenceName, project, scope); + Collection exceptions = ExceptionIndex.getElements(myReferenceName, project, scope); + + long endIndexes = System.currentTimeMillis(); + + ORElementResolver.Resolutions resolutions = project.getService(ORElementResolver.class).getComputation(); + resolutions.add(modules, true); + resolutions.add(variants, false); + resolutions.add(exceptions, false); + + //if (LOG.isTraceEnabled()) { + // LOG.trace(" Resolutions", resolutions.myResolutions.values()); + //} + + long endAddResolutions = System.currentTimeMillis(); + + resolutions.addIncludesEquivalence(); + + long endAddIncludes = System.currentTimeMillis(); + + // Now that everything is resolved, we can use the stack of instructions to add weight to the paths + + for (CodeInstruction instruction : resolvedInstructions) { + if (instruction.mySource instanceof FileBase) { + resolutions.udpateTerminalWeight(((FileBase) instruction.mySource).getModuleName()); + } else if (instruction.myValues != null) { + for (String value : instruction.myValues) { + resolutions.updateWeight(value, instruction.myAlternateValues); + } } + } - return resolveResults; + long endUpdateResolutions = System.currentTimeMillis(); + + resolutions.removeIncomplete(); + Collection sortedResult = resolutions.resolvedElements(); + + if (LOG.isDebugEnabled()) { + LOG.debug(" => found", Joiner.join(", ", sortedResult, + element -> element.getQualifiedName() + + " [" + Platform.getRelativePathToModule(element.getContainingFile()) + "]")); } - return ResolveResult.EMPTY_ARRAY; + long endSort = System.currentTimeMillis(); + + ResolveResult[] resolveResults = new ResolveResult[sortedResult.size()]; + + int i = 0; + PsiElement parent = myElement.getParent(); + for (PsiElement element : sortedResult) { + resolveResults[i] = new UpperResolveResult(element, parent); + i++; + } + + long endAll = System.currentTimeMillis(); + if (LOG_PERF.isDebugEnabled()) { + LOG_PERF.debug("Resolution of " + myReferenceName + " in " + (endAll - startAll) + "ms => " + + " in: " + (endInstructions - startAll) + "ms," + + " rI: " + (endResolvedInstructions - endInstructions) + "ms," + + " id: " + (endIndexes - endResolvedInstructions) + "ms, " + + " aR: " + (endAddResolutions - endIndexes) + "ms," + + " aI: " + (endAddIncludes - endAddResolutions) + "ms," + + " uR: " + (endUpdateResolutions - endAddIncludes) + "ms," + + " sort: " + (endSort - endUpdateResolutions) + "ms" + ); + } + + return resolveResults; } @Override @@ -97,66 +166,23 @@ public PsiElement handleElementRename(@NotNull String newName) throws IncorrectO return myElement; } - private @NotNull Set resolveElementsFromPaths() { - Project project = myElement.getProject(); - GlobalSearchScope scope = GlobalSearchScope.allScope(project); - PsiFinder psiFinder = PsiFinder.getInstance(project); - - QNameFinder qnameFinder = PsiFinder.getQNameFinder(myElement.getLanguage()); - Set paths = qnameFinder.extractPotentialPaths(myElement); - if (LOG.isTraceEnabled()) { - LOG.trace(" -> Paths before resolution: " + Joiner.join(", ", paths)); - } - - Set resolvedElements = new ArrayListSet<>(); - for (String path : paths) { - String qn = path + "." + m_referenceName; - - PsiQualifiedElement variant = psiFinder.findVariant(qn, scope); - if (variant != null) { - resolvedElements.add(variant); - } else { - // Trying to resolve variant from the name, - // Variant might be locally open with module name only - and not including type name... qn can't be used - Collection variants = psiFinder.findVariantByName(path, m_referenceName, scope); - if (!variants.isEmpty()) { - resolvedElements.addAll(variants); - } else { - PsiQualifiedElement exception = psiFinder.findException(qn, both, scope); - if (exception != null) { - resolvedElements.add(exception); - } else { - // Don't resolve local module aliases to their real reference: this is needed for refactoring - Set modulesFromQn = psiFinder.findModulesFromQn(qn, false, both, scope); - if (!modulesFromQn.isEmpty()) { - resolvedElements.addAll(modulesFromQn); - } - } - } - } - } - - PsiElement prevSibling = myElement.getPrevSibling(); - if (prevSibling == null || prevSibling.getNode().getElementType() != m_types.DOT) { - Set modulesReference = psiFinder.findModulesFromQn(m_referenceName, true, both, scope); - if (modulesReference.isEmpty()) { - if (LOG.isTraceEnabled()) { - LOG.trace(" -> No module found for qn " + m_referenceName); - } - } else { - resolvedElements.addAll(modulesReference); - } - } - - return resolvedElements; - } - private static class UpperResolveResult implements ResolveResult { private final PsiElement m_referencedIdentifier; - public UpperResolveResult(PsiQualifiedElement referencedElement) { - PsiUpperIdentifier identifier = ORUtil.findImmediateFirstChildOfClass(referencedElement, PsiUpperIdentifier.class); - m_referencedIdentifier = identifier == null ? referencedElement : identifier; + public UpperResolveResult(@NotNull PsiElement referencedElement, @Nullable PsiElement sourceParent) { + if (referencedElement instanceof PsiModule && ((PsiModule) referencedElement).isComponent() && sourceParent instanceof PsiTagStart) { + PsiElement make = ((PsiModule) referencedElement).getLetExpression("make"); + PsiLowerIdentifier identifier = ORUtil.findImmediateFirstChildOfClass(make, PsiLowerIdentifier.class); + m_referencedIdentifier = identifier == null ? referencedElement : identifier; + } else if (referencedElement instanceof PsiFakeModule) { + // A fake module resolve to its file + m_referencedIdentifier = referencedElement.getContainingFile(); + } else if (referencedElement instanceof PsiNameIdentifierOwner) { + m_referencedIdentifier = ((PsiNameIdentifierOwner) referencedElement).getNameIdentifier(); + } else { + PsiUpperIdentifier identifier = ORUtil.findImmediateFirstChildOfClass(referencedElement, PsiUpperIdentifier.class); + m_referencedIdentifier = identifier == null ? referencedElement : identifier; + } } @Override diff --git a/src/com/reason/lang/core/psi/reference/Resolution.java b/src/com/reason/lang/core/psi/reference/Resolution.java new file mode 100644 index 000000000..b9835f568 --- /dev/null +++ b/src/com/reason/lang/core/psi/reference/Resolution.java @@ -0,0 +1,228 @@ +package com.reason.lang.core.psi.reference; + +import com.intellij.psi.*; +import com.intellij.util.*; +import com.reason.*; +import com.reason.ide.files.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; + +class Resolution implements Comparable { + final @NotNull List myElements = new ArrayList<>(); + private final @Nullable String[] myPath; + private @Nullable String[] myAlternatePath; + + int myLevel; // reverse order + boolean myIsComplete = false; + @Nullable Integer[] myWeights; + + public Resolution(@Nullable String[] path, @NotNull PsiQualifiedPathElement element) { + myPath = path; + myLevel = path == null ? -1 : myPath.length - 1; + myElements.add(element); + } + + public Resolution(String[] path, List elements) { + myPath = path; + myLevel = path == null ? -1 : myPath.length - 1; + myElements.addAll(elements); + } + + public static Resolution createAlternate(Resolution resolution, String[] alternatePath) { + Resolution result = new Resolution(resolution.myPath, resolution.myElements); + int newPathLength = alternatePath.length + resolution.myPath.length; + result.myAlternatePath = alternatePath; + result.myLevel = newPathLength - 2; + return result; + } + + public @Nullable String getCurrentName() { + if (0 <= myLevel) { + boolean hasAlternate = myAlternatePath != null; + int alternateLength = hasAlternate ? myAlternatePath.length : 0; + boolean useAlternate = myLevel < alternateLength; + return useAlternate ? myAlternatePath[myLevel] : myPath[myLevel + (hasAlternate ? 1 - alternateLength : 0)]; + } + return null; + } + + public @Nullable Integer getCurrentWeight() { + return myLevel >= 0 ? myWeights[myLevel] : null; + } + + public @Nullable Integer getWeight(int level) { + return myWeights != null && 0 <= level && level < myPath.length ? myWeights[level] : null; + } + + public int getFirstWeight() { + Integer weight = myWeights == null ? null : myWeights[myWeights.length - 1]; + return weight == null ? Integer.MAX_VALUE : weight; + } + + public void updateCurrentWeight(int weight) { + if (myPath == null) { + return; + } + + if (myWeights == null) { + int alternateLength = myAlternatePath != null ? myAlternatePath.length : 0; + int totalLength = myAlternatePath != null ? alternateLength + myPath.length - 1 : myPath.length; + myWeights = new Integer[totalLength]; + myLevel = totalLength - 1; + } + + if (0 <= myLevel) { + myWeights[myLevel] = weight; + } + + myLevel--; + if (myLevel < 0) { + myIsComplete = true; + } + } + + public boolean isLastLevel() { + return myLevel == 0; + } + + public boolean isInterface() { + PsiFile file = myElements.get(0).getContainingFile(); + return file instanceof FileBase && ((FileBase) file).isInterface(); + } + + public String getTopModuleName() { + return myAlternatePath == null ? myPath[0] : myAlternatePath[0]; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + if (myPath != null) { + for (int i = 0; i < myPath.length; i++) { + String item = myPath[i]; + if (i > 0) { + sb.append(", "); + } + sb.append(item).append("-").append(getWeight(i)); + } + } + + PsiQualifiedNamedElement element = myElements.get(0); + return "(" + myIsComplete + ", level:" + myLevel + ", path:[" + sb.toString() + "], element: '" + element.getQualifiedName() + "' " + element.getClass().getSimpleName() + ")"; + } + + /* + public void setAlternatePath(@NotNull String[] alternatePath) { + int newPathLength = alternatePath.length + myPath.length; + myAlternatePath = alternatePath; + myLevel = newPathLength - 2; + } + */ + + public boolean isComplete() { + return myIsComplete; + } + + public String joinPath() { + if (myAlternatePath == null) { + return Joiner.join(".", myPath); + } + + return Joiner.join(".", myAlternatePath) + "." + Joiner.joinFrom(".", myPath, 1); + } + + @Override public int compareTo(@NotNull Resolution o) { + // path with weight are before empty paths + if (myPath == null && o.myPath == null) { + return 0; + } + if (myPath == null) { + return o.getFirstWeight() != Integer.MAX_VALUE ? 1 : -1; + } + if (o.myPath == null) { + return getFirstWeight() != Integer.MAX_VALUE ? -1 : 1; + } + + // first level with a different weight + int r1Length = myPath.length; + int r1Level = r1Length - 1; + int oLength = o.myPath.length; + int oLevel = oLength - 1; + Integer r1Weight = getWeight(r1Level); + Integer oWeight = o.getWeight(oLevel); + while (0 <= r1Level && 0 <= oLevel && r1Weight != null && r1Weight.equals(oWeight)) { + r1Level--; + oLevel--; + r1Weight = getWeight(r1Level); + oWeight = o.getWeight(oLevel); + } + + // Reach end of path for one of the element, longest path win + if (r1Length < oLength) { + return 1; + } + if (r1Length > oLength) { + return -1; + } + + int levels = Integer.compare(r1Weight == null ? Integer.MAX_VALUE : r1Weight, oWeight == null ? Integer.MAX_VALUE : oWeight); + if (levels == 0) { + if (isInterface() && !o.isInterface()) { + return 1; + } + if (!isInterface() && o.isInterface()) { + return -1; + } + } + + return levels; + } + + public boolean isPathEqualTo(@Nullable String[] otherPath) { + if (myAlternatePath == null) { + if (myPath == null) { + return otherPath == null; + } + return otherPath != null && ArrayUtil.equals(myPath, otherPath, String::compareTo); + } + + if (otherPath == null) { + return false; + } + + int totalLength = myAlternatePath.length + myPath.length - 1; + if (totalLength != otherPath.length) { + return false; + } + + for (int i = 0; i < totalLength; i++) { + String value = i < myAlternatePath.length ? myAlternatePath[i] : myPath[i - 1]; + if (!value.equals(otherPath[i])) { + return false; + } + } + + return true; + } + + public String[] augmentPath(String[] path) { + if (myAlternatePath == null && myPath.length == 1) { + return path; + } + + int totalLength = (myAlternatePath == null ? 1 : myAlternatePath.length) + myPath.length - 1; + String[] newPath = new String[path.length + totalLength - 1]; + + System.arraycopy(path, 0, newPath, 0, path.length); + if (myAlternatePath == null) { + System.arraycopy(myPath, 1, newPath, path.length, myPath.length - 1); + } else { + System.arraycopy(myAlternatePath, 1, newPath, path.length, myAlternatePath.length - 1); + System.arraycopy(myPath, 1, newPath, path.length + myAlternatePath.length - 1, myPath.length - 1); + } + + return newPath; + } +} diff --git a/src/com/reason/lang/core/stub/OclStubBasedElementTypes.java b/src/com/reason/lang/core/stub/OclStubBasedElementTypes.java index 3111411d9..bba14eec0 100644 --- a/src/com/reason/lang/core/stub/OclStubBasedElementTypes.java +++ b/src/com/reason/lang/core/stub/OclStubBasedElementTypes.java @@ -1,36 +1,27 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; -import com.reason.lang.core.psi.impl.PsiFakeModule; import com.reason.lang.core.stub.type.*; -import com.reason.lang.ocaml.OclLanguage; +import com.reason.lang.ocaml.*; public interface OclStubBasedElementTypes { - IStubElementType C_FAKE_MODULE = - new PsiFakeModuleStubElementType(OclLanguage.INSTANCE); - IStubElementType C_EXCEPTION_DECLARATION = - new PsiExceptionStubElementType(OclLanguage.INSTANCE); - IStubElementType C_TYPE_DECLARATION = - new PsiTypeStubElementType(OclLanguage.INSTANCE); - IStubElementType C_EXTERNAL_DECLARATION = - new PsiExternalStubElementType(OclLanguage.INSTANCE); - // ? - IStubElementType C_FUN_PARAM = - new PsiParameterStubElementType("C_FUN_PARAM", OclLanguage.INSTANCE); - IStubElementType C_FUNCTOR_PARAM = - new PsiParameterStubElementType("C_FUNCTOR_PARAM", OclLanguage.INSTANCE); - // - IStubElementType C_FUNCTOR_DECLARATION = - new PsiFunctorModuleStubElementType(OclLanguage.INSTANCE); - IStubElementType C_LET_DECLARATION = - new PsiLetStubElementType(OclLanguage.INSTANCE); - IStubElementType C_MODULE_DECLARATION = - new PsiInnerModuleStubElementType(OclLanguage.INSTANCE); - IStubElementType C_RECORD_FIELD = - new PsiRecordFieldStubElementType(OclLanguage.INSTANCE); - IStubElementType C_VAL_DECLARATION = - new PsiValStubElementType(OclLanguage.INSTANCE); - IStubElementType C_VARIANT_DECLARATION = - new PsiVariantStubElementType(OclLanguage.INSTANCE); + IStubElementType C_FAKE_MODULE = new PsiFakeModuleStubElementType(OclLanguage.INSTANCE); + IStubElementType C_FUNCTOR_DECLARATION = new PsiFunctorModuleStubElementType(OclLanguage.INSTANCE); + IStubElementType C_MODULE_DECLARATION = new PsiInnerModuleStubElementType(OclLanguage.INSTANCE); + + IStubElementType C_EXCEPTION_DECLARATION = new PsiExceptionStubElementType(OclLanguage.INSTANCE); + IStubElementType C_TYPE_DECLARATION = new PsiTypeStubElementType(OclLanguage.INSTANCE); + IStubElementType C_EXTERNAL_DECLARATION = new PsiExternalStubElementType(OclLanguage.INSTANCE); + IStubElementType C_LET_DECLARATION = new PsiLetStubElementType(OclLanguage.INSTANCE); + IStubElementType C_RECORD_FIELD = new PsiRecordFieldStubElementType(OclLanguage.INSTANCE); + IStubElementType C_VAL_DECLARATION = new PsiValStubElementType(OclLanguage.INSTANCE); + IStubElementType C_VARIANT_DECLARATION = new PsiVariantStubElementType(OclLanguage.INSTANCE); + + IStubElementType C_INCLUDE = new PsiIncludeStubElementType(OclLanguage.INSTANCE); + IStubElementType C_OPEN = new PsiOpenStubElementType(OclLanguage.INSTANCE); + + // ? + IStubElementType C_FUN_PARAM = new PsiParameterStubElementType("C_FUN_PARAM", OclLanguage.INSTANCE); + IStubElementType C_FUNCTOR_PARAM = new PsiParameterStubElementType("C_FUNCTOR_PARAM", OclLanguage.INSTANCE); } diff --git a/src/com/reason/lang/core/stub/PsiExceptionStub.java b/src/com/reason/lang/core/stub/PsiExceptionStub.java index edddcf808..2134a8c4e 100644 --- a/src/com/reason/lang/core/stub/PsiExceptionStub.java +++ b/src/com/reason/lang/core/stub/PsiExceptionStub.java @@ -1,36 +1,39 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiException; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiExceptionStub extends NamedStubBase { + private final String[] myPath; + private final @NotNull String myQname; + private final @Nullable String myAlias; - private final String m_path; - private final @NotNull String m_qname; + public PsiExceptionStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path, String alias) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myAlias = alias; + } - public PsiExceptionStub( - StubElement parent, @NotNull IStubElementType elementType, String name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - } + public PsiExceptionStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path, String alias) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myAlias = alias; + } - public PsiExceptionStub( - StubElement parent, @NotNull IStubElementType elementType, StringRef name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - } + public String[] getPath() { + return myPath; + } - public String getPath() { - return m_path; - } + public @NotNull String getQualifiedName() { + return myQname; + } - public @NotNull String getQualifiedName() { - return m_qname; - } + public @Nullable String getAlias() { + return myAlias; + } } diff --git a/src/com/reason/lang/core/stub/PsiExternalStub.java b/src/com/reason/lang/core/stub/PsiExternalStub.java index 0f753b5d9..077378797 100644 --- a/src/com/reason/lang/core/stub/PsiExternalStub.java +++ b/src/com/reason/lang/core/stub/PsiExternalStub.java @@ -1,50 +1,39 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiExternal; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiExternalStub extends NamedStubBase { - private final String m_path; - private final @NotNull String m_qname; - private final boolean m_isFunction; + private final String[] myPath; + private final @NotNull String myQname; + private final boolean myIsFunction; - public PsiExternalStub( - StubElement parent, - @NotNull IStubElementType elementType, - String name, - String path, - boolean isFunction) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - m_isFunction = isFunction; - } + public PsiExternalStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path, boolean isFunction) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myIsFunction = isFunction; + } - public PsiExternalStub( - StubElement parent, - @NotNull IStubElementType elementType, - StringRef name, - String path, - boolean isFunction) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - m_isFunction = isFunction; - } + public PsiExternalStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path, boolean isFunction) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myIsFunction = isFunction; + } - public String getPath() { - return m_path; - } + public String[] getPath() { + return myPath; + } - public @NotNull String getQualifiedName() { - return m_qname; - } + public @NotNull String getQualifiedName() { + return myQname; + } - public boolean isFunction() { - return m_isFunction; - } + public boolean isFunction() { + return myIsFunction; + } } diff --git a/src/com/reason/lang/core/stub/PsiIncludeStub.java b/src/com/reason/lang/core/stub/PsiIncludeStub.java new file mode 100644 index 000000000..88e78a2f0 --- /dev/null +++ b/src/com/reason/lang/core/stub/PsiIncludeStub.java @@ -0,0 +1,46 @@ +package com.reason.lang.core.stub; + +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +public class PsiIncludeStub extends StubBase { + @Nullable private final StringRef myFileModule; + private final String myIncludePath; + private final String[] myQualifiedPath; + private final String[] myResolvedPath; + + public PsiIncludeStub(StubElement parent, IStubElementType elementType, @Nullable StringRef fileModule, String includePath, String[] qualifiedPath, String[] resolvedPath) { + super(parent, elementType); + myFileModule = fileModule; + myIncludePath = includePath; + myQualifiedPath = qualifiedPath; + myResolvedPath = resolvedPath; + } + + public PsiIncludeStub(StubElement parent, IStubElementType elementType, @Nullable String fileModule, String includePath, String[] qualifiedPath, String[] resolvedPath) { + super(parent, elementType); + myFileModule = StringRef.fromString(fileModule); + myIncludePath = includePath; + myQualifiedPath = qualifiedPath; + myResolvedPath = resolvedPath; + } + + public String getIncludePath() { + return myIncludePath; + } + + public String[] getQualifiedPath() { + return myQualifiedPath; + } + + @Nullable + public String getFileModule() { + return myFileModule != null ? myFileModule.getString() : null; + } + + public String[] getResolvedPath() { + return myResolvedPath; + } +} diff --git a/src/com/reason/lang/core/stub/PsiLetStub.java b/src/com/reason/lang/core/stub/PsiLetStub.java index 5178f82e6..3a010b12e 100644 --- a/src/com/reason/lang/core/stub/PsiLetStub.java +++ b/src/com/reason/lang/core/stub/PsiLetStub.java @@ -1,55 +1,55 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiLet; -import java.util.List; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; + +import java.util.*; public class PsiLetStub extends NamedStubBase { - private final String m_qname; - private final String m_alias; - private final boolean m_isFunction; - private final List m_deconstructionNames; - - public PsiLetStub( - StubElement parent, - @NotNull IStubElementType elementType, - String name, - String qname, - String alias, - boolean isFunction, - List deconstructionNames) { - super(parent, elementType, name); - m_qname = qname; - m_alias = alias; - m_isFunction = isFunction; - m_deconstructionNames = deconstructionNames; - } - - public PsiLetStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String qname, String alias, boolean isFunction, List deconstructionNames) { - super(parent, elementType, name); - m_qname = qname; - m_alias = alias; - m_isFunction = isFunction; - m_deconstructionNames = deconstructionNames; - } - - public String getQualifiedName() { - return m_qname; - } - - public String getAlias() { - return m_alias; - } - - public boolean isFunction() { - return m_isFunction; - } - - public List getDeconstructionNames() { - return m_deconstructionNames; - } + private final String[] myPath; + private final String myQname; + private final String myAlias; + private final boolean myIsFunction; + private final List myDeconstructionNames; + + public PsiLetStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path, String alias, boolean isFunction, List deconstructionNames) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myAlias = alias; + myIsFunction = isFunction; + myDeconstructionNames = deconstructionNames; + } + + public PsiLetStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path, String alias, boolean isFunction, List deconstructionNames) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myAlias = alias; + myIsFunction = isFunction; + myDeconstructionNames = deconstructionNames; + } + + public String[] getPath() { + return myPath; + } + + public String getQualifiedName() { + return myQname; + } + + public String getAlias() { + return myAlias; + } + + public boolean isFunction() { + return myIsFunction; + } + + public List getDeconstructionNames() { + return myDeconstructionNames; + } } diff --git a/src/com/reason/lang/core/stub/PsiModuleStub.java b/src/com/reason/lang/core/stub/PsiModuleStub.java index 054ec878c..c08b9fada 100644 --- a/src/com/reason/lang/core/stub/PsiModuleStub.java +++ b/src/com/reason/lang/core/stub/PsiModuleStub.java @@ -1,56 +1,85 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiModule; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiModuleStub extends NamedStubBase { - private final @NotNull String m_path; - private final @NotNull String m_qname; - private final String m_alias; - private final boolean m_isComponent; - private final boolean m_isInterface; + private final @Nullable String[] myPath; + private final @Nullable String[] myQualifiedNameAsPath; + private final @NotNull String myQname; + private final String myAlias; + private final boolean myIsComponent; + private final boolean myIsInterface; + private final boolean myIsTopLevel; + private final boolean myIsModuleType; + private final boolean myIsFunctorCall; - public PsiModuleStub(StubElement parent, @NotNull IStubElementType elementType, @Nullable String name, @NotNull String path, String alias, boolean isComponent, boolean isInterface) { + public PsiModuleStub(StubElement parent, @NotNull IStubElementType elementType, @Nullable String name, + @Nullable String[] path, @Nullable String[] qNamePath, String namespace, String alias, boolean isComponent, + boolean isInterface, boolean isTopLevel, boolean isModuleType, boolean isFunctorCall) { super(parent, elementType, name); - m_path = path; - m_qname = path.length() == 0 ? "" + name : path + "." + name; - m_alias = alias; - m_isComponent = isComponent; - m_isInterface = isInterface; + myPath = path; + myQualifiedNameAsPath = qNamePath; + myQname = namespace == null ? path != null && path.length > 0 ? Joiner.join(".", path) + "." + name : "" + name : namespace; + myAlias = alias; + myIsComponent = isComponent; + myIsInterface = isInterface; + myIsTopLevel = isTopLevel; + myIsModuleType = isModuleType; + myIsFunctorCall = isFunctorCall; } - public PsiModuleStub(StubElement parent, @NotNull IStubElementType elementType, @Nullable StringRef name, @NotNull String path, String alias, boolean isComponent, boolean isInterface) { + public PsiModuleStub(StubElement parent, @NotNull IStubElementType elementType, @Nullable StringRef name, + @Nullable String[] path, @Nullable String[] qNamePath, String namespace, String alias, boolean isComponent, + boolean isInterface, boolean isTopLevel, boolean isModuleType, boolean isFunctorCall) { super(parent, elementType, name); - m_path = path; - m_qname = path.length() == 0 ? "" + name : path + "." + name; - m_alias = alias; - m_isComponent = isComponent; - m_isInterface = isInterface; + myPath = path; + myQualifiedNameAsPath = qNamePath; + myQname = namespace == null ? path != null && path.length > 0 ? Joiner.join(".", path) + "." + name : "" + name : namespace; + myAlias = alias; + myIsComponent = isComponent; + myIsInterface = isInterface; + myIsTopLevel = isTopLevel; + myIsModuleType = isModuleType; + myIsFunctorCall = isFunctorCall; } - public @NotNull String getPath() { - return m_path; + public @Nullable String[] getPath() { + return myPath; } - @NotNull - public String getQualifiedName() { - return m_qname; + public @NotNull String getQualifiedName() { + return myQname; } public String getAlias() { - return m_alias; + return myAlias; } public boolean isComponent() { - return m_isComponent; + return myIsComponent; } public boolean isInterface() { - return m_isInterface; + return myIsInterface; + } + + public boolean isTopLevel() { + return myIsTopLevel; + } + + public boolean isModuleType() { + return myIsModuleType; + } + + public boolean isFunctorCall() { + return myIsFunctorCall; + } + + public @Nullable String[] getQualifiedNameAsPath() { + return myQualifiedNameAsPath; } } diff --git a/src/com/reason/lang/core/stub/PsiOpenStub.java b/src/com/reason/lang/core/stub/PsiOpenStub.java new file mode 100644 index 000000000..e9d71a350 --- /dev/null +++ b/src/com/reason/lang/core/stub/PsiOpenStub.java @@ -0,0 +1,17 @@ +package com.reason.lang.core.stub; + +import com.intellij.psi.stubs.*; +import com.reason.lang.core.psi.*; + +public class PsiOpenStub extends StubBase { + private final String myOpenPath; + + public PsiOpenStub(StubElement parent, IStubElementType elementType, String openPath) { + super(parent, elementType); + myOpenPath = openPath; + } + + public String getOpenPath() { + return myOpenPath; + } +} diff --git a/src/com/reason/lang/core/stub/PsiParameterStub.java b/src/com/reason/lang/core/stub/PsiParameterStub.java index f7e014037..433cb3cf2 100644 --- a/src/com/reason/lang/core/stub/PsiParameterStub.java +++ b/src/com/reason/lang/core/stub/PsiParameterStub.java @@ -1,28 +1,31 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiParameter; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiParameterStub extends NamedStubBase { - private final String m_qname; + private final String[] myPath; + private final String myQname; - public PsiParameterStub( - StubElement parent, @NotNull IStubElementType elementType, String name, String qname) { - super(parent, elementType, name); - m_qname = qname; - } + public PsiParameterStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path, String qName) { + super(parent, elementType, name); + myPath = path; + myQname = qName; + } - public PsiParameterStub( - StubElement parent, @NotNull IStubElementType elementType, StringRef name, String qname) { - super(parent, elementType, name); - m_qname = qname; - } + public PsiParameterStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path, String qname) { + super(parent, elementType, name); + myPath = path; + myQname = qname; + } - public String getQualifiedName() { - return m_qname; - } + public String[] getPath() { + return myPath; + } + + public String getQualifiedName() { + return myQname; + } } diff --git a/src/com/reason/lang/core/stub/PsiRecordFieldStub.java b/src/com/reason/lang/core/stub/PsiRecordFieldStub.java index a7c1e83b6..db8859c9a 100644 --- a/src/com/reason/lang/core/stub/PsiRecordFieldStub.java +++ b/src/com/reason/lang/core/stub/PsiRecordFieldStub.java @@ -1,35 +1,32 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiRecordField; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiRecordFieldStub extends NamedStubBase { - private final String m_path; - private final @NotNull String m_qname; + private final String[] myPath; + private final @NotNull String myQname; - public PsiRecordFieldStub( - StubElement parent, @NotNull IStubElementType elementType, String name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - } + public PsiRecordFieldStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + } - public PsiRecordFieldStub( - StubElement parent, @NotNull IStubElementType elementType, StringRef name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - } + public PsiRecordFieldStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + } - public String getPath() { - return m_path; - } + public String[] getPath() { + return myPath; + } - public @NotNull String getQualifiedName() { - return m_qname; - } + public @NotNull String getQualifiedName() { + return myQname; + } } diff --git a/src/com/reason/lang/core/stub/PsiTypeStub.java b/src/com/reason/lang/core/stub/PsiTypeStub.java index a7a95bdd2..bbbe545bf 100644 --- a/src/com/reason/lang/core/stub/PsiTypeStub.java +++ b/src/com/reason/lang/core/stub/PsiTypeStub.java @@ -1,33 +1,53 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiType; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiTypeStub extends NamedStubBase { - private final String m_path; - private final @NotNull String m_qname; - - public PsiTypeStub(StubElement parent, @NotNull IStubElementType elementType, String name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + getName(); - } - - public PsiTypeStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + getName(); - } - - public String getPath() { - return m_path; - } - - public @NotNull String getQualifiedName() { - return m_qname; - } + private final String[] myPath; + private final @NotNull String myQname; + private final boolean myAbstract; + private final boolean myJsObject; + private final boolean myRecord; + + public PsiTypeStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path, boolean isAbstract, boolean isJsObject, boolean record) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + getName(); + myAbstract = isAbstract; + myJsObject = isJsObject; + myRecord = record; + } + + public PsiTypeStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path, boolean isAbstract, boolean isJsObject, boolean isRecord) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + getName(); + myAbstract = isAbstract; + myJsObject = isJsObject; + myRecord = isRecord; + } + + public String[] getPath() { + return myPath; + } + + public @NotNull String getQualifiedName() { + return myQname; + } + + public boolean isAbstract() { + return myAbstract; + } + + public boolean isJsObject() { + return myJsObject; + } + + public boolean isRecord() { + return myRecord; + } } diff --git a/src/com/reason/lang/core/stub/PsiValStub.java b/src/com/reason/lang/core/stub/PsiValStub.java index 97d821630..5ca6b36d9 100644 --- a/src/com/reason/lang/core/stub/PsiValStub.java +++ b/src/com/reason/lang/core/stub/PsiValStub.java @@ -1,40 +1,39 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiVal; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiValStub extends NamedStubBase { - private final String m_path; - private final @NotNull String m_qname; - private final boolean m_isFunction; + private final String[] myPath; + private final @NotNull String myQname; + private final boolean myIsFunction; - public PsiValStub(StubElement parent, @NotNull IStubElementType elementType, String name, String path, boolean isFunction) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - m_isFunction = isFunction; - } + public PsiValStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path, boolean isFunction) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myIsFunction = isFunction; + } - public PsiValStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String path, boolean isFunction) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - m_isFunction = isFunction; - } + public PsiValStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path, boolean isFunction) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + myIsFunction = isFunction; + } - public String getPath() { - return m_path; - } + public String[] getPath() { + return myPath; + } - public @NotNull String getQualifiedName() { - return m_qname; - } + public @NotNull String getQualifiedName() { + return myQname; + } - public boolean isFunction() { - return m_isFunction; - } + public boolean isFunction() { + return myIsFunction; + } } diff --git a/src/com/reason/lang/core/stub/PsiVariantDeclarationStub.java b/src/com/reason/lang/core/stub/PsiVariantDeclarationStub.java index 119f10f99..c39aba5ba 100644 --- a/src/com/reason/lang/core/stub/PsiVariantDeclarationStub.java +++ b/src/com/reason/lang/core/stub/PsiVariantDeclarationStub.java @@ -1,35 +1,32 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; -import com.intellij.psi.stubs.NamedStubBase; -import com.intellij.psi.stubs.StubElement; -import com.intellij.util.io.StringRef; -import com.reason.lang.core.psi.PsiVariantDeclaration; -import org.jetbrains.annotations.NotNull; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.lang.core.psi.*; +import org.jetbrains.annotations.*; public class PsiVariantDeclarationStub extends NamedStubBase { - private final String m_path; - private final @NotNull String m_qname; + private final String[] myPath; + private final @NotNull String myQname; - public PsiVariantDeclarationStub( - StubElement parent, @NotNull IStubElementType elementType, String name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - } + public PsiVariantDeclarationStub(StubElement parent, @NotNull IStubElementType elementType, String name, String[] path) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + } - public PsiVariantDeclarationStub( - StubElement parent, @NotNull IStubElementType elementType, StringRef name, String path) { - super(parent, elementType, name); - m_path = path; - m_qname = path + "." + name; - } + public PsiVariantDeclarationStub(StubElement parent, @NotNull IStubElementType elementType, StringRef name, String[] path) { + super(parent, elementType, name); + myPath = path; + myQname = Joiner.join(".", path) + "." + name; + } - public String getPath() { - return m_path; - } + public String[] getPath() { + return myPath; + } - public @NotNull String getQualifiedName() { - return m_qname; - } + public @NotNull String getQualifiedName() { + return myQname; + } } diff --git a/src/com/reason/lang/core/stub/RescriptStubBasedElementTypes.java b/src/com/reason/lang/core/stub/RescriptStubBasedElementTypes.java index e2c9a02c7..05fd11b1e 100644 --- a/src/com/reason/lang/core/stub/RescriptStubBasedElementTypes.java +++ b/src/com/reason/lang/core/stub/RescriptStubBasedElementTypes.java @@ -1,36 +1,27 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; -import com.reason.lang.core.psi.impl.PsiFakeModule; import com.reason.lang.core.stub.type.*; -import com.reason.lang.napkin.ResLanguage; +import com.reason.lang.napkin.*; public interface RescriptStubBasedElementTypes { - IStubElementType C_FAKE_MODULE = - new PsiFakeModuleStubElementType(ResLanguage.INSTANCE); - IStubElementType C_EXCEPTION_DECLARATION = - new PsiExceptionStubElementType(ResLanguage.INSTANCE); - IStubElementType C_TYPE_DECLARATION = - new PsiTypeStubElementType(ResLanguage.INSTANCE); - IStubElementType C_EXTERNAL_DECLARATION = - new PsiExternalStubElementType(ResLanguage.INSTANCE); - // ? - IStubElementType C_FUN_PARAM = - new PsiParameterStubElementType("C_FUN_PARAM", ResLanguage.INSTANCE); - IStubElementType C_FUNCTOR_PARAM = - new PsiParameterStubElementType("C_FUNCTOR_PARAM", ResLanguage.INSTANCE); - // - IStubElementType C_FUNCTOR_DECLARATION = - new PsiFunctorModuleStubElementType(ResLanguage.INSTANCE); - IStubElementType C_LET_DECLARATION = - new PsiLetStubElementType(ResLanguage.INSTANCE); - IStubElementType C_MODULE_DECLARATION = - new PsiInnerModuleStubElementType(ResLanguage.INSTANCE); - IStubElementType C_RECORD_FIELD = - new PsiRecordFieldStubElementType(ResLanguage.INSTANCE); - IStubElementType C_VAL_DECLARATION = - new PsiValStubElementType(ResLanguage.INSTANCE); - IStubElementType C_VARIANT_DECLARATION = - new PsiVariantStubElementType(ResLanguage.INSTANCE); + IStubElementType C_FAKE_MODULE = new PsiFakeModuleStubElementType(ResLanguage.INSTANCE); + IStubElementType C_FUNCTOR_DECLARATION = new PsiFunctorModuleStubElementType(ResLanguage.INSTANCE); + IStubElementType C_MODULE_DECLARATION = new PsiInnerModuleStubElementType(ResLanguage.INSTANCE); + + IStubElementType C_EXCEPTION_DECLARATION = new PsiExceptionStubElementType(ResLanguage.INSTANCE); + IStubElementType C_TYPE_DECLARATION = new PsiTypeStubElementType(ResLanguage.INSTANCE); + IStubElementType C_EXTERNAL_DECLARATION = new PsiExternalStubElementType(ResLanguage.INSTANCE); + IStubElementType C_LET_DECLARATION = new PsiLetStubElementType(ResLanguage.INSTANCE); + IStubElementType C_RECORD_FIELD = new PsiRecordFieldStubElementType(ResLanguage.INSTANCE); + IStubElementType C_VAL_DECLARATION = new PsiValStubElementType(ResLanguage.INSTANCE); + IStubElementType C_VARIANT_DECLARATION = new PsiVariantStubElementType(ResLanguage.INSTANCE); + + IStubElementType C_INCLUDE = new PsiIncludeStubElementType(ResLanguage.INSTANCE); + IStubElementType C_OPEN = new PsiOpenStubElementType(ResLanguage.INSTANCE); + + // ? + IStubElementType C_FUN_PARAM = new PsiParameterStubElementType("C_FUN_PARAM", ResLanguage.INSTANCE); + IStubElementType C_FUNCTOR_PARAM = new PsiParameterStubElementType("C_FUNCTOR_PARAM", ResLanguage.INSTANCE); } diff --git a/src/com/reason/lang/core/stub/RmlStubBasedElementTypes.java b/src/com/reason/lang/core/stub/RmlStubBasedElementTypes.java index b150b76b9..6a6b3147f 100644 --- a/src/com/reason/lang/core/stub/RmlStubBasedElementTypes.java +++ b/src/com/reason/lang/core/stub/RmlStubBasedElementTypes.java @@ -1,36 +1,27 @@ package com.reason.lang.core.stub; -import com.intellij.psi.stubs.IStubElementType; +import com.intellij.psi.stubs.*; import com.reason.lang.core.psi.*; -import com.reason.lang.core.psi.impl.PsiFakeModule; import com.reason.lang.core.stub.type.*; -import com.reason.lang.reason.RmlLanguage; +import com.reason.lang.reason.*; public interface RmlStubBasedElementTypes { - IStubElementType C_FAKE_MODULE = - new PsiFakeModuleStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_EXCEPTION_DECLARATION = - new PsiExceptionStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_TYPE_DECLARATION = - new PsiTypeStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_EXTERNAL_DECLARATION = - new PsiExternalStubElementType(RmlLanguage.INSTANCE); - // ? - IStubElementType C_FUN_PARAM = - new PsiParameterStubElementType("C_FUN_PARAM", RmlLanguage.INSTANCE); - IStubElementType C_FUNCTOR_PARAM = - new PsiParameterStubElementType("C_FUNCTOR_PARAM", RmlLanguage.INSTANCE); - // - IStubElementType C_FUNCTOR_DECLARATION = - new PsiFunctorModuleStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_LET_DECLARATION = - new PsiLetStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_MODULE_DECLARATION = - new PsiInnerModuleStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_RECORD_FIELD = - new PsiRecordFieldStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_VAL_DECLARATION = - new PsiValStubElementType(RmlLanguage.INSTANCE); - IStubElementType C_VARIANT_DECLARATION = - new PsiVariantStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_FAKE_MODULE = new PsiFakeModuleStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_FUNCTOR_DECLARATION = new PsiFunctorModuleStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_MODULE_DECLARATION = new PsiInnerModuleStubElementType(RmlLanguage.INSTANCE); + + IStubElementType C_EXCEPTION_DECLARATION = new PsiExceptionStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_TYPE_DECLARATION = new PsiTypeStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_EXTERNAL_DECLARATION = new PsiExternalStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_LET_DECLARATION = new PsiLetStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_VAL_DECLARATION = new PsiValStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_RECORD_FIELD = new PsiRecordFieldStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_VARIANT_DECLARATION = new PsiVariantStubElementType(RmlLanguage.INSTANCE); + + IStubElementType C_INCLUDE = new PsiIncludeStubElementType(RmlLanguage.INSTANCE); + IStubElementType C_OPEN = new PsiOpenStubElementType(RmlLanguage.INSTANCE); + + // ? + IStubElementType C_FUN_PARAM = new PsiParameterStubElementType("C_FUN_PARAM", RmlLanguage.INSTANCE); + IStubElementType C_FUNCTOR_PARAM = new PsiParameterStubElementType("C_FUNCTOR_PARAM", RmlLanguage.INSTANCE); } diff --git a/src/com/reason/lang/core/stub/type/NsFileStubElementType.java b/src/com/reason/lang/core/stub/type/NsFileStubElementType.java index 73d453fc8..5f499a074 100644 --- a/src/com/reason/lang/core/stub/type/NsFileStubElementType.java +++ b/src/com/reason/lang/core/stub/type/NsFileStubElementType.java @@ -13,7 +13,7 @@ import org.jetbrains.annotations.NotNull; public class NsFileStubElementType extends IStubFileElementType { - private static final int VERSION = 4; + private static final int VERSION = 7; public static final IStubFileElementType INSTANCE = new NsFileStubElementType(); private NsFileStubElementType() { diff --git a/src/com/reason/lang/core/stub/type/OclFileStubElementType.java b/src/com/reason/lang/core/stub/type/OclFileStubElementType.java index a5edd9c07..259b06962 100644 --- a/src/com/reason/lang/core/stub/type/OclFileStubElementType.java +++ b/src/com/reason/lang/core/stub/type/OclFileStubElementType.java @@ -9,7 +9,7 @@ import org.jetbrains.annotations.*; public class OclFileStubElementType extends IStubFileElementType { - private static final int VERSION = 6; + private static final int VERSION = 8; public static final IStubFileElementType INSTANCE = new OclFileStubElementType(); private OclFileStubElementType() { diff --git a/src/com/reason/lang/core/stub/type/PsiExceptionStubElementType.java b/src/com/reason/lang/core/stub/type/PsiExceptionStubElementType.java index ac110d539..7db5b30ee 100644 --- a/src/com/reason/lang/core/stub/type/PsiExceptionStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiExceptionStubElementType.java @@ -1,69 +1,66 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import com.intellij.util.io.StringRef; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.PsiException; -import com.reason.lang.core.psi.impl.PsiExceptionImpl; -import com.reason.lang.core.stub.PsiExceptionStub; -import com.reason.lang.core.type.ORTypesUtil; -import java.io.IOException; -import org.jetbrains.annotations.NotNull; +import com.intellij.lang.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; -public class PsiExceptionStubElementType extends ORStubElementType { +import java.io.*; - public PsiExceptionStubElementType(Language language) { - super("C_EXCEPTION_DECLARATION", language); - } +public class PsiExceptionStubElementType extends ORStubElementType { + public static final int VERSION = 6; - @NotNull - public PsiException createPsi(@NotNull PsiExceptionStub stub) { - return new PsiExceptionImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); - } + public PsiExceptionStubElementType(Language language) { + super("C_EXCEPTION_DECLARATION", language); + } - @NotNull - public PsiException createPsi(@NotNull ASTNode node) { - return new PsiExceptionImpl(ORTypesUtil.getInstance(getLanguage()), node); - } + @NotNull + public PsiException createPsi(@NotNull PsiExceptionStub stub) { + return new PsiExceptionImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } - @NotNull - public PsiExceptionStub createStub(@NotNull final PsiException psi, StubElement parentStub) { - return new PsiExceptionStub(parentStub, this, psi.getName(), psi.getPath()); - } + @NotNull + public PsiException createPsi(@NotNull ASTNode node) { + return new PsiExceptionImpl(ORTypesUtil.getInstance(getLanguage()), node); + } - public void serialize( - @NotNull final PsiExceptionStub stub, @NotNull final StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); - } + @NotNull + public PsiExceptionStub createStub(@NotNull PsiException psi, StubElement parentStub) { + return new PsiExceptionStub(parentStub, this, psi.getName(), psi.getPath(), psi.getAlias()); + } - @NotNull - public PsiExceptionStub deserialize( - @NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { - StringRef name = dataStream.readName(); - String path = dataStream.readUTFFast(); + public void serialize(@NotNull PsiExceptionStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); + dataStream.writeName(stub.getAlias()); + } - return new PsiExceptionStub(parentStub, this, name, path); - } + @NotNull + public PsiExceptionStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); + StringRef alias = dataStream.readName(); - public void indexStub(@NotNull final PsiExceptionStub stub, @NotNull final IndexSink sink) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.EXCEPTIONS, name); + return new PsiExceptionStub(parentStub, this, name, path, alias == null ? null : alias.getString()); } - String fqn = stub.getQualifiedName(); - sink.occurrence(IndexKeys.EXCEPTIONS_FQN, fqn.hashCode()); - } + public void indexStub(@NotNull PsiExceptionStub stub, @NotNull IndexSink sink) { + String name = stub.getName(); + if (name != null) { + sink.occurrence(IndexKeys.EXCEPTIONS, name); + } - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); - } + String fqn = stub.getQualifiedName(); + sink.occurrence(IndexKeys.EXCEPTIONS_FQN, fqn.hashCode()); + } + + @NotNull + public String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } } diff --git a/src/com/reason/lang/core/stub/type/PsiExternalStubElementType.java b/src/com/reason/lang/core/stub/type/PsiExternalStubElementType.java index 756978b6c..e010cce32 100644 --- a/src/com/reason/lang/core/stub/type/PsiExternalStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiExternalStubElementType.java @@ -1,65 +1,63 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; +import com.intellij.lang.*; import com.intellij.psi.stubs.*; -import com.intellij.util.io.StringRef; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.PsiExternal; -import com.reason.lang.core.psi.impl.PsiExternalImpl; -import com.reason.lang.core.stub.PsiExternalStub; -import com.reason.lang.core.type.ORTypesUtil; -import java.io.IOException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.util.io.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.io.*; public class PsiExternalStubElementType extends ORStubElementType { + public static final int VERSION = 8; - public PsiExternalStubElementType(@Nullable Language language) { - super("C_EXTERNAL_DECLARATION", language); - } + public PsiExternalStubElementType(@Nullable Language language) { + super("C_EXTERNAL_DECLARATION", language); + } - @NotNull - public PsiExternalImpl createPsi(@NotNull PsiExternalStub stub) { - return new PsiExternalImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); - } + @NotNull + public PsiExternalImpl createPsi(@NotNull PsiExternalStub stub) { + return new PsiExternalImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } - @NotNull - public PsiExternalImpl createPsi(@NotNull ASTNode node) { - return new PsiExternalImpl(ORTypesUtil.getInstance(getLanguage()), node); - } + @NotNull + public PsiExternalImpl createPsi(@NotNull ASTNode node) { + return new PsiExternalImpl(ORTypesUtil.getInstance(getLanguage()), node); + } - @NotNull - public PsiExternalStub createStub(@NotNull PsiExternal psi, StubElement parentStub) { - return new PsiExternalStub(parentStub, this, psi.getName(), psi.getPath(), psi.isFunction()); - } + @NotNull + public PsiExternalStub createStub(@NotNull PsiExternal psi, StubElement parentStub) { + return new PsiExternalStub(parentStub, this, psi.getName(), psi.getPath(), psi.isFunction()); + } - public void serialize(@NotNull PsiExternalStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); - dataStream.writeBoolean(stub.isFunction()); - } + public void serialize(@NotNull PsiExternalStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); + dataStream.writeBoolean(stub.isFunction()); + } - @NotNull - public PsiExternalStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - StringRef name = dataStream.readName(); - String path = dataStream.readUTFFast(); - boolean isFunction = dataStream.readBoolean(); + @NotNull + public PsiExternalStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); + boolean isFunction = dataStream.readBoolean(); - return new PsiExternalStub(parentStub, this, name, path, isFunction); - } + return new PsiExternalStub(parentStub, this, name, path, isFunction); + } - public void indexStub(@NotNull PsiExternalStub stub, @NotNull IndexSink sink) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.EXTERNALS, name); + public void indexStub(@NotNull PsiExternalStub stub, @NotNull IndexSink sink) { + String name = stub.getName(); + if (name != null) { + sink.occurrence(IndexKeys.EXTERNALS, name); + } } - } - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); - } + @NotNull + public String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } } diff --git a/src/com/reason/lang/core/stub/type/PsiFakeModuleStubElementType.java b/src/com/reason/lang/core/stub/type/PsiFakeModuleStubElementType.java index 2f2866e12..368c5734c 100644 --- a/src/com/reason/lang/core/stub/type/PsiFakeModuleStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiFakeModuleStubElementType.java @@ -1,105 +1,23 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.PsiElement; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import com.intellij.testFramework.LightVirtualFile; -import com.intellij.util.io.StringRef; -import com.reason.bs.BsConfigReader; -import com.reason.bs.BsPlatform; -import com.reason.ide.files.FileBase; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.impl.PsiFakeModule; -import com.reason.lang.core.stub.PsiModuleStub; -import com.reason.lang.core.type.ORTypesUtil; +import com.intellij.lang.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; -import java.io.IOException; - -import org.jetbrains.annotations.NotNull; - -public class PsiFakeModuleStubElementType extends ORStubElementType { +public class PsiFakeModuleStubElementType extends PsiModuleStubElementType implements ORCompositeType { public PsiFakeModuleStubElementType(Language language) { super("C_FAKE_MODULE", language); } @NotNull - public PsiFakeModule createPsi(@NotNull final PsiModuleStub stub) { - return new PsiFakeModule(ORTypesUtil.getInstance(getLanguage()), stub, this); - } - - @Override - public @NotNull PsiElement createPsi(ASTNode node) { + public PsiFakeModule createPsi(@NotNull final ASTNode node) { return new PsiFakeModule(ORTypesUtil.getInstance(getLanguage()), node); } @NotNull - public PsiModuleStub createStub(@NotNull final PsiFakeModule fakeModule, final StubElement parentStub) { - FileBase file = (FileBase) fakeModule.getContainingFile(); - - // Finding if it's using a bs virtual namespace - VirtualFile virtualFile = file.getViewProvider().getVirtualFile(); - VirtualFile originalFile = - virtualFile instanceof LightVirtualFile - ? ((LightVirtualFile) virtualFile).getOriginalFile() - : virtualFile; - String namespace = - originalFile == null - ? null - : BsPlatform.findBsConfig(file.getProject(), originalFile) - .map((bsConfig) -> BsConfigReader.read(bsConfig).getNamespace()) - .orElse(null); - - return new PsiModuleStub( - parentStub, - this, - file.getModuleName(), - namespace == null ? "" : namespace, - null, - file.isComponent(), - file.isInterface()); - } - - public void serialize(@NotNull final PsiModuleStub stub, @NotNull final StubOutputStream dataStream) throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getQualifiedName()); - dataStream.writeBoolean(stub.isComponent()); - dataStream.writeBoolean(stub.isInterface()); - } - - @NotNull - public PsiModuleStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { - StringRef moduleName = dataStream.readName(); - String qname = dataStream.readUTFFast(); - boolean isComponent = dataStream.readBoolean(); - boolean isInterface = dataStream.readBoolean(); - - return new PsiModuleStub(parentStub, this, moduleName, qname, null, isComponent, isInterface); - } - - public void indexStub(@NotNull final PsiModuleStub stub, @NotNull final IndexSink sink) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.MODULES, name); - sink.occurrence(IndexKeys.MODULES_TOP_LEVEL, name); - if (stub.isComponent()) { - sink.occurrence(IndexKeys.MODULES_COMP, name); - } - } - - int fqnHash = stub.getQualifiedName().hashCode(); - sink.occurrence(IndexKeys.MODULES_FQN, fqnHash); - if (stub.isComponent()) { - sink.occurrence(IndexKeys.MODULES_COMP_FQN, fqnHash); - } - } - - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); + public PsiFakeModule createPsi(@NotNull final PsiModuleStub stub) { + return new PsiFakeModule(ORTypesUtil.getInstance(getLanguage()), stub, this); } } diff --git a/src/com/reason/lang/core/stub/type/PsiIncludeStubElementType.java b/src/com/reason/lang/core/stub/type/PsiIncludeStubElementType.java new file mode 100644 index 000000000..a3e9bfe2a --- /dev/null +++ b/src/com/reason/lang/core/stub/type/PsiIncludeStubElementType.java @@ -0,0 +1,59 @@ +package com.reason.lang.core.stub.type; + +import com.intellij.lang.*; +import com.intellij.psi.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.*; +import com.reason.ide.files.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.io.*; + +public class PsiIncludeStubElementType extends ORStubElementType { + public static final int VERSION = 2; + + public PsiIncludeStubElementType(@Nullable Language language) { + super("C_INCLUDE", language); + } + + @Override public PsiInclude createPsi(@NotNull PsiIncludeStub stub) { + return new PsiIncludeImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } + + @Override public @NotNull PsiElement createPsi(ASTNode node) { + return new PsiIncludeImpl(ORTypesUtil.getInstance(getLanguage()), node); + } + + @Override public @NotNull PsiIncludeStub createStub(@NotNull PsiInclude psi, StubElement parentStub) { + return new PsiIncludeStub(parentStub, this, ((FileBase) psi.getContainingFile()).getModuleName(), psi.getIncludePath(), psi.getQualifiedPath(), psi.getResolvedPath()); + } + + @Override public void serialize(@NotNull PsiIncludeStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getFileModule()); + dataStream.writeUTFFast(stub.getIncludePath()); + SerializerUtil.writePath(dataStream, stub.getQualifiedPath()); + SerializerUtil.writePath(dataStream, stub.getResolvedPath()); + } + + @Override public @NotNull PsiIncludeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + StringRef fileModule = dataStream.readName(); + String includePath = dataStream.readUTFFast(); + String[] qualifiedPath = SerializerUtil.readPath(dataStream); + String[] resolvedPath = SerializerUtil.readPath(dataStream); + return new PsiIncludeStub(parentStub, this, fileModule, includePath, qualifiedPath, resolvedPath); + } + + @Override public void indexStub(@NotNull PsiIncludeStub stub, @NotNull IndexSink sink) { + sink.occurrence(IndexKeys.INCLUDES, Joiner.join(".", stub.getResolvedPath())); + } + + @Override public @NotNull String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } +} diff --git a/src/com/reason/lang/core/stub/type/PsiLetStubElementType.java b/src/com/reason/lang/core/stub/type/PsiLetStubElementType.java index e43c6d2d4..554b2e65e 100644 --- a/src/com/reason/lang/core/stub/type/PsiLetStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiLetStubElementType.java @@ -1,128 +1,113 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; -import com.intellij.psi.PsiElement; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import com.intellij.util.io.StringRef; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.impl.PsiLetImpl; -import com.reason.lang.core.psi.impl.PsiLowerIdentifier; -import com.reason.lang.core.stub.PsiLetStub; -import com.reason.lang.core.type.ORTypesUtil; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.lang.*; +import com.intellij.psi.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.io.*; +import java.util.*; public class PsiLetStubElementType extends ORStubElementType { + public static final int VERSION = 12; - public PsiLetStubElementType(@Nullable Language language) { - super("C_LET_DECLARATION", language); - } - - @NotNull - public PsiLetImpl createPsi(@NotNull PsiLetStub stub) { - return new PsiLetImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); - } - - @Override - public @NotNull PsiElement createPsi(ASTNode node) { - return new PsiLetImpl(ORTypesUtil.getInstance(getLanguage()), node); - } - - @NotNull - public PsiLetStub createStub(@NotNull PsiLet psi, StubElement parentStub) { - List deconstructedNames = new ArrayList<>(); - if (psi.isDeconsruction()) { - List elements = psi.getDeconstructedElements(); - for (PsiElement element : elements) { - if (element instanceof PsiLowerIdentifier) { - deconstructedNames.add(element.getText()); - } - } + public PsiLetStubElementType(@Nullable Language language) { + super("C_LET_DECLARATION", language); } - return new PsiLetStub( - parentStub, - this, - psi.getName(), - psi.getQualifiedName(), - psi.getAlias(), - psi.isFunction(), - deconstructedNames); - } - - public void serialize(@NotNull PsiLetStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getQualifiedName()); - dataStream.writeBoolean(stub.isFunction()); - - List deconstructionNames = stub.getDeconstructionNames(); - dataStream.writeByte(deconstructionNames.size()); - if (!deconstructionNames.isEmpty()) { - for (String name : deconstructionNames) { - dataStream.writeUTFFast(name); - } + + @NotNull + public PsiLetImpl createPsi(@NotNull PsiLetStub stub) { + return new PsiLetImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); } - String alias = stub.getAlias(); - dataStream.writeBoolean(alias != null); - if (alias != null) { - dataStream.writeUTFFast(stub.getAlias()); + @Override + public @NotNull PsiElement createPsi(ASTNode node) { + return new PsiLetImpl(ORTypesUtil.getInstance(getLanguage()), node); } - } - - @NotNull - public PsiLetStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - StringRef name = dataStream.readName(); - String qname = dataStream.readUTFFast(); - boolean isFunction = dataStream.readBoolean(); - - List deconstructionNames = new ArrayList<>(); - byte namesCount = dataStream.readByte(); - if (namesCount > 0) { - for (int i = 0; i < namesCount; i++) { - deconstructionNames.add(dataStream.readUTFFast()); - } + + @NotNull + public PsiLetStub createStub(@NotNull PsiLet psi, StubElement parentStub) { + List deconstructedNames = new ArrayList<>(); + if (psi.isDeconstruction()) { + List elements = psi.getDeconstructedElements(); + for (PsiElement element : elements) { + if (element instanceof PsiLowerIdentifier) { + deconstructedNames.add(element.getText()); + } + } + } + return new PsiLetStub(parentStub, this, psi.getName(), psi.getPath(), psi.getAlias(), psi.isFunction(), deconstructedNames); } - String alias = null; - boolean isAlias = dataStream.readBoolean(); - if (isAlias) { - alias = dataStream.readUTFFast(); + public void serialize(@NotNull PsiLetStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); + dataStream.writeBoolean(stub.isFunction()); + + List deconstructionNames = stub.getDeconstructionNames(); + dataStream.writeByte(deconstructionNames.size()); + if (!deconstructionNames.isEmpty()) { + for (String name : deconstructionNames) { + dataStream.writeUTFFast(name); + } + } + + String alias = stub.getAlias(); + dataStream.writeBoolean(alias != null); + if (alias != null) { + dataStream.writeUTFFast(stub.getAlias()); + } } - return new PsiLetStub(parentStub, this, name, qname, alias, isFunction, deconstructionNames); - } - - public void indexStub(@NotNull PsiLetStub stub, @NotNull IndexSink sink) { - List deconstructionNames = stub.getDeconstructionNames(); - if (deconstructionNames.isEmpty()) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.LETS, name); - } - } else { - for (String name : deconstructionNames) { - sink.occurrence(IndexKeys.LETS, name); - } + @NotNull + public PsiLetStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); + boolean isFunction = dataStream.readBoolean(); + + List deconstructionNames = new ArrayList<>(); + byte namesCount = dataStream.readByte(); + if (namesCount > 0) { + for (int i = 0; i < namesCount; i++) { + deconstructionNames.add(dataStream.readUTFFast()); + } + } + + String alias = null; + boolean isAlias = dataStream.readBoolean(); + if (isAlias) { + alias = dataStream.readUTFFast(); + } + + return new PsiLetStub(parentStub, this, name, path, alias, isFunction, deconstructionNames); } - String fqn = stub.getQualifiedName(); - if (fqn != null) { - sink.occurrence(IndexKeys.LETS_FQN, fqn.hashCode()); + public void indexStub(@NotNull PsiLetStub stub, @NotNull IndexSink sink) { + List deconstructionNames = stub.getDeconstructionNames(); + if (deconstructionNames.isEmpty()) { + String name = stub.getName(); + if (name != null) { + sink.occurrence(IndexKeys.LETS, name); + } + } else { + for (String name : deconstructionNames) { + sink.occurrence(IndexKeys.LETS, name); + } + } + + String fqn = stub.getQualifiedName(); + if (fqn != null) { + sink.occurrence(IndexKeys.LETS_FQN, fqn.hashCode()); + } } - } - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); - } + public @NotNull String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } } diff --git a/src/com/reason/lang/core/stub/type/PsiModuleStubElementType.java b/src/com/reason/lang/core/stub/type/PsiModuleStubElementType.java index f72e3f80b..16bd31690 100644 --- a/src/com/reason/lang/core/stub/type/PsiModuleStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiModuleStubElementType.java @@ -1,20 +1,18 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.Language; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import com.intellij.util.io.StringRef; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.PsiModule; -import com.reason.lang.core.stub.PsiModuleStub; +import com.intellij.lang.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import org.jetbrains.annotations.*; -import java.io.IOException; - -import org.jetbrains.annotations.NotNull; +import java.io.*; public abstract class PsiModuleStubElementType extends ORStubElementType { + public static final int VERSION = 22; public PsiModuleStubElementType(@NotNull String name, Language language) { super(name, language); @@ -22,23 +20,25 @@ public PsiModuleStubElementType(@NotNull String name, Language language) { @NotNull public PsiModuleStub createStub(@NotNull final PsiModule psi, final StubElement parentStub) { - return new PsiModuleStub( - parentStub, - this, - psi.getName(), - psi.getPath(), - psi.getAlias(), - psi.isComponent(), - psi.isInterface()); + boolean isModuleType = false; + boolean isFunctorCall = false; + if (psi instanceof PsiInnerModule) { + isModuleType = ((PsiInnerModule) psi).isModuleType(); + isFunctorCall = ((PsiInnerModule) psi).isFunctorCall(); + } + + return new PsiModuleStub(parentStub, this, psi.getName(), psi.getPath(), psi.getQualifiedNameAsPath(), null, psi.getAlias(), psi.isComponent(), psi.isInterface(), psi instanceof PsiFakeModule, isModuleType, isFunctorCall); } - public void serialize( - @NotNull final PsiModuleStub stub, @NotNull final StubOutputStream dataStream) - throws IOException { + public void serialize(@NotNull final PsiModuleStub stub, @NotNull final StubOutputStream dataStream) throws IOException { dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); + SerializerUtil.writePath(dataStream, stub.getPath()); + SerializerUtil.writePath(dataStream, stub.getQualifiedNameAsPath()); dataStream.writeBoolean(stub.isComponent()); dataStream.writeBoolean(stub.isInterface()); + dataStream.writeBoolean(stub.isTopLevel()); + dataStream.writeBoolean(stub.isModuleType()); + dataStream.writeBoolean(stub.isFunctorCall()); String alias = stub.getAlias(); dataStream.writeBoolean(alias != null); @@ -47,13 +47,15 @@ public void serialize( } } - @NotNull - public PsiModuleStub deserialize( - @NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { + public @NotNull PsiModuleStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { StringRef moduleName = dataStream.readName(); - String path = dataStream.readUTFFast(); + String[] path = SerializerUtil.readPath(dataStream); + String[] qNamePath = SerializerUtil.readPath(dataStream); boolean isComponent = dataStream.readBoolean(); boolean isInterface = dataStream.readBoolean(); + boolean isTopLevel = dataStream.readBoolean(); + boolean isModuleType = dataStream.readBoolean(); + boolean isFunctorCall = dataStream.readBoolean(); String alias = null; boolean isAlias = dataStream.readBoolean(); @@ -61,16 +63,26 @@ public PsiModuleStub deserialize( alias = dataStream.readUTFFast(); } - return new PsiModuleStub(parentStub, this, moduleName, path, alias, isComponent, isInterface); + return new PsiModuleStub(parentStub, this, moduleName, path, qNamePath, null, alias, isComponent, isInterface, isTopLevel, isModuleType, isFunctorCall); } public void indexStub(@NotNull final PsiModuleStub stub, @NotNull final IndexSink sink) { String name = stub.getName(); if (name != null) { sink.occurrence(IndexKeys.MODULES, name); + if (stub.isTopLevel()) { + sink.occurrence(IndexKeys.MODULES_TOP_LEVEL, name); + } if (stub.isComponent()) { sink.occurrence(IndexKeys.MODULES_COMP, name); } + String alias = stub.getAlias(); + if (alias != null) { + int pos = alias.indexOf("."); + String topName = pos < 0 ? alias : alias.substring(0, pos); + sink.occurrence(IndexKeys.MODULES_ALIASED, topName); + sink.occurrence(IndexKeys.MODULES_ALIASES, stub.getQualifiedName()); + } } int fqnHash = stub.getQualifiedName().hashCode(); diff --git a/src/com/reason/lang/core/stub/type/PsiOpenStubElementType.java b/src/com/reason/lang/core/stub/type/PsiOpenStubElementType.java new file mode 100644 index 000000000..13ae65031 --- /dev/null +++ b/src/com/reason/lang/core/stub/type/PsiOpenStubElementType.java @@ -0,0 +1,57 @@ +package com.reason.lang.core.stub.type; + +import com.intellij.lang.*; +import com.intellij.psi.*; +import com.intellij.psi.stubs.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.io.*; + +public class PsiOpenStubElementType extends ORStubElementType { + public static final int VERSION = 1; + + public PsiOpenStubElementType(@Nullable Language language) { + super("C_OPEN", language); + } + + @Override + public PsiOpen createPsi(@NotNull PsiOpenStub stub) { + return new PsiOpenImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } + + @Override + public @NotNull PsiElement createPsi(ASTNode node) { + return new PsiOpenImpl(ORTypesUtil.getInstance(getLanguage()), node); + } + + @Override + public @NotNull PsiOpenStub createStub(@NotNull PsiOpen psi, StubElement parentStub) { + return new PsiOpenStub(parentStub, this, psi.getPath()); + } + + @Override + public void serialize(@NotNull PsiOpenStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeUTFFast(stub.getOpenPath()); + } + + @Override + public @NotNull PsiOpenStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + String openPath = dataStream.readUTFFast(); + return new PsiOpenStub(parentStub, this, openPath); + } + + @Override + public void indexStub(@NotNull PsiOpenStub stub, @NotNull IndexSink sink) { + sink.occurrence(IndexKeys.OPENS, stub.getOpenPath()); + } + + @Override + public @NotNull String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } +} diff --git a/src/com/reason/lang/core/stub/type/PsiParameterStubElementType.java b/src/com/reason/lang/core/stub/type/PsiParameterStubElementType.java index 43e47a4c6..59c66d6b0 100644 --- a/src/com/reason/lang/core/stub/type/PsiParameterStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiParameterStubElementType.java @@ -13,13 +13,14 @@ import java.io.*; public class PsiParameterStubElementType extends ORStubElementType { + public static final int VERSION = 4; public PsiParameterStubElementType(@NotNull String name, @NotNull Language language) { super(name, language); } @NotNull - public PsiParameterImpl createPsi(@NotNull final PsiParameterStub stub) { + public PsiParameterImpl createPsi(@NotNull PsiParameterStub stub) { return new PsiParameterImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); } @@ -29,24 +30,25 @@ public PsiParameterImpl createPsi(@NotNull ASTNode node) { } @NotNull - public PsiParameterStub createStub(@NotNull final PsiParameter psi, final StubElement parentStub) { - return new PsiParameterStub(parentStub, this, psi.getName(), psi.getQualifiedName()); + public PsiParameterStub createStub(@NotNull PsiParameter psi, StubElement parentStub) { + return new PsiParameterStub(parentStub, this, psi.getName(), psi.getPath(), psi.getQualifiedName()); } - public void serialize(@NotNull final PsiParameterStub stub, @NotNull final StubOutputStream dataStream) - throws IOException { + public void serialize(@NotNull PsiParameterStub stub, @NotNull StubOutputStream dataStream) throws IOException { dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); dataStream.writeUTFFast(stub.getQualifiedName()); } @NotNull - public PsiParameterStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { + public PsiParameterStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); String qname = dataStream.readUTFFast(); - return new PsiParameterStub(parentStub, this, name, qname); + return new PsiParameterStub(parentStub, this, name, path, qname); } - public void indexStub(@NotNull final PsiParameterStub stub, @NotNull final IndexSink sink) { + public void indexStub(@NotNull PsiParameterStub stub, @NotNull IndexSink sink) { String name = stub.getName(); if (name != null) { sink.occurrence(IndexKeys.PARAMETERS, name); diff --git a/src/com/reason/lang/core/stub/type/PsiRecordFieldStubElementType.java b/src/com/reason/lang/core/stub/type/PsiRecordFieldStubElementType.java index 7aeb1cc08..259e782c1 100644 --- a/src/com/reason/lang/core/stub/type/PsiRecordFieldStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiRecordFieldStubElementType.java @@ -1,67 +1,60 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; -import com.intellij.psi.stubs.IndexSink; -import com.intellij.psi.stubs.StubElement; -import com.intellij.psi.stubs.StubInputStream; -import com.intellij.psi.stubs.StubOutputStream; -import com.intellij.util.io.StringRef; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.PsiRecordField; -import com.reason.lang.core.psi.impl.PsiRecordFieldImpl; -import com.reason.lang.core.stub.PsiRecordFieldStub; -import com.reason.lang.core.type.ORTypesUtil; +import com.intellij.lang.*; +import com.intellij.psi.stubs.*; +import com.intellij.util.io.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + import java.io.*; -import org.jetbrains.annotations.NotNull; -public class PsiRecordFieldStubElementType - extends ORStubElementType { +public class PsiRecordFieldStubElementType extends ORStubElementType { + public static final int VERSION = 4; - public PsiRecordFieldStubElementType(@NotNull Language language) { - super("C_RECORD_FIELD", language); - } + public PsiRecordFieldStubElementType(@NotNull Language language) { + super("C_RECORD_FIELD", language); + } - @NotNull - public PsiRecordFieldImpl createPsi(@NotNull final PsiRecordFieldStub stub) { - return new PsiRecordFieldImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); - } + @NotNull + public PsiRecordFieldImpl createPsi(@NotNull PsiRecordFieldStub stub) { + return new PsiRecordFieldImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } - @NotNull - public PsiRecordFieldImpl createPsi(@NotNull final ASTNode node) { - return new PsiRecordFieldImpl(ORTypesUtil.getInstance(getLanguage()), node); - } + @NotNull + public PsiRecordFieldImpl createPsi(@NotNull ASTNode node) { + return new PsiRecordFieldImpl(ORTypesUtil.getInstance(getLanguage()), node); + } - @NotNull - public PsiRecordFieldStub createStub( - @NotNull final PsiRecordField psi, final StubElement parentStub) { - return new PsiRecordFieldStub(parentStub, this, psi.getName(), psi.getPath()); - } + @NotNull + public PsiRecordFieldStub createStub(@NotNull PsiRecordField psi, StubElement parentStub) { + return new PsiRecordFieldStub(parentStub, this, psi.getName(), psi.getPath()); + } - public void serialize( - @NotNull final PsiRecordFieldStub stub, @NotNull final StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); - } + public void serialize(@NotNull final PsiRecordFieldStub stub, @NotNull final StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); + } - @NotNull - public PsiRecordFieldStub deserialize( - @NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { - StringRef name = dataStream.readName(); - String path = dataStream.readUTFFast(); - return new PsiRecordFieldStub(parentStub, this, name, path); - } + @NotNull + public PsiRecordFieldStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { + StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); + return new PsiRecordFieldStub(parentStub, this, name, path); + } - public void indexStub(@NotNull final PsiRecordFieldStub stub, @NotNull final IndexSink sink) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.RECORD_FIELDS, name); + public void indexStub(@NotNull PsiRecordFieldStub stub, @NotNull IndexSink sink) { + String name = stub.getName(); + if (name != null) { + sink.occurrence(IndexKeys.RECORD_FIELDS, name); + } } - } - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); - } + @NotNull + public String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } } diff --git a/src/com/reason/lang/core/stub/type/PsiTypeStubElementType.java b/src/com/reason/lang/core/stub/type/PsiTypeStubElementType.java index e2a2159eb..9230d0c58 100644 --- a/src/com/reason/lang/core/stub/type/PsiTypeStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiTypeStubElementType.java @@ -13,47 +13,54 @@ import java.io.*; public class PsiTypeStubElementType extends ORStubElementType { + public static final int VERSION = 10; - public PsiTypeStubElementType(@NotNull Language language) { - super("C_TYPE_DECLARATION", language); - } - - public @NotNull PsiTypeImpl createPsi(@NotNull PsiTypeStub stub) { - return new PsiTypeImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); - } + public PsiTypeStubElementType(@NotNull Language language) { + super("C_TYPE_DECLARATION", language); + } - public @NotNull PsiTypeImpl createPsi(@NotNull ASTNode node) { - return new PsiTypeImpl(ORTypesUtil.getInstance(getLanguage()), node); - } + public @NotNull PsiTypeImpl createPsi(@NotNull PsiTypeStub stub) { + return new PsiTypeImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } - public @NotNull PsiTypeStub createStub(@NotNull PsiType psi, StubElement parentStub) { - return new PsiTypeStub(parentStub, this, psi.getName(), psi.getPath()); - } + public @NotNull PsiTypeImpl createPsi(@NotNull ASTNode node) { + return new PsiTypeImpl(ORTypesUtil.getInstance(getLanguage()), node); + } - public void serialize(@NotNull PsiTypeStub stub, @NotNull StubOutputStream dataStream) throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); - } + public @NotNull PsiTypeStub createStub(@NotNull PsiType psi, StubElement parentStub) { + return new PsiTypeStub(parentStub, this, psi.getName(), psi.getPath(), psi.isAbstract(), psi.isJsObject(), psi.isRecord()); + } - @NotNull - public PsiTypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { - StringRef name = dataStream.readName(); - String path = dataStream.readUTFFast(); - return new PsiTypeStub(parentStub, this, name, path); - } + public void serialize(@NotNull PsiTypeStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); + dataStream.writeBoolean(stub.isAbstract()); + dataStream.writeBoolean(stub.isJsObject()); + dataStream.writeBoolean(stub.isRecord()); + } - public void indexStub(@NotNull PsiTypeStub stub, @NotNull IndexSink sink) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.TYPES, name); + @NotNull + public PsiTypeStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); + boolean isAbstract = dataStream.readBoolean(); + boolean isJsObject = dataStream.readBoolean(); + boolean isRecord = dataStream.readBoolean(); + return new PsiTypeStub(parentStub, this, name, path, isAbstract, isJsObject, isRecord); } - String fqn = stub.getQualifiedName(); - sink.occurrence(TypeFqnIndex.getInstance().getKey(), fqn.hashCode()); - } + public void indexStub(@NotNull PsiTypeStub stub, @NotNull IndexSink sink) { + String name = stub.getName(); + if (name != null) { + sink.occurrence(IndexKeys.TYPES, name); + } + + String fqn = stub.getQualifiedName(); + sink.occurrence(IndexKeys.TYPES_FQN, fqn.hashCode()); + } - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); - } + @NotNull + public String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } } diff --git a/src/com/reason/lang/core/stub/type/PsiValStubElementType.java b/src/com/reason/lang/core/stub/type/PsiValStubElementType.java index 35378577b..2315b1bb7 100644 --- a/src/com/reason/lang/core/stub/type/PsiValStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiValStubElementType.java @@ -1,67 +1,66 @@ package com.reason.lang.core.stub.type; -import com.intellij.lang.ASTNode; -import com.intellij.lang.Language; +import com.intellij.lang.*; import com.intellij.psi.stubs.*; -import com.intellij.util.io.StringRef; -import com.reason.ide.search.index.IndexKeys; -import com.reason.lang.core.psi.PsiVal; -import com.reason.lang.core.psi.impl.PsiValImpl; -import com.reason.lang.core.stub.PsiValStub; -import com.reason.lang.core.type.ORTypesUtil; -import java.io.IOException; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.intellij.util.io.*; +import com.reason.ide.search.index.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; +import org.jetbrains.annotations.*; + +import java.io.*; public class PsiValStubElementType extends ORStubElementType { + public static final int VERSION = 11; - public PsiValStubElementType(@Nullable Language language) { - super("C_VAL_DECLARATION", language); - } + public PsiValStubElementType(@Nullable Language language) { + super("C_VAL_DECLARATION", language); + } - @NotNull - public PsiValImpl createPsi(@NotNull ASTNode node) { - return new PsiValImpl(ORTypesUtil.getInstance(getLanguage()), node); - } + @NotNull + public PsiValImpl createPsi(@NotNull ASTNode node) { + return new PsiValImpl(ORTypesUtil.getInstance(getLanguage()), node); + } - @NotNull - public PsiValImpl createPsi(@NotNull PsiValStub stub) { - return new PsiValImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); - } + @NotNull + public PsiValImpl createPsi(@NotNull PsiValStub stub) { + return new PsiValImpl(ORTypesUtil.getInstance(getLanguage()), stub, this); + } - @NotNull - public PsiValStub createStub(@NotNull PsiVal psi, StubElement parentStub) { - return new PsiValStub(parentStub, this, psi.getName(), psi.getPath(), psi.isFunction()); - } + @NotNull + public PsiValStub createStub(@NotNull PsiVal psi, StubElement parentStub) { + return new PsiValStub(parentStub, this, psi.getName(), psi.getPath(), psi.isFunction()); + } - public void serialize(@NotNull PsiValStub stub, @NotNull StubOutputStream dataStream) - throws IOException { - dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); - dataStream.writeBoolean(stub.isFunction()); - } + public void serialize(@NotNull PsiValStub stub, @NotNull StubOutputStream dataStream) throws IOException { + dataStream.writeName(stub.getName()); + SerializerUtil.writePath(dataStream, stub.getPath()); + dataStream.writeBoolean(stub.isFunction()); + } - @NotNull - public PsiValStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { - StringRef name = dataStream.readName(); - String path = dataStream.readUTFFast(); - boolean isFunction = dataStream.readBoolean(); - return new PsiValStub(parentStub, this, name, path, isFunction); - } + @NotNull + public PsiValStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { + StringRef name = dataStream.readName(); + String[] path = SerializerUtil.readPath(dataStream); + boolean isFunction = dataStream.readBoolean(); - public void indexStub(@NotNull PsiValStub stub, @NotNull IndexSink sink) { - String name = stub.getName(); - if (name != null) { - sink.occurrence(IndexKeys.VALS, name); + return new PsiValStub(parentStub, this, name, path, isFunction); } - String fqn = stub.getQualifiedName(); - sink.occurrence(IndexKeys.VALS_FQN, fqn.hashCode()); - } + public void indexStub(@NotNull PsiValStub stub, @NotNull IndexSink sink) { + String name = stub.getName(); + if (name != null) { + sink.occurrence(IndexKeys.VALS, name); + } + + String fqn = stub.getQualifiedName(); + sink.occurrence(IndexKeys.VALS_FQN, fqn.hashCode()); + } - @NotNull - public String getExternalId() { - return getLanguage().getID() + "." + super.toString(); - } + @NotNull + public String getExternalId() { + return getLanguage().getID() + "." + super.toString(); + } } diff --git a/src/com/reason/lang/core/stub/type/PsiVariantStubElementType.java b/src/com/reason/lang/core/stub/type/PsiVariantStubElementType.java index f55fa6413..577fabf4f 100644 --- a/src/com/reason/lang/core/stub/type/PsiVariantStubElementType.java +++ b/src/com/reason/lang/core/stub/type/PsiVariantStubElementType.java @@ -14,15 +14,15 @@ import java.io.IOException; import org.jetbrains.annotations.NotNull; -public class PsiVariantStubElementType - extends ORStubElementType { +public class PsiVariantStubElementType extends ORStubElementType { + public static final int VERSION = 5; public PsiVariantStubElementType(Language language) { super("C_VARIANT_DECLARATION", language); } @NotNull - public PsiVariantDeclaration createPsi(@NotNull final PsiVariantDeclarationStub stub) { + public PsiVariantDeclaration createPsi(@NotNull PsiVariantDeclarationStub stub) { return new PsiVariantDeclaration(ORTypesUtil.getInstance(getLanguage()), stub, this); } @@ -32,29 +32,24 @@ public PsiVariantDeclaration createPsi(@NotNull ASTNode node) { } @NotNull - public PsiVariantDeclarationStub createStub( - @NotNull final PsiVariantDeclaration psi, final StubElement parentStub) { + public PsiVariantDeclarationStub createStub(@NotNull PsiVariantDeclaration psi, StubElement parentStub) { return new PsiVariantDeclarationStub(parentStub, this, psi.getName(), psi.getPath()); } - public void serialize( - @NotNull final PsiVariantDeclarationStub stub, @NotNull final StubOutputStream dataStream) - throws IOException { + public void serialize(@NotNull final PsiVariantDeclarationStub stub, @NotNull final StubOutputStream dataStream) throws IOException { dataStream.writeName(stub.getName()); - dataStream.writeUTFFast(stub.getPath()); + SerializerUtil.writePath(dataStream, stub.getPath()); } @NotNull - public PsiVariantDeclarationStub deserialize( - @NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { + public PsiVariantDeclarationStub deserialize(@NotNull final StubInputStream dataStream, final StubElement parentStub) throws IOException { StringRef moduleName = dataStream.readName(); - String path = dataStream.readUTFFast(); + String[] path = SerializerUtil.readPath(dataStream); return new PsiVariantDeclarationStub(parentStub, this, moduleName, path); } - public void indexStub( - @NotNull final PsiVariantDeclarationStub stub, @NotNull final IndexSink sink) { + public void indexStub(@NotNull final PsiVariantDeclarationStub stub, @NotNull final IndexSink sink) { String name = stub.getName(); if (name != null) { sink.occurrence(IndexKeys.VARIANTS, name); diff --git a/src/com/reason/lang/core/stub/type/RmlFileStubElementType.java b/src/com/reason/lang/core/stub/type/RmlFileStubElementType.java index a9c7b6d12..2203db02f 100644 --- a/src/com/reason/lang/core/stub/type/RmlFileStubElementType.java +++ b/src/com/reason/lang/core/stub/type/RmlFileStubElementType.java @@ -1,20 +1,17 @@ package com.reason.lang.core.stub.type; -import com.intellij.psi.PsiFile; -import com.intellij.psi.StubBuilder; +import com.intellij.psi.*; import com.intellij.psi.stubs.*; -import com.intellij.psi.tree.IStubFileElementType; -import com.reason.ide.files.RmlFile; -import com.reason.ide.files.RmlInterfaceFile; -import com.reason.lang.core.stub.RmlFileStub; -import com.reason.lang.reason.RmlLanguage; +import com.intellij.psi.tree.*; +import com.reason.ide.files.*; +import com.reason.lang.core.stub.*; +import com.reason.lang.reason.*; +import org.jetbrains.annotations.*; -import java.io.IOException; - -import org.jetbrains.annotations.NotNull; +import java.io.*; public class RmlFileStubElementType extends IStubFileElementType { - private static final int VERSION = 6; + private static final int VERSION = 7; public static final IStubFileElementType INSTANCE = new RmlFileStubElementType(); private RmlFileStubElementType() { @@ -42,15 +39,13 @@ public int getStubVersion() { } @Override - public void serialize(@NotNull RmlFileStub stub, @NotNull StubOutputStream dataStream) - throws IOException { + public void serialize(@NotNull RmlFileStub stub, @NotNull StubOutputStream dataStream) throws IOException { dataStream.writeBoolean(stub.isComponent()); } @NotNull @Override - public RmlFileStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) - throws IOException { + public RmlFileStub deserialize(@NotNull StubInputStream dataStream, StubElement parentStub) throws IOException { return new RmlFileStub(null, dataStream.readBoolean()); } diff --git a/src/com/reason/lang/core/stub/type/SerializerUtil.java b/src/com/reason/lang/core/stub/type/SerializerUtil.java new file mode 100644 index 000000000..57e2955e7 --- /dev/null +++ b/src/com/reason/lang/core/stub/type/SerializerUtil.java @@ -0,0 +1,31 @@ +package com.reason.lang.core.stub.type; + +import com.intellij.psi.stubs.*; +import org.jetbrains.annotations.*; + +import java.io.*; + +public class SerializerUtil { + static void writePath(@NotNull StubOutputStream dataStream, @Nullable String[] path) throws IOException { + if (path == null) { + dataStream.writeByte(0); + } else { + dataStream.writeByte(path.length); + for (String name : path) { + dataStream.writeUTFFast(name); + } + } + } + + static @Nullable String[] readPath(@NotNull StubInputStream dataStream) throws IOException { + String[] path = null; + byte namesCount = dataStream.readByte(); + if (namesCount > 0) { + path = new String[namesCount]; + for (int i = 0; i < namesCount; i++) { + path[i] = dataStream.readUTFFast(); + } + } + return path; + } +} diff --git a/src/com/reason/lang/core/type/ORTypes.java b/src/com/reason/lang/core/type/ORTypes.java index 94f911403..3769c098d 100644 --- a/src/com/reason/lang/core/type/ORTypes.java +++ b/src/com/reason/lang/core/type/ORTypes.java @@ -15,6 +15,8 @@ public abstract class ORTypes { public ORCompositeType C_FUNCTOR_PARAM; public ORCompositeType C_RECORD_FIELD; public ORCompositeType C_VARIANT_DECLARATION; + public ORCompositeType C_INCLUDE; + public ORCompositeType C_OPEN; // Composite element types @@ -45,8 +47,6 @@ public abstract class ORTypes { public ORCompositeType C_LOWER_IDENTIFIER; public ORCompositeType C_UPPER_IDENTIFIER; public ORCompositeType C_LOCAL_OPEN; - public ORCompositeType C_OPEN; - public ORCompositeType C_INCLUDE; public ORCompositeType C_LET_ATTR; public ORCompositeType C_LET_BINDING; public ORCompositeType C_LOWER_SYMBOL; @@ -205,7 +205,6 @@ public abstract class ORTypes { public ORTokenElementType VARIANT_NAME; public ORTokenElementType PIPE; public ORTokenElementType PIPE_FORWARD; - public ORTokenElementType PIPE_FIRST; public ORTokenElementType PLUS; public ORTokenElementType PERCENT; public ORTokenElementType PLUSDOT; diff --git a/src/com/reason/lang/napkin/ResFlexLexer.java b/src/com/reason/lang/napkin/ResFlexLexer.java index df5410a18..8b3ea5989 100644 --- a/src/com/reason/lang/napkin/ResFlexLexer.java +++ b/src/com/reason/lang/napkin/ResFlexLexer.java @@ -87,25 +87,24 @@ public static int ZZ_CMAP(int ch) { "\17\4\1\67\2\4\2\5\1\70\1\71\1\72\1\73"+ "\1\74\1\75\1\76\1\77\1\100\1\101\1\102\1\103"+ "\1\104\1\105\1\106\1\107\1\110\1\111\1\112\1\113"+ - "\1\114\1\115\1\0\1\47\1\0\3\47\1\116\1\117"+ - "\1\0\1\120\1\54\2\120\3\0\2\55\1\0\1\121"+ - "\2\4\3\7\4\4\1\122\2\4\1\123\1\4\1\124"+ - "\1\125\1\4\1\126\1\4\1\127\2\4\1\130\1\131"+ - "\1\4\1\132\1\133\1\134\4\4\1\135\10\4\1\136"+ - "\1\137\2\4\1\140\1\141\4\4\1\142\3\4\1\143"+ - "\1\4\2\5\1\144\1\145\6\0\1\4\1\55\1\7"+ - "\1\4\1\146\5\4\1\147\2\4\1\150\1\151\1\152"+ - "\2\4\1\153\11\4\1\154\1\155\1\156\1\157\1\160"+ - "\1\4\1\161\5\4\1\162\1\163\2\0\1\4\1\55"+ - "\2\4\1\164\2\4\1\165\2\4\1\166\10\4\1\167"+ - "\1\170\1\171\2\4\1\172\4\4\1\173\1\174\3\4"+ - "\1\175\1\176\1\177\1\200\1\201\4\4\1\202\1\203"+ - "\2\4\1\204\3\4\1\205\1\4\1\206\1\207\1\4"+ - "\1\210\1\211\1\212\1\213\3\4\1\214\3\4\1\215"+ - "\1\216"; + "\1\114\1\0\1\47\1\0\3\47\1\115\1\116\1\0"+ + "\1\117\1\54\2\117\3\0\2\55\1\0\1\120\2\4"+ + "\3\7\4\4\1\121\2\4\1\122\1\4\1\123\1\124"+ + "\1\4\1\125\1\4\1\126\2\4\1\127\1\130\1\4"+ + "\1\131\1\132\1\133\4\4\1\134\10\4\1\135\1\136"+ + "\2\4\1\137\1\140\4\4\1\141\3\4\1\142\1\4"+ + "\2\5\1\143\1\144\6\0\1\4\1\55\1\7\1\4"+ + "\1\145\5\4\1\146\2\4\1\147\1\150\1\151\2\4"+ + "\1\152\11\4\1\153\1\154\1\155\1\156\1\157\1\4"+ + "\1\160\5\4\1\161\1\162\2\0\1\4\1\55\2\4"+ + "\1\163\2\4\1\164\2\4\1\165\10\4\1\166\1\167"+ + "\1\170\2\4\1\171\4\4\1\172\1\173\3\4\1\174"+ + "\1\175\1\176\1\177\1\200\4\4\1\201\1\202\2\4"+ + "\1\203\3\4\1\204\1\4\1\205\1\206\1\4\1\207"+ + "\1\210\1\211\1\212\3\4\1\213\3\4\1\214\1\215"; private static int [] zzUnpackAction() { - int [] result = new int[358]; + int [] result = new int[357]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -149,35 +148,35 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { "\0\u1d2d\0\u1d7a\0\u1dc7\0\u01ce\0\u1e14\0\u1e61\0\u1eae\0\u1efb"+ "\0\u1f48\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u01ce"+ "\0\u01ce\0\u01ce\0\u1f95\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u01ce"+ - "\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u1fe2\0\u01ce\0\u0dd6\0\u202f"+ - "\0\u207c\0\u20c9\0\u2116\0\u2163\0\u01ce\0\u01ce\0\u0f0a\0\u01ce"+ - "\0\u21b0\0\u21b0\0\u0f57\0\u21fd\0\u224a\0\u2297\0\u01ce\0\u22e4"+ - "\0\u2331\0\u0268\0\u237e\0\u23cb\0\u2418\0\u2465\0\u24b2\0\u24ff"+ - "\0\u254c\0\u2599\0\u25e6\0\u01ce\0\u2633\0\u2680\0\u26cd\0\u271a"+ - "\0\u2767\0\u0268\0\u27b4\0\u0268\0\u2801\0\u0268\0\u284e\0\u289b"+ - "\0\u0268\0\u0268\0\u28e8\0\u0268\0\u0268\0\u0268\0\u2935\0\u2982"+ - "\0\u29cf\0\u2a1c\0\u0268\0\u2a69\0\u2ab6\0\u2b03\0\u2b50\0\u2b9d"+ - "\0\u2bea\0\u2c37\0\u2c84\0\u0268\0\u0268\0\u2cd1\0\u2d1e\0\u0268"+ - "\0\u0268\0\u2d6b\0\u2db8\0\u2e05\0\u2e52\0\u2e9f\0\u2eec\0\u2f39"+ - "\0\u2f86\0\u0268\0\u2fd3\0\u3020\0\u306d\0\u01ce\0\u01ce\0\u30ba"+ - "\0\u3107\0\u3154\0\u31a1\0\u31ee\0\u323b\0\u3288\0\u32d5\0\u108b"+ - "\0\u3322\0\u0268\0\u336f\0\u33bc\0\u3409\0\u3456\0\u34a3\0\u0268"+ - "\0\u34f0\0\u353d\0\u0268\0\u0268\0\u0268\0\u358a\0\u35d7\0\u0268"+ - "\0\u3624\0\u3671\0\u36be\0\u370b\0\u3758\0\u37a5\0\u37f2\0\u383f"+ - "\0\u388c\0\u0268\0\u0268\0\u0268\0\u0268\0\u0268\0\u38d9\0\u0268"+ - "\0\u3926\0\u3973\0\u39c0\0\u3a0d\0\u3a5a\0\u02b5\0\u02b5\0\u3aa7"+ - "\0\u3af4\0\u3b41\0\u108b\0\u3b8e\0\u3bdb\0\u0268\0\u3c28\0\u3c75"+ - "\0\u0268\0\u3cc2\0\u3d0f\0\u0268\0\u3d5c\0\u3da9\0\u3df6\0\u3e43"+ - "\0\u3e90\0\u3edd\0\u3f2a\0\u3f77\0\u0268\0\u0268\0\u0268\0\u3fc4"+ - "\0\u4011\0\u0268\0\u405e\0\u40ab\0\u40f8\0\u4145\0\u0268\0\u0268"+ - "\0\u4192\0\u41df\0\u422c\0\u0268\0\u0268\0\u0268\0\u0268\0\u0268"+ - "\0\u4279\0\u42c6\0\u4313\0\u4360\0\u0268\0\u0268\0\u43ad\0\u43fa"+ - "\0\u0268\0\u4447\0\u4494\0\u44e1\0\u0268\0\u452e\0\u0268\0\u0268"+ - "\0\u457b\0\u0268\0\u0268\0\u0268\0\u0268\0\u45c8\0\u4615\0\u4662"+ - "\0\u0268\0\u46af\0\u46fc\0\u4749\0\u0268\0\u0268"; + "\0\u01ce\0\u01ce\0\u01ce\0\u1fe2\0\u01ce\0\u0dd6\0\u202f\0\u207c"+ + "\0\u20c9\0\u2116\0\u2163\0\u01ce\0\u01ce\0\u0f0a\0\u01ce\0\u21b0"+ + "\0\u21b0\0\u0f57\0\u21fd\0\u224a\0\u2297\0\u01ce\0\u22e4\0\u2331"+ + "\0\u0268\0\u237e\0\u23cb\0\u2418\0\u2465\0\u24b2\0\u24ff\0\u254c"+ + "\0\u2599\0\u25e6\0\u01ce\0\u2633\0\u2680\0\u26cd\0\u271a\0\u2767"+ + "\0\u0268\0\u27b4\0\u0268\0\u2801\0\u0268\0\u284e\0\u289b\0\u0268"+ + "\0\u0268\0\u28e8\0\u0268\0\u0268\0\u0268\0\u2935\0\u2982\0\u29cf"+ + "\0\u2a1c\0\u0268\0\u2a69\0\u2ab6\0\u2b03\0\u2b50\0\u2b9d\0\u2bea"+ + "\0\u2c37\0\u2c84\0\u0268\0\u0268\0\u2cd1\0\u2d1e\0\u0268\0\u0268"+ + "\0\u2d6b\0\u2db8\0\u2e05\0\u2e52\0\u2e9f\0\u2eec\0\u2f39\0\u2f86"+ + "\0\u0268\0\u2fd3\0\u3020\0\u306d\0\u01ce\0\u01ce\0\u30ba\0\u3107"+ + "\0\u3154\0\u31a1\0\u31ee\0\u323b\0\u3288\0\u32d5\0\u108b\0\u3322"+ + "\0\u0268\0\u336f\0\u33bc\0\u3409\0\u3456\0\u34a3\0\u0268\0\u34f0"+ + "\0\u353d\0\u0268\0\u0268\0\u0268\0\u358a\0\u35d7\0\u0268\0\u3624"+ + "\0\u3671\0\u36be\0\u370b\0\u3758\0\u37a5\0\u37f2\0\u383f\0\u388c"+ + "\0\u0268\0\u0268\0\u0268\0\u0268\0\u0268\0\u38d9\0\u0268\0\u3926"+ + "\0\u3973\0\u39c0\0\u3a0d\0\u3a5a\0\u02b5\0\u02b5\0\u3aa7\0\u3af4"+ + "\0\u3b41\0\u108b\0\u3b8e\0\u3bdb\0\u0268\0\u3c28\0\u3c75\0\u0268"+ + "\0\u3cc2\0\u3d0f\0\u0268\0\u3d5c\0\u3da9\0\u3df6\0\u3e43\0\u3e90"+ + "\0\u3edd\0\u3f2a\0\u3f77\0\u0268\0\u0268\0\u0268\0\u3fc4\0\u4011"+ + "\0\u0268\0\u405e\0\u40ab\0\u40f8\0\u4145\0\u0268\0\u0268\0\u4192"+ + "\0\u41df\0\u422c\0\u0268\0\u0268\0\u0268\0\u0268\0\u0268\0\u4279"+ + "\0\u42c6\0\u4313\0\u4360\0\u0268\0\u0268\0\u43ad\0\u43fa\0\u0268"+ + "\0\u4447\0\u4494\0\u44e1\0\u0268\0\u452e\0\u0268\0\u0268\0\u457b"+ + "\0\u0268\0\u0268\0\u0268\0\u0268\0\u45c8\0\u4615\0\u4662\0\u0268"+ + "\0\u46af\0\u46fc\0\u4749\0\u0268\0\u0268"; private static int [] zzUnpackRowMap() { - int [] result = new int[358]; + int [] result = new int[357]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -267,277 +266,276 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { "\1\213\40\0\1\214\1\215\2\0\1\216\47\0\1\217"+ "\157\0\1\220\1\221\1\222\113\0\1\223\1\224\47\0"+ "\1\225\44\0\1\226\110\0\1\227\2\0\1\230\1\0"+ - "\1\231\46\0\1\232\44\0\1\233\2\0\1\234\110\0"+ - "\1\235\122\0\1\236\17\0\1\103\1\237\112\0\1\103"+ - "\1\240\1\241\4\103\1\242\3\103\2\242\1\243\1\103"+ - "\1\244\3\103\1\242\13\103\1\242\22\103\2\0\31\103"+ - "\66\0\1\245\113\0\1\246\30\0\1\113\1\247\120\0"+ - "\1\250\112\0\2\251\1\252\15\251\1\0\2\251\1\0"+ - "\2\251\1\0\3\251\1\0\22\251\42\0\1\253\1\254"+ - "\3\0\2\254\1\255\1\0\1\256\1\0\1\115\1\0"+ - "\1\254\6\0\5\115\1\254\61\0\2\257\1\0\2\121"+ - "\2\0\2\121\4\257\2\0\1\121\1\0\2\122\1\0"+ - "\2\257\1\0\3\257\1\0\1\121\2\0\3\257\1\0"+ - "\13\257\43\0\1\260\3\0\2\260\6\0\1\260\3\0"+ - "\1\261\7\0\1\260\32\0\1\261\26\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\2\12\1\262\1\0\22\12"+ + "\1\231\113\0\1\232\2\0\1\233\110\0\1\234\122\0"+ + "\1\235\17\0\1\103\1\236\112\0\1\103\1\237\1\240"+ + "\4\103\1\241\3\103\2\241\1\242\1\103\1\243\3\103"+ + "\1\241\13\103\1\241\22\103\2\0\31\103\66\0\1\244"+ + "\113\0\1\245\30\0\1\113\1\246\120\0\1\247\112\0"+ + "\2\250\1\251\15\250\1\0\2\250\1\0\2\250\1\0"+ + "\3\250\1\0\22\250\42\0\1\252\1\253\3\0\2\253"+ + "\1\254\1\0\1\255\1\0\1\115\1\0\1\253\6\0"+ + "\5\115\1\253\61\0\2\256\1\0\2\121\2\0\2\121"+ + "\4\256\2\0\1\121\1\0\2\122\1\0\2\256\1\0"+ + "\3\256\1\0\1\121\2\0\3\256\1\0\13\256\43\0"+ + "\1\257\3\0\2\257\6\0\1\257\3\0\1\260\7\0"+ + "\1\257\32\0\1\260\26\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\2\12\1\261\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\10\12"+ + "\1\262\11\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\1\263\2\12\1\0\22\12\43\0\1\264\1\0"+ + "\4\264\4\0\3\264\1\0\2\264\10\0\3\264\3\0"+ + "\1\264\62\0\2\265\6\0\1\265\13\0\1\265\71\0"+ + "\1\266\6\0\1\266\75\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\16\12\1\267\3\12\40\0"+ + "\20\12\1\0\1\270\1\12\1\0\2\12\1\0\1\12"+ + "\1\271\1\12\1\0\22\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\4\12\1\272\15\12"+ + "\60\0\1\273\74\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\1\12\1\274\1\12\1\0\6\12\1\275\13\12"+ "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\10\12\1\263\11\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\264\2\12\1\0\22\12\43\0"+ - "\1\265\1\0\4\265\4\0\3\265\1\0\2\265\10\0"+ - "\3\265\3\0\1\265\62\0\2\266\6\0\1\266\13\0"+ - "\1\266\71\0\1\267\6\0\1\267\75\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\16\12\1\270"+ - "\3\12\40\0\20\12\1\0\1\271\1\12\1\0\2\12"+ - "\1\0\1\12\1\272\1\12\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\4\12"+ - "\1\273\15\12\60\0\1\274\74\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\12\1\275\1\12\1\0\6\12"+ - "\1\276\13\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\2\12\1\277\17\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\3\12"+ - "\1\300\16\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\5\12\1\301\14\12\40\0\15\12"+ - "\1\302\2\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\303\2\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\11\12\1\304"+ - "\10\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\12\12\1\305\1\12\1\306\5\12\40\0"+ - "\20\12\1\0\1\307\1\12\1\0\2\12\1\0\3\12"+ - "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\1\310"+ - "\1\12\1\0\3\12\1\0\22\12\40\0\5\12\1\311"+ - "\12\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\6\12\1\312\13\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\3\12\1\0\5\12\1\313\3\12\1\314"+ - "\10\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\2\12\1\315\17\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\2\12\1\316\1\0\3\12"+ - "\1\317\16\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\320\2\12\1\0\11\12\1\321\10\12\40\0"+ - "\20\12\1\0\2\12\1\0\2\12\1\0\2\12\1\322"+ - "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\4\12\1\323\15\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\5\12"+ - "\1\324\14\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\5\12\1\325\1\326\1\327\12\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\330"+ + "\1\0\2\12\1\276\17\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\3\12\1\277\16\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ + "\1\0\5\12\1\300\14\12\40\0\15\12\1\301\2\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\302"+ "\2\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\1\12\1\331\1\12\1\0\22\12\40\0"+ + "\2\12\1\0\3\12\1\0\11\12\1\303\10\12\40\0"+ "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\1\12\1\332\20\12\40\0\13\12\1\333\4\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ - "\20\12\1\0\2\12\1\0\2\12\1\0\2\12\1\334"+ - "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\12\1\335\1\12\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\1\336\2\12\1\0"+ - "\13\12\1\337\6\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\2\12\1\340\1\0\10\12\1\341\11\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\12"+ - "\1\342\1\12\1\0\22\12\40\0\20\12\1\0\1\343"+ - "\1\12\1\0\2\12\1\0\3\12\1\0\5\12\1\344"+ - "\14\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\5\12\1\345\14\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\2\12\1\346"+ - "\17\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\1\12\1\347\1\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\1\12\1\350\1\12\1\0"+ + "\12\12\1\304\1\12\1\305\5\12\40\0\20\12\1\0"+ + "\1\306\1\12\1\0\2\12\1\0\3\12\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\1\307\1\12\1\0"+ + "\3\12\1\0\22\12\40\0\5\12\1\310\12\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\6\12\1\311"+ + "\13\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\3\12\1\0\5\12\1\312\3\12\1\313\10\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ + "\2\12\1\314\17\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\2\12\1\315\1\0\3\12\1\316\16\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\317"+ + "\2\12\1\0\11\12\1\320\10\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\2\12\1\321\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ + "\1\0\4\12\1\322\15\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\5\12\1\323\14\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ + "\1\0\5\12\1\324\1\325\1\326\12\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\1\327\2\12\1\0"+ "\22\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\1\12\1\351\1\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\10\12\1\352"+ - "\11\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\2\12\1\353\1\0\22\12\40\0\20\13\1\0\2\13"+ - "\1\0\2\13\1\0\1\354\2\13\1\0\22\13\40\0"+ - "\20\13\1\0\2\13\1\0\2\13\1\0\3\13\1\0"+ - "\15\13\1\355\4\13\40\0\20\211\1\0\2\211\1\0"+ - "\2\211\1\0\3\211\1\0\22\211\124\0\1\356\114\0"+ - "\1\357\27\0\1\240\112\0\1\240\1\241\121\0\1\360"+ - "\3\0\2\360\6\0\1\360\13\0\1\360\64\0\1\361"+ - "\1\0\4\361\4\0\3\361\1\0\2\361\10\0\3\361"+ - "\3\0\1\361\63\0\1\362\6\0\1\362\13\0\1\362"+ - "\61\0\20\251\1\0\2\251\1\0\2\251\1\0\3\251"+ - "\1\0\22\251\43\0\1\363\3\0\2\363\6\0\1\363"+ - "\13\0\1\363\64\0\1\364\1\0\4\364\4\0\3\364"+ - "\1\0\2\364\10\0\3\364\3\0\1\364\63\0\1\365"+ - "\6\0\1\365\13\0\1\365\61\0\2\257\1\0\2\260"+ - "\2\0\2\260\4\257\2\0\1\260\4\0\2\257\1\0"+ - "\3\257\1\0\1\260\2\0\3\257\1\0\13\257\43\0"+ - "\1\260\3\0\2\260\6\0\1\260\13\0\1\260\61\0"+ + "\1\12\1\330\1\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\1\12\1\331"+ + "\20\12\40\0\13\12\1\332\4\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\2\12\1\333\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\12"+ + "\1\334\1\12\1\0\22\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\1\335\2\12\1\0\13\12\1\336"+ + "\6\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\2\12\1\337\1\0\10\12\1\340\11\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\1\12\1\341\1\12"+ + "\1\0\22\12\40\0\20\12\1\0\1\342\1\12\1\0"+ + "\2\12\1\0\3\12\1\0\5\12\1\343\14\12\40\0"+ "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\3\12\1\305\16\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\3\12\1\0\6\12\1\366\13\12\40\0"+ - "\2\120\1\0\6\265\4\120\3\265\1\367\2\265\1\0"+ - "\2\370\1\0\3\120\1\0\3\265\3\120\1\265\13\120"+ - "\40\0\2\120\2\0\1\266\2\0\2\266\4\120\2\0"+ - "\1\266\4\0\2\120\1\0\3\120\1\0\1\266\2\0"+ - "\3\120\1\0\13\120\40\0\2\120\2\0\1\267\3\0"+ - "\1\267\4\120\2\0\1\267\4\0\2\120\1\0\3\120"+ - "\4\0\3\120\1\0\13\120\40\0\20\12\1\0\1\371"+ + "\5\12\1\344\14\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\2\12\1\345\17\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\1\12\1\346"+ + "\1\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\1\12\1\347\1\12\1\0\22\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\1\12\1\350"+ + "\1\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\10\12\1\351\11\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\2\12\1\352"+ + "\1\0\22\12\40\0\20\13\1\0\2\13\1\0\2\13"+ + "\1\0\1\353\2\13\1\0\22\13\40\0\20\13\1\0"+ + "\2\13\1\0\2\13\1\0\3\13\1\0\15\13\1\354"+ + "\4\13\40\0\20\211\1\0\2\211\1\0\2\211\1\0"+ + "\3\211\1\0\22\211\124\0\1\355\114\0\1\356\27\0"+ + "\1\237\112\0\1\237\1\240\121\0\1\357\3\0\2\357"+ + "\6\0\1\357\13\0\1\357\64\0\1\360\1\0\4\360"+ + "\4\0\3\360\1\0\2\360\10\0\3\360\3\0\1\360"+ + "\63\0\1\361\6\0\1\361\13\0\1\361\61\0\20\250"+ + "\1\0\2\250\1\0\2\250\1\0\3\250\1\0\22\250"+ + "\43\0\1\362\3\0\2\362\6\0\1\362\13\0\1\362"+ + "\64\0\1\363\1\0\4\363\4\0\3\363\1\0\2\363"+ + "\10\0\3\363\3\0\1\363\63\0\1\364\6\0\1\364"+ + "\13\0\1\364\61\0\2\256\1\0\2\257\2\0\2\257"+ + "\4\256\2\0\1\257\4\0\2\256\1\0\3\256\1\0"+ + "\1\257\2\0\3\256\1\0\13\256\43\0\1\257\3\0"+ + "\2\257\6\0\1\257\13\0\1\257\61\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\3\12\1\304"+ + "\16\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\3\12\1\0\6\12\1\365\13\12\40\0\2\120\1\0"+ + "\6\264\4\120\3\264\1\366\2\264\1\0\2\367\1\0"+ + "\3\120\1\0\3\264\3\120\1\264\13\120\40\0\2\120"+ + "\2\0\1\265\2\0\2\265\4\120\2\0\1\265\4\0"+ + "\2\120\1\0\3\120\1\0\1\265\2\0\3\120\1\0"+ + "\13\120\40\0\2\120\2\0\1\266\3\0\1\266\4\120"+ + "\2\0\1\266\4\0\2\120\1\0\3\120\4\0\3\120"+ + "\1\0\13\120\40\0\20\12\1\0\1\370\1\12\1\0"+ + "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\1\371\2\12\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ + "\1\0\5\12\1\372\14\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\5\12\1\373\14\12"+ + "\40\0\20\12\1\0\1\374\1\12\1\0\2\12\1\0"+ + "\3\12\1\0\22\12\40\0\20\12\1\0\1\375\1\12"+ + "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\5\12"+ + "\1\376\14\12\40\0\20\12\1\0\1\377\1\12\1\0"+ + "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\17\12\1\u0100"+ + "\2\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\2\12\1\u0101\1\0\22\12\40\0\20\12\1\0\1\u0102"+ + "\1\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\1\u0103\2\12"+ + "\1\0\22\12\40\0\20\12\1\0\1\u0104\1\12\1\0"+ + "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\3\12\1\u0105"+ + "\16\12\40\0\20\12\1\0\1\u0106\1\12\1\0\2\12"+ + "\1\0\3\12\1\0\22\12\40\0\20\12\1\0\1\u0107"+ "\1\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ - "\20\12\1\0\2\12\1\0\2\12\1\0\1\372\2\12"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\1\u0108\2\12"+ "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\5\12\1\373\14\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\5\12"+ - "\1\374\14\12\40\0\20\12\1\0\1\375\1\12\1\0"+ + "\1\0\3\12\1\0\12\12\1\u0109\7\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\1\12\1\u010a\1\12"+ + "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\1\12\1\u010b\1\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\10\12"+ + "\1\u010c\11\12\40\0\20\12\1\0\1\u010d\1\12\1\0"+ "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ - "\1\376\1\12\1\0\2\12\1\0\3\12\1\0\22\12"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\3\12\1\u010e"+ + "\16\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\3\12\1\0\6\12\1\u010f\13\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\3\12\1\u0110"+ + "\16\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\2\12\1\u0111\1\0\22\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\2\12\1\u0112\17\12"+ "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\5\12\1\377\14\12\40\0\20\12\1\0\1\u0100"+ - "\1\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ + "\1\0\14\12\1\u0113\5\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\7\12\1\u0114\12\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\u0115"+ + "\2\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\10\12\1\u0116\11\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\1\12\1\u0117"+ + "\1\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\12\12\1\u0118\7\12\40\0"+ "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\17\12\1\u0101\2\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\2\12\1\u0102\1\0\22\12\40\0\20\12"+ - "\1\0\1\u0103\1\12\1\0\2\12\1\0\3\12\1\0"+ - "\22\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\1\u0104\2\12\1\0\22\12\40\0\20\12\1\0\1\u0105"+ - "\1\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ + "\7\12\1\u0119\12\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\6\12\1\u011a\13\12\40\0"+ "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\3\12\1\u0106\16\12\40\0\20\12\1\0\1\u0107\1\12"+ + "\1\12\1\u011b\20\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\1\12\1\u011c\1\12\1\0\22\12\40\0"+ + "\20\13\1\0\1\u011d\1\13\1\0\2\13\1\0\3\13"+ + "\1\0\22\13\40\0\20\13\1\0\1\u011e\1\13\1\0"+ + "\2\13\1\0\3\13\1\0\22\13\43\0\1\103\3\0"+ + "\2\103\6\0\1\103\13\0\1\103\64\0\1\103\1\0"+ + "\4\103\4\0\3\103\1\0\2\103\10\0\3\103\3\0"+ + "\1\103\62\0\2\u011f\6\0\1\u011f\13\0\1\u011f\64\0"+ + "\1\115\3\0\2\115\6\0\1\115\13\0\1\115\64\0"+ + "\1\115\1\0\4\115\4\0\3\115\1\0\2\115\10\0"+ + "\3\115\3\0\1\115\62\0\2\u0120\6\0\1\u0120\13\0"+ + "\1\u0120\61\0\20\12\1\0\2\12\1\0\2\12\1\0"+ + "\1\12\1\u0121\1\12\1\0\22\12\40\0\2\256\1\0"+ + "\6\366\4\256\3\366\1\0\2\366\1\0\2\u0122\1\0"+ + "\3\256\1\0\3\366\3\256\1\366\13\256\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\6\12"+ + "\1\u0123\13\12\40\0\13\12\1\u0124\4\12\1\0\2\12"+ "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ - "\1\0\1\u0108\1\12\1\0\2\12\1\0\3\12\1\0"+ + "\1\0\2\12\1\0\2\12\1\0\1\u0125\2\12\1\0"+ "\22\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\1\u0109\2\12\1\0\22\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\3\12\1\0\12\12\1\u010a\7\12"+ + "\2\12\1\u0126\1\0\22\12\40\0\20\12\1\0\2\12"+ + "\1\0\1\u0127\1\12\1\0\3\12\1\0\22\12\40\0"+ + "\5\12\1\u0128\12\12\1\0\2\12\1\0\2\12\1\0"+ + "\3\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\1\12\1\u0129\20\12\40\0"+ + "\20\12\1\0\1\u012a\1\12\1\0\2\12\1\0\3\12"+ + "\1\0\22\12\40\0\20\12\1\0\1\u012b\1\12\1\0"+ + "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\2\12\1\u012c\1\0\22\12"+ "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\12"+ - "\1\u010b\1\12\1\0\22\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\12\1\u010c\1\12\1\0\22\12"+ + "\1\u012d\1\12\1\0\22\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\6\12\1\u012e\13\12"+ "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\10\12\1\u010d\11\12\40\0\20\12\1\0\1\u010e"+ - "\1\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ - "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\3\12\1\u010f\16\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\3\12\1\0\6\12\1\u0110\13\12\40\0"+ + "\1\0\6\12\1\u012f\13\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\5\12\1\u0130\14\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ + "\1\0\12\12\1\u0131\7\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\2\12\1\u0132\1\0\22\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\1\12\1\u0133"+ + "\1\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\7\12\1\u0134\12\12\40\0"+ "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\3\12\1\u0111\16\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\2\12\1\u0112\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\2\12"+ - "\1\u0113\17\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\14\12\1\u0114\5\12\40\0\20\12"+ + "\3\12\1\u0135\16\12\40\0\20\12\1\0\1\u0136\1\12"+ + "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\10\12"+ + "\1\u0137\11\12\40\0\13\12\1\u0138\4\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\7\12"+ - "\1\u0115\12\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\u0116\2\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\10\12\1\u0117"+ - "\11\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\1\12\1\u0118\1\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\12\12\1\u0119"+ - "\7\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\7\12\1\u011a\12\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\6\12\1\u011b"+ - "\13\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\1\12\1\u011c\20\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\1\12\1\u011d\1\12\1\0"+ - "\22\12\40\0\20\13\1\0\1\u011e\1\13\1\0\2\13"+ - "\1\0\3\13\1\0\22\13\40\0\20\13\1\0\1\u011f"+ - "\1\13\1\0\2\13\1\0\3\13\1\0\22\13\43\0"+ - "\1\103\3\0\2\103\6\0\1\103\13\0\1\103\64\0"+ - "\1\103\1\0\4\103\4\0\3\103\1\0\2\103\10\0"+ - "\3\103\3\0\1\103\62\0\2\u0120\6\0\1\u0120\13\0"+ - "\1\u0120\64\0\1\115\3\0\2\115\6\0\1\115\13\0"+ - "\1\115\64\0\1\115\1\0\4\115\4\0\3\115\1\0"+ - "\2\115\10\0\3\115\3\0\1\115\62\0\2\u0121\6\0"+ - "\1\u0121\13\0\1\u0121\61\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\1\12\1\u0122\1\12\1\0\22\12\40\0"+ - "\2\257\1\0\6\367\4\257\3\367\1\0\2\367\1\0"+ - "\2\u0123\1\0\3\257\1\0\3\367\3\257\1\367\13\257"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\6\12\1\u0124\13\12\40\0\13\12\1\u0125\4\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\u0126"+ + "\1\u0139\12\12\40\0\15\12\1\u013a\2\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\12\12"+ + "\1\u013b\7\12\47\0\2\103\6\0\1\103\13\0\1\103"+ + "\70\0\2\115\6\0\1\115\13\0\1\115\61\0\13\12"+ + "\1\u013c\4\12\1\0\2\12\1\0\2\12\1\0\3\12"+ + "\1\0\5\12\1\u013d\14\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\1\12\1\u013e\1\12\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\u013f"+ "\2\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\2\12\1\u0127\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\1\u0128\1\12\1\0\3\12\1\0"+ - "\22\12\40\0\5\12\1\u0129\12\12\1\0\2\12\1\0"+ - "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\1\12\1\u012a"+ - "\20\12\40\0\20\12\1\0\1\u012b\1\12\1\0\2\12"+ - "\1\0\3\12\1\0\22\12\40\0\20\12\1\0\1\u012c"+ - "\1\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ - "\20\12\1\0\2\12\1\0\2\12\1\0\2\12\1\u012d"+ + "\2\12\1\0\1\u0140\2\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\1\12\1\u0141\1\12"+ "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\12\1\u012e\1\12\1\0\22\12\40\0\20\12"+ + "\1\0\1\12\1\u0142\1\12\1\0\22\12\40\0\20\12"+ "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\6\12"+ - "\1\u012f\13\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\6\12\1\u0130\13\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\5\12"+ - "\1\u0131\14\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\12\12\1\u0132\7\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\2\12\1\u0133\1\0"+ - "\22\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\1\12\1\u0134\1\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\7\12\1\u0135"+ - "\12\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\3\12\1\u0136\16\12\40\0\20\12\1\0"+ - "\1\u0137\1\12\1\0\2\12\1\0\3\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\10\12\1\u0138\11\12\40\0\13\12\1\u0139\4\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\7\12\1\u013a\12\12\40\0\15\12\1\u013b\2\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\12\12\1\u013c\7\12\47\0\2\103\6\0\1\103"+ - "\13\0\1\103\70\0\2\115\6\0\1\115\13\0\1\115"+ - "\61\0\13\12\1\u013d\4\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\5\12\1\u013e\14\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\1\12\1\u013f\1\12"+ + "\1\u0143\13\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\1\12\1\u0144\1\12\1\0\22\12\40\0\13\12"+ + "\1\u0145\4\12\1\0\2\12\1\0\2\12\1\0\3\12"+ "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\u0140\2\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\1\u0141\2\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\12"+ - "\1\u0142\1\12\1\0\22\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\12\1\u0143\1\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\6\12\1\u0144\13\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\12\1\u0145\1\12\1\0\22\12"+ - "\40\0\13\12\1\u0146\4\12\1\0\2\12\1\0\2\12"+ + "\1\0\1\12\1\u0146\1\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\7\12"+ + "\1\u0147\12\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\3\12\1\0\1\12\1\u0148\20\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\2\12"+ + "\1\u0149\17\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\3\12\1\0\5\12\1\u014a\14\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\2\12\1\u014b\1\0"+ + "\22\12\40\0\20\12\1\0\1\u014c\1\12\1\0\2\12"+ "\1\0\3\12\1\0\22\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\12\1\u0147\1\12\1\0\22\12"+ + "\1\0\2\12\1\0\3\12\1\0\2\12\1\u014d\17\12"+ "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\7\12\1\u0148\12\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\3\12\1\0\1\12\1\u0149\20\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\2\12\1\u014a\17\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\3\12\1\0\5\12\1\u014b\14\12"+ + "\1\0\10\12\1\u014e\11\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\3\12\1\0\1\12\1\u014f\20\12"+ "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\2\12"+ - "\1\u014c\1\0\22\12\40\0\20\12\1\0\1\u014d\1\12"+ - "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\2\12"+ - "\1\u014e\17\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\3\12\1\0\10\12\1\u014f\11\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\1\12"+ - "\1\u0150\20\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\2\12\1\u0151\1\0\22\12\40\0\13\12\1\u0152"+ - "\4\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ + "\1\u0150\1\0\22\12\40\0\13\12\1\u0151\4\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\22\12\40\0"+ + "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ + "\1\12\1\u0152\20\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\5\12\1\u0153\14\12\40\0"+ + "\20\12\1\0\1\u0154\1\12\1\0\2\12\1\0\3\12"+ + "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\3\12\1\0\10\12\1\u0155\11\12\40\0\20\12"+ + "\1\0\1\u0156\1\12\1\0\2\12\1\0\3\12\1\0"+ "\22\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\1\12\1\u0153\20\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\5\12\1\u0154"+ - "\14\12\40\0\20\12\1\0\1\u0155\1\12\1\0\2\12"+ + "\1\12\1\u0157\1\12\1\0\22\12\40\0\20\12\1\0"+ + "\2\12\1\0\2\12\1\0\3\12\1\0\1\12\1\u0158"+ + "\20\12\40\0\20\12\1\0\1\u0159\1\12\1\0\2\12"+ "\1\0\3\12\1\0\22\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\3\12\1\0\10\12\1\u0156\11\12"+ - "\40\0\20\12\1\0\1\u0157\1\12\1\0\2\12\1\0"+ + "\1\0\2\12\1\0\3\12\1\0\10\12\1\u015a\11\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\u015b"+ + "\2\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\10\12\1\u015c\11\12\40\0"+ + "\13\12\1\u015d\4\12\1\0\2\12\1\0\2\12\1\0"+ "\3\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ - "\2\12\1\0\1\12\1\u0158\1\12\1\0\22\12\40\0"+ + "\2\12\1\0\3\12\1\0\5\12\1\u015e\14\12\40\0"+ "\20\12\1\0\2\12\1\0\2\12\1\0\3\12\1\0"+ - "\1\12\1\u0159\20\12\40\0\20\12\1\0\1\u015a\1\12"+ - "\1\0\2\12\1\0\3\12\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\10\12"+ - "\1\u015b\11\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\u015c\2\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\10\12\1\u015d"+ - "\11\12\40\0\13\12\1\u015e\4\12\1\0\2\12\1\0"+ - "\2\12\1\0\3\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\5\12\1\u015f"+ - "\14\12\40\0\20\12\1\0\2\12\1\0\2\12\1\0"+ - "\3\12\1\0\5\12\1\u0160\14\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\1\u0161\2\12\1\0\22\12"+ - "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\3\12"+ - "\1\0\13\12\1\u0162\6\12\40\0\20\12\1\0\2\12"+ - "\1\0\2\12\1\0\1\u0163\2\12\1\0\22\12\40\0"+ - "\20\12\1\0\1\u0164\1\12\1\0\2\12\1\0\3\12"+ - "\1\0\22\12\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\12\1\u0165\1\12\1\0\22\12\40\0\20\12"+ - "\1\0\2\12\1\0\2\12\1\0\2\12\1\u0166\1\0"+ - "\22\12\34\0"; + "\5\12\1\u015f\14\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\1\u0160\2\12\1\0\22\12\40\0\20\12"+ + "\1\0\2\12\1\0\2\12\1\0\3\12\1\0\13\12"+ + "\1\u0161\6\12\40\0\20\12\1\0\2\12\1\0\2\12"+ + "\1\0\1\u0162\2\12\1\0\22\12\40\0\20\12\1\0"+ + "\1\u0163\1\12\1\0\2\12\1\0\3\12\1\0\22\12"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\12"+ + "\1\u0164\1\12\1\0\22\12\40\0\20\12\1\0\2\12"+ + "\1\0\2\12\1\0\2\12\1\u0165\1\0\22\12\34\0"; private static int [] zzUnpackTrans() { int [] result = new int[18326]; @@ -582,12 +580,12 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { "\5\1\1\11\5\1\17\11\2\1\3\11\2\1\1\11"+ "\1\1\1\0\1\1\1\0\1\11\1\1\1\0\5\1"+ "\1\0\11\1\1\11\41\1\1\11\5\1\11\11\1\1"+ - "\11\11\1\1\1\11\1\0\1\1\1\0\3\1\2\11"+ + "\10\11\1\1\1\11\1\0\1\1\1\0\3\1\2\11"+ "\1\0\1\11\3\1\3\0\1\11\1\1\1\0\12\1"+ "\1\11\61\1\2\11\6\0\52\1\2\0\105\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[358]; + int [] result = new int[357]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -921,19 +919,19 @@ else if (zzAtEOF) { case IN_STRING: { yybegin(INITIAL); tokenEnd(); return types.STRING_VALUE; } // fall though - case 359: break; + case 358: break; case IN_ML_STRING: { yybegin(INITIAL); tokenEnd(); return types.ML_STRING_VALUE; } // fall though - case 360: break; + case 359: break; case IN_ML_COMMENT: { yybegin(INITIAL); tokenEnd(); return types.MULTI_COMMENT; } // fall though - case 361: break; + case 360: break; case IN_SL_COMMENT: { yybegin(INITIAL); tokenEnd(); return types.SINGLE_COMMENT; } // fall though - case 362: break; + case 361: break; default: return null; } @@ -944,712 +942,707 @@ else if (zzAtEOF) { { yybegin(INITIAL); yypushback(1); } // fall through - case 143: break; + case 142: break; case 2: { return BAD_CHARACTER; } // fall through - case 144: break; + case 143: break; case 3: { return WHITE_SPACE; } // fall through - case 145: break; + case 144: break; case 4: { return types.LIDENT; } // fall through - case 146: break; + case 145: break; case 5: { return types.UIDENT; } // fall through - case 147: break; + case 146: break; case 6: { return types.SINGLE_QUOTE; } // fall through - case 148: break; + case 147: break; case 7: { return types.INT_VALUE; } // fall through - case 149: break; + case 148: break; case 8: { return types.UNDERSCORE; } // fall through - case 150: break; + case 149: break; case 9: { return types.DOT; } // fall through - case 151: break; + case 150: break; case 10: { return types.PLUS; } // fall through - case 152: break; + case 151: break; case 11: { return types.BACKSLASH; } // fall through - case 153: break; + case 152: break; case 12: { yybegin(IN_STRING); tokenStart(); } // fall through - case 154: break; + case 153: break; case 13: { yybegin(IN_ML_STRING); tokenStart(); } // fall through - case 155: break; + case 154: break; case 14: { return types.SHARP; } // fall through - case 156: break; + case 155: break; case 15: { return types.SLASH; } // fall through - case 157: break; + case 156: break; case 16: { return types.STAR; } // fall through - case 158: break; + case 157: break; case 17: { return types.COLON; } // fall through - case 159: break; + case 158: break; case 18: { return types.EQ; } // fall through - case 160: break; + case 159: break; case 19: { return types.GT; } // fall through - case 161: break; + case 160: break; case 20: { return types.MINUS; } // fall through - case 162: break; + case 161: break; case 21: { return types.LT; } // fall through - case 163: break; + case 162: break; case 22: { return types.PIPE; } // fall through - case 164: break; + case 163: break; case 23: { return types.EXCLAMATION_MARK; } // fall through - case 165: break; + case 164: break; case 24: { return types.AMPERSAND; } // fall through - case 166: break; + case 165: break; case 25: { return types.COMMA; } // fall through - case 167: break; + case 166: break; case 26: { return types.SEMI; } // fall through - case 168: break; + case 167: break; case 27: { return types.LPAREN; } // fall through - case 169: break; + case 168: break; case 28: { return types.RPAREN; } // fall through - case 170: break; + case 169: break; case 29: { return types.LBRACE; } // fall through - case 171: break; + case 170: break; case 30: { return types.RBRACE; } // fall through - case 172: break; + case 171: break; case 31: { return types.LBRACKET; } // fall through - case 173: break; + case 172: break; case 32: { return types.RBRACKET; } // fall through - case 174: break; + case 173: break; case 33: { return types.ARROBASE; } // fall through - case 175: break; + case 174: break; case 34: { return types.QUESTION_MARK; } // fall through - case 176: break; + case 175: break; case 35: { return types.DOLLAR; } // fall through - case 177: break; + case 176: break; case 36: { return types.TILDE; } // fall through - case 178: break; + case 177: break; case 37: { return types.CARRET; } // fall through - case 179: break; + case 178: break; case 38: { return types.PERCENT; } // fall through - case 180: break; + case 179: break; case 39: { } // fall through - case 181: break; + case 180: break; case 40: { yybegin(INITIAL); tokenEnd(); return types.STRING_VALUE; } // fall through - case 182: break; + case 181: break; case 41: { yybegin(INITIAL); tokenEnd(); return types.ML_STRING_VALUE; } // fall through - case 183: break; + case 182: break; case 42: { inCommentString = !inCommentString; } // fall through - case 184: break; + case 183: break; case 43: { yybegin(INITIAL); tokenEnd(); return types.SINGLE_COMMENT; } // fall through - case 185: break; + case 184: break; case 44: { return types.TYPE_ARGUMENT; } // fall through - case 186: break; + case 185: break; case 45: { return types.FLOAT_VALUE; } // fall through - case 187: break; + case 186: break; case 46: { return types.OF; } // fall through - case 188: break; + case 187: break; case 47: { return types.OR; } // fall through - case 189: break; + case 188: break; case 48: { return types.DOTDOT; } // fall through - case 190: break; + case 189: break; case 49: { return types.PLUSDOT; } // fall through - case 191: break; + case 190: break; case 50: { return types.TO; } // fall through - case 192: break; + case 191: break; case 51: { return types.AS; } // fall through - case 193: break; + case 192: break; case 52: { return types.DO; } // fall through - case 194: break; + case 193: break; case 53: { return types.IF; } // fall through - case 195: break; + case 194: break; case 54: { return types.IN; } // fall through - case 196: break; + case 195: break; case 55: { return types.JS_STRING_OPEN/*Template*/; } // fall through - case 197: break; + case 196: break; case 56: { return types.POLY_VARIANT; } // fall through - case 198: break; + case 197: break; case 57: { return types.SHARPSHARP; } // fall through - case 199: break; + case 198: break; case 58: { return types.SLASHDOT; } // fall through - case 200: break; + case 199: break; case 59: { yybegin(IN_SL_COMMENT); tokenStart(); } // fall through - case 201: break; + case 200: break; case 60: { yybegin(IN_ML_COMMENT); commentDepth = 1; tokenStart(); } // fall through - case 202: break; + case 201: break; case 61: { return types.TAG_AUTO_CLOSE; } // fall through - case 203: break; + case 202: break; case 62: { return types.STARDOT; } // fall through - case 204: break; + case 203: break; case 63: { return types.SHORTCUT; } // fall through - case 205: break; + case 204: break; case 64: { return types.COLON_EQ; } // fall through - case 206: break; + case 205: break; case 65: { return types.COLON_GT; } // fall through - case 207: break; + case 206: break; case 66: { return types.EQEQ; } // fall through - case 208: break; + case 207: break; case 67: { return types.ARROW; } // fall through - case 209: break; + case 208: break; case 68: { return types.MINUSDOT; } // fall through - case 210: break; + case 209: break; case 69: { return types.RIGHT_ARROW; } // fall through - case 211: break; + case 210: break; case 70: { return types.TAG_LT_SLASH; } // fall through - case 212: break; + case 211: break; case 71: { return types.LT_OR_EQUAL; } // fall through - case 213: break; + case 212: break; case 72: { return types.LEFT_ARROW; } // fall through - case 214: break; + case 213: break; case 73: - { return types.PIPE_FIRST; - } - // fall through - case 215: break; - case 74: { return types.PIPE_FORWARD; } // fall through - case 216: break; - case 75: + case 214: break; + case 74: { return types.L_OR; } // fall through - case 217: break; - case 76: + case 215: break; + case 75: { return types.NOT_EQ; } // fall through - case 218: break; - case 77: + case 216: break; + case 76: { return types.L_AND; } // fall through - case 219: break; - case 78: + case 217: break; + case 77: { if (!inCommentString) commentDepth += 1; } // fall through - case 220: break; - case 79: + case 218: break; + case 78: { if (!inCommentString) { commentDepth -= 1; if(commentDepth == 0) { yybegin(INITIAL); tokenEnd(); return types.MULTI_COMMENT; } } } // fall through - case 221: break; - case 80: + case 219: break; + case 79: { return types.CHAR_VALUE; } // fall through - case 222: break; - case 81: + case 220: break; + case 80: { return types.FOR; } // fall through - case 223: break; - case 82: + case 221: break; + case 81: { return types.DOTDOTDOT; } // fall through - case 224: break; - case 83: + case 222: break; + case 82: { return types.END; } // fall through - case 225: break; - case 84: + case 223: break; + case 83: { return types.PRI; } // fall through - case 226: break; - case 85: + case 224: break; + case 84: { return types.PUB; } // fall through - case 227: break; - case 86: + case 225: break; + case 85: { return types.NEW; } // fall through - case 228: break; - case 87: + case 226: break; + case 86: { return types.TRY; } // fall through - case 229: break; - case 88: + case 227: break; + case 87: { return types.REF; } // fall through - case 230: break; - case 89: + case 228: break; + case 88: { return types.REC; } // fall through - case 231: break; - case 90: + case 229: break; + case 89: { return types.RAW; } // fall through - case 232: break; - case 91: + case 230: break; + case 90: { return types.AND; } // fall through - case 233: break; - case 92: + case 231: break; + case 91: { return types.ASR; } // fall through - case 234: break; - case 93: + case 232: break; + case 92: { return types.SIG; } // fall through - case 235: break; - case 94: + case 233: break; + case 93: { return types.LOR; } // fall through - case 236: break; - case 95: + case 234: break; + case 94: { return types.LET; } // fall through - case 237: break; - case 96: + case 235: break; + case 95: { return types.LSR; } // fall through - case 238: break; - case 97: + case 236: break; + case 96: { return types.LSL; } // fall through - case 239: break; - case 98: + case 237: break; + case 97: { return types.MOD; } // fall through - case 240: break; - case 99: + case 238: break; + case 98: { return types.VAL; } // fall through - case 241: break; - case 100: + case 239: break; + case 99: { return types.EQEQEQ; } // fall through - case 242: break; - case 101: + case 240: break; + case 100: { return types.NOT_EQEQ; } // fall through - case 243: break; - case 102: + case 241: break; + case 101: { return types.OPEN; } // fall through - case 244: break; - case 103: + case 242: break; + case 102: { return types.ELSE; } // fall through - case 245: break; - case 104: + case 243: break; + case 103: { return types.BOOL_VALUE; } // fall through - case 246: break; - case 105: + case 244: break; + case 104: { return types.THEN; } // fall through - case 247: break; - case 106: + case 245: break; + case 105: { return types.TYPE; } // fall through - case 248: break; - case 107: + case 246: break; + case 106: { return types.DONE; } // fall through - case 249: break; - case 108: + case 247: break; + case 107: { return types.LXOR; } // fall through - case 250: break; - case 109: + case 248: break; + case 108: { return types.LAND; } // fall through - case 251: break; - case 110: + case 249: break; + case 109: { return types.LAZY; } // fall through - case 252: break; - case 111: + case 250: break; + case 110: { return types.WITH; } // fall through - case 253: break; - case 112: + case 251: break; + case 111: { return types.WHEN; } // fall through - case 254: break; - case 113: + case 252: break; + case 112: { return types.UNIT; } // fall through - case 255: break; - case 114: + case 253: break; + case 113: { return types.NONE; } // fall through - case 256: break; - case 115: + case 254: break; + case 114: { return types.SOME; } // fall through - case 257: break; - case 116: + case 255: break; + case 115: { return types.BEGIN; } // fall through - case 258: break; - case 117: + case 256: break; + case 116: { return types.ENDIF; } // fall through - case 259: break; - case 118: + case 257: break; + case 117: { return types.RAISE; } // fall through - case 260: break; - case 119: + case 258: break; + case 118: { return types.CATCH; } // fall through - case 261: break; - case 120: + case 259: break; + case 119: { return types.CLASS; } // fall through - case 262: break; - case 121: + case 260: break; + case 120: { return types.WHILE; } // fall through - case 263: break; - case 122: + case 261: break; + case 121: { return types.MATCH; } // fall through - case 264: break; - case 123: + case 262: break; + case 122: { return types.OBJECT; } // fall through - case 265: break; - case 124: + case 263: break; + case 123: { return types.OPTION; } // fall through - case 266: break; - case 125: + case 264: break; + case 124: { return types.NONREC; } // fall through - case 267: break; - case 126: + case 265: break; + case 125: { return types.ASSERT; } // fall through - case 268: break; - case 127: + case 266: break; + case 126: { return types.DOWNTO; } // fall through - case 269: break; - case 128: + case 267: break; + case 127: { return types.STRUCT; } // fall through - case 270: break; - case 129: + case 268: break; + case 128: { return types.SWITCH; } // fall through - case 271: break; - case 130: + case 269: break; + case 129: { return types.MODULE; } // fall through - case 272: break; - case 131: + case 270: break; + case 130: { return types.METHOD; } // fall through - case 273: break; - case 132: + case 271: break; + case 131: { return types.FUNCTOR; } // fall through - case 274: break; - case 133: + case 272: break; + case 132: { return types.PRIVATE; } // fall through - case 275: break; - case 134: + case 273: break; + case 133: { return types.INCLUDE; } // fall through - case 276: break; - case 135: + case 274: break; + case 134: { return types.INHERIT; } // fall through - case 277: break; - case 136: + case 275: break; + case 135: { return types.MUTABLE; } // fall through - case 278: break; - case 137: + case 276: break; + case 136: { return types.VIRTUAL; } // fall through - case 279: break; - case 138: + case 277: break; + case 137: { return types.FUNCTION; } // fall through - case 280: break; - case 139: + case 278: break; + case 138: { return types.EXTERNAL; } // fall through - case 281: break; - case 140: + case 279: break; + case 139: { return types.EXCEPTION; } // fall through - case 282: break; - case 141: + case 280: break; + case 140: { return types.CONSTRAINT; } // fall through - case 283: break; - case 142: + case 281: break; + case 141: { return types.INITIALIZER; } // fall through - case 284: break; + case 282: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/src/com/reason/lang/napkin/ResQNameFinder.java b/src/com/reason/lang/napkin/ResQNameFinder.java index ee32223b6..33c19ca28 100644 --- a/src/com/reason/lang/napkin/ResQNameFinder.java +++ b/src/com/reason/lang/napkin/ResQNameFinder.java @@ -97,7 +97,7 @@ private ResQNameFinder() { resolvedQualifiedNames.add(openName + resolvedPathExtension); resolvedQualifiedNames.add(moduleName + "." + openName + resolvedPathExtension); } else if (item instanceof PsiOpen || item instanceof PsiInclude) { - String openName = item instanceof PsiOpen ? ((PsiOpen) item).getPath() : ((PsiInclude) item).getPath(); + String openName = item instanceof PsiOpen ? ((PsiOpen) item).getPath() : ((PsiInclude) item).getIncludePath(); // Add open value to all previous elements qualifiedNames.addAll(extendPathWith(filePath, openName, qualifiedNames)); qualifiedNames.add(openName + pathExtension); @@ -116,7 +116,7 @@ private ResQNameFinder() { resolvedQualifiedNames.add(letQName + resolvedPathExtension); } } else if (item instanceof PsiFunction) { - PsiQualifiedElement parent = PsiTreeUtil.getParentOfType(item, PsiQualifiedElement.class); + PsiQualifiedNamedElement parent = PsiTreeUtil.getParentOfType(item, PsiQualifiedNamedElement.class); if (parent != null) { String parentQName = parent.getQualifiedName(); // Register all parameters of function diff --git a/src/com/reason/lang/napkin/ResTypes.java b/src/com/reason/lang/napkin/ResTypes.java index d974d292e..b9a0086c3 100644 --- a/src/com/reason/lang/napkin/ResTypes.java +++ b/src/com/reason/lang/napkin/ResTypes.java @@ -10,8 +10,7 @@ private ResTypes() { // Stub element types C_FAKE_MODULE = (ORCompositeType) RescriptStubBasedElementTypes.C_FAKE_MODULE; - C_EXCEPTION_DECLARATION = - (ORCompositeType) RescriptStubBasedElementTypes.C_EXCEPTION_DECLARATION; + C_EXCEPTION_DECLARATION = (ORCompositeType) RescriptStubBasedElementTypes.C_EXCEPTION_DECLARATION; C_TYPE_DECLARATION = (ORCompositeType) RescriptStubBasedElementTypes.C_TYPE_DECLARATION; C_EXTERNAL_DECLARATION = (ORCompositeType) RescriptStubBasedElementTypes.C_EXTERNAL_DECLARATION; C_LET_DECLARATION = (ORCompositeType) RescriptStubBasedElementTypes.C_LET_DECLARATION; @@ -22,6 +21,8 @@ private ResTypes() { C_FUNCTOR_PARAM = (ORCompositeType) RescriptStubBasedElementTypes.C_FUNCTOR_PARAM; C_RECORD_FIELD = (ORCompositeType) RescriptStubBasedElementTypes.C_RECORD_FIELD; C_VARIANT_DECLARATION = (ORCompositeType) RescriptStubBasedElementTypes.C_VARIANT_DECLARATION; + C_INCLUDE = (ORCompositeType) RescriptStubBasedElementTypes.C_INCLUDE; + C_OPEN = (ORCompositeType) RescriptStubBasedElementTypes.C_OPEN; // Composite element types @@ -52,7 +53,6 @@ private ResTypes() { C_FUNCTOR_RESULT = new ORCompositeElementType("C_FUNCTOR_RESULT", ResLanguage.INSTANCE); C_IF = new ORCompositeElementType("C_IF", ResLanguage.INSTANCE); C_IF_THEN_SCOPE = new ORCompositeElementType("C_IF_THEN_SCOPE", ResLanguage.INSTANCE); - C_INCLUDE = new ORCompositeElementType("C_INCLUDE", ResLanguage.INSTANCE); C_INTERPOLATION_EXPR = new ORCompositeElementType("C_INTERPOLATION_EXPR", ResLanguage.INSTANCE); C_INTERPOLATION_PART = new ORCompositeElementType("C_INTERPOLATION_PART", ResLanguage.INSTANCE); C_INTERPOLATION_REF = new ORCompositeElementType("C_INTERPOLATION_REF", ResLanguage.INSTANCE); @@ -71,7 +71,6 @@ private ResTypes() { C_OBJECT = new ORCompositeElementType("C_OBJECT", ResLanguage.INSTANCE); C_OBJECT_FIELD = new ORCompositeElementType("C_OBJECT_FIELD", ResLanguage.INSTANCE); C_OPTION = new ORCompositeElementType("C_OPTION", ResLanguage.INSTANCE); - C_OPEN = new ORCompositeElementType("C_OPEN", ResLanguage.INSTANCE); C_PARAMETERS = new ORCompositeElementType("C_PARAMETERS", ResLanguage.INSTANCE); C_PATTERN_MATCH_BODY = new ORCompositeElementType("C_PATTERN_MATCH_BODY", ResLanguage.INSTANCE); C_PATTERN_MATCH_EXPR = new ORCompositeElementType("C_PATTERN_MATCH_EXPR", ResLanguage.INSTANCE); @@ -183,7 +182,6 @@ private ResTypes() { VARIANT_NAME = new ORTokenElementType("VARIANT_NAME", ResLanguage.INSTANCE); PIPE = new ORTokenElementType("PIPE", ResLanguage.INSTANCE); PIPE_FORWARD = new ORTokenElementType("PIPE_FORWARD", ResLanguage.INSTANCE); - PIPE_FIRST = new ORTokenElementType("PIPE_FIRST", ResLanguage.INSTANCE); PLUS = new ORTokenElementType("PLUS", ResLanguage.INSTANCE); PERCENT = new ORTokenElementType("PERCENT", ResLanguage.INSTANCE); PLUSDOT = new ORTokenElementType("PLUSDOT", ResLanguage.INSTANCE); diff --git a/src/com/reason/lang/napkin/Rescript.flex b/src/com/reason/lang/napkin/Rescript.flex index 9dbccf41a..9f2192382 100644 --- a/src/com/reason/lang/napkin/Rescript.flex +++ b/src/com/reason/lang/napkin/Rescript.flex @@ -187,7 +187,6 @@ ESCAPE_CHAR= {ESCAPE_BACKSLASH} | {ESCAPE_SINGLE_QUOTE} | {ESCAPE_LF} | {ESCAPE_ "->" { return types.RIGHT_ARROW; } "<-" { return types.LEFT_ARROW; } "|>" { return types.PIPE_FORWARD; } - "|." { return types.PIPE_FIRST; } "" { return types.TAG_AUTO_CLOSE; } diff --git a/src/com/reason/lang/ocaml/OCaml.flex b/src/com/reason/lang/ocaml/OCaml.flex index beec238ad..1bda96497 100644 --- a/src/com/reason/lang/ocaml/OCaml.flex +++ b/src/com/reason/lang/ocaml/OCaml.flex @@ -192,7 +192,6 @@ ESCAPE_CHAR= {ESCAPE_BACKSLASH} | {ESCAPE_SINGLE_QUOTE} | {ESCAPE_LF} | {ESCAPE_ "->" { return types.RIGHT_ARROW; } "<-" { return types.LEFT_ARROW; } "|>" { return types.PIPE_FORWARD; } - "|." { return types.PIPE_FIRST; } "" { return types.TAG_AUTO_CLOSE; } "[|" { return types.LARRAY; } diff --git a/src/com/reason/lang/ocaml/OCamlLexer.java b/src/com/reason/lang/ocaml/OCamlLexer.java index fc4b0fcd6..c6f744498 100644 --- a/src/com/reason/lang/ocaml/OCamlLexer.java +++ b/src/com/reason/lang/ocaml/OCamlLexer.java @@ -86,25 +86,25 @@ public static int ZZ_CMAP(int ch) { "\2\0\1\67\1\70\1\71\1\72\1\73\1\74\1\75"+ "\1\76\1\77\1\100\1\101\1\102\1\103\1\104\1\105"+ "\1\106\1\107\1\110\1\111\1\112\1\113\1\114\1\115"+ - "\1\116\1\0\1\46\1\0\3\46\1\117\1\120\1\121"+ - "\1\51\2\121\3\0\2\52\1\0\1\122\1\4\1\123"+ - "\3\7\4\4\1\124\2\4\1\125\1\4\1\126\1\127"+ - "\1\4\1\130\1\4\1\131\2\4\1\132\1\133\1\4"+ - "\1\134\1\135\1\136\4\4\1\137\7\4\1\140\1\141"+ - "\2\4\1\142\1\143\4\4\1\144\3\4\1\145\1\4"+ - "\2\5\2\0\1\146\1\147\1\150\1\151\6\0\1\4"+ - "\1\52\1\7\1\4\1\152\5\4\1\153\2\4\1\154"+ - "\1\155\1\156\2\4\1\157\10\4\1\160\1\161\1\162"+ - "\1\163\1\164\1\4\1\165\5\4\1\166\1\167\1\170"+ - "\4\0\1\4\1\52\2\4\1\171\2\4\1\172\2\4"+ - "\1\173\10\4\1\174\1\175\2\4\1\176\2\4\1\0"+ - "\1\177\1\200\2\4\1\201\1\202\3\4\1\203\1\204"+ - "\1\205\1\206\1\207\4\4\1\210\1\211\2\4\1\212"+ - "\1\213\3\4\1\214\1\4\1\215\1\216\1\4\1\217"+ - "\1\220\1\221\1\222\3\4\1\223\3\4\1\224\1\225"; + "\1\0\1\46\1\0\3\46\1\116\1\117\1\120\1\51"+ + "\2\120\3\0\2\52\1\0\1\121\1\4\1\122\3\7"+ + "\4\4\1\123\2\4\1\124\1\4\1\125\1\126\1\4"+ + "\1\127\1\4\1\130\2\4\1\131\1\132\1\4\1\133"+ + "\1\134\1\135\4\4\1\136\7\4\1\137\1\140\2\4"+ + "\1\141\1\142\4\4\1\143\3\4\1\144\1\4\2\5"+ + "\2\0\1\145\1\146\1\147\1\150\6\0\1\4\1\52"+ + "\1\7\1\4\1\151\5\4\1\152\2\4\1\153\1\154"+ + "\1\155\2\4\1\156\10\4\1\157\1\160\1\161\1\162"+ + "\1\163\1\4\1\164\5\4\1\165\1\166\1\167\4\0"+ + "\1\4\1\52\2\4\1\170\2\4\1\171\2\4\1\172"+ + "\10\4\1\173\1\174\2\4\1\175\2\4\1\0\1\176"+ + "\1\177\2\4\1\200\1\201\3\4\1\202\1\203\1\204"+ + "\1\205\1\206\4\4\1\207\1\210\2\4\1\211\1\212"+ + "\3\4\1\213\1\4\1\214\1\215\1\4\1\216\1\217"+ + "\1\220\1\221\3\4\1\222\3\4\1\223\1\224"; private static int [] zzUnpackAction() { - int [] result = new int[363]; + int [] result = new int[362]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -148,36 +148,36 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { "\0\u0134\0\u0134\0\u1fe2\0\u202f\0\u0134\0\u207c\0\u0134\0\u0134"+ "\0\u0134\0\u20c9\0\u0134\0\u0134\0\u0134\0\u0134\0\u0134\0\u0134"+ "\0\u0134\0\u0134\0\u0134\0\u0134\0\u0134\0\u0134\0\u0134\0\u0134"+ - "\0\u0134\0\u2116\0\u0134\0\u0134\0\u0ebd\0\u2163\0\u21b0\0\u21fd"+ - "\0\u224a\0\u2297\0\u0134\0\u0134\0\u0134\0\u22e4\0\u22e4\0\u0ff1"+ - "\0\u2331\0\u237e\0\u23cb\0\u0134\0\u2418\0\u2465\0\u01ce\0\u24b2"+ - "\0\u24ff\0\u254c\0\u2599\0\u25e6\0\u2633\0\u2680\0\u26cd\0\u271a"+ - "\0\u0134\0\u2767\0\u27b4\0\u2801\0\u284e\0\u289b\0\u01ce\0\u28e8"+ - "\0\u01ce\0\u2935\0\u01ce\0\u2982\0\u29cf\0\u01ce\0\u01ce\0\u2a1c"+ - "\0\u01ce\0\u01ce\0\u01ce\0\u2a69\0\u2ab6\0\u2b03\0\u2b50\0\u01ce"+ - "\0\u2b9d\0\u2bea\0\u2c37\0\u2c84\0\u2cd1\0\u2d1e\0\u2d6b\0\u01ce"+ - "\0\u01ce\0\u2db8\0\u2e05\0\u01ce\0\u01ce\0\u2e52\0\u2e9f\0\u2eec"+ - "\0\u2f39\0\u2f86\0\u2fd3\0\u3020\0\u306d\0\u01ce\0\u30ba\0\u3107"+ - "\0\u3154\0\u31a1\0\u31ee\0\u0134\0\u0134\0\u0134\0\u0134\0\u323b"+ - "\0\u3288\0\u32d5\0\u3322\0\u336f\0\u33bc\0\u3409\0\u3456\0\u1125"+ - "\0\u34a3\0\u01ce\0\u34f0\0\u353d\0\u358a\0\u35d7\0\u3624\0\u01ce"+ - "\0\u3671\0\u36be\0\u01ce\0\u01ce\0\u01ce\0\u370b\0\u3758\0\u01ce"+ - "\0\u37a5\0\u37f2\0\u383f\0\u388c\0\u38d9\0\u3926\0\u3973\0\u39c0"+ - "\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u3a0d\0\u01ce\0\u3a5a"+ - "\0\u3aa7\0\u3af4\0\u3b41\0\u3b8e\0\u021b\0\u021b\0\u3bdb\0\u3c28"+ - "\0\u3c75\0\u3cc2\0\u3d0f\0\u3d5c\0\u1125\0\u3da9\0\u3df6\0\u01ce"+ - "\0\u3e43\0\u3e90\0\u01ce\0\u3edd\0\u3f2a\0\u01ce\0\u3f77\0\u3fc4"+ - "\0\u4011\0\u405e\0\u40ab\0\u40f8\0\u4145\0\u4192\0\u01ce\0\u01ce"+ - "\0\u41df\0\u422c\0\u01ce\0\u4279\0\u42c6\0\u4313\0\u0134\0\u0134"+ - "\0\u4360\0\u43ad\0\u01ce\0\u01ce\0\u43fa\0\u4447\0\u4494\0\u01ce"+ - "\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u44e1\0\u452e\0\u457b\0\u45c8"+ - "\0\u01ce\0\u01ce\0\u4615\0\u4662\0\u0134\0\u01ce\0\u46af\0\u46fc"+ - "\0\u4749\0\u01ce\0\u4796\0\u01ce\0\u01ce\0\u47e3\0\u01ce\0\u01ce"+ - "\0\u01ce\0\u01ce\0\u4830\0\u487d\0\u48ca\0\u01ce\0\u4917\0\u4964"+ - "\0\u49b1\0\u01ce\0\u01ce"; + "\0\u2116\0\u0134\0\u0134\0\u0ebd\0\u2163\0\u21b0\0\u21fd\0\u224a"+ + "\0\u2297\0\u0134\0\u0134\0\u0134\0\u22e4\0\u22e4\0\u0ff1\0\u2331"+ + "\0\u237e\0\u23cb\0\u0134\0\u2418\0\u2465\0\u01ce\0\u24b2\0\u24ff"+ + "\0\u254c\0\u2599\0\u25e6\0\u2633\0\u2680\0\u26cd\0\u271a\0\u0134"+ + "\0\u2767\0\u27b4\0\u2801\0\u284e\0\u289b\0\u01ce\0\u28e8\0\u01ce"+ + "\0\u2935\0\u01ce\0\u2982\0\u29cf\0\u01ce\0\u01ce\0\u2a1c\0\u01ce"+ + "\0\u01ce\0\u01ce\0\u2a69\0\u2ab6\0\u2b03\0\u2b50\0\u01ce\0\u2b9d"+ + "\0\u2bea\0\u2c37\0\u2c84\0\u2cd1\0\u2d1e\0\u2d6b\0\u01ce\0\u01ce"+ + "\0\u2db8\0\u2e05\0\u01ce\0\u01ce\0\u2e52\0\u2e9f\0\u2eec\0\u2f39"+ + "\0\u2f86\0\u2fd3\0\u3020\0\u306d\0\u01ce\0\u30ba\0\u3107\0\u3154"+ + "\0\u31a1\0\u31ee\0\u0134\0\u0134\0\u0134\0\u0134\0\u323b\0\u3288"+ + "\0\u32d5\0\u3322\0\u336f\0\u33bc\0\u3409\0\u3456\0\u1125\0\u34a3"+ + "\0\u01ce\0\u34f0\0\u353d\0\u358a\0\u35d7\0\u3624\0\u01ce\0\u3671"+ + "\0\u36be\0\u01ce\0\u01ce\0\u01ce\0\u370b\0\u3758\0\u01ce\0\u37a5"+ + "\0\u37f2\0\u383f\0\u388c\0\u38d9\0\u3926\0\u3973\0\u39c0\0\u01ce"+ + "\0\u01ce\0\u01ce\0\u01ce\0\u01ce\0\u3a0d\0\u01ce\0\u3a5a\0\u3aa7"+ + "\0\u3af4\0\u3b41\0\u3b8e\0\u021b\0\u021b\0\u3bdb\0\u3c28\0\u3c75"+ + "\0\u3cc2\0\u3d0f\0\u3d5c\0\u1125\0\u3da9\0\u3df6\0\u01ce\0\u3e43"+ + "\0\u3e90\0\u01ce\0\u3edd\0\u3f2a\0\u01ce\0\u3f77\0\u3fc4\0\u4011"+ + "\0\u405e\0\u40ab\0\u40f8\0\u4145\0\u4192\0\u01ce\0\u01ce\0\u41df"+ + "\0\u422c\0\u01ce\0\u4279\0\u42c6\0\u4313\0\u0134\0\u0134\0\u4360"+ + "\0\u43ad\0\u01ce\0\u01ce\0\u43fa\0\u4447\0\u4494\0\u01ce\0\u01ce"+ + "\0\u01ce\0\u01ce\0\u01ce\0\u44e1\0\u452e\0\u457b\0\u45c8\0\u01ce"+ + "\0\u01ce\0\u4615\0\u4662\0\u0134\0\u01ce\0\u46af\0\u46fc\0\u4749"+ + "\0\u01ce\0\u4796\0\u01ce\0\u01ce\0\u47e3\0\u01ce\0\u01ce\0\u01ce"+ + "\0\u01ce\0\u4830\0\u487d\0\u48ca\0\u01ce\0\u4917\0\u4964\0\u49b1"+ + "\0\u01ce\0\u01ce"; private static int [] zzUnpackRowMap() { - int [] result = new int[363]; + int [] result = new int[362]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -264,276 +264,276 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { "\1\203\16\0\1\204\21\0\1\205\115\0\1\206\115\0"+ "\1\207\1\210\1\211\113\0\1\212\1\213\113\0\1\214"+ "\47\0\1\215\45\0\1\216\113\0\1\217\1\220\1\221"+ - "\2\0\1\222\42\0\1\223\45\0\1\224\2\0\1\225"+ - "\2\0\1\226\40\0\1\227\45\0\1\230\117\0\1\231"+ - "\110\0\1\232\125\0\1\233\115\0\1\234\12\0\1\77"+ - "\1\235\112\0\1\77\1\236\1\237\4\77\1\240\3\77"+ - "\2\240\1\241\1\77\1\242\3\77\1\240\13\77\1\240"+ - "\21\77\2\0\32\77\65\0\1\243\134\0\1\244\15\0"+ - "\1\245\112\0\2\246\1\247\15\246\1\0\2\246\1\0"+ - "\2\246\1\0\3\246\1\0\22\246\42\0\1\250\1\251"+ - "\3\0\2\251\1\252\1\0\1\253\1\0\1\106\1\0"+ - "\1\251\6\0\5\106\1\251\61\0\2\254\1\0\2\112"+ - "\2\0\2\112\4\254\2\0\1\112\1\0\2\113\1\0"+ - "\2\254\1\0\3\254\1\0\1\112\2\0\3\254\1\0"+ - "\13\254\43\0\1\255\3\0\2\255\6\0\1\255\3\0"+ - "\1\256\7\0\1\255\33\0\1\256\25\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\2\10\1\257\1\0\22\10"+ + "\2\0\1\222\110\0\1\223\2\0\1\224\2\0\1\225"+ + "\40\0\1\226\45\0\1\227\117\0\1\230\110\0\1\231"+ + "\125\0\1\232\115\0\1\233\12\0\1\77\1\234\112\0"+ + "\1\77\1\235\1\236\4\77\1\237\3\77\2\237\1\240"+ + "\1\77\1\241\3\77\1\237\13\77\1\237\21\77\2\0"+ + "\32\77\65\0\1\242\134\0\1\243\15\0\1\244\112\0"+ + "\2\245\1\246\15\245\1\0\2\245\1\0\2\245\1\0"+ + "\3\245\1\0\22\245\42\0\1\247\1\250\3\0\2\250"+ + "\1\251\1\0\1\252\1\0\1\106\1\0\1\250\6\0"+ + "\5\106\1\250\61\0\2\253\1\0\2\112\2\0\2\112"+ + "\4\253\2\0\1\112\1\0\2\113\1\0\2\253\1\0"+ + "\3\253\1\0\1\112\2\0\3\253\1\0\13\253\43\0"+ + "\1\254\3\0\2\254\6\0\1\254\3\0\1\255\7\0"+ + "\1\254\33\0\1\255\25\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\2\10\1\256\1\0\22\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\7\10"+ + "\1\257\12\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\1\260\2\10\1\0\22\10\43\0\1\261\1\0"+ + "\4\261\4\0\3\261\1\0\2\261\10\0\3\261\3\0"+ + "\1\261\62\0\2\262\6\0\1\262\13\0\1\262\71\0"+ + "\1\263\6\0\1\263\75\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\16\10\1\264\3\10\40\0"+ + "\20\10\1\0\1\265\1\10\1\0\2\10\1\0\1\10"+ + "\1\266\1\10\1\0\22\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\4\10\1\267\15\10"+ + "\60\0\1\270\74\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\1\10\1\271\1\10\1\0\6\10\1\272\13\10"+ "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ - "\1\0\7\10\1\260\12\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\1\261\2\10\1\0\22\10\43\0"+ - "\1\262\1\0\4\262\4\0\3\262\1\0\2\262\10\0"+ - "\3\262\3\0\1\262\62\0\2\263\6\0\1\263\13\0"+ - "\1\263\71\0\1\264\6\0\1\264\75\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\16\10\1\265"+ - "\3\10\40\0\20\10\1\0\1\266\1\10\1\0\2\10"+ - "\1\0\1\10\1\267\1\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\4\10"+ - "\1\270\15\10\60\0\1\271\74\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\1\10\1\272\1\10\1\0\6\10"+ - "\1\273\13\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\2\10\1\274\17\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\3\10"+ - "\1\275\16\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\5\10\1\276\14\10\40\0\15\10"+ - "\1\277\2\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\2\10\1\273\17\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\3\10\1\274\16\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\5\10\1\275\14\10\40\0\15\10\1\276\2\10"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\22\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\1\277"+ + "\2\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\10\10\1\300\11\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ + "\11\10\1\301\2\10\1\302\5\10\40\0\20\10\1\0"+ + "\1\303\1\10\1\0\2\10\1\0\3\10\1\0\22\10"+ + "\40\0\20\10\1\0\2\10\1\0\1\304\1\10\1\0"+ + "\3\10\1\0\22\10\40\0\5\10\1\305\12\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\6\10\1\306"+ + "\13\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ + "\3\10\1\0\5\10\1\307\2\10\1\310\11\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ + "\2\10\1\311\17\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\2\10\1\312\1\0\3\10\1\313\16\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\1\314"+ + "\2\10\1\0\10\10\1\315\11\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\2\10\1\316\1\0\22\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\4\10\1\317\15\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\5\10\1\320\14\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\5\10\1\321\1\322\3\10\1\323\7\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\1\324\2\10"+ "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\1\300\2\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\10\10\1\301"+ - "\11\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\11\10\1\302\2\10\1\303\5\10\40\0"+ - "\20\10\1\0\1\304\1\10\1\0\2\10\1\0\3\10"+ - "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\1\305"+ - "\1\10\1\0\3\10\1\0\22\10\40\0\5\10\1\306"+ - "\12\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\6\10\1\307\13\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\5\10\1\310\2\10\1\311"+ - "\11\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\2\10\1\312\17\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\2\10\1\313\1\0\3\10"+ - "\1\314\16\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\1\315\2\10\1\0\10\10\1\316\11\10\40\0"+ - "\20\10\1\0\2\10\1\0\2\10\1\0\2\10\1\317"+ + "\1\0\3\10\1\0\1\10\1\325\20\10\40\0\13\10"+ + "\1\326\4\10\1\0\2\10\1\0\2\10\1\0\3\10"+ "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\4\10\1\320\15\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\5\10"+ - "\1\321\14\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\5\10\1\322\1\323\3\10\1\324"+ - "\7\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\1\325\2\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\1\10\1\326\20\10"+ - "\40\0\13\10\1\327\4\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\2\10\1\330\1\0\22\10\40\0"+ - "\20\10\1\0\2\10\1\0\2\10\1\0\1\10\1\331"+ - "\1\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\1\332\2\10\1\0\13\10\1\333\6\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\2\10"+ - "\1\334\1\0\7\10\1\335\12\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\10\1\336\1\10\1\0"+ - "\22\10\40\0\20\10\1\0\1\337\1\10\1\0\2\10"+ - "\1\0\3\10\1\0\5\10\1\340\14\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\5\10"+ - "\1\341\14\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\2\10\1\342\17\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\10\1\343\1\10"+ + "\1\0\2\10\1\327\1\0\22\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\1\10\1\330\1\10\1\0"+ + "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ + "\1\331\2\10\1\0\13\10\1\332\6\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\2\10\1\333\1\0"+ + "\7\10\1\334\12\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\10\1\335\1\10\1\0\22\10\40\0"+ + "\20\10\1\0\1\336\1\10\1\0\2\10\1\0\3\10"+ + "\1\0\5\10\1\337\14\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\5\10\1\340\14\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\2\10\1\341\17\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\1\10\1\342\1\10\1\0\22\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\1\10"+ + "\1\343\1\10\1\0\22\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\1\10\1\344\1\10\1\0\22\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\7\10\1\345\12\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\2\10\1\346\1\0\22\10\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\1\347\2\11"+ + "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\3\11\1\0\15\11\1\350\4\11\40\0\20\200"+ + "\1\0\2\200\1\0\2\200\1\0\3\200\1\0\22\200"+ + "\67\0\1\351\12\0\1\352\57\0\1\353\172\0\1\354"+ + "\116\0\1\355\114\0\1\356\26\0\1\235\112\0\1\235"+ + "\1\236\121\0\1\357\3\0\2\357\6\0\1\357\13\0"+ + "\1\357\64\0\1\360\1\0\4\360\4\0\3\360\1\0"+ + "\2\360\10\0\3\360\3\0\1\360\63\0\1\361\6\0"+ + "\1\361\13\0\1\361\61\0\20\245\1\0\2\245\1\0"+ + "\2\245\1\0\3\245\1\0\22\245\43\0\1\362\3\0"+ + "\2\362\6\0\1\362\13\0\1\362\64\0\1\363\1\0"+ + "\4\363\4\0\3\363\1\0\2\363\10\0\3\363\3\0"+ + "\1\363\63\0\1\364\6\0\1\364\13\0\1\364\61\0"+ + "\2\253\1\0\2\254\2\0\2\254\4\253\2\0\1\254"+ + "\4\0\2\253\1\0\3\253\1\0\1\254\2\0\3\253"+ + "\1\0\13\253\43\0\1\254\3\0\2\254\6\0\1\254"+ + "\13\0\1\254\61\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\3\10\1\0\3\10\1\301\16\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\6\10"+ + "\1\365\13\10\40\0\2\111\1\0\6\261\4\111\3\261"+ + "\1\366\2\261\1\0\2\367\1\0\3\111\1\0\3\261"+ + "\3\111\1\261\13\111\40\0\2\111\2\0\1\262\2\0"+ + "\2\262\4\111\2\0\1\262\4\0\2\111\1\0\3\111"+ + "\1\0\1\262\2\0\3\111\1\0\13\111\40\0\2\111"+ + "\2\0\1\263\3\0\1\263\4\111\2\0\1\263\4\0"+ + "\2\111\1\0\3\111\4\0\3\111\1\0\13\111\40\0"+ + "\20\10\1\0\1\370\1\10\1\0\2\10\1\0\3\10"+ "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\1\10\1\344\1\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\10\1\345\1\10"+ + "\1\0\1\371\2\10\1\0\22\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\5\10\1\372"+ + "\14\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ + "\3\10\1\0\5\10\1\373\14\10\40\0\20\10\1\0"+ + "\1\374\1\10\1\0\2\10\1\0\3\10\1\0\22\10"+ + "\40\0\20\10\1\0\1\375\1\10\1\0\2\10\1\0"+ + "\3\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\5\10\1\376\14\10\40\0"+ + "\20\10\1\0\1\377\1\10\1\0\2\10\1\0\3\10"+ "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\7\10\1\346\12\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\2\10\1\347\1\0"+ - "\22\10\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\1\350\2\11\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\15\11\1\351\4\11"+ - "\40\0\20\200\1\0\2\200\1\0\2\200\1\0\3\200"+ - "\1\0\22\200\67\0\1\352\12\0\1\353\57\0\1\354"+ - "\172\0\1\355\116\0\1\356\114\0\1\357\26\0\1\236"+ - "\112\0\1\236\1\237\121\0\1\360\3\0\2\360\6\0"+ - "\1\360\13\0\1\360\64\0\1\361\1\0\4\361\4\0"+ - "\3\361\1\0\2\361\10\0\3\361\3\0\1\361\63\0"+ - "\1\362\6\0\1\362\13\0\1\362\61\0\20\246\1\0"+ - "\2\246\1\0\2\246\1\0\3\246\1\0\22\246\43\0"+ - "\1\363\3\0\2\363\6\0\1\363\13\0\1\363\64\0"+ - "\1\364\1\0\4\364\4\0\3\364\1\0\2\364\10\0"+ - "\3\364\3\0\1\364\63\0\1\365\6\0\1\365\13\0"+ - "\1\365\61\0\2\254\1\0\2\255\2\0\2\255\4\254"+ - "\2\0\1\255\4\0\2\254\1\0\3\254\1\0\1\255"+ - "\2\0\3\254\1\0\13\254\43\0\1\255\3\0\2\255"+ - "\6\0\1\255\13\0\1\255\61\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\3\10\1\302\16\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ - "\1\0\6\10\1\366\13\10\40\0\2\111\1\0\6\262"+ - "\4\111\3\262\1\367\2\262\1\0\2\370\1\0\3\111"+ - "\1\0\3\262\3\111\1\262\13\111\40\0\2\111\2\0"+ - "\1\263\2\0\2\263\4\111\2\0\1\263\4\0\2\111"+ - "\1\0\3\111\1\0\1\263\2\0\3\111\1\0\13\111"+ - "\40\0\2\111\2\0\1\264\3\0\1\264\4\111\2\0"+ - "\1\264\4\0\2\111\1\0\3\111\4\0\3\111\1\0"+ - "\13\111\40\0\20\10\1\0\1\371\1\10\1\0\2\10"+ + "\1\0\3\10\1\0\17\10\1\u0100\2\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\2\10\1\u0101\1\0"+ + "\22\10\40\0\20\10\1\0\1\u0102\1\10\1\0\2\10"+ "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\1\372\2\10\1\0\22\10\40\0"+ + "\1\0\2\10\1\0\1\u0103\2\10\1\0\22\10\40\0"+ + "\20\10\1\0\1\u0104\1\10\1\0\2\10\1\0\3\10"+ + "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\3\10\1\0\3\10\1\u0105\16\10\40\0\20\10"+ + "\1\0\1\u0106\1\10\1\0\2\10\1\0\3\10\1\0"+ + "\22\10\40\0\20\10\1\0\1\u0107\1\10\1\0\2\10"+ + "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\1\u0108\2\10\1\0\22\10\40\0"+ "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\5\10\1\373\14\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\5\10\1\374\14\10\40\0"+ - "\20\10\1\0\1\375\1\10\1\0\2\10\1\0\3\10"+ - "\1\0\22\10\40\0\20\10\1\0\1\376\1\10\1\0"+ + "\11\10\1\u0109\10\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\10\1\u010a\1\10\1\0\22\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\1\10\1\u010b"+ + "\1\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\7\10\1\u010c\12\10\40\0"+ + "\20\10\1\0\1\u010d\1\10\1\0\2\10\1\0\3\10"+ + "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\3\10\1\0\3\10\1\u010e\16\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\3\10"+ + "\1\u010f\16\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\2\10\1\u0110\1\0\22\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\2\10\1\u0111"+ + "\17\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ + "\3\10\1\0\14\10\1\u0112\5\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\12\10\1\u0113"+ + "\7\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ + "\1\u0114\2\10\1\0\22\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\7\10\1\u0115\12\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\1\10"+ + "\1\u0116\1\10\1\0\22\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\11\10\1\u0117\10\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\12\10\1\u0118\7\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\3\10\1\0\6\10\1\u0119\13\10"+ + "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\1\10\1\u011a\20\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\1\10\1\u011b\1\10\1\0\22\10"+ + "\40\0\20\11\1\0\1\u011c\1\11\1\0\2\11\1\0"+ + "\3\11\1\0\22\11\40\0\20\11\1\0\1\u011d\1\11"+ + "\1\0\2\11\1\0\3\11\1\0\22\11\75\0\1\u011e"+ + "\115\0\1\u011f\1\0\1\u0120\57\0\1\77\3\0\2\77"+ + "\6\0\1\77\13\0\1\77\64\0\1\77\1\0\4\77"+ + "\4\0\3\77\1\0\2\77\10\0\3\77\3\0\1\77"+ + "\62\0\2\u0121\6\0\1\u0121\13\0\1\u0121\64\0\1\106"+ + "\3\0\2\106\6\0\1\106\13\0\1\106\64\0\1\106"+ + "\1\0\4\106\4\0\3\106\1\0\2\106\10\0\3\106"+ + "\3\0\1\106\62\0\2\u0122\6\0\1\u0122\13\0\1\u0122"+ + "\61\0\20\10\1\0\2\10\1\0\2\10\1\0\1\10"+ + "\1\u0123\1\10\1\0\22\10\40\0\2\253\1\0\6\366"+ + "\4\253\3\366\1\0\2\366\1\0\2\u0124\1\0\3\253"+ + "\1\0\3\366\3\253\1\366\13\253\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\6\10\1\u0125"+ + "\13\10\40\0\13\10\1\u0126\4\10\1\0\2\10\1\0"+ "\2\10\1\0\3\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\5\10\1\377"+ - "\14\10\40\0\20\10\1\0\1\u0100\1\10\1\0\2\10"+ - "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\17\10\1\u0101\2\10"+ + "\2\10\1\0\2\10\1\0\1\u0127\2\10\1\0\22\10"+ "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\2\10"+ - "\1\u0102\1\0\22\10\40\0\20\10\1\0\1\u0103\1\10"+ - "\1\0\2\10\1\0\3\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\u0104\2\10\1\0"+ - "\22\10\40\0\20\10\1\0\1\u0105\1\10\1\0\2\10"+ - "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\3\10\1\u0106\16\10"+ - "\40\0\20\10\1\0\1\u0107\1\10\1\0\2\10\1\0"+ - "\3\10\1\0\22\10\40\0\20\10\1\0\1\u0108\1\10"+ - "\1\0\2\10\1\0\3\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\u0109\2\10\1\0"+ - "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\11\10\1\u010a\10\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\10\1\u010b\1\10\1\0"+ - "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\1\10\1\u010c\1\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\7\10\1\u010d"+ - "\12\10\40\0\20\10\1\0\1\u010e\1\10\1\0\2\10"+ + "\1\u0128\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\1\u0129\1\10\1\0\3\10\1\0\22\10\40\0\5\10"+ + "\1\u012a\12\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\3\10\1\0\1\10\1\u012b\20\10\40\0\20\10"+ + "\1\0\1\u012c\1\10\1\0\2\10\1\0\3\10\1\0"+ + "\22\10\40\0\20\10\1\0\1\u012d\1\10\1\0\2\10"+ "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\3\10\1\u010f\16\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ - "\1\0\3\10\1\u0110\16\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\2\10\1\u0111\1\0\22\10\40\0"+ - "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\2\10\1\u0112\17\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\14\10\1\u0113\5\10\40\0"+ + "\1\0\2\10\1\0\2\10\1\u012e\1\0\22\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\1\10\1\u012f"+ + "\1\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\6\10\1\u0130\13\10\40\0"+ "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\12\10\1\u0114\7\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\1\u0115\2\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\7\10"+ - "\1\u0116\12\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\1\10\1\u0117\1\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\11\10"+ - "\1\u0118\10\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\12\10\1\u0119\7\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\6\10"+ - "\1\u011a\13\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\1\10\1\u011b\20\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\10\1\u011c\1\10"+ - "\1\0\22\10\40\0\20\11\1\0\1\u011d\1\11\1\0"+ - "\2\11\1\0\3\11\1\0\22\11\40\0\20\11\1\0"+ - "\1\u011e\1\11\1\0\2\11\1\0\3\11\1\0\22\11"+ - "\75\0\1\u011f\115\0\1\u0120\1\0\1\u0121\57\0\1\77"+ - "\3\0\2\77\6\0\1\77\13\0\1\77\64\0\1\77"+ - "\1\0\4\77\4\0\3\77\1\0\2\77\10\0\3\77"+ - "\3\0\1\77\62\0\2\u0122\6\0\1\u0122\13\0\1\u0122"+ - "\64\0\1\106\3\0\2\106\6\0\1\106\13\0\1\106"+ - "\64\0\1\106\1\0\4\106\4\0\3\106\1\0\2\106"+ - "\10\0\3\106\3\0\1\106\62\0\2\u0123\6\0\1\u0123"+ - "\13\0\1\u0123\61\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\1\10\1\u0124\1\10\1\0\22\10\40\0\2\254"+ - "\1\0\6\367\4\254\3\367\1\0\2\367\1\0\2\u0125"+ - "\1\0\3\254\1\0\3\367\3\254\1\367\13\254\40\0"+ + "\6\10\1\u0131\13\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\5\10\1\u0132\14\10\40\0"+ "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\6\10\1\u0126\13\10\40\0\13\10\1\u0127\4\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\22\10\40\0"+ - "\20\10\1\0\2\10\1\0\2\10\1\0\1\u0128\2\10"+ + "\11\10\1\u0133\10\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\2\10\1\u0134\1\0\22\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\1\10\1\u0135\1\10"+ "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\2\10\1\u0129\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\1\u012a\1\10\1\0\3\10\1\0\22\10"+ - "\40\0\5\10\1\u012b\12\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\1\10\1\u012c\20\10"+ - "\40\0\20\10\1\0\1\u012d\1\10\1\0\2\10\1\0"+ - "\3\10\1\0\22\10\40\0\20\10\1\0\1\u012e\1\10"+ - "\1\0\2\10\1\0\3\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\2\10\1\u012f\1\0"+ + "\1\0\3\10\1\0\3\10\1\u0136\16\10\40\0\20\10"+ + "\1\0\1\u0137\1\10\1\0\2\10\1\0\3\10\1\0"+ "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\1\10\1\u0130\1\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\6\10\1\u0131"+ - "\13\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\6\10\1\u0132\13\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\5\10\1\u0133"+ - "\14\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\11\10\1\u0134\10\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\2\10\1\u0135\1\0\22\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\1\10"+ - "\1\u0136\1\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\3\10\1\u0137\16\10"+ - "\40\0\20\10\1\0\1\u0138\1\10\1\0\2\10\1\0"+ - "\3\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\7\10\1\u0139\12\10\40\0"+ - "\13\10\1\u013a\4\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\12\10\1\u013b\7\10\40\0"+ - "\15\10\1\u013c\2\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\11\10\1\u013d\10\10\100\0"+ - "\1\u013e\75\0\1\u013f\100\0\1\u0140\116\0\2\77\6\0"+ - "\1\77\13\0\1\77\70\0\2\106\6\0\1\106\13\0"+ - "\1\106\61\0\13\10\1\u0141\4\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\5\10\1\u0142\14\10\40\0"+ - "\20\10\1\0\2\10\1\0\2\10\1\0\1\10\1\u0143"+ - "\1\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\1\u0144\2\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\u0145\2\10\1\0"+ + "\3\10\1\0\7\10\1\u0138\12\10\40\0\13\10\1\u0139"+ + "\4\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\1\10\1\u0146\1\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\10\1\u0147\1\10\1\0"+ + "\3\10\1\0\12\10\1\u013a\7\10\40\0\15\10\1\u013b"+ + "\2\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\6\10\1\u0148\13\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\10\1\u0149\1\10\1\0"+ - "\22\10\40\0\13\10\1\u014a\4\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\10\1\u014b\1\10\1\0"+ + "\3\10\1\0\11\10\1\u013c\10\10\100\0\1\u013d\75\0"+ + "\1\u013e\100\0\1\u013f\116\0\2\77\6\0\1\77\13\0"+ + "\1\77\70\0\2\106\6\0\1\106\13\0\1\106\61\0"+ + "\13\10\1\u0140\4\10\1\0\2\10\1\0\2\10\1\0"+ + "\3\10\1\0\5\10\1\u0141\14\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\1\10\1\u0142\1\10\1\0"+ "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\12\10\1\u014c\7\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\1\10\1\u014d"+ - "\20\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\2\10\1\u014e\17\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\3\10\1\0\5\10\1\u014f"+ - "\14\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\2\10\1\u0150\1\0\22\10\40\0\20\10\1\0\1\u0151"+ - "\1\10\1\0\2\10\1\0\3\10\1\0\22\10\40\0"+ + "\1\u0143\2\10\1\0\22\10\40\0\20\10\1\0\2\10"+ + "\1\0\2\10\1\0\1\u0144\2\10\1\0\22\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\1\10\1\u0145"+ + "\1\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\10\1\u0146\1\10\1\0\22\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ + "\6\10\1\u0147\13\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\10\1\u0148\1\10\1\0\22\10\40\0"+ + "\13\10\1\u0149\4\10\1\0\2\10\1\0\2\10\1\0"+ + "\3\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\10\1\u014a\1\10\1\0\22\10\40\0"+ "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\2\10\1\u0152\17\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\7\10\1\u0153\12\10\40\0"+ + "\12\10\1\u014b\7\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\1\10\1\u014c\20\10\40\0"+ "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\1\10\1\u0154\20\10\45\0\1\u0155\107\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\2\10\1\u0156\1\0\22\10"+ - "\40\0\13\10\1\u0157\4\10\1\0\2\10\1\0\2\10"+ + "\2\10\1\u014d\17\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\3\10\1\0\5\10\1\u014e\14\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\2\10\1\u014f"+ + "\1\0\22\10\40\0\20\10\1\0\1\u0150\1\10\1\0"+ + "\2\10\1\0\3\10\1\0\22\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\2\10\1\u0151"+ + "\17\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ + "\3\10\1\0\7\10\1\u0152\12\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\1\10\1\u0153"+ + "\20\10\45\0\1\u0154\107\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\2\10\1\u0155\1\0\22\10\40\0\13\10"+ + "\1\u0156\4\10\1\0\2\10\1\0\2\10\1\0\3\10"+ + "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\3\10\1\0\1\10\1\u0157\20\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\5\10"+ + "\1\u0158\14\10\40\0\20\10\1\0\1\u0159\1\10\1\0"+ + "\2\10\1\0\3\10\1\0\22\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\3\10\1\0\7\10\1\u015a"+ + "\12\10\40\0\20\10\1\0\1\u015b\1\10\1\0\2\10"+ "\1\0\3\10\1\0\22\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\1\10\1\u0158\20\10"+ + "\1\0\2\10\1\0\1\10\1\u015c\1\10\1\0\22\10"+ "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ - "\1\0\5\10\1\u0159\14\10\40\0\20\10\1\0\1\u015a"+ + "\1\0\1\10\1\u015d\20\10\40\0\20\10\1\0\1\u015e"+ "\1\10\1\0\2\10\1\0\3\10\1\0\22\10\40\0"+ "\20\10\1\0\2\10\1\0\2\10\1\0\3\10\1\0"+ - "\7\10\1\u015b\12\10\40\0\20\10\1\0\1\u015c\1\10"+ + "\7\10\1\u015f\12\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\u0160\2\10\1\0\22\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\7\10"+ + "\1\u0161\12\10\40\0\13\10\1\u0162\4\10\1\0\2\10"+ "\1\0\2\10\1\0\3\10\1\0\22\10\40\0\20\10"+ - "\1\0\2\10\1\0\2\10\1\0\1\10\1\u015d\1\10"+ - "\1\0\22\10\40\0\20\10\1\0\2\10\1\0\2\10"+ - "\1\0\3\10\1\0\1\10\1\u015e\20\10\40\0\20\10"+ - "\1\0\1\u015f\1\10\1\0\2\10\1\0\3\10\1\0"+ - "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\3\10\1\0\7\10\1\u0160\12\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\u0161\2\10\1\0\22\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ - "\1\0\7\10\1\u0162\12\10\40\0\13\10\1\u0163\4\10"+ - "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\22\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\3\10"+ - "\1\0\5\10\1\u0164\14\10\40\0\20\10\1\0\2\10"+ - "\1\0\2\10\1\0\3\10\1\0\5\10\1\u0165\14\10"+ - "\40\0\20\10\1\0\2\10\1\0\2\10\1\0\1\u0166"+ - "\2\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ - "\2\10\1\0\3\10\1\0\13\10\1\u0167\6\10\40\0"+ - "\20\10\1\0\2\10\1\0\2\10\1\0\1\u0168\2\10"+ - "\1\0\22\10\40\0\20\10\1\0\1\u0169\1\10\1\0"+ - "\2\10\1\0\3\10\1\0\22\10\40\0\20\10\1\0"+ - "\2\10\1\0\2\10\1\0\1\10\1\u016a\1\10\1\0"+ + "\1\0\2\10\1\0\2\10\1\0\3\10\1\0\5\10"+ + "\1\u0163\14\10\40\0\20\10\1\0\2\10\1\0\2\10"+ + "\1\0\3\10\1\0\5\10\1\u0164\14\10\40\0\20\10"+ + "\1\0\2\10\1\0\2\10\1\0\1\u0165\2\10\1\0"+ "\22\10\40\0\20\10\1\0\2\10\1\0\2\10\1\0"+ - "\2\10\1\u016b\1\0\22\10\34\0"; + "\3\10\1\0\13\10\1\u0166\6\10\40\0\20\10\1\0"+ + "\2\10\1\0\2\10\1\0\1\u0167\2\10\1\0\22\10"+ + "\40\0\20\10\1\0\1\u0168\1\10\1\0\2\10\1\0"+ + "\3\10\1\0\22\10\40\0\20\10\1\0\2\10\1\0"+ + "\2\10\1\0\1\10\1\u0169\1\10\1\0\22\10\40\0"+ + "\20\10\1\0\2\10\1\0\2\10\1\0\2\10\1\u016a"+ + "\1\0\22\10\34\0"; private static int [] zzUnpackTrans() { int [] result = new int[18942]; @@ -577,13 +577,13 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { "\4\0\2\11\21\1\1\11\31\1\1\11\3\1\12\11"+ "\2\1\2\11\2\1\1\0\1\1\1\0\1\11\1\1"+ "\1\0\5\1\1\0\11\1\1\11\45\1\2\11\2\0"+ - "\1\11\1\1\3\11\1\1\17\11\1\1\2\11\1\0"+ + "\1\11\1\1\3\11\1\1\16\11\1\1\2\11\1\0"+ "\1\1\1\0\3\1\3\11\3\1\3\0\1\11\1\1"+ "\1\0\12\1\1\11\60\1\2\0\4\11\6\0\52\1"+ "\4\0\32\1\1\0\2\11\24\1\1\11\26\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[363]; + int [] result = new int[362]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -917,11 +917,11 @@ else if (zzAtEOF) { case IN_STRING: { yybegin(INITIAL); tokenEnd(); return types.STRING_VALUE; } // fall though - case 364: break; + case 363: break; case IN_OCAML_ML_COMMENT: { yybegin(INITIAL); tokenEnd(); return types.MULTI_COMMENT; } // fall though - case 365: break; + case 364: break; default: return null; } @@ -932,747 +932,742 @@ else if (zzAtEOF) { { yybegin(INITIAL); yypushback(1); } // fall through - case 150: break; + case 149: break; case 2: { return BAD_CHARACTER; } // fall through - case 151: break; + case 150: break; case 3: { return WHITE_SPACE; } // fall through - case 152: break; + case 151: break; case 4: { return types.LIDENT; } // fall through - case 153: break; + case 152: break; case 5: { return types.UIDENT; } // fall through - case 154: break; + case 153: break; case 6: { return types.SINGLE_QUOTE; } // fall through - case 155: break; + case 154: break; case 7: { return types.INT_VALUE; } // fall through - case 156: break; + case 155: break; case 8: { return types.UNDERSCORE; } // fall through - case 157: break; + case 156: break; case 9: { return types.DOT; } // fall through - case 158: break; + case 157: break; case 10: { return types.PLUS; } // fall through - case 159: break; + case 158: break; case 11: { yybegin(IN_STRING); tokenStart(); } // fall through - case 160: break; + case 159: break; case 12: { return types.BACKTICK; } // fall through - case 161: break; + case 160: break; case 13: { return types.LPAREN; } // fall through - case 162: break; + case 161: break; case 14: { return types.STAR; } // fall through - case 163: break; + case 162: break; case 15: { return types.SHARP; } // fall through - case 164: break; + case 163: break; case 16: { return types.ARROBASE; } // fall through - case 165: break; + case 164: break; case 17: { return types.COLON; } // fall through - case 166: break; + case 165: break; case 18: { return types.EQ; } // fall through - case 167: break; + case 166: break; case 19: { return types.GT; } // fall through - case 168: break; + case 167: break; case 20: { return types.MINUS; } // fall through - case 169: break; + case 168: break; case 21: { return types.LT; } // fall through - case 170: break; + case 169: break; case 22: { return types.PIPE; } // fall through - case 171: break; + case 170: break; case 23: { return types.SLASH; } // fall through - case 172: break; + case 171: break; case 24: { return types.LBRACKET; } // fall through - case 173: break; + case 172: break; case 25: { return types.RBRACKET; } // fall through - case 174: break; + case 173: break; case 26: { return types.EXCLAMATION_MARK; } // fall through - case 175: break; + case 174: break; case 27: { return types.SEMI; } // fall through - case 176: break; + case 175: break; case 28: { return types.AMPERSAND; } // fall through - case 177: break; + case 176: break; case 29: { return types.COMMA; } // fall through - case 178: break; + case 177: break; case 30: { return types.RPAREN; } // fall through - case 179: break; + case 178: break; case 31: { return types.LBRACE; } // fall through - case 180: break; + case 179: break; case 32: { return types.RBRACE; } // fall through - case 181: break; + case 180: break; case 33: { return types.QUESTION_MARK; } // fall through - case 182: break; + case 181: break; case 34: { return types.DOLLAR; } // fall through - case 183: break; + case 182: break; case 35: { return types.TILDE; } // fall through - case 184: break; + case 183: break; case 36: { return types.CARRET; } // fall through - case 185: break; + case 184: break; case 37: { return types.PERCENT; } // fall through - case 186: break; + case 185: break; case 38: { } // fall through - case 187: break; + case 186: break; case 39: { yybegin(INITIAL); tokenEnd(); return types.STRING_VALUE; } // fall through - case 188: break; + case 187: break; case 40: { inCommentString = !inCommentString; } // fall through - case 189: break; + case 188: break; case 41: { return types.TYPE_ARGUMENT; } // fall through - case 190: break; + case 189: break; case 42: { return types.FLOAT_VALUE; } // fall through - case 191: break; + case 190: break; case 43: { return types.OF; } // fall through - case 192: break; + case 191: break; case 44: { return types.OR; } // fall through - case 193: break; + case 192: break; case 45: { return types.DOTDOT; } // fall through - case 194: break; + case 193: break; case 46: { return types.PLUSDOT; } // fall through - case 195: break; + case 194: break; case 47: { return types.TO; } // fall through - case 196: break; + case 195: break; case 48: { return types.AS; } // fall through - case 197: break; + case 196: break; case 49: { return types.DO; } // fall through - case 198: break; + case 197: break; case 50: { return types.IF; } // fall through - case 199: break; + case 198: break; case 51: { return types.IN; } // fall through - case 200: break; + case 199: break; case 52: { return types.POLY_VARIANT; } // fall through - case 201: break; + case 200: break; case 53: { yybegin(IN_OCAML_ML_COMMENT); commentDepth = 1; tokenStart(); } // fall through - case 202: break; + case 201: break; case 54: { return types.STARDOT; } // fall through - case 203: break; + case 202: break; case 55: { return types.SHARPSHARP; } // fall through - case 204: break; + case 203: break; case 56: { return types.ARROBASE_2; } // fall through - case 205: break; + case 204: break; case 57: { return types.SHORTCUT; } // fall through - case 206: break; + case 205: break; case 58: { return types.COLON_EQ; } // fall through - case 207: break; + case 206: break; case 59: { return types.COLON_GT; } // fall through - case 208: break; + case 207: break; case 60: { return types.EQEQ; } // fall through - case 209: break; + case 208: break; case 61: { return types.ARROW; } // fall through - case 210: break; + case 209: break; case 62: { return types.GT_OR_EQUAL; } // fall through - case 211: break; + case 210: break; case 63: { return types.MINUSDOT; } // fall through - case 212: break; + case 211: break; case 64: { return types.RIGHT_ARROW; } // fall through - case 213: break; + case 212: break; case 65: { return types.LT_OR_EQUAL; } // fall through - case 214: break; + case 213: break; case 66: { return types.OP_STRUCT_DIFF; } // fall through - case 215: break; + case 214: break; case 67: { return types.LEFT_ARROW; } // fall through - case 216: break; + case 215: break; case 68: { return types.TAG_LT_SLASH; } // fall through - case 217: break; + case 216: break; case 69: - { return types.PIPE_FIRST; - } - // fall through - case 218: break; - case 70: { return types.PIPE_FORWARD; } // fall through - case 219: break; - case 71: + case 217: break; + case 70: { return types.L_OR; } // fall through - case 220: break; - case 72: + case 218: break; + case 71: { return types.RARRAY; } // fall through - case 221: break; - case 73: + case 219: break; + case 72: { return types.SLASHDOT; } // fall through - case 222: break; - case 74: + case 220: break; + case 73: { return types.TAG_AUTO_CLOSE; } // fall through - case 223: break; - case 75: + case 221: break; + case 74: { return types.LARRAY; } // fall through - case 224: break; - case 76: + case 222: break; + case 75: { return types.NOT_EQ; } // fall through - case 225: break; - case 77: + case 223: break; + case 76: { return types.SEMISEMI; } // fall through - case 226: break; - case 78: + case 224: break; + case 77: { return types.L_AND; } // fall through - case 227: break; - case 79: + case 225: break; + case 78: { if (!inCommentString) commentDepth += 1; } // fall through - case 228: break; - case 80: + case 226: break; + case 79: { if (!inCommentString) { commentDepth -= 1; if(commentDepth == 0) { yybegin(INITIAL); tokenEnd(); return types.MULTI_COMMENT; } } } // fall through - case 229: break; - case 81: + case 227: break; + case 80: { return types.CHAR_VALUE; } // fall through - case 230: break; - case 82: + case 228: break; + case 81: { return types.FOR; } // fall through - case 231: break; - case 83: + case 229: break; + case 82: { return types.FUN; } // fall through - case 232: break; - case 84: + case 230: break; + case 83: { return types.DOTDOTDOT; } // fall through - case 233: break; - case 85: + case 231: break; + case 84: { return types.END; } // fall through - case 234: break; - case 86: + case 232: break; + case 85: { return types.PRI; } // fall through - case 235: break; - case 87: + case 233: break; + case 86: { return types.PUB; } // fall through - case 236: break; - case 88: + case 234: break; + case 87: { return types.NEW; } // fall through - case 237: break; - case 89: + case 235: break; + case 88: { return types.TRY; } // fall through - case 238: break; - case 90: + case 236: break; + case 89: { return types.REF; } // fall through - case 239: break; - case 91: + case 237: break; + case 90: { return types.REC; } // fall through - case 240: break; - case 92: + case 238: break; + case 91: { return types.RAW; } // fall through - case 241: break; - case 93: + case 239: break; + case 92: { return types.AND; } // fall through - case 242: break; - case 94: + case 240: break; + case 93: { return types.ASR; } // fall through - case 243: break; - case 95: + case 241: break; + case 94: { return types.SIG; } // fall through - case 244: break; - case 96: + case 242: break; + case 95: { return types.LOR; } // fall through - case 245: break; - case 97: + case 243: break; + case 96: { return types.LET; } // fall through - case 246: break; - case 98: + case 244: break; + case 97: { return types.LSR; } // fall through - case 247: break; - case 99: + case 245: break; + case 98: { return types.LSL; } // fall through - case 248: break; - case 100: + case 246: break; + case 99: { return types.MOD; } // fall through - case 249: break; - case 101: + case 247: break; + case 100: { return types.VAL; } // fall through - case 250: break; - case 102: + case 248: break; + case 101: { return types.DIRECTIVE_IF; } // fall through - case 251: break; - case 103: + case 249: break; + case 102: { return types.ARROBASE_3; } // fall through - case 252: break; - case 104: + case 250: break; + case 103: { return types.EQEQEQ; } // fall through - case 253: break; - case 105: + case 251: break; + case 104: { return types.NOT_EQEQ; } // fall through - case 254: break; - case 106: + case 252: break; + case 105: { return types.OPEN; } // fall through - case 255: break; - case 107: + case 253: break; + case 106: { return types.ELSE; } // fall through - case 256: break; - case 108: + case 254: break; + case 107: { return types.BOOL_VALUE; } // fall through - case 257: break; - case 109: + case 255: break; + case 108: { return types.THEN; } // fall through - case 258: break; - case 110: + case 256: break; + case 109: { return types.TYPE; } // fall through - case 259: break; - case 111: + case 257: break; + case 110: { return types.DONE; } // fall through - case 260: break; - case 112: + case 258: break; + case 111: { return types.LXOR; } // fall through - case 261: break; - case 113: + case 259: break; + case 112: { return types.LAND; } // fall through - case 262: break; - case 114: + case 260: break; + case 113: { return types.LAZY; } // fall through - case 263: break; - case 115: + case 261: break; + case 114: { return types.WITH; } // fall through - case 264: break; - case 116: + case 262: break; + case 115: { return types.WHEN; } // fall through - case 265: break; - case 117: + case 263: break; + case 116: { return types.UNIT; } // fall through - case 266: break; - case 118: + case 264: break; + case 117: { return types.NONE; } // fall through - case 267: break; - case 119: + case 265: break; + case 118: { return types.SOME; } // fall through - case 268: break; - case 120: + case 266: break; + case 119: { return types.DIRECTIVE_END; } // fall through - case 269: break; - case 121: + case 267: break; + case 120: { return types.BEGIN; } // fall through - case 270: break; - case 122: + case 268: break; + case 121: { return types.ENDIF; } // fall through - case 271: break; - case 123: + case 269: break; + case 122: { return types.RAISE; } // fall through - case 272: break; - case 124: + case 270: break; + case 123: { return types.CLASS; } // fall through - case 273: break; - case 125: + case 271: break; + case 124: { return types.WHILE; } // fall through - case 274: break; - case 126: + case 272: break; + case 125: { return types.MATCH; } // fall through - case 275: break; - case 127: + case 273: break; + case 126: { return types.DIRECTIVE_ELSE; } // fall through - case 276: break; - case 128: + case 274: break; + case 127: { return types.DIRECTIVE_ELIF; } // fall through - case 277: break; - case 129: + case 275: break; + case 128: { return types.OBJECT; } // fall through - case 278: break; - case 130: + case 276: break; + case 129: { return types.OPTION; } // fall through - case 279: break; - case 131: + case 277: break; + case 130: { return types.NONREC; } // fall through - case 280: break; - case 132: + case 278: break; + case 131: { return types.ASSERT; } // fall through - case 281: break; - case 133: + case 279: break; + case 132: { return types.DOWNTO; } // fall through - case 282: break; - case 134: + case 280: break; + case 133: { return types.STRUCT; } // fall through - case 283: break; - case 135: + case 281: break; + case 134: { return types.SWITCH; } // fall through - case 284: break; - case 136: + case 282: break; + case 135: { return types.MODULE; } // fall through - case 285: break; - case 137: + case 283: break; + case 136: { return types.METHOD; } // fall through - case 286: break; - case 138: + case 284: break; + case 137: { return types.DIRECTIVE_ENDIF; } // fall through - case 287: break; - case 139: + case 285: break; + case 138: { return types.FUNCTOR; } // fall through - case 288: break; - case 140: + case 286: break; + case 139: { return types.PRIVATE; } // fall through - case 289: break; - case 141: + case 287: break; + case 140: { return types.INCLUDE; } // fall through - case 290: break; - case 142: + case 288: break; + case 141: { return types.INHERIT; } // fall through - case 291: break; - case 143: + case 289: break; + case 142: { return types.MUTABLE; } // fall through - case 292: break; - case 144: + case 290: break; + case 143: { return types.VIRTUAL; } // fall through - case 293: break; - case 145: + case 291: break; + case 144: { return types.FUNCTION; } // fall through - case 294: break; - case 146: + case 292: break; + case 145: { return types.EXTERNAL; } // fall through - case 295: break; - case 147: + case 293: break; + case 146: { return types.EXCEPTION; } // fall through - case 296: break; - case 148: + case 294: break; + case 147: { return types.CONSTRAINT; } // fall through - case 297: break; - case 149: + case 295: break; + case 148: { return types.INITIALIZER; } // fall through - case 298: break; + case 296: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/src/com/reason/lang/ocaml/OclParser.java b/src/com/reason/lang/ocaml/OclParser.java index 6f3d5fb83..bf32cee90 100644 --- a/src/com/reason/lang/ocaml/OclParser.java +++ b/src/com/reason/lang/ocaml/OclParser.java @@ -814,8 +814,7 @@ private void parseLBrace(@NotNull ParserState state) { state.mark(m_types.C_FUN_PARAM); } - state - .markScope(m_types.C_RECORD_EXPR, m_types.LBRACE) + state.markScope(m_types.C_RECORD_EXPR, m_types.LBRACE) .advance() .mark(m_types.C_RECORD_FIELD); } @@ -888,6 +887,8 @@ private void parseLIdent(@NotNull ParserState state) { state.wrapWith(m_types.C_LOWER_IDENTIFIER); } else if (state.is(m_types.C_DECONSTRUCTION)) { state.wrapWith(m_types.C_LOWER_IDENTIFIER); + } else if (state.is(m_types.C_RECORD_FIELD)) { + state.wrapWith(m_types.C_LOWER_IDENTIFIER); } else if (state.is(m_types.C_MACRO_NAME)) { // [@ |>x.y<| ... ] state.advance(); diff --git a/src/com/reason/lang/ocaml/OclQNameFinder.java b/src/com/reason/lang/ocaml/OclQNameFinder.java index f72dcdaae..9928bf104 100644 --- a/src/com/reason/lang/ocaml/OclQNameFinder.java +++ b/src/com/reason/lang/ocaml/OclQNameFinder.java @@ -91,7 +91,7 @@ private OclQNameFinder() { resolvedQualifiedNames.addAll(extendPathWith(filePath, openName, resolvedQualifiedNames)); resolvedQualifiedNames.add(openName + resolvedPathExtension); } else if (item instanceof PsiOpen || item instanceof PsiInclude) { - String openName = item instanceof PsiOpen ? ((PsiOpen) item).getPath() : ((PsiInclude) item).getPath(); + String openName = item instanceof PsiOpen ? ((PsiOpen) item).getPath() : ((PsiInclude) item).getIncludePath(); String moduleName = ((FileBase) sourceElement.getContainingFile()).getModuleName(); // Add open value to all previous elements qualifiedNames.addAll(extendPathWith(filePath, openName, qualifiedNames)); diff --git a/src/com/reason/lang/ocaml/OclTypes.java b/src/com/reason/lang/ocaml/OclTypes.java index 3d8ea5cdb..91b251206 100644 --- a/src/com/reason/lang/ocaml/OclTypes.java +++ b/src/com/reason/lang/ocaml/OclTypes.java @@ -22,6 +22,8 @@ private OclTypes() { C_FUNCTOR_PARAM = (ORCompositeType) OclStubBasedElementTypes.C_FUNCTOR_PARAM; C_RECORD_FIELD = (ORCompositeType) OclStubBasedElementTypes.C_RECORD_FIELD; C_VARIANT_DECLARATION = (ORCompositeType) OclStubBasedElementTypes.C_VARIANT_DECLARATION; + C_INCLUDE = (ORCompositeType) OclStubBasedElementTypes.C_INCLUDE; + C_OPEN = (ORCompositeType) OclStubBasedElementTypes.C_OPEN; // Composite element types @@ -42,7 +44,6 @@ private OclTypes() { C_DO_LOOP = new ORCompositeElementType("C_DO_LOOP", OclLanguage.INSTANCE); C_LOWER_IDENTIFIER = new ORCompositeElementType("C_LOWER_IDENTIFIER", OclLanguage.INSTANCE); C_UPPER_IDENTIFIER = new ORCompositeElementType("C_UPPER_IDENTIFIER", OclLanguage.INSTANCE); - C_INCLUDE = new ORCompositeElementType("C_INCLUDE", OclLanguage.INSTANCE); C_FUN_CALL_PARAMS = new ORCompositeElementType("C_FUN_CALL_PARAMS", OclLanguage.INSTANCE); C_FUN_EXPR = new ORCompositeElementType("C_FUN_EXPR", OclLanguage.INSTANCE); C_FUN_PARAMS = new ORCompositeElementType("C_FUN_PARAMS", OclLanguage.INSTANCE); @@ -69,7 +70,6 @@ private OclTypes() { C_NAMED_PARAM = new ORCompositeElementType("C_NAMED_PARAM", OclLanguage.INSTANCE); C_OBJECT = new ORCompositeElementType("C_OBJECT", OclLanguage.INSTANCE); C_OBJECT_FIELD = new ORCompositeElementType("C_OBJECT_FIELD", OclLanguage.INSTANCE); - C_OPEN = new ORCompositeElementType("C_OPEN", OclLanguage.INSTANCE); C_OPTION = new ORCompositeElementType("C_OPTION", OclLanguage.INSTANCE); C_PARAMETERS = new ORCompositeElementType("C_PARAMETERS", OclLanguage.INSTANCE); C_PATTERN_MATCH_BODY = new ORCompositeElementType("C_PATTERN_MATCH_BODY", OclLanguage.INSTANCE); @@ -185,7 +185,6 @@ private OclTypes() { VARIANT_NAME = new ORTokenElementType("VARIANT_NAME", OclLanguage.INSTANCE); PIPE = new ORTokenElementType("PIPE", OclLanguage.INSTANCE); PIPE_FORWARD = new ORTokenElementType("PIPE_FORWARD", OclLanguage.INSTANCE); - PIPE_FIRST = new ORTokenElementType("PIPE_FIRST", OclLanguage.INSTANCE); PLUS = new ORTokenElementType("PLUS", OclLanguage.INSTANCE); PERCENT = new ORTokenElementType("PERCENT", OclLanguage.INSTANCE); PLUSDOT = new ORTokenElementType("PLUSDOT", OclLanguage.INSTANCE); diff --git a/src/com/reason/lang/reason/ReasonML.flex b/src/com/reason/lang/reason/ReasonML.flex index 7dfe831ff..78cb4b74d 100644 --- a/src/com/reason/lang/reason/ReasonML.flex +++ b/src/com/reason/lang/reason/ReasonML.flex @@ -194,7 +194,6 @@ ESCAPE_CHAR= {ESCAPE_BACKSLASH} | {ESCAPE_SINGLE_QUOTE} | {ESCAPE_LF} | {ESCAPE_ "->" { return types.RIGHT_ARROW; } "<-" { return types.LEFT_ARROW; } "|>" { return types.PIPE_FORWARD; } - "|." { return types.PIPE_FIRST; } "" { return types.TAG_AUTO_CLOSE; } "[|" { return types.LARRAY; } diff --git a/src/com/reason/lang/reason/ReasonMLLexer.java b/src/com/reason/lang/reason/ReasonMLLexer.java index ade54b28d..e1382c04b 100644 --- a/src/com/reason/lang/reason/ReasonMLLexer.java +++ b/src/com/reason/lang/reason/ReasonMLLexer.java @@ -86,28 +86,27 @@ public static int ZZ_CMAP(int ch) { "\1\61\1\62\3\4\1\63\1\64\20\4\2\5\1\65"+ "\1\66\1\67\1\70\1\71\1\72\2\0\1\73\1\74"+ "\1\75\1\76\1\77\1\100\1\101\1\102\1\103\1\104"+ - "\1\105\1\106\1\107\1\110\1\0\1\111\1\112\1\113"+ - "\1\114\1\115\1\0\1\116\1\117\1\120\1\121\1\0"+ - "\1\46\1\0\3\46\1\122\1\123\1\0\1\124\1\52"+ - "\2\124\3\0\2\53\1\0\1\125\1\4\1\126\3\7"+ - "\4\4\1\127\2\4\1\130\1\4\1\131\1\132\1\4"+ - "\1\133\1\4\1\134\2\4\1\135\1\136\1\4\1\137"+ - "\1\140\1\141\4\4\1\142\7\4\1\143\1\144\2\4"+ - "\1\145\1\146\4\4\1\147\3\4\1\150\1\4\2\5"+ - "\2\0\1\151\1\152\1\153\1\154\1\155\1\156\6\0"+ - "\1\4\1\53\1\7\1\4\1\157\5\4\1\160\2\4"+ - "\1\161\1\162\1\163\2\4\1\164\10\4\1\165\1\166"+ - "\1\167\1\170\1\171\1\4\1\172\5\4\1\173\1\174"+ - "\1\175\4\0\1\4\1\53\2\4\1\176\2\4\1\177"+ - "\2\4\1\200\10\4\1\201\1\202\2\4\1\203\2\4"+ - "\1\0\1\204\1\205\2\4\1\206\1\207\3\4\1\210"+ - "\1\211\1\212\1\213\1\214\4\4\1\215\1\216\2\4"+ - "\1\217\1\220\3\4\1\221\1\4\1\222\1\223\1\4"+ - "\1\224\1\225\1\226\1\227\3\4\1\230\3\4\1\231"+ - "\1\232"; + "\1\105\1\106\1\107\1\0\1\110\1\111\1\112\1\113"+ + "\1\114\1\0\1\115\1\116\1\117\1\120\1\0\1\46"+ + "\1\0\3\46\1\121\1\122\1\0\1\123\1\52\2\123"+ + "\3\0\2\53\1\0\1\124\1\4\1\125\3\7\4\4"+ + "\1\126\2\4\1\127\1\4\1\130\1\131\1\4\1\132"+ + "\1\4\1\133\2\4\1\134\1\135\1\4\1\136\1\137"+ + "\1\140\4\4\1\141\7\4\1\142\1\143\2\4\1\144"+ + "\1\145\4\4\1\146\3\4\1\147\1\4\2\5\2\0"+ + "\1\150\1\151\1\152\1\153\1\154\1\155\6\0\1\4"+ + "\1\53\1\7\1\4\1\156\5\4\1\157\2\4\1\160"+ + "\1\161\1\162\2\4\1\163\10\4\1\164\1\165\1\166"+ + "\1\167\1\170\1\4\1\171\5\4\1\172\1\173\1\174"+ + "\4\0\1\4\1\53\2\4\1\175\2\4\1\176\2\4"+ + "\1\177\10\4\1\200\1\201\2\4\1\202\2\4\1\0"+ + "\1\203\1\204\2\4\1\205\1\206\3\4\1\207\1\210"+ + "\1\211\1\212\1\213\4\4\1\214\1\215\2\4\1\216"+ + "\1\217\3\4\1\220\1\4\1\221\1\222\1\4\1\223"+ + "\1\224\1\225\1\226\3\4\1\227\3\4\1\230\1\231"; private static int [] zzUnpackAction() { - int [] result = new int[373]; + int [] result = new int[372]; int offset = 0; offset = zzUnpackAction(ZZ_ACTION_PACKED_0, offset, result); return result; @@ -150,38 +149,38 @@ private static int zzUnpackAction(String packed, int offset, int [] result) { "\0\u1d2d\0\u1d7a\0\u1dc7\0\u1e14\0\u1e61\0\u1eae\0\u1efb\0\u1f48"+ "\0\u1f95\0\u1fe2\0\u202f\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181"+ "\0\u207c\0\u20c9\0\u0181\0\u2116\0\u0181\0\u0181\0\u0181\0\u2163"+ - "\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181"+ - "\0\u21b0\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u21fd\0\u0181"+ - "\0\u224a\0\u0181\0\u0181\0\u0f0a\0\u2297\0\u22e4\0\u2331\0\u237e"+ - "\0\u23cb\0\u0181\0\u0181\0\u103e\0\u0181\0\u2418\0\u2418\0\u108b"+ - "\0\u2465\0\u24b2\0\u24ff\0\u0181\0\u254c\0\u2599\0\u021b\0\u25e6"+ - "\0\u2633\0\u2680\0\u26cd\0\u271a\0\u2767\0\u27b4\0\u2801\0\u284e"+ - "\0\u0181\0\u289b\0\u28e8\0\u2935\0\u2982\0\u29cf\0\u021b\0\u2a1c"+ - "\0\u021b\0\u2a69\0\u021b\0\u2ab6\0\u2b03\0\u021b\0\u021b\0\u2b50"+ - "\0\u021b\0\u021b\0\u021b\0\u2b9d\0\u2bea\0\u2c37\0\u2c84\0\u021b"+ - "\0\u2cd1\0\u2d1e\0\u2d6b\0\u2db8\0\u2e05\0\u2e52\0\u2e9f\0\u021b"+ - "\0\u021b\0\u2eec\0\u2f39\0\u021b\0\u021b\0\u2f86\0\u2fd3\0\u3020"+ - "\0\u306d\0\u30ba\0\u3107\0\u3154\0\u31a1\0\u021b\0\u31ee\0\u323b"+ - "\0\u3288\0\u32d5\0\u3322\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181"+ - "\0\u0181\0\u336f\0\u33bc\0\u3409\0\u3456\0\u34a3\0\u34f0\0\u353d"+ - "\0\u358a\0\u11bf\0\u35d7\0\u021b\0\u3624\0\u3671\0\u36be\0\u370b"+ - "\0\u3758\0\u021b\0\u37a5\0\u37f2\0\u021b\0\u021b\0\u021b\0\u383f"+ - "\0\u388c\0\u021b\0\u38d9\0\u3926\0\u3973\0\u39c0\0\u3a0d\0\u3a5a"+ - "\0\u3aa7\0\u3af4\0\u021b\0\u021b\0\u021b\0\u021b\0\u021b\0\u3b41"+ - "\0\u021b\0\u3b8e\0\u3bdb\0\u3c28\0\u3c75\0\u3cc2\0\u0268\0\u0268"+ - "\0\u3d0f\0\u3d5c\0\u3da9\0\u3df6\0\u3e43\0\u3e90\0\u11bf\0\u3edd"+ - "\0\u3f2a\0\u021b\0\u3f77\0\u3fc4\0\u021b\0\u4011\0\u405e\0\u021b"+ - "\0\u40ab\0\u40f8\0\u4145\0\u4192\0\u41df\0\u422c\0\u4279\0\u42c6"+ - "\0\u021b\0\u021b\0\u4313\0\u4360\0\u021b\0\u43ad\0\u43fa\0\u4447"+ - "\0\u0181\0\u0181\0\u4494\0\u44e1\0\u021b\0\u021b\0\u452e\0\u457b"+ - "\0\u45c8\0\u021b\0\u021b\0\u021b\0\u021b\0\u021b\0\u4615\0\u4662"+ - "\0\u46af\0\u46fc\0\u021b\0\u021b\0\u4749\0\u4796\0\u0181\0\u021b"+ - "\0\u47e3\0\u4830\0\u487d\0\u021b\0\u48ca\0\u021b\0\u021b\0\u4917"+ - "\0\u021b\0\u021b\0\u021b\0\u021b\0\u4964\0\u49b1\0\u49fe\0\u021b"+ - "\0\u4a4b\0\u4a98\0\u4ae5\0\u021b\0\u021b"; + "\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u21b0"+ + "\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u21fd\0\u0181\0\u224a"+ + "\0\u0181\0\u0181\0\u0f0a\0\u2297\0\u22e4\0\u2331\0\u237e\0\u23cb"+ + "\0\u0181\0\u0181\0\u103e\0\u0181\0\u2418\0\u2418\0\u108b\0\u2465"+ + "\0\u24b2\0\u24ff\0\u0181\0\u254c\0\u2599\0\u021b\0\u25e6\0\u2633"+ + "\0\u2680\0\u26cd\0\u271a\0\u2767\0\u27b4\0\u2801\0\u284e\0\u0181"+ + "\0\u289b\0\u28e8\0\u2935\0\u2982\0\u29cf\0\u021b\0\u2a1c\0\u021b"+ + "\0\u2a69\0\u021b\0\u2ab6\0\u2b03\0\u021b\0\u021b\0\u2b50\0\u021b"+ + "\0\u021b\0\u021b\0\u2b9d\0\u2bea\0\u2c37\0\u2c84\0\u021b\0\u2cd1"+ + "\0\u2d1e\0\u2d6b\0\u2db8\0\u2e05\0\u2e52\0\u2e9f\0\u021b\0\u021b"+ + "\0\u2eec\0\u2f39\0\u021b\0\u021b\0\u2f86\0\u2fd3\0\u3020\0\u306d"+ + "\0\u30ba\0\u3107\0\u3154\0\u31a1\0\u021b\0\u31ee\0\u323b\0\u3288"+ + "\0\u32d5\0\u3322\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181\0\u0181"+ + "\0\u336f\0\u33bc\0\u3409\0\u3456\0\u34a3\0\u34f0\0\u353d\0\u358a"+ + "\0\u11bf\0\u35d7\0\u021b\0\u3624\0\u3671\0\u36be\0\u370b\0\u3758"+ + "\0\u021b\0\u37a5\0\u37f2\0\u021b\0\u021b\0\u021b\0\u383f\0\u388c"+ + "\0\u021b\0\u38d9\0\u3926\0\u3973\0\u39c0\0\u3a0d\0\u3a5a\0\u3aa7"+ + "\0\u3af4\0\u021b\0\u021b\0\u021b\0\u021b\0\u021b\0\u3b41\0\u021b"+ + "\0\u3b8e\0\u3bdb\0\u3c28\0\u3c75\0\u3cc2\0\u0268\0\u0268\0\u3d0f"+ + "\0\u3d5c\0\u3da9\0\u3df6\0\u3e43\0\u3e90\0\u11bf\0\u3edd\0\u3f2a"+ + "\0\u021b\0\u3f77\0\u3fc4\0\u021b\0\u4011\0\u405e\0\u021b\0\u40ab"+ + "\0\u40f8\0\u4145\0\u4192\0\u41df\0\u422c\0\u4279\0\u42c6\0\u021b"+ + "\0\u021b\0\u4313\0\u4360\0\u021b\0\u43ad\0\u43fa\0\u4447\0\u0181"+ + "\0\u0181\0\u4494\0\u44e1\0\u021b\0\u021b\0\u452e\0\u457b\0\u45c8"+ + "\0\u021b\0\u021b\0\u021b\0\u021b\0\u021b\0\u4615\0\u4662\0\u46af"+ + "\0\u46fc\0\u021b\0\u021b\0\u4749\0\u4796\0\u0181\0\u021b\0\u47e3"+ + "\0\u4830\0\u487d\0\u021b\0\u48ca\0\u021b\0\u021b\0\u4917\0\u021b"+ + "\0\u021b\0\u021b\0\u021b\0\u4964\0\u49b1\0\u49fe\0\u021b\0\u4a4b"+ + "\0\u4a98\0\u4ae5\0\u021b\0\u021b"; private static int [] zzUnpackRowMap() { - int [] result = new int[373]; + int [] result = new int[372]; int offset = 0; offset = zzUnpackRowMap(ZZ_ROWMAP_PACKED_0, offset, result); return result; @@ -269,278 +268,277 @@ private static int zzUnpackRowMap(String packed, int offset, int [] result) { "\1\210\115\0\1\211\16\0\1\212\21\0\1\213\115\0"+ "\1\214\115\0\1\215\1\216\1\217\113\0\1\220\1\221"+ "\113\0\1\222\47\0\1\223\45\0\1\224\106\0\1\225"+ - "\4\0\1\226\1\0\1\227\45\0\1\230\30\0\1\231"+ - "\14\0\1\232\2\0\1\233\1\0\1\234\1\0\1\235"+ - "\110\0\1\236\74\0\1\237\17\0\1\240\110\0\1\241"+ - "\126\0\1\242\115\0\1\243\11\0\1\100\1\244\112\0"+ - "\1\100\1\245\1\246\4\100\1\247\3\100\2\247\1\250"+ - "\1\100\1\251\3\100\1\247\13\100\1\247\21\100\2\0"+ - "\32\100\65\0\1\252\113\0\1\253\31\0\1\107\1\254"+ - "\120\0\1\255\112\0\2\256\1\257\15\256\1\0\2\256"+ - "\1\0\2\256\1\0\3\256\1\0\22\256\42\0\1\260"+ - "\1\261\3\0\2\261\1\262\1\0\1\263\1\0\1\111"+ - "\1\0\1\261\6\0\5\111\1\261\61\0\2\264\1\0"+ - "\2\115\2\0\2\115\4\264\2\0\1\115\1\0\2\116"+ - "\1\0\2\264\1\0\3\264\1\0\1\115\2\0\3\264"+ - "\1\0\13\264\43\0\1\265\3\0\2\265\6\0\1\265"+ - "\3\0\1\266\7\0\1\265\33\0\1\266\25\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\2\11\1\267\1\0"+ - "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\7\11\1\270\12\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\1\271\2\11\1\0\22\11"+ - "\43\0\1\272\1\0\4\272\4\0\3\272\1\0\2\272"+ - "\10\0\3\272\3\0\1\272\62\0\2\273\6\0\1\273"+ - "\13\0\1\273\71\0\1\274\6\0\1\274\75\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\16\11"+ - "\1\275\3\11\40\0\20\11\1\0\1\276\1\11\1\0"+ - "\2\11\1\0\1\11\1\277\1\11\1\0\22\11\40\0"+ + "\4\0\1\226\1\0\1\227\76\0\1\230\14\0\1\231"+ + "\2\0\1\232\1\0\1\233\1\0\1\234\110\0\1\235"+ + "\74\0\1\236\17\0\1\237\110\0\1\240\126\0\1\241"+ + "\115\0\1\242\11\0\1\100\1\243\112\0\1\100\1\244"+ + "\1\245\4\100\1\246\3\100\2\246\1\247\1\100\1\250"+ + "\3\100\1\246\13\100\1\246\21\100\2\0\32\100\65\0"+ + "\1\251\113\0\1\252\31\0\1\107\1\253\120\0\1\254"+ + "\112\0\2\255\1\256\15\255\1\0\2\255\1\0\2\255"+ + "\1\0\3\255\1\0\22\255\42\0\1\257\1\260\3\0"+ + "\2\260\1\261\1\0\1\262\1\0\1\111\1\0\1\260"+ + "\6\0\5\111\1\260\61\0\2\263\1\0\2\115\2\0"+ + "\2\115\4\263\2\0\1\115\1\0\2\116\1\0\2\263"+ + "\1\0\3\263\1\0\1\115\2\0\3\263\1\0\13\263"+ + "\43\0\1\264\3\0\2\264\6\0\1\264\3\0\1\265"+ + "\7\0\1\264\33\0\1\265\25\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\2\11\1\266\1\0\22\11\40\0"+ "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\4\11\1\300\15\11\60\0\1\301\74\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\1\11\1\302\1\11\1\0"+ - "\6\11\1\303\13\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\2\11\1\304\17\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\3\11\1\305\16\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\5\11\1\306\14\11\40\0"+ - "\15\11\1\307\2\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\310\2\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\10\11"+ - "\1\311\11\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\11\11\1\312\2\11\1\313\5\11"+ - "\40\0\20\11\1\0\1\314\1\11\1\0\2\11\1\0"+ + "\7\11\1\267\12\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\1\270\2\11\1\0\22\11\43\0\1\271"+ + "\1\0\4\271\4\0\3\271\1\0\2\271\10\0\3\271"+ + "\3\0\1\271\62\0\2\272\6\0\1\272\13\0\1\272"+ + "\71\0\1\273\6\0\1\273\75\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\16\11\1\274\3\11"+ + "\40\0\20\11\1\0\1\275\1\11\1\0\2\11\1\0"+ + "\1\11\1\276\1\11\1\0\22\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\4\11\1\277"+ + "\15\11\60\0\1\300\74\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\1\11\1\301\1\11\1\0\6\11\1\302"+ + "\13\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\2\11\1\303\17\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\3\11\1\304"+ + "\16\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\5\11\1\305\14\11\40\0\15\11\1\306"+ + "\2\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ + "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\1\307\2\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\10\11\1\310\11\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ + "\1\0\11\11\1\311\2\11\1\312\5\11\40\0\20\11"+ + "\1\0\1\313\1\11\1\0\2\11\1\0\3\11\1\0"+ + "\22\11\40\0\20\11\1\0\2\11\1\0\1\314\1\11"+ + "\1\0\3\11\1\0\22\11\40\0\5\11\1\315\12\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\6\11"+ + "\1\316\13\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\3\11\1\0\5\11\1\317\2\11\1\320\11\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ + "\1\0\2\11\1\321\17\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\2\11\1\322\1\0\3\11\1\323"+ + "\16\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\1\324\2\11\1\0\10\11\1\325\11\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\2\11\1\326\1\0"+ + "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\4\11\1\327\15\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\5\11\1\330"+ + "\14\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\5\11\1\331\1\332\3\11\1\333\7\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\334"+ + "\2\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\3\11\1\0\1\11\1\335\20\11\40\0"+ + "\13\11\1\336\4\11\1\0\2\11\1\0\2\11\1\0"+ "\3\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\1\315\1\11\1\0\3\11\1\0\22\11\40\0\5\11"+ - "\1\316\12\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\6\11\1\317\13\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\5\11\1\320\2\11"+ - "\1\321\11\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\2\11\1\322\17\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\2\11\1\323\1\0"+ - "\3\11\1\324\16\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\325\2\11\1\0\10\11\1\326\11\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\2\11"+ - "\1\327\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\4\11\1\330\15\11\40\0"+ + "\2\11\1\0\2\11\1\337\1\0\22\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\1\11\1\340\1\11"+ + "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\1\341\2\11\1\0\13\11\1\342\6\11\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\2\11\1\343"+ + "\1\0\7\11\1\344\12\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\1\11\1\345\1\11\1\0\22\11"+ + "\40\0\20\11\1\0\1\346\1\11\1\0\2\11\1\0"+ + "\3\11\1\0\5\11\1\347\14\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\5\11\1\350"+ + "\14\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\2\11\1\351\17\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\1\11\1\352\1\11\1\0"+ + "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\1\11\1\353\1\11\1\0\22\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\1\11\1\354\1\11\1\0"+ + "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\7\11\1\355\12\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\2\11\1\356\1\0\22\11"+ + "\40\0\20\12\1\0\2\12\1\0\2\12\1\0\1\357"+ + "\2\12\1\0\22\12\40\0\20\12\1\0\2\12\1\0"+ + "\2\12\1\0\3\12\1\0\15\12\1\360\4\12\40\0"+ + "\20\203\1\0\2\203\1\0\2\203\1\0\3\203\1\0"+ + "\22\203\67\0\1\361\12\0\1\362\57\0\1\363\172\0"+ + "\1\364\116\0\1\365\124\0\1\366\110\0\1\367\110\0"+ + "\1\370\26\0\1\244\112\0\1\244\1\245\121\0\1\371"+ + "\3\0\2\371\6\0\1\371\13\0\1\371\64\0\1\372"+ + "\1\0\4\372\4\0\3\372\1\0\2\372\10\0\3\372"+ + "\3\0\1\372\63\0\1\373\6\0\1\373\13\0\1\373"+ + "\61\0\20\255\1\0\2\255\1\0\2\255\1\0\3\255"+ + "\1\0\22\255\43\0\1\374\3\0\2\374\6\0\1\374"+ + "\13\0\1\374\64\0\1\375\1\0\4\375\4\0\3\375"+ + "\1\0\2\375\10\0\3\375\3\0\1\375\63\0\1\376"+ + "\6\0\1\376\13\0\1\376\61\0\2\263\1\0\2\264"+ + "\2\0\2\264\4\263\2\0\1\264\4\0\2\263\1\0"+ + "\3\263\1\0\1\264\2\0\3\263\1\0\13\263\43\0"+ + "\1\264\3\0\2\264\6\0\1\264\13\0\1\264\61\0"+ "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\5\11\1\331\14\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\5\11\1\332\1\333\3\11"+ - "\1\334\7\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\335\2\11\1\0\22\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\3\11\1\0\1\11\1\336"+ - "\20\11\40\0\13\11\1\337\4\11\1\0\2\11\1\0"+ + "\3\11\1\311\16\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\3\11\1\0\6\11\1\377\13\11\40\0"+ + "\2\114\1\0\6\271\4\114\3\271\1\u0100\2\271\1\0"+ + "\2\u0101\1\0\3\114\1\0\3\271\3\114\1\271\13\114"+ + "\40\0\2\114\2\0\1\272\2\0\2\272\4\114\2\0"+ + "\1\272\4\0\2\114\1\0\3\114\1\0\1\272\2\0"+ + "\3\114\1\0\13\114\40\0\2\114\2\0\1\273\3\0"+ + "\1\273\4\114\2\0\1\273\4\0\2\114\1\0\3\114"+ + "\4\0\3\114\1\0\13\114\40\0\20\11\1\0\1\u0102"+ + "\1\11\1\0\2\11\1\0\3\11\1\0\22\11\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\1\u0103\2\11"+ + "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\3\11\1\0\5\11\1\u0104\14\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\5\11"+ + "\1\u0105\14\11\40\0\20\11\1\0\1\u0106\1\11\1\0"+ "\2\11\1\0\3\11\1\0\22\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\2\11\1\340\1\0\22\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\11"+ - "\1\341\1\11\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\1\342\2\11\1\0\13\11\1\343"+ - "\6\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\2\11\1\344\1\0\7\11\1\345\12\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\1\11\1\346\1\11"+ - "\1\0\22\11\40\0\20\11\1\0\1\347\1\11\1\0"+ - "\2\11\1\0\3\11\1\0\5\11\1\350\14\11\40\0"+ + "\1\u0107\1\11\1\0\2\11\1\0\3\11\1\0\22\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ + "\1\0\5\11\1\u0108\14\11\40\0\20\11\1\0\1\u0109"+ + "\1\11\1\0\2\11\1\0\3\11\1\0\22\11\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ + "\17\11\1\u010a\2\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\2\11\1\u010b\1\0\22\11\40\0\20\11"+ + "\1\0\1\u010c\1\11\1\0\2\11\1\0\3\11\1\0"+ + "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\1\u010d\2\11\1\0\22\11\40\0\20\11\1\0\1\u010e"+ + "\1\11\1\0\2\11\1\0\3\11\1\0\22\11\40\0"+ "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\5\11\1\351\14\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\2\11\1\352\17\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\1\11\1\353"+ - "\1\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\11\1\354\1\11\1\0\22\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\1\11\1\355"+ - "\1\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\7\11\1\356\12\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\2\11\1\357"+ - "\1\0\22\11\40\0\20\12\1\0\2\12\1\0\2\12"+ - "\1\0\1\360\2\12\1\0\22\12\40\0\20\12\1\0"+ - "\2\12\1\0\2\12\1\0\3\12\1\0\15\12\1\361"+ - "\4\12\40\0\20\203\1\0\2\203\1\0\2\203\1\0"+ - "\3\203\1\0\22\203\67\0\1\362\12\0\1\363\57\0"+ - "\1\364\172\0\1\365\116\0\1\366\124\0\1\367\110\0"+ - "\1\370\110\0\1\371\26\0\1\245\112\0\1\245\1\246"+ - "\121\0\1\372\3\0\2\372\6\0\1\372\13\0\1\372"+ - "\64\0\1\373\1\0\4\373\4\0\3\373\1\0\2\373"+ - "\10\0\3\373\3\0\1\373\63\0\1\374\6\0\1\374"+ - "\13\0\1\374\61\0\20\256\1\0\2\256\1\0\2\256"+ - "\1\0\3\256\1\0\22\256\43\0\1\375\3\0\2\375"+ - "\6\0\1\375\13\0\1\375\64\0\1\376\1\0\4\376"+ - "\4\0\3\376\1\0\2\376\10\0\3\376\3\0\1\376"+ - "\63\0\1\377\6\0\1\377\13\0\1\377\61\0\2\264"+ - "\1\0\2\265\2\0\2\265\4\264\2\0\1\265\4\0"+ - "\2\264\1\0\3\264\1\0\1\265\2\0\3\264\1\0"+ - "\13\264\43\0\1\265\3\0\2\265\6\0\1\265\13\0"+ - "\1\265\61\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\3\11\1\312\16\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\3\11\1\0\6\11\1\u0100"+ - "\13\11\40\0\2\114\1\0\6\272\4\114\3\272\1\u0101"+ - "\2\272\1\0\2\u0102\1\0\3\114\1\0\3\272\3\114"+ - "\1\272\13\114\40\0\2\114\2\0\1\273\2\0\2\273"+ - "\4\114\2\0\1\273\4\0\2\114\1\0\3\114\1\0"+ - "\1\273\2\0\3\114\1\0\13\114\40\0\2\114\2\0"+ - "\1\274\3\0\1\274\4\114\2\0\1\274\4\0\2\114"+ - "\1\0\3\114\4\0\3\114\1\0\13\114\40\0\20\11"+ - "\1\0\1\u0103\1\11\1\0\2\11\1\0\3\11\1\0"+ + "\3\11\1\u010f\16\11\40\0\20\11\1\0\1\u0110\1\11"+ + "\1\0\2\11\1\0\3\11\1\0\22\11\40\0\20\11"+ + "\1\0\1\u0111\1\11\1\0\2\11\1\0\3\11\1\0"+ "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\1\u0104\2\11\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\5\11\1\u0105\14\11"+ + "\1\u0112\2\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\11\11\1\u0113\10\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\11"+ + "\1\u0114\1\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\1\11\1\u0115\1\11\1\0\22\11"+ "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\5\11\1\u0106\14\11\40\0\20\11\1\0\1\u0107"+ + "\1\0\7\11\1\u0116\12\11\40\0\20\11\1\0\1\u0117"+ "\1\11\1\0\2\11\1\0\3\11\1\0\22\11\40\0"+ - "\20\11\1\0\1\u0108\1\11\1\0\2\11\1\0\3\11"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ + "\3\11\1\u0118\16\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\3\11\1\0\3\11\1\u0119\16\11\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\2\11\1\u011a"+ "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\5\11\1\u0109\14\11\40\0\20\11"+ - "\1\0\1\u010a\1\11\1\0\2\11\1\0\3\11\1\0"+ + "\1\0\3\11\1\0\2\11\1\u011b\17\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\14\11"+ + "\1\u011c\5\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\3\11\1\0\12\11\1\u011d\7\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\1\u011e\2\11\1\0"+ "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\17\11\1\u010b\2\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\2\11\1\u010c\1\0\22\11"+ - "\40\0\20\11\1\0\1\u010d\1\11\1\0\2\11\1\0"+ - "\3\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\u010e\2\11\1\0\22\11\40\0\20\11"+ - "\1\0\1\u010f\1\11\1\0\2\11\1\0\3\11\1\0"+ + "\3\11\1\0\7\11\1\u011f\12\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\1\11\1\u0120\1\11\1\0"+ "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\3\11\1\u0110\16\11\40\0\20\11\1\0"+ - "\1\u0111\1\11\1\0\2\11\1\0\3\11\1\0\22\11"+ - "\40\0\20\11\1\0\1\u0112\1\11\1\0\2\11\1\0"+ - "\3\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\u0113\2\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\11\11"+ - "\1\u0114\10\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\11\1\u0115\1\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\1\11\1\u0116\1\11"+ + "\3\11\1\0\11\11\1\u0121\10\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\12\11\1\u0122"+ + "\7\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\3\11\1\0\6\11\1\u0123\13\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\1\11\1\u0124"+ + "\20\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ + "\1\11\1\u0125\1\11\1\0\22\11\40\0\20\12\1\0"+ + "\1\u0126\1\12\1\0\2\12\1\0\3\12\1\0\22\12"+ + "\40\0\20\12\1\0\1\u0127\1\12\1\0\2\12\1\0"+ + "\3\12\1\0\22\12\75\0\1\u0128\115\0\1\u0129\1\0"+ + "\1\u012a\57\0\1\100\3\0\2\100\6\0\1\100\13\0"+ + "\1\100\64\0\1\100\1\0\4\100\4\0\3\100\1\0"+ + "\2\100\10\0\3\100\3\0\1\100\62\0\2\u012b\6\0"+ + "\1\u012b\13\0\1\u012b\64\0\1\111\3\0\2\111\6\0"+ + "\1\111\13\0\1\111\64\0\1\111\1\0\4\111\4\0"+ + "\3\111\1\0\2\111\10\0\3\111\3\0\1\111\62\0"+ + "\2\u012c\6\0\1\u012c\13\0\1\u012c\61\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\1\11\1\u012d\1\11\1\0"+ + "\22\11\40\0\2\263\1\0\6\u0100\4\263\3\u0100\1\0"+ + "\2\u0100\1\0\2\u012e\1\0\3\263\1\0\3\u0100\3\263"+ + "\1\u0100\13\263\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\3\11\1\0\6\11\1\u012f\13\11\40\0\13\11"+ + "\1\u0130\4\11\1\0\2\11\1\0\2\11\1\0\3\11"+ "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\7\11\1\u0117\12\11\40\0\20\11"+ - "\1\0\1\u0118\1\11\1\0\2\11\1\0\3\11\1\0"+ + "\1\0\1\u0131\2\11\1\0\22\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\2\11\1\u0132\1\0\22\11"+ + "\40\0\20\11\1\0\2\11\1\0\1\u0133\1\11\1\0"+ + "\3\11\1\0\22\11\40\0\5\11\1\u0134\12\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\22\11\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ + "\1\11\1\u0135\20\11\40\0\20\11\1\0\1\u0136\1\11"+ + "\1\0\2\11\1\0\3\11\1\0\22\11\40\0\20\11"+ + "\1\0\1\u0137\1\11\1\0\2\11\1\0\3\11\1\0"+ "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\3\11\1\u0119\16\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\3\11\1\0\3\11\1\u011a"+ - "\16\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\2\11\1\u011b\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\2\11\1\u011c\17\11"+ + "\2\11\1\u0138\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\1\11\1\u0139\1\11\1\0\22\11"+ "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\14\11\1\u011d\5\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\12\11\1\u011e\7\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\u011f"+ - "\2\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\7\11\1\u0120\12\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\1\11\1\u0121"+ - "\1\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\11\11\1\u0122\10\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\12\11\1\u0123\7\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\6\11\1\u0124\13\11\40\0"+ + "\1\0\6\11\1\u013a\13\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\6\11\1\u013b\13\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ + "\1\0\5\11\1\u013c\14\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\11\11\1\u013d\10\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\2\11"+ + "\1\u013e\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\1\11\1\u013f\1\11\1\0\22\11\40\0"+ "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\1\11\1\u0125\20\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\11\1\u0126\1\11\1\0\22\11\40\0"+ - "\20\12\1\0\1\u0127\1\12\1\0\2\12\1\0\3\12"+ - "\1\0\22\12\40\0\20\12\1\0\1\u0128\1\12\1\0"+ - "\2\12\1\0\3\12\1\0\22\12\75\0\1\u0129\115\0"+ - "\1\u012a\1\0\1\u012b\57\0\1\100\3\0\2\100\6\0"+ - "\1\100\13\0\1\100\64\0\1\100\1\0\4\100\4\0"+ - "\3\100\1\0\2\100\10\0\3\100\3\0\1\100\62\0"+ - "\2\u012c\6\0\1\u012c\13\0\1\u012c\64\0\1\111\3\0"+ - "\2\111\6\0\1\111\13\0\1\111\64\0\1\111\1\0"+ - "\4\111\4\0\3\111\1\0\2\111\10\0\3\111\3\0"+ - "\1\111\62\0\2\u012d\6\0\1\u012d\13\0\1\u012d\61\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\1\11\1\u012e"+ - "\1\11\1\0\22\11\40\0\2\264\1\0\6\u0101\4\264"+ - "\3\u0101\1\0\2\u0101\1\0\2\u012f\1\0\3\264\1\0"+ - "\3\u0101\3\264\1\u0101\13\264\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\6\11\1\u0130\13\11"+ - "\40\0\13\11\1\u0131\4\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\1\u0132\2\11\1\0\22\11\40\0"+ - "\20\11\1\0\2\11\1\0\2\11\1\0\2\11\1\u0133"+ - "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\1\u0134"+ - "\1\11\1\0\3\11\1\0\22\11\40\0\5\11\1\u0135"+ - "\12\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\1\11\1\u0136\20\11\40\0\20\11\1\0"+ - "\1\u0137\1\11\1\0\2\11\1\0\3\11\1\0\22\11"+ - "\40\0\20\11\1\0\1\u0138\1\11\1\0\2\11\1\0"+ - "\3\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\2\11\1\u0139\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\1\11\1\u013a\1\11"+ - "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\6\11\1\u013b\13\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\6\11"+ - "\1\u013c\13\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\5\11\1\u013d\14\11\40\0\20\11"+ + "\3\11\1\u0140\16\11\40\0\20\11\1\0\1\u0141\1\11"+ + "\1\0\2\11\1\0\3\11\1\0\22\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\7\11"+ + "\1\u0142\12\11\40\0\13\11\1\u0143\4\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\22\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\12\11"+ + "\1\u0144\7\11\40\0\15\11\1\u0145\2\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\22\11\40\0\20\11"+ "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\11\11"+ - "\1\u013e\10\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\2\11\1\u013f\1\0\22\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\1\11\1\u0140\1\11\1\0"+ + "\1\u0146\10\11\100\0\1\u0147\75\0\1\u0148\100\0\1\u0149"+ + "\116\0\2\100\6\0\1\100\13\0\1\100\70\0\2\111"+ + "\6\0\1\111\13\0\1\111\61\0\13\11\1\u014a\4\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\5\11"+ + "\1\u014b\14\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\1\11\1\u014c\1\11\1\0\22\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\1\u014d\2\11\1\0"+ "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\3\11\1\u0141\16\11\40\0\20\11\1\0"+ - "\1\u0142\1\11\1\0\2\11\1\0\3\11\1\0\22\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\7\11\1\u0143\12\11\40\0\13\11\1\u0144\4\11"+ + "\1\u014e\2\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\1\11\1\u014f\1\11\1\0\22\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\11"+ + "\1\u0150\1\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\6\11\1\u0151\13\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\11"+ + "\1\u0152\1\11\1\0\22\11\40\0\13\11\1\u0153\4\11"+ "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\22\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\11"+ + "\1\u0154\1\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\12\11\1\u0155\7\11"+ "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\12\11\1\u0145\7\11\40\0\15\11\1\u0146\2\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\22\11"+ + "\1\0\1\11\1\u0156\20\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\3\11\1\0\2\11\1\u0157\17\11"+ "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\11\11\1\u0147\10\11\100\0\1\u0148\75\0\1\u0149"+ - "\100\0\1\u014a\116\0\2\100\6\0\1\100\13\0\1\100"+ - "\70\0\2\111\6\0\1\111\13\0\1\111\61\0\13\11"+ - "\1\u014b\4\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\5\11\1\u014c\14\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\1\11\1\u014d\1\11\1\0\22\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\u014e"+ - "\2\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\u014f\2\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\1\11\1\u0150\1\11"+ + "\1\0\5\11\1\u0158\14\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\2\11\1\u0159\1\0\22\11\40\0"+ + "\20\11\1\0\1\u015a\1\11\1\0\2\11\1\0\3\11"+ "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\11\1\u0151\1\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\6\11"+ - "\1\u0152\13\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\11\1\u0153\1\11\1\0\22\11\40\0\13\11"+ - "\1\u0154\4\11\1\0\2\11\1\0\2\11\1\0\3\11"+ + "\1\0\3\11\1\0\2\11\1\u015b\17\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\7\11"+ + "\1\u015c\12\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\3\11\1\0\1\11\1\u015d\20\11\45\0\1\u015e"+ + "\107\0\20\11\1\0\2\11\1\0\2\11\1\0\2\11"+ + "\1\u015f\1\0\22\11\40\0\13\11\1\u0160\4\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\22\11\40\0"+ + "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ + "\1\11\1\u0161\20\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\3\11\1\0\5\11\1\u0162\14\11\40\0"+ + "\20\11\1\0\1\u0163\1\11\1\0\2\11\1\0\3\11"+ "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\11\1\u0155\1\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\12\11"+ - "\1\u0156\7\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\1\11\1\u0157\20\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\2\11"+ - "\1\u0158\17\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\3\11\1\0\5\11\1\u0159\14\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\2\11\1\u015a\1\0"+ - "\22\11\40\0\20\11\1\0\1\u015b\1\11\1\0\2\11"+ - "\1\0\3\11\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\2\11\1\u015c\17\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\7\11\1\u015d\12\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\1\11\1\u015e\20\11"+ - "\45\0\1\u015f\107\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\2\11\1\u0160\1\0\22\11\40\0\13\11\1\u0161"+ - "\4\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ + "\1\0\3\11\1\0\7\11\1\u0164\12\11\40\0\20\11"+ + "\1\0\1\u0165\1\11\1\0\2\11\1\0\3\11\1\0"+ "\22\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\1\11\1\u0162\20\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\3\11\1\0\5\11\1\u0163"+ - "\14\11\40\0\20\11\1\0\1\u0164\1\11\1\0\2\11"+ + "\1\11\1\u0166\1\11\1\0\22\11\40\0\20\11\1\0"+ + "\2\11\1\0\2\11\1\0\3\11\1\0\1\11\1\u0167"+ + "\20\11\40\0\20\11\1\0\1\u0168\1\11\1\0\2\11"+ "\1\0\3\11\1\0\22\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\3\11\1\0\7\11\1\u0165\12\11"+ - "\40\0\20\11\1\0\1\u0166\1\11\1\0\2\11\1\0"+ + "\1\0\2\11\1\0\3\11\1\0\7\11\1\u0169\12\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\u016a"+ + "\2\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\3\11\1\0\7\11\1\u016b\12\11\40\0"+ + "\13\11\1\u016c\4\11\1\0\2\11\1\0\2\11\1\0"+ "\3\11\1\0\22\11\40\0\20\11\1\0\2\11\1\0"+ - "\2\11\1\0\1\11\1\u0167\1\11\1\0\22\11\40\0"+ + "\2\11\1\0\3\11\1\0\5\11\1\u016d\14\11\40\0"+ "\20\11\1\0\2\11\1\0\2\11\1\0\3\11\1\0"+ - "\1\11\1\u0168\20\11\40\0\20\11\1\0\1\u0169\1\11"+ - "\1\0\2\11\1\0\3\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\7\11"+ - "\1\u016a\12\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\u016b\2\11\1\0\22\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\3\11\1\0\7\11\1\u016c"+ - "\12\11\40\0\13\11\1\u016d\4\11\1\0\2\11\1\0"+ - "\2\11\1\0\3\11\1\0\22\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\3\11\1\0\5\11\1\u016e"+ - "\14\11\40\0\20\11\1\0\2\11\1\0\2\11\1\0"+ - "\3\11\1\0\5\11\1\u016f\14\11\40\0\20\11\1\0"+ - "\2\11\1\0\2\11\1\0\1\u0170\2\11\1\0\22\11"+ - "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\3\11"+ - "\1\0\13\11\1\u0171\6\11\40\0\20\11\1\0\2\11"+ - "\1\0\2\11\1\0\1\u0172\2\11\1\0\22\11\40\0"+ - "\20\11\1\0\1\u0173\1\11\1\0\2\11\1\0\3\11"+ - "\1\0\22\11\40\0\20\11\1\0\2\11\1\0\2\11"+ - "\1\0\1\11\1\u0174\1\11\1\0\22\11\40\0\20\11"+ - "\1\0\2\11\1\0\2\11\1\0\2\11\1\u0175\1\0"+ - "\22\11\34\0"; + "\5\11\1\u016e\14\11\40\0\20\11\1\0\2\11\1\0"+ + "\2\11\1\0\1\u016f\2\11\1\0\22\11\40\0\20\11"+ + "\1\0\2\11\1\0\2\11\1\0\3\11\1\0\13\11"+ + "\1\u0170\6\11\40\0\20\11\1\0\2\11\1\0\2\11"+ + "\1\0\1\u0171\2\11\1\0\22\11\40\0\20\11\1\0"+ + "\1\u0172\1\11\1\0\2\11\1\0\3\11\1\0\22\11"+ + "\40\0\20\11\1\0\2\11\1\0\2\11\1\0\1\11"+ + "\1\u0173\1\11\1\0\22\11\40\0\20\11\1\0\2\11"+ + "\1\0\2\11\1\0\2\11\1\u0174\1\0\22\11\34\0"; private static int [] zzUnpackTrans() { int [] result = new int[19250]; @@ -585,14 +583,14 @@ private static int zzUnpackTrans(String packed, int offset, int [] result) { "\3\1\11\11\2\1\2\11\2\1\1\11\1\1\1\0"+ "\1\1\1\0\1\11\1\1\1\0\5\1\1\0\11\1"+ "\1\11\45\1\5\11\2\0\1\11\1\1\3\11\1\1"+ - "\10\11\1\0\5\11\1\0\1\11\1\1\2\11\1\0"+ + "\7\11\1\0\5\11\1\0\1\11\1\1\2\11\1\0"+ "\1\1\1\0\3\1\2\11\1\0\1\11\3\1\3\0"+ "\1\11\1\1\1\0\12\1\1\11\60\1\2\0\6\11"+ "\6\0\52\1\4\0\32\1\1\0\2\11\24\1\1\11"+ "\26\1"; private static int [] zzUnpackAttribute() { - int [] result = new int[373]; + int [] result = new int[372]; int offset = 0; offset = zzUnpackAttribute(ZZ_ATTRIBUTE_PACKED_0, offset, result); return result; @@ -926,15 +924,15 @@ else if (zzAtEOF) { case IN_STRING: { yybegin(INITIAL); tokenEnd(); return types.STRING_VALUE; } // fall though - case 374: break; + case 373: break; case IN_REASON_ML_COMMENT: { yybegin(INITIAL); tokenEnd(); return types.MULTI_COMMENT; } // fall though - case 375: break; + case 374: break; case IN_REASON_SL_COMMENT: { yybegin(INITIAL); tokenEnd(); return types.SINGLE_COMMENT; } // fall though - case 376: break; + case 375: break; default: return null; } @@ -945,772 +943,767 @@ else if (zzAtEOF) { { yybegin(INITIAL); yypushback(1); } // fall through - case 155: break; + case 154: break; case 2: { return BAD_CHARACTER; } // fall through - case 156: break; + case 155: break; case 3: { return WHITE_SPACE; } // fall through - case 157: break; + case 156: break; case 4: { return types.LIDENT; } // fall through - case 158: break; + case 157: break; case 5: { return types.UIDENT; } // fall through - case 159: break; + case 158: break; case 6: { return types.SINGLE_QUOTE; } // fall through - case 160: break; + case 159: break; case 7: { return types.INT_VALUE; } // fall through - case 161: break; + case 160: break; case 8: { return types.UNDERSCORE; } // fall through - case 162: break; + case 161: break; case 9: { return types.DOT; } // fall through - case 163: break; + case 162: break; case 10: { return types.PLUS; } // fall through - case 164: break; + case 163: break; case 11: { yybegin(IN_STRING); tokenStart(); } // fall through - case 165: break; + case 164: break; case 12: { return types.BACKTICK; } // fall through - case 166: break; + case 165: break; case 13: { return types.SLASH; } // fall through - case 167: break; + case 166: break; case 14: { return types.STAR; } // fall through - case 168: break; + case 167: break; case 15: { return types.SHARP; } // fall through - case 169: break; + case 168: break; case 16: { return types.ARROBASE; } // fall through - case 170: break; + case 169: break; case 17: { return types.COLON; } // fall through - case 171: break; + case 170: break; case 18: { return types.EQ; } // fall through - case 172: break; + case 171: break; case 19: { return types.GT; } // fall through - case 173: break; + case 172: break; case 20: { return types.MINUS; } // fall through - case 174: break; + case 173: break; case 21: { return types.LT; } // fall through - case 175: break; + case 174: break; case 22: { return types.PIPE; } // fall through - case 176: break; + case 175: break; case 23: { return types.LBRACKET; } // fall through - case 177: break; + case 176: break; case 24: { return types.RBRACKET; } // fall through - case 178: break; + case 177: break; case 25: { return types.LBRACE; } // fall through - case 179: break; + case 178: break; case 26: { return types.RBRACE; } // fall through - case 180: break; + case 179: break; case 27: { return types.EXCLAMATION_MARK; } // fall through - case 181: break; + case 180: break; case 28: { return types.SEMI; } // fall through - case 182: break; + case 181: break; case 29: { return types.AMPERSAND; } // fall through - case 183: break; + case 182: break; case 30: { return types.COMMA; } // fall through - case 184: break; + case 183: break; case 31: { return types.LPAREN; } // fall through - case 185: break; + case 184: break; case 32: { return types.RPAREN; } // fall through - case 186: break; + case 185: break; case 33: { return types.QUESTION_MARK; } // fall through - case 187: break; + case 186: break; case 34: { return types.DOLLAR; } // fall through - case 188: break; + case 187: break; case 35: { return types.TILDE; } // fall through - case 189: break; + case 188: break; case 36: { return types.CARRET; } // fall through - case 190: break; + case 189: break; case 37: { return types.PERCENT; } // fall through - case 191: break; + case 190: break; case 38: { } // fall through - case 192: break; + case 191: break; case 39: { yybegin(INITIAL); tokenEnd(); return types.STRING_VALUE; } // fall through - case 193: break; + case 192: break; case 40: { inCommentString = !inCommentString; } // fall through - case 194: break; + case 193: break; case 41: { yybegin(INITIAL); tokenEnd(); return types.SINGLE_COMMENT; } // fall through - case 195: break; + case 194: break; case 42: { return types.TYPE_ARGUMENT; } // fall through - case 196: break; + case 195: break; case 43: { return types.FLOAT_VALUE; } // fall through - case 197: break; + case 196: break; case 44: { return types.OF; } // fall through - case 198: break; + case 197: break; case 45: { return types.OR; } // fall through - case 199: break; + case 198: break; case 46: { return types.DOTDOT; } // fall through - case 200: break; + case 199: break; case 47: { return types.PLUSDOT; } // fall through - case 201: break; + case 200: break; case 48: { return types.TO; } // fall through - case 202: break; + case 201: break; case 49: { return types.AS; } // fall through - case 203: break; + case 202: break; case 50: { return types.DO; } // fall through - case 204: break; + case 203: break; case 51: { return types.IF; } // fall through - case 205: break; + case 204: break; case 52: { return types.IN; } // fall through - case 206: break; + case 205: break; case 53: { return types.POLY_VARIANT; } // fall through - case 207: break; + case 206: break; case 54: { return types.SLASHDOT; } // fall through - case 208: break; + case 207: break; case 55: { yybegin(IN_REASON_SL_COMMENT); tokenStart(); } // fall through - case 209: break; + case 208: break; case 56: { yybegin(IN_REASON_ML_COMMENT); commentDepth = 1; tokenStart(); } // fall through - case 210: break; + case 209: break; case 57: { return types.TAG_AUTO_CLOSE; } // fall through - case 211: break; + case 210: break; case 58: { return types.STARDOT; } // fall through - case 212: break; + case 211: break; case 59: { return types.SHARPSHARP; } // fall through - case 213: break; + case 212: break; case 60: { return types.ARROBASE_2; } // fall through - case 214: break; + case 213: break; case 61: { return types.SHORTCUT; } // fall through - case 215: break; + case 214: break; case 62: { return types.COLON_EQ; } // fall through - case 216: break; + case 215: break; case 63: { return types.COLON_GT; } // fall through - case 217: break; + case 216: break; case 64: { return types.EQEQ; } // fall through - case 218: break; + case 217: break; case 65: { return types.ARROW; } // fall through - case 219: break; + case 218: break; case 66: { return types.GT_OR_EQUAL; } // fall through - case 220: break; + case 219: break; case 67: { return types.MINUSDOT; } // fall through - case 221: break; + case 220: break; case 68: { return types.RIGHT_ARROW; } // fall through - case 222: break; + case 221: break; case 69: { return types.TAG_LT_SLASH; } // fall through - case 223: break; + case 222: break; case 70: { return types.LT_OR_EQUAL; } // fall through - case 224: break; + case 223: break; case 71: { return types.LEFT_ARROW; } // fall through - case 225: break; + case 224: break; case 72: - { return types.PIPE_FIRST; - } - // fall through - case 226: break; - case 73: { return types.PIPE_FORWARD; } // fall through - case 227: break; - case 74: + case 225: break; + case 73: { return types.L_OR; } // fall through - case 228: break; - case 75: + case 226: break; + case 74: { return types.RARRAY; } // fall through - case 229: break; - case 76: + case 227: break; + case 75: { return types.ML_STRING_CLOSE; /*bs MultiLine*/ } // fall through - case 230: break; - case 77: + case 228: break; + case 76: { return types.LARRAY; } // fall through - case 231: break; - case 78: + case 229: break; + case 77: { return types.ML_STRING_OPEN; /*bs MultiLine*/ } // fall through - case 232: break; - case 79: + case 230: break; + case 78: { return types.NOT_EQ; } // fall through - case 233: break; - case 80: + case 231: break; + case 79: { return types.SEMISEMI; } // fall through - case 234: break; - case 81: + case 232: break; + case 80: { return types.L_AND; } // fall through - case 235: break; - case 82: + case 233: break; + case 81: { if (!inCommentString) commentDepth += 1; } // fall through - case 236: break; - case 83: + case 234: break; + case 82: { if (!inCommentString) { commentDepth -= 1; if(commentDepth == 0) { yybegin(INITIAL); tokenEnd(); return types.MULTI_COMMENT; } } } // fall through - case 237: break; - case 84: + case 235: break; + case 83: { return types.CHAR_VALUE; } // fall through - case 238: break; - case 85: + case 236: break; + case 84: { return types.FOR; } // fall through - case 239: break; - case 86: + case 237: break; + case 85: { return types.FUN; } // fall through - case 240: break; - case 87: + case 238: break; + case 86: { return types.DOTDOTDOT; } // fall through - case 241: break; - case 88: + case 239: break; + case 87: { return types.END; } // fall through - case 242: break; - case 89: + case 240: break; + case 88: { return types.PRI; } // fall through - case 243: break; - case 90: + case 241: break; + case 89: { return types.PUB; } // fall through - case 244: break; - case 91: + case 242: break; + case 90: { return types.NEW; } // fall through - case 245: break; - case 92: + case 243: break; + case 91: { return types.TRY; } // fall through - case 246: break; - case 93: + case 244: break; + case 92: { return types.REF; } // fall through - case 247: break; - case 94: + case 245: break; + case 93: { return types.REC; } // fall through - case 248: break; - case 95: + case 246: break; + case 94: { return types.RAW; } // fall through - case 249: break; - case 96: + case 247: break; + case 95: { return types.AND; } // fall through - case 250: break; - case 97: + case 248: break; + case 96: { return types.ASR; } // fall through - case 251: break; - case 98: + case 249: break; + case 97: { return types.SIG; } // fall through - case 252: break; - case 99: + case 250: break; + case 98: { return types.LOR; } // fall through - case 253: break; - case 100: + case 251: break; + case 99: { return types.LET; } // fall through - case 254: break; - case 101: + case 252: break; + case 100: { return types.LSR; } // fall through - case 255: break; - case 102: + case 253: break; + case 101: { return types.LSL; } // fall through - case 256: break; - case 103: + case 254: break; + case 102: { return types.MOD; } // fall through - case 257: break; - case 104: + case 255: break; + case 103: { return types.VAL; } // fall through - case 258: break; - case 105: + case 256: break; + case 104: { return types.DIRECTIVE_IF; } // fall through - case 259: break; - case 106: + case 257: break; + case 105: { return types.ARROBASE_3; } // fall through - case 260: break; - case 107: + case 258: break; + case 106: { return types.EQEQEQ; } // fall through - case 261: break; - case 108: + case 259: break; + case 107: { return types.JS_STRING_CLOSE; /*js interpolation*/ } // fall through - case 262: break; - case 109: + case 260: break; + case 108: { return types.JS_STRING_OPEN; /*js interpolation*/ } // fall through - case 263: break; - case 110: + case 261: break; + case 109: { return types.NOT_EQEQ; } // fall through - case 264: break; - case 111: + case 262: break; + case 110: { return types.OPEN; } // fall through - case 265: break; - case 112: + case 263: break; + case 111: { return types.ELSE; } // fall through - case 266: break; - case 113: + case 264: break; + case 112: { return types.BOOL_VALUE; } // fall through - case 267: break; - case 114: + case 265: break; + case 113: { return types.THEN; } // fall through - case 268: break; - case 115: + case 266: break; + case 114: { return types.TYPE; } // fall through - case 269: break; - case 116: + case 267: break; + case 115: { return types.DONE; } // fall through - case 270: break; - case 117: + case 268: break; + case 116: { return types.LXOR; } // fall through - case 271: break; - case 118: + case 269: break; + case 117: { return types.LAND; } // fall through - case 272: break; - case 119: + case 270: break; + case 118: { return types.LAZY; } // fall through - case 273: break; - case 120: + case 271: break; + case 119: { return types.WITH; } // fall through - case 274: break; - case 121: + case 272: break; + case 120: { return types.WHEN; } // fall through - case 275: break; - case 122: + case 273: break; + case 121: { return types.UNIT; } // fall through - case 276: break; - case 123: + case 274: break; + case 122: { return types.NONE; } // fall through - case 277: break; - case 124: + case 275: break; + case 123: { return types.SOME; } // fall through - case 278: break; - case 125: + case 276: break; + case 124: { return types.DIRECTIVE_END; } // fall through - case 279: break; - case 126: + case 277: break; + case 125: { return types.BEGIN; } // fall through - case 280: break; - case 127: + case 278: break; + case 126: { return types.ENDIF; } // fall through - case 281: break; - case 128: + case 279: break; + case 127: { return types.RAISE; } // fall through - case 282: break; - case 129: + case 280: break; + case 128: { return types.CLASS; } // fall through - case 283: break; - case 130: + case 281: break; + case 129: { return types.WHILE; } // fall through - case 284: break; - case 131: + case 282: break; + case 130: { return types.MATCH; } // fall through - case 285: break; - case 132: + case 283: break; + case 131: { return types.DIRECTIVE_ELSE; } // fall through - case 286: break; - case 133: + case 284: break; + case 132: { return types.DIRECTIVE_ELIF; } // fall through - case 287: break; - case 134: + case 285: break; + case 133: { return types.OBJECT; } // fall through - case 288: break; - case 135: + case 286: break; + case 134: { return types.OPTION; } // fall through - case 289: break; - case 136: + case 287: break; + case 135: { return types.NONREC; } // fall through - case 290: break; - case 137: + case 288: break; + case 136: { return types.ASSERT; } // fall through - case 291: break; - case 138: + case 289: break; + case 137: { return types.DOWNTO; } // fall through - case 292: break; - case 139: + case 290: break; + case 138: { return types.STRUCT; } // fall through - case 293: break; - case 140: + case 291: break; + case 139: { return types.SWITCH; } // fall through - case 294: break; - case 141: + case 292: break; + case 140: { return types.MODULE; } // fall through - case 295: break; - case 142: + case 293: break; + case 141: { return types.METHOD; } // fall through - case 296: break; - case 143: + case 294: break; + case 142: { return types.DIRECTIVE_ENDIF; } // fall through - case 297: break; - case 144: + case 295: break; + case 143: { return types.FUNCTOR; } // fall through - case 298: break; - case 145: + case 296: break; + case 144: { return types.PRIVATE; } // fall through - case 299: break; - case 146: + case 297: break; + case 145: { return types.INCLUDE; } // fall through - case 300: break; - case 147: + case 298: break; + case 146: { return types.INHERIT; } // fall through - case 301: break; - case 148: + case 299: break; + case 147: { return types.MUTABLE; } // fall through - case 302: break; - case 149: + case 300: break; + case 148: { return types.VIRTUAL; } // fall through - case 303: break; - case 150: + case 301: break; + case 149: { return types.FUNCTION; } // fall through - case 304: break; - case 151: + case 302: break; + case 150: { return types.EXTERNAL; } // fall through - case 305: break; - case 152: + case 303: break; + case 151: { return types.EXCEPTION; } // fall through - case 306: break; - case 153: + case 304: break; + case 152: { return types.CONSTRAINT; } // fall through - case 307: break; - case 154: + case 305: break; + case 153: { return types.INITIALIZER; } // fall through - case 308: break; + case 306: break; default: zzScanError(ZZ_NO_MATCH); } diff --git a/src/com/reason/lang/reason/RmlParser.java b/src/com/reason/lang/reason/RmlParser.java index 751882496..f013c20b7 100644 --- a/src/com/reason/lang/reason/RmlParser.java +++ b/src/com/reason/lang/reason/RmlParser.java @@ -725,12 +725,8 @@ private void parseLIdent(@NotNull ParserState state) { .remapCurrentToken(m_types.PROPERTY_NAME) .mark(m_types.C_TAG_PROPERTY) .setWhitespaceSkippedCallback(endJsxPropertyIfWhitespace(state)); - } else if (state.isCurrentResolution(recordBinding)) { - state.mark(m_types.C_RECORD_FIELD); } else if (state.isCurrentResolution(jsObjectBinding)) { state.mark(m_types.C_OBJECT_FIELD); - } else if (state.is(m_types.C_RECORD_EXPR)) { - state.mark(m_types.C_RECORD_FIELD); } else { IElementType nextElementType = state.lookAhead(1); @@ -740,13 +736,19 @@ private void parseLIdent(@NotNull ParserState state) { } else if (nextElementType == m_types.QUESTION_MARK && !state.in(m_types.C_TAG_START)) { // a ternary :: |>x<| ? ... state.mark(m_types.C_TERNARY).mark(m_types.C_BINARY_CONDITION); + } else if (state.is(m_types.C_RECORD_EXPR)) { + state.mark(m_types.C_RECORD_FIELD).wrapWith(m_types.C_LOWER_IDENTIFIER); + } else if (state.isCurrentResolution(recordBinding)) { + state.mark(m_types.C_RECORD_FIELD).wrapWith(m_types.C_LOWER_IDENTIFIER); + } else if (state.is(m_types.C_RECORD_FIELD)) { + state.wrapWith(m_types.C_LOWER_IDENTIFIER); } } if (state.is(m_types.C_DECONSTRUCTION) || (state.is(m_types.C_FUN_PARAM) && !state.isPrevious(m_types.C_FUN_CALL_PARAMS))) { state.wrapWith(m_types.C_LOWER_IDENTIFIER); - } else if (!state.is(m_types.C_TAG_PROPERTY)) { + } else if (!state.is(m_types.C_RECORD_FIELD) && !state.is(m_types.C_TAG_PROPERTY)) { state.wrapWith(m_types.C_LOWER_SYMBOL); } } diff --git a/src/com/reason/lang/reason/RmlQNameFinder.java b/src/com/reason/lang/reason/RmlQNameFinder.java index 1e7e798ac..e54a1c152 100644 --- a/src/com/reason/lang/reason/RmlQNameFinder.java +++ b/src/com/reason/lang/reason/RmlQNameFinder.java @@ -97,7 +97,7 @@ private RmlQNameFinder() { resolvedQualifiedNames.add(openName + resolvedPathExtension); resolvedQualifiedNames.add(moduleName + "." + openName + resolvedPathExtension); } else if (item instanceof PsiOpen || item instanceof PsiInclude) { - String openName = item instanceof PsiOpen ? ((PsiOpen) item).getPath() : ((PsiInclude) item).getPath(); + String openName = item instanceof PsiOpen ? ((PsiOpen) item).getPath() : ((PsiInclude) item).getIncludePath(); // Add open value to all previous elements qualifiedNames.addAll(extendPathWith(filePath, openName, qualifiedNames)); qualifiedNames.add(openName + pathExtension); @@ -116,7 +116,7 @@ private RmlQNameFinder() { resolvedQualifiedNames.add(letQName + resolvedPathExtension); } } else if (item instanceof PsiFunction) { - PsiQualifiedElement parent = PsiTreeUtil.getParentOfType(item, PsiQualifiedElement.class); + PsiQualifiedNamedElement parent = PsiTreeUtil.getParentOfType(item, PsiQualifiedNamedElement.class); if (parent != null) { String parentQName = parent.getQualifiedName(); // Register all parameters of function diff --git a/src/com/reason/lang/reason/RmlTypes.java b/src/com/reason/lang/reason/RmlTypes.java index c172cd800..db17d0974 100644 --- a/src/com/reason/lang/reason/RmlTypes.java +++ b/src/com/reason/lang/reason/RmlTypes.java @@ -1,280 +1,276 @@ package com.reason.lang.reason; -import com.reason.lang.core.stub.RmlStubBasedElementTypes; -import com.reason.lang.core.type.ORCompositeElementType; -import com.reason.lang.core.type.ORCompositeType; -import com.reason.lang.core.type.ORTokenElementType; -import com.reason.lang.core.type.ORTypes; +import com.reason.lang.core.stub.*; +import com.reason.lang.core.type.*; public class RmlTypes extends ORTypes { - public static final RmlTypes INSTANCE = new RmlTypes(); + public static final RmlTypes INSTANCE = new RmlTypes(); - private RmlTypes() { - // Stub element types + private RmlTypes() { + // Stub element types - C_FAKE_MODULE = (ORCompositeType) RmlStubBasedElementTypes.C_FAKE_MODULE; - C_EXCEPTION_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_EXCEPTION_DECLARATION; - C_TYPE_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_TYPE_DECLARATION; - C_EXTERNAL_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_EXTERNAL_DECLARATION; - C_LET_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_LET_DECLARATION; - C_MODULE_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_MODULE_DECLARATION; - C_VAL_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_VAL_DECLARATION; - C_FUN_PARAM = (ORCompositeType) RmlStubBasedElementTypes.C_FUN_PARAM; - C_FUNCTOR_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_FUNCTOR_DECLARATION; - C_FUNCTOR_PARAM = (ORCompositeType) RmlStubBasedElementTypes.C_FUNCTOR_PARAM; - C_RECORD_FIELD = (ORCompositeType) RmlStubBasedElementTypes.C_RECORD_FIELD; - C_VARIANT_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_VARIANT_DECLARATION; + C_FAKE_MODULE = (ORCompositeType) RmlStubBasedElementTypes.C_FAKE_MODULE; + C_EXCEPTION_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_EXCEPTION_DECLARATION; + C_TYPE_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_TYPE_DECLARATION; + C_EXTERNAL_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_EXTERNAL_DECLARATION; + C_LET_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_LET_DECLARATION; + C_MODULE_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_MODULE_DECLARATION; + C_VAL_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_VAL_DECLARATION; + C_FUN_PARAM = (ORCompositeType) RmlStubBasedElementTypes.C_FUN_PARAM; + C_FUNCTOR_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_FUNCTOR_DECLARATION; + C_FUNCTOR_PARAM = (ORCompositeType) RmlStubBasedElementTypes.C_FUNCTOR_PARAM; + C_RECORD_FIELD = (ORCompositeType) RmlStubBasedElementTypes.C_RECORD_FIELD; + C_VARIANT_DECLARATION = (ORCompositeType) RmlStubBasedElementTypes.C_VARIANT_DECLARATION; + C_INCLUDE = (ORCompositeType) RmlStubBasedElementTypes.C_INCLUDE; + C_OPEN = (ORCompositeType) RmlStubBasedElementTypes.C_OPEN; - // Composite element types + // Composite element types - C_ANNOTATION = new ORCompositeElementType("C_ANNOTATION", RmlLanguage.INSTANCE); - C_MIXIN_FIELD = new ORCompositeElementType("C_MIXIN_FIELD", RmlLanguage.INSTANCE); - C_ASSERT_STMT = new ORCompositeElementType("C_ASSERT_STMT", RmlLanguage.INSTANCE); - C_BINARY_CONDITION = new ORCompositeElementType("C_BIN_CONDITION", RmlLanguage.INSTANCE); - C_CLASS_DECLARATION = new ORCompositeElementType("C_CLASS_DECLARATION", RmlLanguage.INSTANCE); - C_CLASS_CONSTR = new ORCompositeElementType("C_CLASS_CONSTR", RmlLanguage.INSTANCE); - C_CLASS_PARAMS = new ORCompositeElementType("C_CLASS_PARAMS", RmlLanguage.INSTANCE); - C_CLASS_FIELD = new ORCompositeElementType("C_CLASS_FIELD", RmlLanguage.INSTANCE); - C_CLASS_METHOD = new ORCompositeElementType("C_CLASS_METHOD", RmlLanguage.INSTANCE); - C_CONSTRAINTS = new ORCompositeElementType("C_CONSTRAINTS", RmlLanguage.INSTANCE); - C_CONSTRAINT = new ORCompositeElementType("C_CONSTRAINT", RmlLanguage.INSTANCE); - C_CUSTOM_OPERATOR = new ORCompositeElementType("C_CUSTOM_OPERATOR", RmlLanguage.INSTANCE); - C_DECONSTRUCTION = new ORCompositeElementType("C_DECONSTRUCTION", RmlLanguage.INSTANCE); - C_DEFAULT_VALUE = new ORCompositeElementType("C_DEFAULT_VALUE", RmlLanguage.INSTANCE); - C_DIRECTIVE = new ORCompositeElementType("C_DIRECTIVE", RmlLanguage.INSTANCE); - C_DO_LOOP = new ORCompositeElementType("C_DO_LOOP", RmlLanguage.INSTANCE); - C_LOWER_IDENTIFIER = new ORCompositeElementType("C_LOWER_IDENTIFIER", RmlLanguage.INSTANCE); - C_UPPER_IDENTIFIER = new ORCompositeElementType("C_UPPER_IDENTIFIER", RmlLanguage.INSTANCE); - C_FUN_CALL_PARAMS = new ORCompositeElementType("C_FUN_CALL_PARAMS", RmlLanguage.INSTANCE); - C_FUN_EXPR = new ORCompositeElementType("C_FUN_EXPR", RmlLanguage.INSTANCE); - C_FUN_PARAMS = new ORCompositeElementType("C_FUN_PARAMS", RmlLanguage.INSTANCE); - C_FUN_BODY = new ORCompositeElementType("C_FUN_BODY", RmlLanguage.INSTANCE); - C_FUNCTOR_BINDING = new ORCompositeElementType("C_FUNCTOR_BINDING", RmlLanguage.INSTANCE); - C_FUNCTOR_CALL = new ORCompositeElementType("C_FUNCTOR_CALL", RmlLanguage.INSTANCE); - C_FUNCTOR_PARAMS = new ORCompositeElementType("C_FUNCTOR_PARAMS", RmlLanguage.INSTANCE); - C_FUNCTOR_RESULT = new ORCompositeElementType("C_FUNCTOR_RESULT", RmlLanguage.INSTANCE); - C_IF = new ORCompositeElementType("C_IF", RmlLanguage.INSTANCE); - C_IF_THEN_SCOPE = new ORCompositeElementType("C_IF_THEN_SCOPE", RmlLanguage.INSTANCE); - C_INCLUDE = new ORCompositeElementType("C_INCLUDE", RmlLanguage.INSTANCE); - C_INTERPOLATION_EXPR = new ORCompositeElementType("C_INTERPOLATION_EXPR", RmlLanguage.INSTANCE); - C_INTERPOLATION_PART = new ORCompositeElementType("C_INTERPOLATION_PART", RmlLanguage.INSTANCE); - C_INTERPOLATION_REF = new ORCompositeElementType("C_INTERPOLATION_REF", RmlLanguage.INSTANCE); - C_JS_OBJECT = new ORCompositeElementType("C_JS_OBJECT", RmlLanguage.INSTANCE); - C_LET_ATTR = new ORCompositeElementType("C_LET_ATTR", RmlLanguage.INSTANCE); - C_LET_BINDING = new ORCompositeElementType("C_LET_BINDING", RmlLanguage.INSTANCE); - C_LOCAL_OPEN = new ORCompositeElementType("C_LOCAL_OPEN", RmlLanguage.INSTANCE); - C_TYPE_VARIABLE = new ORCompositeElementType("C_TYPE_VARIABLE", RmlLanguage.INSTANCE); - C_LOWER_SYMBOL = new ORCompositeElementType("C_LOWER_SYMBOL", RmlLanguage.INSTANCE); - C_MACRO_EXPR = new ORCompositeElementType("C_MACRO_EXPR", RmlLanguage.INSTANCE); - C_MACRO_NAME = new ORCompositeElementType("C_MACRO_NAME", RmlLanguage.INSTANCE); - C_NAMED_PARAM = new ORCompositeElementType("C_NAMED_PARAM", RmlLanguage.INSTANCE); - C_MACRO_RAW_BODY = new ORCompositeElementType("C_MACRO_RAW_BODY", RmlLanguage.INSTANCE); - C_MODULE_TYPE = new ORCompositeElementType("C_MODULE_TYPE", RmlLanguage.INSTANCE); - C_ML_INTERPOLATOR = new ORCompositeElementType("C_ML_INTERPOLATOR", RmlLanguage.INSTANCE); - C_OBJECT = new ORCompositeElementType("C_OBJECT", RmlLanguage.INSTANCE); - C_OBJECT_FIELD = new ORCompositeElementType("C_OBJECT_FIELD", RmlLanguage.INSTANCE); - C_OPTION = new ORCompositeElementType("C_OPTION", RmlLanguage.INSTANCE); - C_OPEN = new ORCompositeElementType("C_OPEN", RmlLanguage.INSTANCE); - C_PARAMETERS = new ORCompositeElementType("C_PARAMETERS", RmlLanguage.INSTANCE); - C_PATTERN_MATCH_BODY = new ORCompositeElementType("C_PATTERN_MATCH_BODY", RmlLanguage.INSTANCE); - C_PATTERN_MATCH_EXPR = new ORCompositeElementType("C_PATTERN_MATCH_EXPR", RmlLanguage.INSTANCE); - C_RECORD_EXPR = new ORCompositeElementType("C_RECORD_EXPR", RmlLanguage.INSTANCE); - C_RAW = new ORCompositeElementType("C_RAW", RmlLanguage.INSTANCE); - C_SIG_EXPR = new ORCompositeElementType("C_SIG_EXPR", RmlLanguage.INSTANCE); - C_SIG_ITEM = new ORCompositeElementType("C_SIG_ITEM", RmlLanguage.INSTANCE); - C_SCOPED_EXPR = new ORCompositeElementType("C_SCOPED_EXPR", RmlLanguage.INSTANCE); - C_STRUCT_EXPR = new ORCompositeElementType("C_STRUCT_EXPR", RmlLanguage.INSTANCE); - C_SWITCH_EXPR = new ORCompositeElementType("C_SWITCH_EXPR", RmlLanguage.INSTANCE); - C_TAG = new ORCompositeElementType("C_TAG", RmlLanguage.INSTANCE); - C_TAG_PROP_VALUE = new ORCompositeElementType("C_TAG_PROP_VALUE", RmlLanguage.INSTANCE); - C_TAG_BODY = new ORCompositeElementType("C_TAG_BODY", RmlLanguage.INSTANCE); - C_TAG_CLOSE = new ORCompositeElementType("C_TAG_CLOSE", RmlLanguage.INSTANCE); - C_TAG_PROPERTY = new ORCompositeElementType("C_TAG_PROPERTY", RmlLanguage.INSTANCE); - C_TAG_START = new ORCompositeElementType("C_TAG_START", RmlLanguage.INSTANCE); - C_TERNARY = new ORCompositeElementType("C_TERNARY", RmlLanguage.INSTANCE); - C_TRY_EXPR = new ORCompositeElementType("C_TRY_EXPR", RmlLanguage.INSTANCE); - C_TRY_BODY = new ORCompositeElementType("C_TRY_BODY", RmlLanguage.INSTANCE); - C_TRY_HANDLER = new ORCompositeElementType("C_TRY_HANDLER", RmlLanguage.INSTANCE); - C_TRY_HANDLERS = new ORCompositeElementType("C_TRY_HANDLERS", RmlLanguage.INSTANCE); - C_TYPE_BINDING = new ORCompositeElementType("C_TYPE_BINDING", RmlLanguage.INSTANCE); - C_UNIT = new ORCompositeElementType("C_UNIT", RmlLanguage.INSTANCE); - C_DUMMY = new ORCompositeElementType("C_DUMMY", RmlLanguage.INSTANCE); - C_UPPER_SYMBOL = new ORCompositeElementType("C_UPPER_SYMBOL", RmlLanguage.INSTANCE); - C_VARIANT = new ORCompositeElementType("C_VARIANT", RmlLanguage.INSTANCE); - C_VARIANT_CONSTRUCTOR = - new ORCompositeElementType("C_VARIANT_CONSTRUCTOR", RmlLanguage.INSTANCE); - C_WHILE = new ORCompositeElementType("C_WHILE", RmlLanguage.INSTANCE); + C_ANNOTATION = new ORCompositeElementType("C_ANNOTATION", RmlLanguage.INSTANCE); + C_MIXIN_FIELD = new ORCompositeElementType("C_MIXIN_FIELD", RmlLanguage.INSTANCE); + C_ASSERT_STMT = new ORCompositeElementType("C_ASSERT_STMT", RmlLanguage.INSTANCE); + C_BINARY_CONDITION = new ORCompositeElementType("C_BIN_CONDITION", RmlLanguage.INSTANCE); + C_CLASS_DECLARATION = new ORCompositeElementType("C_CLASS_DECLARATION", RmlLanguage.INSTANCE); + C_CLASS_CONSTR = new ORCompositeElementType("C_CLASS_CONSTR", RmlLanguage.INSTANCE); + C_CLASS_PARAMS = new ORCompositeElementType("C_CLASS_PARAMS", RmlLanguage.INSTANCE); + C_CLASS_FIELD = new ORCompositeElementType("C_CLASS_FIELD", RmlLanguage.INSTANCE); + C_CLASS_METHOD = new ORCompositeElementType("C_CLASS_METHOD", RmlLanguage.INSTANCE); + C_CONSTRAINTS = new ORCompositeElementType("C_CONSTRAINTS", RmlLanguage.INSTANCE); + C_CONSTRAINT = new ORCompositeElementType("C_CONSTRAINT", RmlLanguage.INSTANCE); + C_CUSTOM_OPERATOR = new ORCompositeElementType("C_CUSTOM_OPERATOR", RmlLanguage.INSTANCE); + C_DECONSTRUCTION = new ORCompositeElementType("C_DECONSTRUCTION", RmlLanguage.INSTANCE); + C_DEFAULT_VALUE = new ORCompositeElementType("C_DEFAULT_VALUE", RmlLanguage.INSTANCE); + C_DIRECTIVE = new ORCompositeElementType("C_DIRECTIVE", RmlLanguage.INSTANCE); + C_DO_LOOP = new ORCompositeElementType("C_DO_LOOP", RmlLanguage.INSTANCE); + C_LOWER_IDENTIFIER = new ORCompositeElementType("C_LOWER_IDENTIFIER", RmlLanguage.INSTANCE); + C_UPPER_IDENTIFIER = new ORCompositeElementType("C_UPPER_IDENTIFIER", RmlLanguage.INSTANCE); + C_FUN_CALL_PARAMS = new ORCompositeElementType("C_FUN_CALL_PARAMS", RmlLanguage.INSTANCE); + C_FUN_EXPR = new ORCompositeElementType("C_FUN_EXPR", RmlLanguage.INSTANCE); + C_FUN_PARAMS = new ORCompositeElementType("C_FUN_PARAMS", RmlLanguage.INSTANCE); + C_FUN_BODY = new ORCompositeElementType("C_FUN_BODY", RmlLanguage.INSTANCE); + C_FUNCTOR_BINDING = new ORCompositeElementType("C_FUNCTOR_BINDING", RmlLanguage.INSTANCE); + C_FUNCTOR_CALL = new ORCompositeElementType("C_FUNCTOR_CALL", RmlLanguage.INSTANCE); + C_FUNCTOR_PARAMS = new ORCompositeElementType("C_FUNCTOR_PARAMS", RmlLanguage.INSTANCE); + C_FUNCTOR_RESULT = new ORCompositeElementType("C_FUNCTOR_RESULT", RmlLanguage.INSTANCE); + C_IF = new ORCompositeElementType("C_IF", RmlLanguage.INSTANCE); + C_IF_THEN_SCOPE = new ORCompositeElementType("C_IF_THEN_SCOPE", RmlLanguage.INSTANCE); + C_INTERPOLATION_EXPR = new ORCompositeElementType("C_INTERPOLATION_EXPR", RmlLanguage.INSTANCE); + C_INTERPOLATION_PART = new ORCompositeElementType("C_INTERPOLATION_PART", RmlLanguage.INSTANCE); + C_INTERPOLATION_REF = new ORCompositeElementType("C_INTERPOLATION_REF", RmlLanguage.INSTANCE); + C_JS_OBJECT = new ORCompositeElementType("C_JS_OBJECT", RmlLanguage.INSTANCE); + C_LET_ATTR = new ORCompositeElementType("C_LET_ATTR", RmlLanguage.INSTANCE); + C_LET_BINDING = new ORCompositeElementType("C_LET_BINDING", RmlLanguage.INSTANCE); + C_LOCAL_OPEN = new ORCompositeElementType("C_LOCAL_OPEN", RmlLanguage.INSTANCE); + C_TYPE_VARIABLE = new ORCompositeElementType("C_TYPE_VARIABLE", RmlLanguage.INSTANCE); + C_LOWER_SYMBOL = new ORCompositeElementType("C_LOWER_SYMBOL", RmlLanguage.INSTANCE); + C_MACRO_EXPR = new ORCompositeElementType("C_MACRO_EXPR", RmlLanguage.INSTANCE); + C_MACRO_NAME = new ORCompositeElementType("C_MACRO_NAME", RmlLanguage.INSTANCE); + C_NAMED_PARAM = new ORCompositeElementType("C_NAMED_PARAM", RmlLanguage.INSTANCE); + C_MACRO_RAW_BODY = new ORCompositeElementType("C_MACRO_RAW_BODY", RmlLanguage.INSTANCE); + C_MODULE_TYPE = new ORCompositeElementType("C_MODULE_TYPE", RmlLanguage.INSTANCE); + C_ML_INTERPOLATOR = new ORCompositeElementType("C_ML_INTERPOLATOR", RmlLanguage.INSTANCE); + C_OBJECT = new ORCompositeElementType("C_OBJECT", RmlLanguage.INSTANCE); + C_OBJECT_FIELD = new ORCompositeElementType("C_OBJECT_FIELD", RmlLanguage.INSTANCE); + C_OPTION = new ORCompositeElementType("C_OPTION", RmlLanguage.INSTANCE); + C_PARAMETERS = new ORCompositeElementType("C_PARAMETERS", RmlLanguage.INSTANCE); + C_PATTERN_MATCH_BODY = new ORCompositeElementType("C_PATTERN_MATCH_BODY", RmlLanguage.INSTANCE); + C_PATTERN_MATCH_EXPR = new ORCompositeElementType("C_PATTERN_MATCH_EXPR", RmlLanguage.INSTANCE); + C_RECORD_EXPR = new ORCompositeElementType("C_RECORD_EXPR", RmlLanguage.INSTANCE); + C_RAW = new ORCompositeElementType("C_RAW", RmlLanguage.INSTANCE); + C_SIG_EXPR = new ORCompositeElementType("C_SIG_EXPR", RmlLanguage.INSTANCE); + C_SIG_ITEM = new ORCompositeElementType("C_SIG_ITEM", RmlLanguage.INSTANCE); + C_SCOPED_EXPR = new ORCompositeElementType("C_SCOPED_EXPR", RmlLanguage.INSTANCE); + C_STRUCT_EXPR = new ORCompositeElementType("C_STRUCT_EXPR", RmlLanguage.INSTANCE); + C_SWITCH_EXPR = new ORCompositeElementType("C_SWITCH_EXPR", RmlLanguage.INSTANCE); + C_TAG = new ORCompositeElementType("C_TAG", RmlLanguage.INSTANCE); + C_TAG_PROP_VALUE = new ORCompositeElementType("C_TAG_PROP_VALUE", RmlLanguage.INSTANCE); + C_TAG_BODY = new ORCompositeElementType("C_TAG_BODY", RmlLanguage.INSTANCE); + C_TAG_CLOSE = new ORCompositeElementType("C_TAG_CLOSE", RmlLanguage.INSTANCE); + C_TAG_PROPERTY = new ORCompositeElementType("C_TAG_PROPERTY", RmlLanguage.INSTANCE); + C_TAG_START = new ORCompositeElementType("C_TAG_START", RmlLanguage.INSTANCE); + C_TERNARY = new ORCompositeElementType("C_TERNARY", RmlLanguage.INSTANCE); + C_TRY_EXPR = new ORCompositeElementType("C_TRY_EXPR", RmlLanguage.INSTANCE); + C_TRY_BODY = new ORCompositeElementType("C_TRY_BODY", RmlLanguage.INSTANCE); + C_TRY_HANDLER = new ORCompositeElementType("C_TRY_HANDLER", RmlLanguage.INSTANCE); + C_TRY_HANDLERS = new ORCompositeElementType("C_TRY_HANDLERS", RmlLanguage.INSTANCE); + C_TYPE_BINDING = new ORCompositeElementType("C_TYPE_BINDING", RmlLanguage.INSTANCE); + C_UNIT = new ORCompositeElementType("C_UNIT", RmlLanguage.INSTANCE); + C_DUMMY = new ORCompositeElementType("C_DUMMY", RmlLanguage.INSTANCE); + C_UPPER_SYMBOL = new ORCompositeElementType("C_UPPER_SYMBOL", RmlLanguage.INSTANCE); + C_VARIANT = new ORCompositeElementType("C_VARIANT", RmlLanguage.INSTANCE); + C_VARIANT_CONSTRUCTOR = + new ORCompositeElementType("C_VARIANT_CONSTRUCTOR", RmlLanguage.INSTANCE); + C_WHILE = new ORCompositeElementType("C_WHILE", RmlLanguage.INSTANCE); - // Token element types + // Token element types - BOOL_VALUE = new ORTokenElementType("BOOL_VALUE", RmlLanguage.INSTANCE); - STRING_VALUE = new ORTokenElementType("STRING_VALUE", RmlLanguage.INSTANCE); - FLOAT_VALUE = new ORTokenElementType("FLOAT_VALUE", RmlLanguage.INSTANCE); - CATCH = new ORTokenElementType("CATCH", RmlLanguage.INSTANCE); - CHAR_VALUE = new ORTokenElementType("CHAR_VALUE", RmlLanguage.INSTANCE); - INT_VALUE = new ORTokenElementType("INT_VALUE", RmlLanguage.INSTANCE); - EXCEPTION_NAME = new ORTokenElementType("EXCEPTION_NAME", RmlLanguage.INSTANCE); - PROPERTY_NAME = new ORTokenElementType("PROPERTY_NAME", RmlLanguage.INSTANCE); - SWITCH = new ORTokenElementType("SWITCH", RmlLanguage.INSTANCE); - FUNCTION = new ORTokenElementType("FUNCTION", RmlLanguage.INSTANCE); - FUN = new ORTokenElementType("FUN", RmlLanguage.INSTANCE); - FUNCTOR = new ORTokenElementType("FUNCTOR", RmlLanguage.INSTANCE); - IF = new ORTokenElementType("IF", RmlLanguage.INSTANCE); - AND = new ORTokenElementType("AND", RmlLanguage.INSTANCE); - L_AND = new ORTokenElementType("L_AND", RmlLanguage.INSTANCE); - L_OR = new ORTokenElementType("L_OR", RmlLanguage.INSTANCE); - ARROBASE = new ORTokenElementType("ARROBASE", RmlLanguage.INSTANCE); - ARROBASE_2 = new ORTokenElementType("ARROBASE_2", RmlLanguage.INSTANCE); - ARROBASE_3 = new ORTokenElementType("ARROBASE_3", RmlLanguage.INSTANCE); - ARROW = new ORTokenElementType("ARROW", RmlLanguage.INSTANCE); - ASSERT = new ORTokenElementType("ASSERT", RmlLanguage.INSTANCE); - AS = new ORTokenElementType("AS", RmlLanguage.INSTANCE); - BACKTICK = new ORTokenElementType("BACKTICK", RmlLanguage.INSTANCE); - BEGIN = new ORTokenElementType("BEGIN", RmlLanguage.INSTANCE); - CARRET = new ORTokenElementType("CARRET", RmlLanguage.INSTANCE); - COLON = new ORTokenElementType("COLON", RmlLanguage.INSTANCE); - COMMA = new ORTokenElementType("COMMA", RmlLanguage.INSTANCE); - SINGLE_COMMENT = new ORTokenElementType("SINGLE_COMMENT", RmlLanguage.INSTANCE); - MULTI_COMMENT = new ORTokenElementType("MULTI_COMMENT", RmlLanguage.INSTANCE); - DIFF = new ORTokenElementType("DIFF", RmlLanguage.INSTANCE); - DIRECTIVE_IF = new ORTokenElementType("DIRECTIVE_IF", RmlLanguage.INSTANCE); - DIRECTIVE_ELSE = new ORTokenElementType("DIRECTIVE_ELSE", RmlLanguage.INSTANCE); - DIRECTIVE_ELIF = new ORTokenElementType("DIRECTIVE_ELIF", RmlLanguage.INSTANCE); - DIRECTIVE_END = new ORTokenElementType("DIRECTIVE_END", RmlLanguage.INSTANCE); - DIRECTIVE_ENDIF = new ORTokenElementType("DIRECTIVE_ENDIF", RmlLanguage.INSTANCE); - LT_OR_EQUAL = new ORTokenElementType("LT_OR_EQUAL", RmlLanguage.INSTANCE); - GT_OR_EQUAL = new ORTokenElementType("GT_OR_EQUAL", RmlLanguage.INSTANCE); - DOLLAR = new ORTokenElementType("DOLLAR", RmlLanguage.INSTANCE); - DOT = new ORTokenElementType("DOT", RmlLanguage.INSTANCE); - DOTDOTDOT = new ORTokenElementType("DOTDOTDOT", RmlLanguage.INSTANCE); - DO = new ORTokenElementType("DO", RmlLanguage.INSTANCE); - DONE = new ORTokenElementType("DONE", RmlLanguage.INSTANCE); - ELSE = new ORTokenElementType("ELSE", RmlLanguage.INSTANCE); - END = new ORTokenElementType("END", RmlLanguage.INSTANCE); - ENDIF = new ORTokenElementType("ENDIF", RmlLanguage.INSTANCE); - NOT_EQ = new ORTokenElementType("EQ", RmlLanguage.INSTANCE); - NOT_EQEQ = new ORTokenElementType("EQEQ", RmlLanguage.INSTANCE); - EQ = new ORTokenElementType("EQ", RmlLanguage.INSTANCE); - EQEQ = new ORTokenElementType("EQEQ", RmlLanguage.INSTANCE); - EQEQEQ = new ORTokenElementType("EQEQEQ", RmlLanguage.INSTANCE); - EXCEPTION = new ORTokenElementType("EXCEPTION", RmlLanguage.INSTANCE); - EXCLAMATION_MARK = new ORTokenElementType("EXCLAMATION_MARK", RmlLanguage.INSTANCE); - EXTERNAL = new ORTokenElementType("EXTERNAL", RmlLanguage.INSTANCE); - FOR = new ORTokenElementType("FOR", RmlLanguage.INSTANCE); - TYPE_ARGUMENT = new ORTokenElementType("TYPE_ARGUMENT", RmlLanguage.INSTANCE); - GT = new ORTokenElementType("GT", RmlLanguage.INSTANCE); - IN = new ORTokenElementType("IN", RmlLanguage.INSTANCE); - LAZY = new ORTokenElementType("LAZY", RmlLanguage.INSTANCE); - INCLUDE = new ORTokenElementType("INCLUDE", RmlLanguage.INSTANCE); - LARRAY = new ORTokenElementType("LARRAY", RmlLanguage.INSTANCE); - LBRACE = new ORTokenElementType("LBRACE", RmlLanguage.INSTANCE); - LBRACKET = new ORTokenElementType("LBRACKET", RmlLanguage.INSTANCE); - LET = new ORTokenElementType("LET", RmlLanguage.INSTANCE); - LIDENT = new ORTokenElementType("LIDENT", RmlLanguage.INSTANCE); - LPAREN = new ORTokenElementType("LPAREN", RmlLanguage.INSTANCE); - LT = new ORTokenElementType("LT", RmlLanguage.INSTANCE); - MATCH = new ORTokenElementType("MATCH", RmlLanguage.INSTANCE); - MINUS = new ORTokenElementType("MINUS", RmlLanguage.INSTANCE); - MINUSDOT = new ORTokenElementType("MINUSDOT", RmlLanguage.INSTANCE); - MODULE = new ORTokenElementType("MODULE", RmlLanguage.INSTANCE); - MUTABLE = new ORTokenElementType("MUTABLE", RmlLanguage.INSTANCE); - NONE = new ORTokenElementType("NONE", RmlLanguage.INSTANCE); - OF = new ORTokenElementType("OF", RmlLanguage.INSTANCE); - OPEN = new ORTokenElementType("OPEN", RmlLanguage.INSTANCE); - OPTION = new ORTokenElementType("OPTION", RmlLanguage.INSTANCE); - POLY_VARIANT = new ORTokenElementType("POLY_VARIANT", RmlLanguage.INSTANCE); - VARIANT_NAME = new ORTokenElementType("VARIANT_NAME", RmlLanguage.INSTANCE); - PIPE = new ORTokenElementType("PIPE", RmlLanguage.INSTANCE); - PIPE_FORWARD = new ORTokenElementType("PIPE_FORWARD", RmlLanguage.INSTANCE); - PIPE_FIRST = new ORTokenElementType("PIPE_FIRST", RmlLanguage.INSTANCE); - PLUS = new ORTokenElementType("PLUS", RmlLanguage.INSTANCE); - PERCENT = new ORTokenElementType("PERCENT", RmlLanguage.INSTANCE); - PLUSDOT = new ORTokenElementType("PLUSDOT", RmlLanguage.INSTANCE); - QUESTION_MARK = new ORTokenElementType("QUESTION_MARK", RmlLanguage.INSTANCE); - SINGLE_QUOTE = new ORTokenElementType("SINGLE_QUOTE", RmlLanguage.INSTANCE); - DOUBLE_QUOTE = new ORTokenElementType("DOUBLE_QUOTE", RmlLanguage.INSTANCE); - RAISE = new ORTokenElementType("RAISE", RmlLanguage.INSTANCE); - RARRAY = new ORTokenElementType("RARRAY", RmlLanguage.INSTANCE); - RBRACE = new ORTokenElementType("RBRACE", RmlLanguage.INSTANCE); - RBRACKET = new ORTokenElementType("RBRACKET", RmlLanguage.INSTANCE); - REC = new ORTokenElementType("REC", RmlLanguage.INSTANCE); - REF = new ORTokenElementType("REF", RmlLanguage.INSTANCE); - RPAREN = new ORTokenElementType("RPAREN", RmlLanguage.INSTANCE); - SEMI = new ORTokenElementType("SEMI", RmlLanguage.INSTANCE); - SIG = new ORTokenElementType("SIG", RmlLanguage.INSTANCE); - SHARP = new ORTokenElementType("SHARP", RmlLanguage.INSTANCE); - SHARPSHARP = new ORTokenElementType("SHARPSHARP", RmlLanguage.INSTANCE); - SHORTCUT = new ORTokenElementType("SHORTCUT", RmlLanguage.INSTANCE); - SLASH = new ORTokenElementType("SLASH", RmlLanguage.INSTANCE); - SLASH_2 = new ORTokenElementType("SLASH_2", RmlLanguage.INSTANCE); - SLASHDOT = new ORTokenElementType("SLASHDOT", RmlLanguage.INSTANCE); - SOME = new ORTokenElementType("SOME", RmlLanguage.INSTANCE); - STAR = new ORTokenElementType("STAR", RmlLanguage.INSTANCE); - STARDOT = new ORTokenElementType("STARDOT", RmlLanguage.INSTANCE); - STRUCT = new ORTokenElementType("STRUCT", RmlLanguage.INSTANCE); - OP_STRUCT_DIFF = new ORTokenElementType("OP_STRUCT_DIFF", RmlLanguage.INSTANCE); - TAG_AUTO_CLOSE = new ORTokenElementType("TAG_AUTO_CLOSE", RmlLanguage.INSTANCE); - TAG_NAME = new ORTokenElementType("TAG_NAME", RmlLanguage.INSTANCE); - TAG_LT = new ORTokenElementType("TAG_LT", RmlLanguage.INSTANCE); - TAG_LT_SLASH = new ORTokenElementType("TAG_LT_SLASH", RmlLanguage.INSTANCE); - TAG_GT = new ORTokenElementType("TAG_GT", RmlLanguage.INSTANCE); - TILDE = new ORTokenElementType("TILDE", RmlLanguage.INSTANCE); - TO = new ORTokenElementType("TO", RmlLanguage.INSTANCE); - THEN = new ORTokenElementType("THEN", RmlLanguage.INSTANCE); - TRY = new ORTokenElementType("TRY", RmlLanguage.INSTANCE); - TYPE = new ORTokenElementType("TYPE", RmlLanguage.INSTANCE); - UIDENT = new ORTokenElementType("UIDENT", RmlLanguage.INSTANCE); - UNIT = new ORTokenElementType("UNIT", RmlLanguage.INSTANCE); - VAL = new ORTokenElementType("VAL", RmlLanguage.INSTANCE); - PUB = new ORTokenElementType("PUB", RmlLanguage.INSTANCE); - PRI = new ORTokenElementType("PRI", RmlLanguage.INSTANCE); - WHEN = new ORTokenElementType("WHEN", RmlLanguage.INSTANCE); - WHILE = new ORTokenElementType("WHILE", RmlLanguage.INSTANCE); - WITH = new ORTokenElementType("WITH", RmlLanguage.INSTANCE); - RAW = new ORTokenElementType("RAW", RmlLanguage.INSTANCE); + BOOL_VALUE = new ORTokenElementType("BOOL_VALUE", RmlLanguage.INSTANCE); + STRING_VALUE = new ORTokenElementType("STRING_VALUE", RmlLanguage.INSTANCE); + FLOAT_VALUE = new ORTokenElementType("FLOAT_VALUE", RmlLanguage.INSTANCE); + CATCH = new ORTokenElementType("CATCH", RmlLanguage.INSTANCE); + CHAR_VALUE = new ORTokenElementType("CHAR_VALUE", RmlLanguage.INSTANCE); + INT_VALUE = new ORTokenElementType("INT_VALUE", RmlLanguage.INSTANCE); + EXCEPTION_NAME = new ORTokenElementType("EXCEPTION_NAME", RmlLanguage.INSTANCE); + PROPERTY_NAME = new ORTokenElementType("PROPERTY_NAME", RmlLanguage.INSTANCE); + SWITCH = new ORTokenElementType("SWITCH", RmlLanguage.INSTANCE); + FUNCTION = new ORTokenElementType("FUNCTION", RmlLanguage.INSTANCE); + FUN = new ORTokenElementType("FUN", RmlLanguage.INSTANCE); + FUNCTOR = new ORTokenElementType("FUNCTOR", RmlLanguage.INSTANCE); + IF = new ORTokenElementType("IF", RmlLanguage.INSTANCE); + AND = new ORTokenElementType("AND", RmlLanguage.INSTANCE); + L_AND = new ORTokenElementType("L_AND", RmlLanguage.INSTANCE); + L_OR = new ORTokenElementType("L_OR", RmlLanguage.INSTANCE); + ARROBASE = new ORTokenElementType("ARROBASE", RmlLanguage.INSTANCE); + ARROBASE_2 = new ORTokenElementType("ARROBASE_2", RmlLanguage.INSTANCE); + ARROBASE_3 = new ORTokenElementType("ARROBASE_3", RmlLanguage.INSTANCE); + ARROW = new ORTokenElementType("ARROW", RmlLanguage.INSTANCE); + ASSERT = new ORTokenElementType("ASSERT", RmlLanguage.INSTANCE); + AS = new ORTokenElementType("AS", RmlLanguage.INSTANCE); + BACKTICK = new ORTokenElementType("BACKTICK", RmlLanguage.INSTANCE); + BEGIN = new ORTokenElementType("BEGIN", RmlLanguage.INSTANCE); + CARRET = new ORTokenElementType("CARRET", RmlLanguage.INSTANCE); + COLON = new ORTokenElementType("COLON", RmlLanguage.INSTANCE); + COMMA = new ORTokenElementType("COMMA", RmlLanguage.INSTANCE); + SINGLE_COMMENT = new ORTokenElementType("SINGLE_COMMENT", RmlLanguage.INSTANCE); + MULTI_COMMENT = new ORTokenElementType("MULTI_COMMENT", RmlLanguage.INSTANCE); + DIFF = new ORTokenElementType("DIFF", RmlLanguage.INSTANCE); + DIRECTIVE_IF = new ORTokenElementType("DIRECTIVE_IF", RmlLanguage.INSTANCE); + DIRECTIVE_ELSE = new ORTokenElementType("DIRECTIVE_ELSE", RmlLanguage.INSTANCE); + DIRECTIVE_ELIF = new ORTokenElementType("DIRECTIVE_ELIF", RmlLanguage.INSTANCE); + DIRECTIVE_END = new ORTokenElementType("DIRECTIVE_END", RmlLanguage.INSTANCE); + DIRECTIVE_ENDIF = new ORTokenElementType("DIRECTIVE_ENDIF", RmlLanguage.INSTANCE); + LT_OR_EQUAL = new ORTokenElementType("LT_OR_EQUAL", RmlLanguage.INSTANCE); + GT_OR_EQUAL = new ORTokenElementType("GT_OR_EQUAL", RmlLanguage.INSTANCE); + DOLLAR = new ORTokenElementType("DOLLAR", RmlLanguage.INSTANCE); + DOT = new ORTokenElementType("DOT", RmlLanguage.INSTANCE); + DOTDOTDOT = new ORTokenElementType("DOTDOTDOT", RmlLanguage.INSTANCE); + DO = new ORTokenElementType("DO", RmlLanguage.INSTANCE); + DONE = new ORTokenElementType("DONE", RmlLanguage.INSTANCE); + ELSE = new ORTokenElementType("ELSE", RmlLanguage.INSTANCE); + END = new ORTokenElementType("END", RmlLanguage.INSTANCE); + ENDIF = new ORTokenElementType("ENDIF", RmlLanguage.INSTANCE); + NOT_EQ = new ORTokenElementType("EQ", RmlLanguage.INSTANCE); + NOT_EQEQ = new ORTokenElementType("EQEQ", RmlLanguage.INSTANCE); + EQ = new ORTokenElementType("EQ", RmlLanguage.INSTANCE); + EQEQ = new ORTokenElementType("EQEQ", RmlLanguage.INSTANCE); + EQEQEQ = new ORTokenElementType("EQEQEQ", RmlLanguage.INSTANCE); + EXCEPTION = new ORTokenElementType("EXCEPTION", RmlLanguage.INSTANCE); + EXCLAMATION_MARK = new ORTokenElementType("EXCLAMATION_MARK", RmlLanguage.INSTANCE); + EXTERNAL = new ORTokenElementType("EXTERNAL", RmlLanguage.INSTANCE); + FOR = new ORTokenElementType("FOR", RmlLanguage.INSTANCE); + TYPE_ARGUMENT = new ORTokenElementType("TYPE_ARGUMENT", RmlLanguage.INSTANCE); + GT = new ORTokenElementType("GT", RmlLanguage.INSTANCE); + IN = new ORTokenElementType("IN", RmlLanguage.INSTANCE); + LAZY = new ORTokenElementType("LAZY", RmlLanguage.INSTANCE); + INCLUDE = new ORTokenElementType("INCLUDE", RmlLanguage.INSTANCE); + LARRAY = new ORTokenElementType("LARRAY", RmlLanguage.INSTANCE); + LBRACE = new ORTokenElementType("LBRACE", RmlLanguage.INSTANCE); + LBRACKET = new ORTokenElementType("LBRACKET", RmlLanguage.INSTANCE); + LET = new ORTokenElementType("LET", RmlLanguage.INSTANCE); + LIDENT = new ORTokenElementType("LIDENT", RmlLanguage.INSTANCE); + LPAREN = new ORTokenElementType("LPAREN", RmlLanguage.INSTANCE); + LT = new ORTokenElementType("LT", RmlLanguage.INSTANCE); + MATCH = new ORTokenElementType("MATCH", RmlLanguage.INSTANCE); + MINUS = new ORTokenElementType("MINUS", RmlLanguage.INSTANCE); + MINUSDOT = new ORTokenElementType("MINUSDOT", RmlLanguage.INSTANCE); + MODULE = new ORTokenElementType("MODULE", RmlLanguage.INSTANCE); + MUTABLE = new ORTokenElementType("MUTABLE", RmlLanguage.INSTANCE); + NONE = new ORTokenElementType("NONE", RmlLanguage.INSTANCE); + OF = new ORTokenElementType("OF", RmlLanguage.INSTANCE); + OPEN = new ORTokenElementType("OPEN", RmlLanguage.INSTANCE); + OPTION = new ORTokenElementType("OPTION", RmlLanguage.INSTANCE); + POLY_VARIANT = new ORTokenElementType("POLY_VARIANT", RmlLanguage.INSTANCE); + VARIANT_NAME = new ORTokenElementType("VARIANT_NAME", RmlLanguage.INSTANCE); + PIPE = new ORTokenElementType("PIPE", RmlLanguage.INSTANCE); + PIPE_FORWARD = new ORTokenElementType("PIPE_FORWARD", RmlLanguage.INSTANCE); + PLUS = new ORTokenElementType("PLUS", RmlLanguage.INSTANCE); + PERCENT = new ORTokenElementType("PERCENT", RmlLanguage.INSTANCE); + PLUSDOT = new ORTokenElementType("PLUSDOT", RmlLanguage.INSTANCE); + QUESTION_MARK = new ORTokenElementType("QUESTION_MARK", RmlLanguage.INSTANCE); + SINGLE_QUOTE = new ORTokenElementType("SINGLE_QUOTE", RmlLanguage.INSTANCE); + DOUBLE_QUOTE = new ORTokenElementType("DOUBLE_QUOTE", RmlLanguage.INSTANCE); + RAISE = new ORTokenElementType("RAISE", RmlLanguage.INSTANCE); + RARRAY = new ORTokenElementType("RARRAY", RmlLanguage.INSTANCE); + RBRACE = new ORTokenElementType("RBRACE", RmlLanguage.INSTANCE); + RBRACKET = new ORTokenElementType("RBRACKET", RmlLanguage.INSTANCE); + REC = new ORTokenElementType("REC", RmlLanguage.INSTANCE); + REF = new ORTokenElementType("REF", RmlLanguage.INSTANCE); + RPAREN = new ORTokenElementType("RPAREN", RmlLanguage.INSTANCE); + SEMI = new ORTokenElementType("SEMI", RmlLanguage.INSTANCE); + SIG = new ORTokenElementType("SIG", RmlLanguage.INSTANCE); + SHARP = new ORTokenElementType("SHARP", RmlLanguage.INSTANCE); + SHARPSHARP = new ORTokenElementType("SHARPSHARP", RmlLanguage.INSTANCE); + SHORTCUT = new ORTokenElementType("SHORTCUT", RmlLanguage.INSTANCE); + SLASH = new ORTokenElementType("SLASH", RmlLanguage.INSTANCE); + SLASH_2 = new ORTokenElementType("SLASH_2", RmlLanguage.INSTANCE); + SLASHDOT = new ORTokenElementType("SLASHDOT", RmlLanguage.INSTANCE); + SOME = new ORTokenElementType("SOME", RmlLanguage.INSTANCE); + STAR = new ORTokenElementType("STAR", RmlLanguage.INSTANCE); + STARDOT = new ORTokenElementType("STARDOT", RmlLanguage.INSTANCE); + STRUCT = new ORTokenElementType("STRUCT", RmlLanguage.INSTANCE); + OP_STRUCT_DIFF = new ORTokenElementType("OP_STRUCT_DIFF", RmlLanguage.INSTANCE); + TAG_AUTO_CLOSE = new ORTokenElementType("TAG_AUTO_CLOSE", RmlLanguage.INSTANCE); + TAG_NAME = new ORTokenElementType("TAG_NAME", RmlLanguage.INSTANCE); + TAG_LT = new ORTokenElementType("TAG_LT", RmlLanguage.INSTANCE); + TAG_LT_SLASH = new ORTokenElementType("TAG_LT_SLASH", RmlLanguage.INSTANCE); + TAG_GT = new ORTokenElementType("TAG_GT", RmlLanguage.INSTANCE); + TILDE = new ORTokenElementType("TILDE", RmlLanguage.INSTANCE); + TO = new ORTokenElementType("TO", RmlLanguage.INSTANCE); + THEN = new ORTokenElementType("THEN", RmlLanguage.INSTANCE); + TRY = new ORTokenElementType("TRY", RmlLanguage.INSTANCE); + TYPE = new ORTokenElementType("TYPE", RmlLanguage.INSTANCE); + UIDENT = new ORTokenElementType("UIDENT", RmlLanguage.INSTANCE); + UNIT = new ORTokenElementType("UNIT", RmlLanguage.INSTANCE); + VAL = new ORTokenElementType("VAL", RmlLanguage.INSTANCE); + PUB = new ORTokenElementType("PUB", RmlLanguage.INSTANCE); + PRI = new ORTokenElementType("PRI", RmlLanguage.INSTANCE); + WHEN = new ORTokenElementType("WHEN", RmlLanguage.INSTANCE); + WHILE = new ORTokenElementType("WHILE", RmlLanguage.INSTANCE); + WITH = new ORTokenElementType("WITH", RmlLanguage.INSTANCE); + RAW = new ORTokenElementType("RAW", RmlLanguage.INSTANCE); - ASR = new ORTokenElementType("ASR", RmlLanguage.INSTANCE); - CLASS = new ORTokenElementType("CLASS", RmlLanguage.INSTANCE); - CONSTRAINT = new ORTokenElementType("CONSTRAINT", RmlLanguage.INSTANCE); - DOWNTO = new ORTokenElementType("DOWNTO", RmlLanguage.INSTANCE); - INHERIT = new ORTokenElementType("INHERIT", RmlLanguage.INSTANCE); - INITIALIZER = new ORTokenElementType("INITIALIZER", RmlLanguage.INSTANCE); - LAND = new ORTokenElementType("LAND", RmlLanguage.INSTANCE); - LOR = new ORTokenElementType("LOR", RmlLanguage.INSTANCE); - LSL = new ORTokenElementType("LSL", RmlLanguage.INSTANCE); - LSR = new ORTokenElementType("LSR", RmlLanguage.INSTANCE); - LXOR = new ORTokenElementType("LXOR", RmlLanguage.INSTANCE); - METHOD = new ORTokenElementType("METHOD", RmlLanguage.INSTANCE); - MOD = new ORTokenElementType("MOD", RmlLanguage.INSTANCE); - NEW = new ORTokenElementType("NEW", RmlLanguage.INSTANCE); - NONREC = new ORTokenElementType("NONREC", RmlLanguage.INSTANCE); - OR = new ORTokenElementType("OR", RmlLanguage.INSTANCE); - PRIVATE = new ORTokenElementType("PRIVATE", RmlLanguage.INSTANCE); - VIRTUAL = new ORTokenElementType("VIRTUAL", RmlLanguage.INSTANCE); + ASR = new ORTokenElementType("ASR", RmlLanguage.INSTANCE); + CLASS = new ORTokenElementType("CLASS", RmlLanguage.INSTANCE); + CONSTRAINT = new ORTokenElementType("CONSTRAINT", RmlLanguage.INSTANCE); + DOWNTO = new ORTokenElementType("DOWNTO", RmlLanguage.INSTANCE); + INHERIT = new ORTokenElementType("INHERIT", RmlLanguage.INSTANCE); + INITIALIZER = new ORTokenElementType("INITIALIZER", RmlLanguage.INSTANCE); + LAND = new ORTokenElementType("LAND", RmlLanguage.INSTANCE); + LOR = new ORTokenElementType("LOR", RmlLanguage.INSTANCE); + LSL = new ORTokenElementType("LSL", RmlLanguage.INSTANCE); + LSR = new ORTokenElementType("LSR", RmlLanguage.INSTANCE); + LXOR = new ORTokenElementType("LXOR", RmlLanguage.INSTANCE); + METHOD = new ORTokenElementType("METHOD", RmlLanguage.INSTANCE); + MOD = new ORTokenElementType("MOD", RmlLanguage.INSTANCE); + NEW = new ORTokenElementType("NEW", RmlLanguage.INSTANCE); + NONREC = new ORTokenElementType("NONREC", RmlLanguage.INSTANCE); + OR = new ORTokenElementType("OR", RmlLanguage.INSTANCE); + PRIVATE = new ORTokenElementType("PRIVATE", RmlLanguage.INSTANCE); + VIRTUAL = new ORTokenElementType("VIRTUAL", RmlLanguage.INSTANCE); - COLON_EQ = new ORTokenElementType("COLON_EQ", RmlLanguage.INSTANCE); - COLON_GT = new ORTokenElementType("COLON_GT", RmlLanguage.INSTANCE); - DOTDOT = new ORTokenElementType("DOTDOT", RmlLanguage.INSTANCE); - SEMISEMI = new ORTokenElementType("SEMISEMI", RmlLanguage.INSTANCE); - GT_BRACKET = new ORTokenElementType("GT_BRACKET", RmlLanguage.INSTANCE); - GT_BRACE = new ORTokenElementType("GT_BRACE", RmlLanguage.INSTANCE); - LEFT_ARROW = new ORTokenElementType("LEFT_ARROW", RmlLanguage.INSTANCE); - RIGHT_ARROW = new ORTokenElementType("RIGHT_ARROW", RmlLanguage.INSTANCE); + COLON_EQ = new ORTokenElementType("COLON_EQ", RmlLanguage.INSTANCE); + COLON_GT = new ORTokenElementType("COLON_GT", RmlLanguage.INSTANCE); + DOTDOT = new ORTokenElementType("DOTDOT", RmlLanguage.INSTANCE); + SEMISEMI = new ORTokenElementType("SEMISEMI", RmlLanguage.INSTANCE); + GT_BRACKET = new ORTokenElementType("GT_BRACKET", RmlLanguage.INSTANCE); + GT_BRACE = new ORTokenElementType("GT_BRACE", RmlLanguage.INSTANCE); + LEFT_ARROW = new ORTokenElementType("LEFT_ARROW", RmlLanguage.INSTANCE); + RIGHT_ARROW = new ORTokenElementType("RIGHT_ARROW", RmlLanguage.INSTANCE); - OBJECT = new ORTokenElementType("OBJECT", RmlLanguage.INSTANCE); - RECORD = new ORTokenElementType("RECORD", RmlLanguage.INSTANCE); + OBJECT = new ORTokenElementType("OBJECT", RmlLanguage.INSTANCE); + RECORD = new ORTokenElementType("RECORD", RmlLanguage.INSTANCE); - AMPERSAND = new ORTokenElementType("AMPERSAND", RmlLanguage.INSTANCE); - BRACKET_GT = new ORTokenElementType("BRACKET_GT", RmlLanguage.INSTANCE); - BRACKET_LT = new ORTokenElementType("BRACKET_LT", RmlLanguage.INSTANCE); - BRACE_LT = new ORTokenElementType("BRACE_LT", RmlLanguage.INSTANCE); + AMPERSAND = new ORTokenElementType("AMPERSAND", RmlLanguage.INSTANCE); + BRACKET_GT = new ORTokenElementType("BRACKET_GT", RmlLanguage.INSTANCE); + BRACKET_LT = new ORTokenElementType("BRACKET_LT", RmlLanguage.INSTANCE); + BRACE_LT = new ORTokenElementType("BRACE_LT", RmlLanguage.INSTANCE); - ML_STRING_VALUE = new ORTokenElementType("ML_STRING_VALUE", RmlLanguage.INSTANCE); - ML_STRING_OPEN = new ORTokenElementType("ML_STRING_OPEN", RmlLanguage.INSTANCE); - ML_STRING_CLOSE = new ORTokenElementType("ML_STRING_CLOSE", RmlLanguage.INSTANCE); - JS_STRING_OPEN = new ORTokenElementType("JS_STRING_OPEN", RmlLanguage.INSTANCE); - JS_STRING_CLOSE = new ORTokenElementType("JS_STRING_CLOSE", RmlLanguage.INSTANCE); - UNDERSCORE = new ORTokenElementType("UNDERSCORE", RmlLanguage.INSTANCE); - } + ML_STRING_VALUE = new ORTokenElementType("ML_STRING_VALUE", RmlLanguage.INSTANCE); + ML_STRING_OPEN = new ORTokenElementType("ML_STRING_OPEN", RmlLanguage.INSTANCE); + ML_STRING_CLOSE = new ORTokenElementType("ML_STRING_CLOSE", RmlLanguage.INSTANCE); + JS_STRING_OPEN = new ORTokenElementType("JS_STRING_OPEN", RmlLanguage.INSTANCE); + JS_STRING_CLOSE = new ORTokenElementType("JS_STRING_CLOSE", RmlLanguage.INSTANCE); + UNDERSCORE = new ORTokenElementType("UNDERSCORE", RmlLanguage.INSTANCE); + } } diff --git a/tests/com/reason/bs/BsPlatformTest.java b/tests/com/reason/bs/BsPlatformTest.java deleted file mode 100644 index 47bf26035..000000000 --- a/tests/com/reason/bs/BsPlatformTest.java +++ /dev/null @@ -1,68 +0,0 @@ -package com.reason.bs; - -import com.intellij.mock.*; -import com.intellij.openapi.project.*; -import com.intellij.openapi.vfs.*; -import org.junit.*; -import org.mockito.Mock; - -import java.util.*; - -import static com.reason.bs.BsConstants.*; -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.*; - -@SuppressWarnings("ConstantConditions") -public class BsPlatformTest { - - private static final String MOCK_ROOT = "MOCK_DIRECTORY"; - - @Mock private Project mockProject; - - @Before - public void setUp() { - initMocks(this); - } - - @Test - public void testFindBsbExecutable_platformSpecificBinary() { - MockVirtualFile mockSourceFile = MockVirtualFile.file("mock-source-file.bs"); - MockVirtualFile mockSourceDirectory = MockVirtualFile.dir("src", mockSourceFile); - - MockVirtualFile mockBsbExecutable = MockVirtualFile.file(BSB_EXE_NAME + ".exe"); - MockVirtualFile mockPlatformDirectory = MockVirtualFile.dir(BsPlatform.getOsBsPrefix(), mockBsbExecutable); - MockVirtualFile mockBsPlatformDirectory = MockVirtualFile.dir(BS_PLATFORM_NAME, mockPlatformDirectory); - MockVirtualFile mockNodeModulesDirectory = MockVirtualFile.dir("node_modules", mockBsPlatformDirectory); - - MockVirtualFile mockBsConfigFile = MockVirtualFile.file(BS_CONFIG_FILENAME); - - MockVirtualFile mockRootDirectory = MockVirtualFile.dir(MOCK_ROOT, mockBsConfigFile, mockNodeModulesDirectory, mockSourceDirectory); - when(mockProject.getBasePath()).thenReturn(mockRootDirectory.getPath()); - - Optional bsbExecutable = BsPlatform.findBsbExecutable(mockProject, mockSourceFile); - assertTrue(bsbExecutable.isPresent()); - assertEquals(mockBsbExecutable, bsbExecutable.get()); - } - - @Test - public void testFindBsbExecutable_platformAgnosticWrapper() { - MockVirtualFile mockSourceFile = MockVirtualFile.file("mock-source-file.bs"); - MockVirtualFile mockSourceDirectory = MockVirtualFile.dir("src", mockSourceFile); - - String bsbWrapperFilename = BSB_EXE_NAME + BsPlatform.getOsBinaryWrapperExtension(); - MockVirtualFile mockBsbExecutableWrapper = MockVirtualFile.file(bsbWrapperFilename); - MockVirtualFile mockBsPlatformDirectory = MockVirtualFile.dir(BS_PLATFORM_NAME, mockBsbExecutableWrapper); - MockVirtualFile mockNodeModulesDirectory = MockVirtualFile.dir("node_modules", mockBsPlatformDirectory); - - MockVirtualFile mockBsConfigFile = MockVirtualFile.file(BS_CONFIG_FILENAME); - - MockVirtualFile mockRootDirectory = MockVirtualFile.dir(MOCK_ROOT, mockBsConfigFile, mockNodeModulesDirectory, mockSourceDirectory); - when(mockProject.getBasePath()).thenReturn(mockRootDirectory.getPath()); - - Optional bsbExecutableWrapper = BsPlatform.findBsbExecutable(mockProject, mockBsPlatformDirectory); - assertTrue(bsbExecutableWrapper.isPresent()); - assertEquals(mockBsbExecutableWrapper, bsbExecutableWrapper.get()); - } - -} diff --git a/tests/com/reason/ide/ORBasePlatformTestCase.java b/tests/com/reason/ide/ORBasePlatformTestCase.java index 76b037e31..f182b6d90 100644 --- a/tests/com/reason/ide/ORBasePlatformTestCase.java +++ b/tests/com/reason/ide/ORBasePlatformTestCase.java @@ -1,26 +1,20 @@ package com.reason.ide; -import com.intellij.lang.Language; -import com.intellij.lang.LanguageDocumentation; -import com.intellij.lang.documentation.DocumentationProvider; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.CharsetToolkit; -import com.intellij.psi.PsiElement; -import com.intellij.psi.PsiFile; -import com.intellij.psi.impl.DebugUtil; -import com.intellij.testFramework.fixtures.BasePlatformTestCase; -import com.reason.ide.files.FileBase; -import com.reason.lang.core.ORUtil; -import com.reason.lang.core.psi.PsiQualifiedElement; -import com.reason.lang.core.psi.impl.PsiLowerIdentifier; -import com.reason.lang.core.psi.impl.PsiUpperIdentifier; +import com.intellij.lang.*; +import com.intellij.lang.documentation.*; +import com.intellij.openapi.util.io.*; +import com.intellij.openapi.vfs.*; +import com.intellij.psi.*; +import com.intellij.psi.impl.*; +import com.intellij.testFramework.fixtures.*; +import com.reason.ide.files.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.impl.*; +import org.jetbrains.annotations.*; -import java.io.File; -import java.io.IOException; +import java.io.*; import java.util.*; -import org.jetbrains.annotations.NotNull; - public abstract class ORBasePlatformTestCase extends BasePlatformTestCase { @NotNull @@ -33,7 +27,7 @@ protected FileBase configureCode(@NotNull String fileName, @NotNull String code) return (FileBase) file; } - protected PsiElement getNameIdentifier(PsiQualifiedElement e) { + protected PsiElement getNameIdentifier(PsiQualifiedNamedElement e) { return ORUtil.findImmediateFirstChildOfAnyClass(e, PsiUpperIdentifier.class, PsiLowerIdentifier.class); } diff --git a/tests/com/reason/ide/ORFileUtilsTest.java b/tests/com/reason/ide/ORFileUtilsTest.java deleted file mode 100644 index 8e6f311f1..000000000 --- a/tests/com/reason/ide/ORFileUtilsTest.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.reason.ide; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.*; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mockStatic; - -import com.intellij.mock.MockVirtualFile; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.search.FilenameIndex; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.indexing.ID; -import com.reason.esy.EsyPackageJson; - -import java.util.Optional; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ID.class, EsyPackageJson.class, FilenameIndex.class, GlobalSearchScope.class}) -public class ORFileUtilsTest { - -// @Mock GlobalSearchScope mockScope; -// @Mock private Project mockProject; - -// @Before -// public void setUp() { -// initMocks(this); -// mockStatic(ID.class); -// mockStatic(EsyPackageJson.class); -// mockStatic(FilenameIndex.class); -// mockStatic(GlobalSearchScope.class); -// when(GlobalSearchScope.allScope(mockProject)).thenReturn(mockScope); -// } - - @Test - public void testFindAncestorRecursive_startAtRootOfFileSystem() { -// VirtualFile mockFile = spy(VirtualFile.class); -// when(mockFile.isDirectory()).thenReturn(false); -// when(mockFile.getParent()).thenReturn(null); -// Optional ancestor = ORFileUtils.findAncestor(mockProject, "", mockFile); -// verify(mockFile).isDirectory(); -// verify(mockFile).getParent(); -// assertFalse(ancestor.isPresent()); - assertTrue(true); // mock not working - } - - @Test - public void testFindAncestorRecursive_hitRootOfFileSystem() { -// String mockProjectBasePath = "mock-path"; -// when(mockProject.getBasePath()).thenReturn(mockProjectBasePath); -// VirtualFile mockStart = spy(VirtualFile.class); -// when(mockStart.isDirectory()).thenReturn(true); -// when(mockStart.getPath()).thenReturn(mockProjectBasePath); -// Optional ancestor = ORFileUtils.findAncestor(mockProject, "", mockStart); -// assertFalse(ancestor.isPresent()); - assertTrue(true); // mock not working - } - - @Test - public void testFindAncestorRecursive_targetFound() { -// VirtualFile mockTarget = new MockVirtualFile("mock-target"); -// String targetName = mockTarget.getName(); -// VirtualFile mockStart = spy(VirtualFile.class); -// when(mockStart.isDirectory()).thenReturn(true); -// when(mockStart.findChild(targetName)).thenReturn(mockTarget); -// Optional ancestor = -// ORFileUtils.findAncestor(mockProject, targetName, mockStart); -// assertTrue(ancestor.isPresent()); -// assertEquals(mockTarget, ancestor.get()); - assertTrue(true); // mock not working - } -} diff --git a/tests/com/reason/ide/ORProjectManagerTest.java b/tests/com/reason/ide/ORProjectManagerTest.java deleted file mode 100644 index 3b5b86393..000000000 --- a/tests/com/reason/ide/ORProjectManagerTest.java +++ /dev/null @@ -1,224 +0,0 @@ -package com.reason.ide; - -import static com.reason.dune.Dune.*; -import static org.junit.Assert.*; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.when; -import static org.mockito.MockitoAnnotations.initMocks; -import static org.powermock.api.mockito.PowerMockito.mockStatic; - -import com.intellij.mock.MockApplication; -import com.intellij.mock.MockVirtualFile; -import com.intellij.openapi.Disposable; -import com.intellij.openapi.application.ApplicationManager; -import com.intellij.openapi.project.Project; -import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.psi.search.FilenameIndex; -import com.intellij.psi.search.GlobalSearchScope; -import com.intellij.util.indexing.ID; -import com.reason.bs.BsConstants; -import com.reason.esy.EsyConstants; -import com.reason.esy.EsyPackageJson; -import com.reason.ide.files.EsyPackageJsonFileType; - -import java.util.Arrays; -import java.util.Collections; -import java.util.Iterator; -import java.util.LinkedHashSet; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.stubbing.OngoingStubbing; -import org.powermock.core.classloader.annotations.PrepareForTest; -import org.powermock.modules.junit4.PowerMockRunner; - -//@RunWith(PowerMockRunner.class) -//@PrepareForTest({ -// ApplicationManager.class, -// EsyPackageJson.class, -// FilenameIndex.class, -// GlobalSearchScope.class, -// ID.class -//}) -public class ORProjectManagerTest { - -// @Mock Disposable mockDisposable; -// @Mock GlobalSearchScope mockScope; -// @Mock private Project mockProject; - -// @Before -// public void setUp() { -// initMocks(this); -// mockStatic(ID.class); -// when(ID.create(any())).thenReturn(null); -// mockStatic(ApplicationManager.class); -// mockStatic(EsyPackageJson.class); -// mockStatic(FilenameIndex.class); -// mockStatic(GlobalSearchScope.class); -// when(ApplicationManager.getApplication()).thenReturn(new MockApplication(mockDisposable)); -// when(GlobalSearchScope.allScope(mockProject)).thenReturn(mockScope); -// } - - @Test - public void testIsModuleNoMatches() { -// when(FilenameIndex.getVirtualFilesByName(any(), any(), any())).thenReturn(Collections.emptyList()); -// assertFalse(ORProjectManager.isBsProject(mockProject)); -// assertFalse(ORProjectManager.isDuneProject(mockProject)); -// assertFalse(ORProjectManager.isEsyProject(mockProject)); - assertTrue(true); // mock not working - } - - @Test - public void testIsBsProject() { -// MockVirtualFile mockBsConfig = new MockVirtualFile("bsconfig.json"); -// registerMockFile(mockBsConfig); -// assertTrue(ORProjectManager.isBsProject(mockProject)); - assertTrue(true); // mock not working - } - - @Test - public void testIsEsyProject() { -// MockVirtualFile mockEsyConfig = new MockVirtualFile(EsyPackageJsonFileType.getDefaultFilename()); -// registerMockFile(mockEsyConfig); -// -// OngoingStubbing whenIsEsyPackageJson = when(EsyPackageJson.isEsyPackageJson(mockEsyConfig)); -// -// whenIsEsyPackageJson.thenReturn(false); -// assertFalse("File not recognized as esy package.json.", ORProjectManager.isEsyProject(mockProject)); -// -// whenIsEsyPackageJson.thenReturn(true); -// assertTrue(ORProjectManager.isEsyProject(mockProject)); - assertTrue(true); // mock not working - } - - @Test - public void testIsDuneProject_allDuneFileTypes() { -// MockVirtualFile mockDuneFile = new MockVirtualFile(DUNE_FILENAME); -// MockVirtualFile mockDuneProjectFile = new MockVirtualFile(DUNE_PROJECT_FILENAME); -// MockVirtualFile mockJBuilderFile = new MockVirtualFile(LEGACY_JBUILDER_FILENAME); -// registerMockFile(mockDuneFile); -// assertTrue(ORProjectManager.isDuneProject(mockProject)); -// registerMockFile(mockDuneProjectFile); -// assertTrue(ORProjectManager.isDuneProject(mockProject)); -// registerMockFile(mockJBuilderFile); -// assertTrue(ORProjectManager.isDuneProject(mockProject)); - assertTrue(true); // mock not working - } - - @Test - public void testFindBsConfigurationFiles_sortedByFileDepth() { -// String mockFileName = BsConstants.BS_CONFIG_FILENAME; -// MockVirtualFile mockBsConfigFileParent = new MockVirtualFile(mockFileName); -// MockVirtualFile mockBsConfigFile = new MockVirtualFile(mockFileName); -// MockVirtualFile mockBsConfigFileChild = new MockVirtualFile(mockFileName); - // set up mock file hierarchy -// mockBsConfigFile.setParent(mockBsConfigFileParent); -// mockBsConfigFileChild.setParent(mockBsConfigFile); -// -// MockVirtualFile[] mocksUnsorted = { -// mockBsConfigFile, mockBsConfigFileChild, mockBsConfigFileParent -// }; -// MockVirtualFile[] mocksSorted = { -// mockBsConfigFileParent, mockBsConfigFile, mockBsConfigFileChild -// }; -// -// when(FilenameIndex.getVirtualFilesByName(mockProject, mockFileName, mockScope)) -// .thenReturn(Arrays.asList(mocksUnsorted)); -// -// LinkedHashSet bsConfigurationFiles = -// ORProjectManager.findBsConfigurationFiles(mockProject); -// assertMocksSorted(bsConfigurationFiles, mocksSorted); - assertTrue(true); // mock not working - } - - @Test - public void testFindDuneConfigurationFiles_sortedByFileType() { -// MockVirtualFile mockDuneFile = new MockVirtualFile(DUNE_FILENAME); -// MockVirtualFile mockDuneProjectFile = new MockVirtualFile(DUNE_PROJECT_FILENAME); -// MockVirtualFile mockJBuilderFile = new MockVirtualFile(LEGACY_JBUILDER_FILENAME); -// -// MockVirtualFile[] mocksUnsorted = {mockJBuilderFile, mockDuneFile, mockDuneProjectFile}; -// MockVirtualFile[] mocksSorted = {mockDuneProjectFile, mockDuneFile, mockJBuilderFile}; - - // test prioritizing of dune file types by registering mocks to be returned out of order -// for (MockVirtualFile mockFile : mocksUnsorted) { -// registerMockFile(mockFile); -// } -// -// LinkedHashSet duneConfigurationFiles = -// ORProjectManager.findDuneConfigurationFiles(mockProject); -// assertMocksSorted(duneConfigurationFiles, mocksSorted); - assertTrue(true); // mock not working - } - - @Test - public void testFindDuneConfigurationFiles_sortedByFileDepth() { -// String mockFileName = DUNE_FILENAME; -// MockVirtualFile mockDuneFileParent = new MockVirtualFile(mockFileName); -// MockVirtualFile mockDuneFile = new MockVirtualFile(mockFileName); -// MockVirtualFile mockDuneFileChild = new MockVirtualFile(mockFileName); - // set up mock file hierarchy -// mockDuneFile.setParent(mockDuneFileParent); -// mockDuneFileChild.setParent(mockDuneFile); -// -// MockVirtualFile[] mocksUnsorted = {mockDuneFile, mockDuneFileChild, mockDuneFileParent}; -// MockVirtualFile[] mocksSorted = {mockDuneFileParent, mockDuneFile, mockDuneFileChild}; -// -// when(FilenameIndex.getVirtualFilesByName(mockProject, mockFileName, mockScope)) -// .thenReturn(Arrays.asList(mocksUnsorted)); -// -// LinkedHashSet duneConfigurationFiles = -// ORProjectManager.findDuneConfigurationFiles(mockProject); -// assertMocksSorted(duneConfigurationFiles, mocksSorted); - assertTrue(true); // mock not working - } - - @Test - public void testFindEsyConfigurationFiles_sortedByFileDepth() { -// String mockFileName = EsyConstants.ESY_CONFIG_FILENAME; -// MockVirtualFile mockEsyConfigFileParent = new MockVirtualFile(mockFileName); -// MockVirtualFile mockEsyConfigFile = new MockVirtualFile(mockFileName); -// MockVirtualFile mockEsyConfigFileChild = new MockVirtualFile(mockFileName); - // set up mock file hierarchy -// mockEsyConfigFile.setParent(mockEsyConfigFileParent); -// mockEsyConfigFileChild.setParent(mockEsyConfigFile); -// -// MockVirtualFile[] mocksUnsorted = { -// mockEsyConfigFile, mockEsyConfigFileChild, mockEsyConfigFileParent -// }; -// MockVirtualFile[] mocksSorted = { -// mockEsyConfigFileParent, mockEsyConfigFile, mockEsyConfigFileChild -// }; -// -// when(FilenameIndex.getVirtualFilesByName(mockProject, mockFileName, mockScope)) -// .thenReturn(Arrays.asList(mocksUnsorted)); -// -// when(EsyPackageJson.isEsyPackageJson(any())).thenReturn(true); -// -// LinkedHashSet esyConfigurationFiles = -// ORProjectManager.findEsyConfigurationFiles(mockProject); -// assertMocksSorted(esyConfigurationFiles, mocksSorted); - assertTrue(true); // mock not working - } - -// private void registerMockFile(VirtualFile mockFile) { -// registerMockFile(mockFile.getName(), mockFile); -// } - -// private void registerMockFile(String filename, VirtualFile fileToReturn) { -// when(FilenameIndex.getVirtualFilesByName(mockProject, filename, mockScope)) -// .thenReturn(Collections.singletonList(fileToReturn)); -// } - -// private void assertMocksSorted( -// LinkedHashSet actualOrder, VirtualFile[] expectedOrder) { -// assertEquals(expectedOrder.length, actualOrder.size()); -// Iterator iterator = actualOrder.iterator(); -// for (VirtualFile expected : expectedOrder) { -// VirtualFile next = iterator.next(); -// assertEquals(expected, next); -// } -// } -} diff --git a/tests/com/reason/ide/PsiFinderTest.java b/tests/com/reason/ide/PsiFinderTest.java index 008396722..95f645ac1 100644 --- a/tests/com/reason/ide/PsiFinderTest.java +++ b/tests/com/reason/ide/PsiFinderTest.java @@ -1,149 +1,192 @@ package com.reason.ide; -import static com.intellij.psi.search.GlobalSearchScope.allScope; -import static com.reason.lang.core.ExpressionFilterConstants.NO_FILTER; -import static com.reason.lang.core.ORFileType.*; -import static com.reason.lang.core.psi.ExpressionScope.all; - -import com.intellij.psi.search.GlobalSearchScope; -import com.reason.ide.files.FileBase; -import com.reason.ide.search.PsiFinder; -import com.reason.lang.core.psi.PsiException; -import com.reason.lang.core.psi.PsiInnerModule; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.PsiModule; -import com.reason.lang.core.psi.impl.PsiFakeModule; +import com.intellij.psi.search.*; +import com.intellij.psi.util.*; +import com.reason.ide.files.*; +import com.reason.ide.search.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; + import java.util.*; +import static com.intellij.psi.search.GlobalSearchScope.*; +import static com.reason.lang.core.ExpressionFilterConstants.*; +import static com.reason.lang.core.ORFileType.*; +import static com.reason.lang.core.psi.ExpressionScope.*; + @SuppressWarnings("ConstantConditions") public class PsiFinderTest extends ORBasePlatformTestCase { - public void testModuleLet() { - myFixture.configureByText("ReasonReact.rei", "module Router: { type api; };"); - myFixture.configureByText("ReasonReact.re", "module Router = { type impl; };"); - - GlobalSearchScope scope = allScope(getProject()); - List modulesA = - new ArrayList<>( - PsiFinder.getInstance(getProject()) - .findModulesbyName("Router", interfaceOnly, null, scope)); - List modulesB = - new ArrayList<>( - PsiFinder.getInstance(getProject()) - .findModulesbyName("Router", implementationOnly, null, scope)); - List modulesC = - new ArrayList<>( - PsiFinder.getInstance(getProject()) - .findModulesbyName("Router", interfaceOrImplementation, null, scope)); - List modulesD = - new ArrayList<>( - PsiFinder.getInstance(getProject()).findModulesbyName("Router", both, null, scope)); - - assertSize(1, modulesA); - assertEquals( - "type api", modulesA.get(0).getExpressions(all, NO_FILTER).iterator().next().getText()); - - assertSize(1, modulesB); - assertEquals( - "type impl", modulesB.get(0).getExpressions(all, NO_FILTER).iterator().next().getText()); - - assertSize(1, modulesC); - assertEquals( - "type api", modulesC.get(0).getExpressions(all, NO_FILTER).iterator().next().getText()); - - assertSize(2, modulesD); - } - - public void testFindRelatedFile() { - FileBase intf = (FileBase) myFixture.configureByText("A.rei", "module Router: { let x = 1; };"); - FileBase impl = (FileBase) myFixture.configureByText("A.re", "module Router: { let x = 1; };"); - FileBase implOnly = - (FileBase) myFixture.configureByText("B.re", "module Router: { let x = 1; };"); - - FileBase implRelated = PsiFinder.getInstance(getProject()).findRelatedFile(intf); - FileBase intfRelated = PsiFinder.getInstance(getProject()).findRelatedFile(impl); - FileBase onlyRelated = PsiFinder.getInstance(getProject()).findRelatedFile(implOnly); - - assertEquals("A.re", implRelated.getName()); - assertEquals("A.rei", intfRelated.getName()); - assertNull(onlyRelated); - } - - public void testFindModuleByQn() { - myFixture.configureByText("a.rei", "module A: { let x = 1; };"); - myFixture.configureByText("A.re", "module A = { let x = 1; };"); - - List fileModules = - new ArrayList<>( - PsiFinder.getInstance(getProject()) - .findModulesFromQn("A", true, both, allScope(getProject()))); - List innerModules = - new ArrayList<>( - PsiFinder.getInstance(getProject()) - .findModulesFromQn("A.A", true, both, allScope(getProject()))); - - assertSize(2, fileModules); - assertInstanceOf(fileModules.get(0), PsiFakeModule.class); - assertInstanceOf(fileModules.get(1), PsiFakeModule.class); - - assertSize(2, innerModules); - assertInstanceOf(innerModules.get(0), PsiInnerModule.class); - assertInstanceOf(innerModules.get(1), PsiInnerModule.class); - } - - public void testException() { - myFixture.configureByText("A.rei", "exception Ex;"); - myFixture.configureByText("A.re", "exception Ex;"); - - PsiFinder psiFinder = PsiFinder.getInstance(getProject()); - PsiException intf1 = psiFinder.findException("A.Ex", interfaceOnly, allScope(getProject())); - PsiException intf2 = - psiFinder.findException("A.Ex", interfaceOrImplementation, allScope(getProject())); - PsiException impl = psiFinder.findException("A.Ex", implementationOnly, allScope(getProject())); - - assertEquals("rei", intf1.getContainingFile().getFileType().getDefaultExtension()); - assertEquals("rei", intf2.getContainingFile().getFileType().getDefaultExtension()); - assertEquals("re", impl.getContainingFile().getFileType().getDefaultExtension()); - } - - public void testFindModuleAlias() { - myFixture.configureByText("Belt_Option.mli", "type t;"); - myFixture.configureByText("Belt_Option.ml", "type t;"); - myFixture.configureByText("Belt.ml", "module Option = Belt_Option;"); - - PsiFinder psiFinder = PsiFinder.getInstance(getProject()); - List moduleAliases = - new ArrayList<>(psiFinder.findModuleAlias("Belt.Option", allScope(getProject()))); - - assertSize(2, moduleAliases); - assertInstanceOf(moduleAliases.get(0), PsiFakeModule.class); - assertInstanceOf(moduleAliases.get(1), PsiFakeModule.class); - } - - public void test_Ns_letDeconstruction() { - configureCode("A.res", "let x = something;"); - configureCode("B.res", "let (x, y) = other;"); - - Set lets = PsiFinder.getInstance(getProject()).findLets("x", both); - - assertSize(2, lets); - } - - public void test_Rml_letDeconstruction() { - configureCode("A.re", "let x = something;"); - configureCode("B.re", "let (x, y) = other;"); - - Set lets = PsiFinder.getInstance(getProject()).findLets("x", both); - - assertSize(2, lets); - } - - public void test_Ocl_letDeconstruction() { - configureCode("A.ml", "let x = something"); - configureCode("B.ml", "let (x, y) = other"); - - Set lets = PsiFinder.getInstance(getProject()).findLets("x", both); - - assertSize(2, lets); - } + public void test_findModuleBack_simple() { + FileBase a = configureCode("A.re", "module B = {}; include B;"); + PsiInclude e = PsiTreeUtil.getChildOfType(a, PsiInclude.class); + + PsiQualifiedPathElement module = PsiFinder.getInstance(getProject()).findModuleBack(e, e.getIncludePath()); + + assertEquals("A.B", module.getQualifiedName()); + } + + public void test_findModuleBack_multi() { + FileBase a = configureCode("A.re", "module B = { module C = { module D = {}; }; }; include B.C.D;"); + PsiInclude e = PsiTreeUtil.getChildOfType(a, PsiInclude.class); + + PsiQualifiedPathElement module = PsiFinder.getInstance(getProject()).findModuleBack(e, e.getIncludePath()); + + assertEquals("A.B.C.D", module.getQualifiedName()); + } + + public void test_findModuleBack_alias() { + FileBase a = configureCode("A.re", "module B = {}; module C = B; include C;"); + PsiInclude e = PsiTreeUtil.getChildOfType(a, PsiInclude.class); + + PsiQualifiedPathElement module = PsiFinder.getInstance(getProject()).findModuleBack(e, e.getIncludePath()); + + assertEquals("A.B", module.getQualifiedName()); + } + + public void test_findModuleBack_alias_multi() { + FileBase a = configureCode("A.re", "module B = { module C = {}; }; module D = B.C; include D;"); + PsiInclude e = PsiTreeUtil.getChildOfType(a, PsiInclude.class); + + PsiQualifiedPathElement module = PsiFinder.getInstance(getProject()).findModuleBack(e, e.getIncludePath()); + + assertEquals("A.B.C", module.getQualifiedName()); + } + + public void test_findModuleBack_alias_include_multi() { + FileBase a = configureCode("A.re", "module B = { module C = { type t; }; }; module D = B; include D.C;"); + PsiInclude e = PsiTreeUtil.getChildOfType(a, PsiInclude.class); + + PsiQualifiedPathElement module = PsiFinder.getInstance(getProject()).findModuleBack(e, e.getIncludePath()); + + assertEquals("A.B.C", module.getQualifiedName()); + } + + public void testModuleLet() { + myFixture.configureByText("ReasonReact.rei", "module Router: { type api; };"); + myFixture.configureByText("ReasonReact.re", "module Router = { type impl; };"); + + GlobalSearchScope scope = allScope(getProject()); + List modulesA = + new ArrayList<>( + PsiFinder.getInstance(getProject()) + .findModulesbyName("Router", interfaceOnly, null, scope)); + List modulesB = + new ArrayList<>( + PsiFinder.getInstance(getProject()) + .findModulesbyName("Router", implementationOnly, null, scope)); + List modulesC = + new ArrayList<>( + PsiFinder.getInstance(getProject()) + .findModulesbyName("Router", interfaceOrImplementation, null, scope)); + List modulesD = + new ArrayList<>( + PsiFinder.getInstance(getProject()).findModulesbyName("Router", both, null, scope)); + + assertSize(1, modulesA); + assertEquals( + "type api", modulesA.get(0).getExpressions(all, NO_FILTER).iterator().next().getText()); + + assertSize(1, modulesB); + assertEquals( + "type impl", modulesB.get(0).getExpressions(all, NO_FILTER).iterator().next().getText()); + + assertSize(1, modulesC); + assertEquals( + "type api", modulesC.get(0).getExpressions(all, NO_FILTER).iterator().next().getText()); + + assertSize(2, modulesD); + } + + public void testFindRelatedFile() { + FileBase intf = (FileBase) myFixture.configureByText("A.rei", "module Router: { let x = 1; };"); + FileBase impl = (FileBase) myFixture.configureByText("A.re", "module Router: { let x = 1; };"); + FileBase implOnly = + (FileBase) myFixture.configureByText("B.re", "module Router: { let x = 1; };"); + + FileBase implRelated = PsiFinder.getInstance(getProject()).findRelatedFile(intf); + FileBase intfRelated = PsiFinder.getInstance(getProject()).findRelatedFile(impl); + FileBase onlyRelated = PsiFinder.getInstance(getProject()).findRelatedFile(implOnly); + + assertEquals("A.re", implRelated.getName()); + assertEquals("A.rei", intfRelated.getName()); + assertNull(onlyRelated); + } + + public void testFindModuleByQn() { + myFixture.configureByText("a.rei", "module A: { let x = 1; };"); + myFixture.configureByText("A.re", "module A = { let x = 1; };"); + + List fileModules = + new ArrayList<>( + PsiFinder.getInstance(getProject()) + .findModulesFromQn("A", true, both, allScope(getProject()))); + List innerModules = + new ArrayList<>( + PsiFinder.getInstance(getProject()) + .findModulesFromQn("A.A", true, both, allScope(getProject()))); + + assertSize(2, fileModules); + assertInstanceOf(fileModules.get(0), PsiFakeModule.class); + assertInstanceOf(fileModules.get(1), PsiFakeModule.class); + + assertSize(2, innerModules); + assertInstanceOf(innerModules.get(0), PsiInnerModule.class); + assertInstanceOf(innerModules.get(1), PsiInnerModule.class); + } + + public void testException() { + myFixture.configureByText("A.rei", "exception Ex;"); + myFixture.configureByText("A.re", "exception Ex;"); + + PsiFinder psiFinder = PsiFinder.getInstance(getProject()); + PsiException intf1 = psiFinder.findException("A.Ex", interfaceOnly, allScope(getProject())); + PsiException intf2 = + psiFinder.findException("A.Ex", interfaceOrImplementation, allScope(getProject())); + PsiException impl = psiFinder.findException("A.Ex", implementationOnly, allScope(getProject())); + + assertEquals("rei", intf1.getContainingFile().getFileType().getDefaultExtension()); + assertEquals("rei", intf2.getContainingFile().getFileType().getDefaultExtension()); + assertEquals("re", impl.getContainingFile().getFileType().getDefaultExtension()); + } + + public void testFindModuleAlias() { + myFixture.configureByText("Belt_Option.mli", "type t;"); + myFixture.configureByText("Belt_Option.ml", "type t;"); + myFixture.configureByText("Belt.ml", "module Option = Belt_Option;"); + + PsiFinder psiFinder = PsiFinder.getInstance(getProject()); + List moduleAliases = new ArrayList<>(psiFinder.findModuleAlias("Belt.Option", allScope(getProject()))); + + assertSize(2, moduleAliases); + assertInstanceOf(moduleAliases.get(0), PsiFakeModule.class); + assertInstanceOf(moduleAliases.get(1), PsiFakeModule.class); + } + + public void test_Ns_letDeconstruction() { + configureCode("A.res", "let x = something;"); + configureCode("B.res", "let (x, y) = other;"); + + Set lets = PsiFinder.getInstance(getProject()).findLets("x", both); + + assertSize(2, lets); + } + + public void test_Rml_letDeconstruction() { + configureCode("A.re", "let x = something;"); + configureCode("B.re", "let (x, y) = other;"); + + Set lets = PsiFinder.getInstance(getProject()).findLets("x", both); + + assertSize(2, lets); + } + + public void test_Ocl_letDeconstruction() { + configureCode("A.ml", "let x = something"); + configureCode("B.ml", "let (x, y) = other"); + + Set lets = PsiFinder.getInstance(getProject()).findLets("x", both); + + assertSize(2, lets); + } } diff --git a/tests/com/reason/ide/intention/FunctionBracesIntentionTest.java b/tests/com/reason/ide/intention/FunctionBracesIntentionTest.java index ef231ca20..478dde39b 100644 --- a/tests/com/reason/ide/intention/FunctionBracesIntentionTest.java +++ b/tests/com/reason/ide/intention/FunctionBracesIntentionTest.java @@ -1,44 +1,42 @@ package com.reason.ide.intention; -import com.intellij.codeInsight.intention.IntentionAction; -import com.reason.ide.ORBasePlatformTestCase; +import com.intellij.codeInsight.intention.*; +import com.reason.ide.*; @SuppressWarnings("ConstantConditions") public class FunctionBracesIntentionTest extends ORBasePlatformTestCase { - public static final String ADD_BRACES = "Add braces to blockless function"; - - public void testBasic() { - configureCode("A.re", "let add = (x, y) => x + y;"); - IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); - myFixture.launchAction(bracesAction); - - myFixture.checkResult("let add = (x, y) => { x + y; };"); - } - - public void test_withSignature() { - configureCode("A.re", "let add = (x: int => int, y: int) => x + y;"); - IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); - myFixture.launchAction(bracesAction); - - myFixture.checkResult("let add = (x: int => int, y: int) => { x + y; };"); - } - - public void test_jsx2ComponentFunction() { - configureCode( - "A.re", "let make = (children) => { ...component, render: self => v/>, };"); - IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); - myFixture.launchAction(bracesAction); - - myFixture.checkResult( - "let make = (children) => { ...component, render: self => {
; }, };"); - } - - // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/67 - public void test_GH_67() { - configureCode("A.re", "Js.Promise.( Api.all() |> then_(result => Js.log(result)) );"); - IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); - myFixture.launchAction(bracesAction); - - myFixture.checkResult("Js.Promise.( Api.all() |> then_(result => { Js.log(result); }) );"); - } + public static final String ADD_BRACES = "Add braces to blockless function"; + + public void testBasic() { + configureCode("A.re", "let add = (x, y) => x + y;"); + IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); + myFixture.launchAction(bracesAction); + + myFixture.checkResult("let add = (x, y) => { x + y; };"); + } + + public void test_withSignature() { + configureCode("A.re", "let add = (x: int => int, y: int) => x + y;"); + IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); + myFixture.launchAction(bracesAction); + + myFixture.checkResult("let add = (x: int => int, y: int) => { x + y; };"); + } + + public void test_jsx2ComponentFunction() { + configureCode("A.re", "let make = (children) => { ...component, render: self => v/>, };"); + IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); + myFixture.launchAction(bracesAction); + + myFixture.checkResult("let make = (children) => { ...component, render: self => {
; }, };"); + } + + // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/67 + public void test_GH_67() { + configureCode("A.re", "Js.Promise.( Api.all() |> then_(result => Js.log(result)) );"); + IntentionAction bracesAction = myFixture.getAvailableIntention(ADD_BRACES); + myFixture.launchAction(bracesAction); + + myFixture.checkResult("Js.Promise.( Api.all() |> then_(result => { Js.log(result); }) );"); + } } diff --git a/tests/com/reason/ide/reference/FindLIdentUsagesOCLTest.java b/tests/com/reason/ide/reference/FindLIdentUsagesOCLTest.java new file mode 100644 index 000000000..ca2f8e295 --- /dev/null +++ b/tests/com/reason/ide/reference/FindLIdentUsagesOCLTest.java @@ -0,0 +1,27 @@ +package com.reason.ide.reference; + +import com.intellij.usageView.*; +import com.reason.ide.*; +import com.reason.lang.core.psi.*; + +import java.util.*; + +@SuppressWarnings("ConstantConditions") +public class FindLIdentUsagesOCLTest extends ORBasePlatformTestCase { + public void test_from_module() { + configureCode("FLIA.ml", "let x = 1"); + configureCode("FLIB.ml", "let y = FLIA.x + 2;"); + + Collection usages = myFixture.testFindUsages("FLIA.ml"); + assertSize(1, usages); + } + + public void test_same_module() { + configureCode("FLIC.ml", "let x = 1\n let y = x + 1"); + + List usages = (List) myFixture.testFindUsages("FLIC.ml"); + assertSize(1, usages); + UsageInfo usageInfo = usages.get(0); + assertEquals("x + 1", usageInfo.getElement().getParent().getText()); + } +} diff --git a/tests/com/reason/ide/reference/FindLIdentUsagesRMLTest.java b/tests/com/reason/ide/reference/FindLIdentUsagesRMLTest.java new file mode 100644 index 000000000..1d339ea87 --- /dev/null +++ b/tests/com/reason/ide/reference/FindLIdentUsagesRMLTest.java @@ -0,0 +1,39 @@ +package com.reason.ide.reference; + +import com.intellij.usageView.*; +import com.reason.ide.*; +import com.reason.lang.core.psi.*; + +import java.util.*; + +@SuppressWarnings("ConstantConditions") +public class FindLIdentUsagesRMLTest extends ORBasePlatformTestCase { + public void test_from_module() { + configureCode("FLIA.re", "let x = 1;"); + configureCode("FLIB.re", "let y = FLIA.x + 2;"); + + Collection usages = myFixture.testFindUsages("FLIA.re"); + assertSize(1, usages); + } + + public void test_same_module() { + configureCode("FLIC.re", "let x = 1; let y = x + 1;"); + + List usages = (List) myFixture.testFindUsages("FLIC.re"); + assertSize(1, usages); + UsageInfo usageInfo = usages.get(0); + assertEquals("x + 1", usageInfo.getElement().getParent().getText()); + } + + public void test_module_signature() { + configureCode("A.rei", "module B: { type t; let toString: t => string; }; module C: { type t; let toString: t => string; };"); + + List usages = (List) myFixture.testFindUsages("A.rei"); + assertSize(1, usages); + UsageInfo usageInfo = usages.get(0); + assertEquals("t", usageInfo.getElement().getParent().getText()); + assertEquals("A.B.toString", ((PsiQualifiedPathElement) usageInfo.getElement().getParent().getParent().getParent()).getQualifiedName()); + } + + +} diff --git a/tests/com/reason/ide/reference/FindLIdentUsagesTest.java b/tests/com/reason/ide/reference/FindLIdentUsagesTest.java deleted file mode 100644 index f17e81bf8..000000000 --- a/tests/com/reason/ide/reference/FindLIdentUsagesTest.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.usageView.UsageInfo; -import com.reason.ide.ORBasePlatformTestCase; -import java.util.*; - -@SuppressWarnings("ConstantConditions") -public class FindLIdentUsagesTest extends ORBasePlatformTestCase { - - public void test_Rml_fromModule() { - configureCode("FLIA.re", "let x = 1;"); - configureCode("FLIB.re", "let y = FLIA.x + 2;"); - - Collection usages = myFixture.testFindUsages("FLIA.re"); - assertSize(1, usages); - } - - public void test_Rml_sameModule() { - configureCode("FLIC.re", "let x = 1; let y = x + 1;"); - - List usages = (List) myFixture.testFindUsages("FLIC.re"); - assertSize(1, usages); - UsageInfo usageInfo = usages.get(0); - assertEquals("x + 1", usageInfo.getElement().getParent().getText()); - } -} diff --git a/tests/com/reason/ide/reference/FindUIdentUsagesOCLTest.java b/tests/com/reason/ide/reference/FindUIdentUsagesOCLTest.java new file mode 100644 index 000000000..0d700b5f9 --- /dev/null +++ b/tests/com/reason/ide/reference/FindUIdentUsagesOCLTest.java @@ -0,0 +1,17 @@ +package com.reason.ide.reference; + +import com.intellij.usageView.*; +import com.reason.ide.*; + +import java.util.*; + +@SuppressWarnings("ConstantConditions") +public class FindUIdentUsagesOCLTest extends ORBasePlatformTestCase { + public void test_exception() { + configureCode("A.ml", "exception ExceptionName\n let _ = raise ExceptionName"); + + Collection usages = myFixture.testFindUsages("A.ml"); + assertSize(1, usages); + assertEquals("raise ExceptionName", usages.iterator().next().getElement().getParent().getText()); + } +} diff --git a/tests/com/reason/ide/reference/FindUIdentUsagesRMLTest.java b/tests/com/reason/ide/reference/FindUIdentUsagesRMLTest.java new file mode 100644 index 000000000..66bc6b391 --- /dev/null +++ b/tests/com/reason/ide/reference/FindUIdentUsagesRMLTest.java @@ -0,0 +1,17 @@ +package com.reason.ide.reference; + +import com.intellij.usageView.*; +import com.reason.ide.*; + +import java.util.*; + +@SuppressWarnings("ConstantConditions") +public class FindUIdentUsagesRMLTest extends ORBasePlatformTestCase { + public void test_exception() { + configureCode("A.re", "exception ExceptionName; raise(ExceptionName);"); + + Collection usages = myFixture.testFindUsages("A.re"); + assertSize(1, usages); + assertEquals("(ExceptionName)", usages.iterator().next().getElement().getParent().getText()); + } +} diff --git a/tests/com/reason/ide/reference/FindUIdentUsagesTest.java b/tests/com/reason/ide/reference/FindUIdentUsagesTest.java deleted file mode 100644 index add932c7c..000000000 --- a/tests/com/reason/ide/reference/FindUIdentUsagesTest.java +++ /dev/null @@ -1,17 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.testFramework.fixtures.BasePlatformTestCase; -import com.intellij.usageView.UsageInfo; -import java.util.Collection; - -@SuppressWarnings("ConstantConditions") -public class FindUIdentUsagesTest extends BasePlatformTestCase { - - public void testException() { - myFixture.configureByText("A.re", "exception ExceptionName; raise(ExceptionName);"); - - Collection usages = myFixture.testFindUsages("A.re"); - assertSize(1, usages); - assertEquals("(ExceptionName)", usages.iterator().next().getElement().getParent().getText()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveDeconstructionTest.java b/tests/com/reason/ide/reference/ResolveDeconstructionTest.java deleted file mode 100644 index 26776799f..000000000 --- a/tests/com/reason/ide/reference/ResolveDeconstructionTest.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; - -public class ResolveDeconstructionTest extends ORBasePlatformTestCase { - - public void test_Ns_GH_167() { - configureCode( - "A.res", "let (count, setCount) = React.useState(() => 0);\n" + "setCount(1);"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals(12, elementAtCaret.getTextOffset()); - } - - public void test_Rml_GH_167() { - configureCode( - "A.re", "let (count, setCount) = React.useState(() => 0);\n" + "setCount(1);"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals(12, elementAtCaret.getTextOffset()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveExternalElementRMLTest.java b/tests/com/reason/ide/reference/ResolveExternalElementRMLTest.java deleted file mode 100644 index 57936928e..000000000 --- a/tests/com/reason/ide/reference/ResolveExternalElementRMLTest.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiQualifiedElement; - -public class ResolveExternalElementRMLTest extends ORBasePlatformTestCase { - - public void testLocalOpenWithParens() { - configureCode("A.re", "module A1 = { external a : int = \"\"; };"); - configureCode("B.re", "let b = A.(A1.a);"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.A1.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void testLocalOpenWithParens2() { - myFixture.configureByText("A.re", "module A1 = { external a : int = \"\"; };"); - myFixture.configureByText("B.re", "let a = A.A1.(a);"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("A.A1.a", ((PsiQualifiedElement) elementAtCaret.getParent()).getQualifiedName()); - } - - public void testLocalOpenWithPipeFirst() { - myFixture.configureByText("A.re", "module A1 = { external add : int => int = \"\"; };"); - myFixture.configureByText("B.re", "let x = A.A1.(x->add);"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("A.A1.add", ((PsiQualifiedElement) elementAtCaret.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveInFunctorTest.java b/tests/com/reason/ide/reference/ResolveInFunctorTest.java deleted file mode 100644 index 335c0fe18..000000000 --- a/tests/com/reason/ide/reference/ResolveInFunctorTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiQualifiedElement; - -public class ResolveInFunctorTest extends ORBasePlatformTestCase { - - public void test_Rml_Body() { - configureCode("A.re", "module Make = (M:I) => { let a = 3; };"); - configureCode("B.re", "module Instance = A.Make({}); let b = Instance.a;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.Make.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_Ocl_LocalOpenWithParens() { - configureCode("A.ml", "module Make (M:I) = struct let a = 3 end"); - configureCode("B.ml", "module Instance = A.Make(struct end)\n let b = Instance.a"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.Make.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_Rml_FileInclude() { - configureCode("A.re", "module Make = (M:I) => { let a = 3; }; include Make({})"); - configureCode("B.re", "let b = A.a;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.Make.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_Rml_ResultWithAlias() { - configureCode("A.re", "module type Result = { let a: int; };"); - configureCode("B.re", "module T = A; module Make = (M:Intf): T.Result => { let b = 3; };"); - configureCode("C.re", "module Instance = Make({}); let c = Instance.a;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.Result.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveJsxPropertyElementRMLTest.java b/tests/com/reason/ide/reference/ResolveJsxPropertyElementRMLTest.java index 4f47f6112..8f4701417 100644 --- a/tests/com/reason/ide/reference/ResolveJsxPropertyElementRMLTest.java +++ b/tests/com/reason/ide/reference/ResolveJsxPropertyElementRMLTest.java @@ -1,76 +1,60 @@ package com.reason.ide.reference; -import com.intellij.psi.PsiElement; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.PsiParameter; +import com.intellij.psi.*; +import com.reason.ide.*; -@SuppressWarnings("ConstantConditions") public class ResolveJsxPropertyElementRMLTest extends ORBasePlatformTestCase { + public void test_basic() { + configureCode("X.re", "let make = (~value) =>
;"); + configureCode("A.re", " =1>;"); - public void test_basic() { - configureCode("X.re", "let make = ~value =>
;"); - configureCode("A.re", " =1>;"); + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X.make[value]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("X.make[value]", ((PsiParameter) e.getParent()).getQualifiedName()); - } + public void test_basic_multiple_props() { + configureCode("X.re", "let make = (~propA, ~propB, ~propC) =>
;"); + configureCode("A.re", " />;"); - public void test_basic_multiple_props() { - configureCode("X.re", "let make = (~propA, ~propB, ~propC) =>
;"); - configureCode("A.re", " />;"); + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X.make[propC]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("X.make[propC]", ((PsiParameter) e.getParent()).getQualifiedName()); - } + public void test_basic_nested() { + configureCode("A.re", "module X = { let make = (~value) =>
; }; =1>;"); - public void test_basic_nested() { - configureCode("A.re", "module X = { let make = ~value =>
; }; =1>;"); + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.make[value]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("value", e.getText()); - } + public void test_autoclose() { + configureCode("X.re", "let make = (~value) =>
;"); + configureCode("A.re", " =1/>;"); - public void test_autoclose() { - configureCode("X.re", "let make = ~value =>
;"); - configureCode("A.re", " =1/>;"); + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X.make[value]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("X.make[value]", ((PsiParameter) e.getParent()).getQualifiedName()); - } + public void test_open() { + configureCode("A.re", "module X = { let make = (~value) =>
; };"); + configureCode("B.re", "open A; =1;"); - public void test_open() { - configureCode("A.re", "module X = { let make = ~value =>
; };"); - configureCode("B.re", "open A; =1;"); + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.make[value]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("value", e.getText()); - } + public void test_multiple() { + configureCode("A.re", "module X = { let make = (~value) =>
; }; module Y = { let make = (~value) =>
; }; "); + configureCode("B.re", "open A; =1;"); - public void test_multiple() { - configureCode( - "A.re", - "module X = { let make = ~value =>
; }; module Y = { let make = ~value =>
; }; "); - configureCode("B.re", "open A; =1;"); + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.make[value]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.X.make", PsiTreeUtil.getParentOfType(e, PsiLet.class).getQualifiedName()); - } + public void test_make_make() { + configureCode("A.re", "module X = { let make = (~value) =>
; }; let make = (~value) => = 1>; "); - public void test_make_make() { - configureCode( - "A.re", - "module X = { let make = ~value =>
; }; let make = ~value => = 1>; "); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.X.make", PsiTreeUtil.getParentOfType(e, PsiLet.class).getQualifiedName()); - } + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.make[value]", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } } diff --git a/tests/com/reason/ide/reference/ResolveJsxPropertyElementRSTest.java b/tests/com/reason/ide/reference/ResolveJsxPropertyElementRSTest.java deleted file mode 100644 index 598694fe4..000000000 --- a/tests/com/reason/ide/reference/ResolveJsxPropertyElementRSTest.java +++ /dev/null @@ -1,76 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.PsiParameter; - -@SuppressWarnings("ConstantConditions") -public class ResolveJsxPropertyElementRSTest extends ORBasePlatformTestCase { - - public void test_basic() { - configureCode("X.res", "let make = ~value =>
;"); - configureCode("A.res", " =1;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("X.make[value]", ((PsiParameter) e.getParent()).getQualifiedName()); - } - - public void test_basic_multiple_props() { - configureCode("X.res", "let make = (~propA, ~propB, ~propC) =>
;"); - configureCode("A.res", " />;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("X.make[propC]", ((PsiParameter) e.getParent()).getQualifiedName()); - } - - public void test_basic_nested() { - configureCode("A.res", "module X = { let make = ~value =>
; }; =1;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("value", e.getText()); - } - - public void test_autoclose() { - configureCode("X.re", "let make = ~value =>
;"); - configureCode("A.re", " =1/>;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("X.make[value]", ((PsiParameter) e.getParent()).getQualifiedName()); - } - - public void test_open() { - configureCode("A.res", "module X = { let make = ~value =>
; };"); - configureCode("B.res", "open A; =1;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("value", e.getText()); - } - - public void test_multiple() { - configureCode( - "A.res", - "module X = { let make = ~value =>
; }; module Y = { let make = ~value =>
; }; "); - configureCode("B.res", "open A; =1;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.X.make", PsiTreeUtil.getParentOfType(e, PsiLet.class).getQualifiedName()); - } - - public void test_make_make() { - configureCode( - "A.re", - "module X = { let make = ~value =>
; }; let make = ~value => = 1>; "); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.X.make", PsiTreeUtil.getParentOfType(e, PsiLet.class).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveJsxTagElementRMLTest.java b/tests/com/reason/ide/reference/ResolveJsxTagElementRMLTest.java new file mode 100644 index 000000000..0ed0911a0 --- /dev/null +++ b/tests/com/reason/ide/reference/ResolveJsxTagElementRMLTest.java @@ -0,0 +1,45 @@ +package com.reason.ide.reference; + +import com.intellij.psi.*; +import com.reason.ide.*; + +public class ResolveJsxTagElementRMLTest extends ORBasePlatformTestCase { + public void test_basic() { + configureCode("X.re", "[@react.component] let make = (~value) =>
;"); + configureCode("A.re", " >;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X.make", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_not_a_component() { + configureCode("X.re", "let make = (~value) =>
;"); + configureCode("A.re", " >;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } + + public void test_nested() { + configureCode("A.re", "module X = { module Y = { [@react.component] let make = (~value) =>
; }; }; >;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.Y.make", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_autoclose() { + configureCode("X.re", "[@react.component] let make = (~value) =>
;"); + configureCode("A.re", " />;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X.make", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open() { + configureCode("A.re", "module X = { [@react.component] let make = (~value) =>
; };"); + configureCode("B.re", "open A; "); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.make", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } +} diff --git a/tests/com/reason/ide/reference/ResolveLetElementTest.java b/tests/com/reason/ide/reference/ResolveLetElementTest.java deleted file mode 100644 index 1b8ed57ca..000000000 --- a/tests/com/reason/ide/reference/ResolveLetElementTest.java +++ /dev/null @@ -1,101 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.PsiQualifiedElement; - -public class ResolveLetElementTest extends ORBasePlatformTestCase { - - public void test_RML_in_module_binding() { - configureCode("A.re", "module X = { let foo = 1; let z = foo; };"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.X.foo", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_NS_in_module_binding() { - configureCode("A.res", "module X = { let foo = 1; let z = foo; };"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.X.foo", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_RML_LocalOpenWithParens() { - configureCode("A.re", "module A1 = { let a = 3; };"); - configureCode("B.re", "let b = A.(A1.a);"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.A1.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_OCL_LocalOpenWithParens() { - configureCode("A.ml", "module A1 = struct let a = 3 end"); - configureCode("B.ml", "let b = A.(A1.a)"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.A1.a", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_RML_LocalOpenWithParens2() { - configureCode("A.re", "module A1 = { let a = 3; };"); - configureCode("B.re", "let a = A.A1.(a);"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.A1.a", ((PsiLet) e.getParent()).getQualifiedName()); - } - - public void test_RML_LocalOpenWithPipeFirst() { - configureCode("A.re", "module A1 = { let add = x => x + 3; };"); - configureCode("B.re", "let x = A.A1.(x->add);"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.A1.add", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_RML_InnerScope() { - configureCode("A.re", "let x = 1; let a = { let x = 2; x + 10 };"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.x", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_OCL_InnerScope() { - configureCode("A.ml", "let x = 1\nlet a = let x = 2 in x + 10"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.x", ((PsiLet) e.getParent()).getQualifiedName()); - } - - public void test_RML_innerScopeInFunction() { - configureCode("A.re", "let x = 1; let fn = { let x = 2; fn1(x); };"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.fn.x", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_OCL_innerScopeInFunction() { - configureCode("A.ml", "let x = 1\nlet fn = let x = 2 in fn1 x"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.fn.x", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - } - - public void test_RML_innerScopeInImpl() { - configureCode("A.rei", "let x:int;"); - configureCode("A.re", "let x = 1; let fn = { let foo = 2; fn1(foo); };"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.fn.foo", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - assertEquals("A.re", e.getContainingFile().getName()); - } - - public void test_RML_localModuleAlias() { - configureCode("A.rei", "let x:int;"); - configureCode("B.re", "module X = A; X.x"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.x", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); - assertEquals("A.rei", e.getContainingFile().getName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveLowerElementOCLTest.java b/tests/com/reason/ide/reference/ResolveLowerElementOCLTest.java new file mode 100644 index 000000000..b682959d7 --- /dev/null +++ b/tests/com/reason/ide/reference/ResolveLowerElementOCLTest.java @@ -0,0 +1,231 @@ +package com.reason.ide.reference; + +import com.intellij.psi.*; +import com.reason.ide.*; +import com.reason.lang.core.psi.*; + +public class ResolveLowerElementOCLTest extends ORBasePlatformTestCase { + public void test_let_in_module_binding() { + configureCode("A.ml", "let foo = 2 module X = struct let foo = 1 let z = foo end"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.foo", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_inner_scope() { + configureCode("A.ml", "let x = 1\n let a = let x = 2 in x + 10"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.a.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_inner_scope_in_function() { + configureCode("A.ml", "let x = 1\n let fn = let x = 2 in fn1 x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.fn.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_inner_scope_in_impl() { + configureCode("A.mli", "val x:int"); + configureCode("A.ml", "let x = 1\n let fn = let foo = 2 in fn1 foo"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.fn.foo", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + assertEquals("A.ml", e.getContainingFile().getName()); + } + + public void test_let_local_module_alias() { + configureCode("A.mli", "val x:int"); + configureCode("B.ml", "let x = 1\n module X = A\n let _ = X.x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_path() { + configureCode("A.ml", "module X = struct module Y = struct let z = 1 end end"); + configureCode("B.ml", "module C = A.X.Y\n let _ = C.z"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.Y.z", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open() { + configureCode("B.ml", "let x = 1"); + configureCode("A.ml", "let x = 2 open B let _ = x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_open() { + configureCode("B.ml", "let x = 1"); + configureCode("A.ml", "let x = 2 module C = B open C let _ = x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_local_open_parens() { + configureCode("A.ml", "module A1 = struct let a = 1 end"); + configureCode("B.ml", "let a = 2 let b = A.(A1.a)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_local_open_parens_2() { + configureCode("A.ml", "module A1 = struct let a = 3 end"); + configureCode("B.ml", "let a = A.A1.(a)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_type() { + configureCode("A.ml", "type t type t' = t"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_type_with_path() { + configureCode("A.ml", "type t"); + configureCode("B.ml", "type t = A.t"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_type_with_path_2() { + configureCode("A.ml", "type t\n type y = X.Y.t"); + + assertThrows(AssertionError.class, "element not found in file A.ml", () -> { + PsiElement e = myFixture.getElementAtCaret(); + }); + } + + public void test_function() { + configureCode("A.ml", "module B = struct let bb = 1 end\n module C = struct let cc x = x end let z = C.cc(B.bb)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.B.bb", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_function_open() { + configureCode("B.ml", "module C = struct let make x = x\n let convert x = x end"); + configureCode("A.ml", "open B\n let _ = C.make([| C.convert |])"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.C.convert", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_param_parenLess() { + configureCode("A.ml", "let add10 x = x + 10;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.add10[x]", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_local_open_parens() { + configureCode("A.ml", "module A1 = struct external a : int = \"\" end"); + configureCode("B.ml", "let b = A.(A1.a)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_local_open_parens_2() { + configureCode("A.ml", "module A1 = struct external a : int = \"\" end"); + configureCode("B.ml", "let a = A.A1.(a)"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_include() { + configureCode("A.ml", "module B = struct type t end\n module C = B\n include C\n type x = t"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.B.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_include_qualified() { + configureCode("A.ml", "module B = struct module C = struct type t end end\n module D = B\n include D.C"); + configureCode("C.ml", "type t = A.t"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.B.C.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_multiple_module() { + configureCode("Command.ml", "module Settings = struct module Action = struct let convert x = x end end"); + configureCode("A.ml", "module C = Y\n open Command\n Settings.Action.convert"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Command.Settings.Action.convert", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open_include() { + configureCode("Css_Core.ml", "let fontStyle x = x"); + configureCode("Css.ml", "include Css_Core"); + configureCode("A.ml", "open Css\n let _ = fontStyle"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css_Core.fontStyle", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open_include_deep() { + configureCode("Css_Rule.ml", "let fontStyle x = x"); + configureCode("Css_Core.ml", "module Rules = struct include Css_Rule end"); + configureCode("Css.ml", "include Css_Core"); + configureCode("A.ml", "open Css.Rules\n let _ = fontStyle"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css_Rule.fontStyle", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + /* + public void test_functor_body() { + configureCode("A.ml", "module Make(M:I) = struct let a = 3 end"); + configureCode("B.ml", "module Instance = A.Make(struct end) let b = Instance.a"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Make.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_file_include_functor() { + configureCode("A.re", "module Make = (M:I) => { let a = 3; }; include Make({})"); + configureCode("B.re", "let b = A.a;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Make.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_functor_result_with_alias() { + configureCode("A.ml", "module type Result = sig let a: int end"); + configureCode("B.ml", "module T = A\n module Make(M:Intf): T.Result = struct let b = 3 end"); + configureCode("C.ml", "module Instance = Make(struct end) let c = Instance.a"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Result.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + */ + + public void test_GH_303() { + configureCode("B.ml", "type t1 = {bar: string}"); + configureCode("A.ml", "type t = {bar: string} let bar item = item.bar"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.t.bar", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_GH_303_2() { + configureCode("B.ml", "type t1 = {bar:string}"); + configureCode("A.ml", "type t = {bar: string} let bar item = item.bar"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.bar", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } +} diff --git a/tests/com/reason/ide/reference/ResolveLowerElementRMLTest.java b/tests/com/reason/ide/reference/ResolveLowerElementRMLTest.java new file mode 100644 index 000000000..7037e4f30 --- /dev/null +++ b/tests/com/reason/ide/reference/ResolveLowerElementRMLTest.java @@ -0,0 +1,373 @@ +package com.reason.ide.reference; + +import com.intellij.psi.*; +import com.reason.ide.*; +import com.reason.lang.core.psi.PsiParameter; +import com.reason.lang.core.psi.*; + +public class ResolveLowerElementRMLTest extends ORBasePlatformTestCase { + @Override + protected String getTestDataPath() { + return "testData/com/reason/ide/reference"; + } + + public void test_let_in_module_binding() { + configureCode("A.re", "let foo = 2; module X = { let foo = 1; let z = foo; };"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.foo", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_inner_scope() { + configureCode("A.re", "let x = 1; let a = { let x = 2; x + 10 };"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.a.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_inner_scope_in_function() { + configureCode("A.re", "let x = 1; let fn = { let x = 2; fn1(x); };"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.fn.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_inner_scope_in_impl() { + configureCode("A.rei", "let x:int;"); + configureCode("A.re", "let x = 1; let fn = { let foo = 2; fn1(foo); };"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.fn.foo", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + assertEquals("A.re", e.getContainingFile().getName()); + } + + public void test_let_local_module_alias() { + configureCode("A.rei", "let x:int;"); + configureCode("B.re", "let x = 1; module X = A; X.x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_path() { + configureCode("A.re", "module W = { module X = { module Y = { module Z = { let z = 1; }; }; }; };"); + configureCode("B.re", "module C = A.W.X; module D = C.Y.Z; D.z"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.W.X.Y.Z.z", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_x() { + configureCode("A.re", "module Mode = { type t; };"); + configureCode("B.re", "module B1 = { module Mode = A.Mode; };"); + configureCode("C.re", "B.B1.Mode.t"); // B.B1.Mode.t -> A.Mode.t + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Mode.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open() { + configureCode("B.re", "let x = 1;"); + configureCode("A.re", "let x = 2; open B; x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_open() { + configureCode("B.re", "let x = 1;"); + configureCode("A.re", "let x = 2; module C = B; open C; x"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_local_open_parens() { + configureCode("A.re", "module A1 = { let a = 1; };"); + configureCode("B.re", "let a = 2; let b = A.(A1.a);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_local_open_parens_2() { + configureCode("A.re", "module A1 = { let a = 3; };"); + configureCode("B.re", "let a = A.A1.(a);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiLet) e.getParent()).getQualifiedName()); + } + + public void test_type() { + configureCode("A.re", "type t; type t' = t;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_type_with_path() { + configureCode("A.re", "type t;"); + configureCode("B.re", "type t = A.t;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_type_with_path_2() { + configureCode("A.re", "type t; type y = X.Y.t"); + + assertThrows(AssertionError.class, "element not found in file A.re", () -> { + PsiElement e = myFixture.getElementAtCaret(); + }); + } + + public void test_function() { + configureCode("A.re", "module B = { let bb = 1; }; module C = { let cc = x => x; }; let z = C.cc(B.bb);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.B.bb", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_function_open() { + configureCode("B.re", "module C = { let make = x => x; let convert = x => x; }"); + configureCode("A.re", "open B; C.make([| C.convert |]);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.C.convert", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_param_parenLess() { + configureCode("A.re", "let add10 = x => x + 10;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertInstanceOf(e.getParent(), PsiParameter.class); + assertEquals("A.add10[x]", ((PsiParameter) e.getParent()).getQualifiedName()); + } + + public void test_local_open_parens() { + configureCode("A.re", "module A1 = { external a : int = \"\"; };"); + configureCode("B.re", "let b = A.(A1.a);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_local_open_parens_2() { + configureCode("A.re", "module A1 = { external a : int = \"\"; };"); + configureCode("B.re", "let a = A.A1.(a);"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.A1.a", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_local_open_parens_3() { + configureCode("A.re", "module A1 = { type t = | Variant; let toString = x => x; };"); + configureCode("B.re", "A.A1.(Variant->toString);"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.A1.toString", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_include() { + configureCode("A.re", "module B = { type t; }; module C = B; include C; type x = t;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.B.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_include_2() { + configureCode("Css_AtomicTypes.rei", "module Visibility: { type t = [ | `visible | `hidden | `collapse]; };"); + configureCode("Css_Legacy_Core.re", "module Types = Css_AtomicTypes;"); + configureCode("Css.re", "include Css_Legacy_Core;"); + configureCode("A.re", "type layoutRule; let visibility: [< Css.Types.Length.t | Css.Types.Visibility.t ] => layoutRule;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css_AtomicTypes.Visibility.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_include_qualified() { + configureCode("A.re", "module B = { module C = { type t; }; }; module D = B; include D.C;"); + configureCode("C.re", "type t = A.t;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.B.C.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_module_signature() { + configureCode("A.re", "module B: { type t; let toString: t => string; }; module C: { type t; let toString: t => string; };"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.C.t", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_let_Local_open_pipe_first() { + configureCode("A.re", "module A1 = { let add = x => x + 3; };"); + configureCode("B.re", "let x = A.A1.(x->add);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.A1.add", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_external_local_open_pipe_first() { + configureCode("A.re", "module A1 = { external add : int => int = \"\"; };"); + configureCode("B.re", "let x = A.A1.(x->add);"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.A1.add", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_pipe_first() { + configureCode("Css.mli", "val px: int => string;"); + configureCode("A.re", "Dimensions.spacing.small->Css.px"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css.px", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_pipe_first_open() { + configureCode("Css.mli", "val px: int => string;"); + configureCode("A.re", "let make = () => { open Css; Dimensions.spacing.small->px; }"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css.px", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_pipe_first_open_2() { + configureCode("Core.re", "module Async = { let get = x => x; };"); + configureCode("A.re", "open Core.Async; request->get(\"windows/settings\")"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Core.Async.get", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_pipe_first_open_with_path() { + configureCode("Css.mli", "module Rule = { val px: int => string; };"); + configureCode("A.re", "let make = () => { open Css; Dimensions.spacing.small->Rule.px; }"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css.Rule.px", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_multiple_module() { + configureCode("Command.re", "module Settings = { module Action = { let convert = x => x; }; };"); + configureCode("A.re", "module C = Y; open Command; Settings.Action.convert"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Command.Settings.Action.convert", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_variant_constructor() { + configureCode("B.re", "let convert = x => x;"); + configureCode("A.re", "X.Variant(B.convert())"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.convert", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_variant_constructor_tuple() { + configureCode("B.re", "type t('a) = | Variant('a, 'b);"); + configureCode("A.re", "let x = 1; B.Variant(X.Y, x)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.x", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open_include() { + configureCode("Css_Core.re", "let fontStyle = x => x;"); + configureCode("Css.re", "include Css_Core;"); + configureCode("A.re", "open Css; fontStyle"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css_Core.fontStyle", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open_include_deep() { + configureCode("Css_Rule.re", "let fontStyle = x => x;"); + configureCode("Css_Core.re", "module Rules = { include Css_Rule; }"); + configureCode("Css.re", "include Css_Core;"); + configureCode("A.re", "open Css.Rules; fontStyle"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Css_Rule.fontStyle", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_resolution_1() { + configureCode("Belt_MapString.mli", "val get: 'v t -> key -> 'v option"); + configureCode("Belt_Map.ml", "module String = Belt_MapString;"); + configureCode("Belt_Option.mli", "val flatMap : 'a option -> ('a -> 'b option) -> 'b option"); + configureCode("Belt.re", "module Option = Belt_Option; module Map = Belt_Map;"); + configureCode("A.re", "let x = (dict, locale) => locale->Belt.Option.flatMap(dict->Belt.Map.String.get);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt_Option.flatMap", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_resolution_2() { + configureCode("Belt_MapString.mli", "val get: 'v t -> key -> 'v option"); + configureCode("Belt_Map.ml", "module String = Belt_MapString;"); + configureCode("Belt_Option.mli", "val flatMap : 'a option -> ('a -> 'b option) -> 'b option"); + configureCode("Belt.re", "module Option = Belt_Option; module Map = Belt_Map;"); + configureCode("A.re", "let x = (dict, locale) => locale->Belt.Option.flatMap(dict->Belt.Map.String.get);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt_MapString.get", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + /* + public void test_functor_body() { + configureCode("A.re", "module Make = (M:I) => { let a = 3; };"); + configureCode("B.re", "module Instance = A.Make({}); let b = Instance.a;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Make.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_file_include_functor() { + configureCode("A.re", "module Make = (M:I) => { let a = 3; }; include Make({})"); + configureCode("B.re", "let b = A.a;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Make.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_functor_result_with_alias() { + configureCode("A.re", "module type Result = { let a: int; };"); + configureCode("B.re", "module T = A; module Make = (M:Intf): T.Result => { let b = 3; };"); + configureCode("C.re", "module Instance = Make({}); let c = Instance.a;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.Result.a", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_path_functor() { + configureCode("pervasives.mli", "external compare : 'a -> 'a -> int = \"%compare\""); + configureCode("A.re", "module B = X.Functor({ let cmp = Pervasives.compare; })"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Pervasives.compare", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + */ + + public void test_GH_167_deconstruction() { + configureCode("A.re", "let (count, setCount) = React.useState(() => 0); setCount(1);"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals(12, elementAtCaret.getTextOffset()); + } + + public void test_GH_303() { + configureCode("B.re", "type t1 = {bar: string};"); + configureCode("A.re", "type t = {bar: string}; let bar = item => item.bar;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.t.bar", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_GH_303_2() { + configureCode("B.re", "type t1 = {bar:string};"); + configureCode("A.re", "type t = {bar: string}; let bar = item => item.bar;"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.bar", ((PsiLet) e.getParent()).getQualifiedName()); + } +} diff --git a/tests/com/reason/ide/reference/ResolveModuleElementTest.java b/tests/com/reason/ide/reference/ResolveModuleElementTest.java deleted file mode 100644 index 326a014cf..000000000 --- a/tests/com/reason/ide/reference/ResolveModuleElementTest.java +++ /dev/null @@ -1,67 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiQualifiedElement; - -public class ResolveModuleElementTest extends ORBasePlatformTestCase { - - public void testBasicNull() { - configureCode("Dimensions.re", "let space = 5;"); - configureCode("Comp.re", "Dimensions"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("Dimensions.re", ((PsiQualifiedElement) elementAtCaret).getName()); - } - - public void testBasic() { - configureCode("Dimensions.re", "let space = 5;"); - configureCode("Comp.re", "let D = Dimensions"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("Dimensions.re", ((PsiQualifiedElement) elementAtCaret).getName()); - } - - public void testWithAlias() { - configureCode("A1.re", "module A11 = {};"); - configureCode("A.re", "module A1 = {};"); - configureCode("B.re", "module X = A; X.A1);"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("A.A1", ((PsiQualifiedElement) elementAtCaret.getParent()).getQualifiedName()); - } - - public void test_Rml_withLocalAlias() { - configureCode("Belt.re", "let x = 1;"); - configureCode("A.re", "module B = Belt; B"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("A.B", ((PsiQualifiedElement) elementAtCaret.getParent()).getQualifiedName()); - } - - public void testWithAliasAndInterface() { - configureCode("C.rei", "module A1 = {};"); - configureCode("D.re", "module X = C; X.A1;"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("C.A1", ((PsiQualifiedElement) elementAtCaret.getParent()).getQualifiedName()); - } - - public void testOpen() { - configureCode("Belt.re", "module Option = {}"); - configureCode("Dummy.re", "open Belt.Option;"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals( - "Belt.Option", ((PsiQualifiedElement) elementAtCaret.getParent()).getQualifiedName()); - assertEquals("Belt.re", elementAtCaret.getContainingFile().getName()); - } - - public void testInclude() { - configureCode("Css_Core.rei", "let display: string => rule"); - configureCode("Css.re", "include Css_Core; include Css_Core.Make({})"); - - PsiElement elementAtCaret = myFixture.getElementAtCaret(); - assertEquals("Css_Core", ((PsiQualifiedElement) elementAtCaret).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveParameterElementOCLTest.java b/tests/com/reason/ide/reference/ResolveParameterElementOCLTest.java deleted file mode 100644 index 6c90182e5..000000000 --- a/tests/com/reason/ide/reference/ResolveParameterElementOCLTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.*; -import com.reason.ide.*; -import com.reason.lang.core.psi.PsiParameter; - -public class ResolveParameterElementOCLTest extends ORBasePlatformTestCase { - public void test_parenLess() { - configureCode("A.ml", "let add10 x = x + 10"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.add10[x]", ((PsiParameter) e.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveParameterElementRMLTest.java b/tests/com/reason/ide/reference/ResolveParameterElementRMLTest.java deleted file mode 100644 index a60d373b0..000000000 --- a/tests/com/reason/ide/reference/ResolveParameterElementRMLTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.*; -import com.reason.ide.*; -import com.reason.lang.core.psi.PsiParameter; - -public class ResolveParameterElementRMLTest extends ORBasePlatformTestCase { - public void test_parenLess() { - configureCode("A.re", "let add10 = x => x + 10;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.add10[x]", ((PsiParameter) e.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveParameterElementRSTest.java b/tests/com/reason/ide/reference/ResolveParameterElementRSTest.java deleted file mode 100644 index 8e1cabfde..000000000 --- a/tests/com/reason/ide/reference/ResolveParameterElementRSTest.java +++ /dev/null @@ -1,15 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.*; -import com.reason.ide.*; -import com.reason.lang.core.psi.PsiParameter; - -public class ResolveParameterElementRSTest extends ORBasePlatformTestCase { - public void test_parenLess() { - configureCode("A.res", "let add10 = x => x + 10;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertInstanceOf(e.getParent(), PsiParameter.class); - assertEquals("A.add10[x]", ((PsiParameter) e.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveRecordFieldsTest.java b/tests/com/reason/ide/reference/ResolveRecordFieldsTest.java deleted file mode 100644 index 96be7bada..000000000 --- a/tests/com/reason/ide/reference/ResolveRecordFieldsTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiRecordField; - -public class ResolveRecordFieldsTest extends ORBasePlatformTestCase { - - public void test_Ns_sameNameWithPath() { - configureCode("A.res", "type t = { f: string }; let x: f = \"\";"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.t.f", ((PsiRecordField) e).getQualifiedName()); - } - - public void test_Rml_sameNameWithPath() { - configureCode("A.re", "type t = { f: string }; let x: f = \"\";"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.t.f", ((PsiRecordField) e).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveTypeElementTest.java b/tests/com/reason/ide/reference/ResolveTypeElementTest.java deleted file mode 100644 index 664c65261..000000000 --- a/tests/com/reason/ide/reference/ResolveTypeElementTest.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiType; - -public class ResolveTypeElementTest extends ORBasePlatformTestCase { - - public void test_Rml_basicSameFile() { - configureCode("A.rei", "type t; type t' = t;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.t", ((PsiType) e.getParent()).getQualifiedName()); - } - - public void test_Ns_SameNameWithPath() { - configureCode("A.res", "type t;"); - configureCode("B.res", "type t = A.t;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.t", ((PsiType) e.getParent()).getQualifiedName()); - } - - public void test_Rml_SameNameWithPath() { - configureCode("A.re", "type t;"); - configureCode("B.re", "type t = A.t;"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.t", ((PsiType) e.getParent()).getQualifiedName()); - } - - public void test_Ocl_SameNameWithPath() { - configureCode("A.ml", "type t"); - configureCode("B.ml", "type t = A.t"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.t", ((PsiType) e.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/reference/ResolveUpperElementOCLTest.java b/tests/com/reason/ide/reference/ResolveUpperElementOCLTest.java new file mode 100644 index 000000000..697ab4827 --- /dev/null +++ b/tests/com/reason/ide/reference/ResolveUpperElementOCLTest.java @@ -0,0 +1,175 @@ +package com.reason.ide.reference; + +import com.intellij.psi.*; +import com.reason.ide.*; +import com.reason.lang.core.psi.*; + +public class ResolveUpperElementOCLTest extends ORBasePlatformTestCase { + public void test_basic_file() { + configureCode("Dimensions.ml", "let space = 5"); + configureCode("Comp.ml", "Dimensions"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Dimensions.ml", ((PsiQualifiedNamedElement) elementAtCaret).getName()); + } + + public void test_interface_implementation() { + configureCode("A.mli", "type t"); + configureCode("A.ml", "type t"); + configureCode("B.ml", "A"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.ml", ((PsiNamedElement) e).getName()); + } + + public void test_let_alias() { + configureCode("Dimensions.ml", "let space = 5"); + configureCode("Comp.ml", "let s = Dimensions.space"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Dimensions.ml", ((PsiQualifiedNamedElement) elementAtCaret).getName()); + } + + public void test_alias() { + configureCode("A1.ml", "module A11 = struct end"); + configureCode("A.ml", "module A1 = struct end"); + configureCode("B.ml", "module X = A\n let _ = X.A1"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.A1", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_alias_path_no_resolution() { + configureCode("A.ml", "module X = struct module Y = struct let z = 1 end end"); + configureCode("B.ml", "module C = A.X\n let _ = C.Y"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.C", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_path_resolution() { + configureCode("A.ml", "module X = struct module Y = struct let z = 1 end end"); + configureCode("B.ml", "module C = A.X\n let _ = C.Y"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.Y", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_local_alias() { + configureCode("Belt.ml", "let x = 1;"); + configureCode("A.ml", "module B = Belt\n B"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.B", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_alias_interface() { + configureCode("C.mli", "module A1 = struct end"); + configureCode("D.ml", "module X = C\n let _ = X.A1"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("C.A1", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_open() { + configureCode("Belt.ml", "module Option = struct end"); + configureCode("Dummy.ml", "open Belt.Option"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Belt.Option", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + assertEquals("Belt.ml", elementAtCaret.getContainingFile().getName()); + } + + public void test_include_path() { + configureCode("Css_Core.mli", "let display: string -> rule"); + configureCode("Css.ml", "include Css_Core\n include Css_Core.Make({})"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Css_Core", ((PsiQualifiedNamedElement) elementAtCaret).getQualifiedName()); + } + + public void test_include_alias() { + configureCode("Css_AtomicTypes.mli", "module Color = struct type t end"); + configureCode("Css_Core.mli", "module Types = Css_AtomicTypes"); + configureCode("Css.ml", "include Css_Core"); + configureCode("A.ml", "Css.Types.Color"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Css_AtomicTypes.Color", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_variant_with_path() { + configureCode("A.ml", "type a = | Variant"); + configureCode("B.ml", "type b = | Variant"); + configureCode("C.ml", "A.Variant"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_variant_module_alias() { + configureCode("Aaa.ml", "type t = | Test"); + configureCode("Bbb.ml", "module A = Aaa\n let _ = A.Test"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Aaa.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_variant_module_alias_inner() { + configureCode("Aaa.ml", "module Option = struct type t = | Test end"); + configureCode("Bbb.ml", "module A = Aaa\n let _ = A.Option.Test"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Aaa.Option.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_variant_constructor() { + configureCode("A.ml", "type a = | Variant(int)"); + configureCode("B.ml", "let _ = A.Variant(1)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_exception() { + myFixture.configureByText("A.ml", "exception ExceptionName\n let _ = raise ExceptionName"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.ExceptionName", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_belt_alias() { + configureCode("String.ml", "type t"); + configureCode("Belt.ml", "module Map = Belt_Map"); + configureCode("Belt_Map.ml", "module String = Belt_MapString"); + configureCode("Belt_MapString.ml", "type t"); + configureCode("A.ml", "Belt.Map.String"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt_Map.String", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + /* + public void test_functor_inside() { + configureCode("F.ml", "module type S = sig module X : sig end end\n" + + "module M() : S = struct module X = struct end end \n" + + "module A = M(struct end)\n" + + "module X2 = struct module X1 = struct module X = struct end end end\n" + + "module V = A.X"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("F.S.X", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); + } + + public void test_functor_outside() { + configureCode("F.ml", "module type S = sig module X : sig end end\n" + + "module M() : S = struct module X = struct end end \n" + + "module A = M(struct end)"); + configureCode("B.ml", "module X2 = struct module X1 = struct module X = struct end end end\n" + + "module V = F.A.X"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("F.S.X", ((PsiQualifiedElement) e.getParent()).getQualifiedName()); + } + */ +} diff --git a/tests/com/reason/ide/reference/ResolveUpperElementRMLTest.java b/tests/com/reason/ide/reference/ResolveUpperElementRMLTest.java new file mode 100644 index 000000000..2cfda7a2a --- /dev/null +++ b/tests/com/reason/ide/reference/ResolveUpperElementRMLTest.java @@ -0,0 +1,225 @@ +package com.reason.ide.reference; + +import com.intellij.psi.*; +import com.reason.ide.*; +import com.reason.lang.core.psi.*; + +public class ResolveUpperElementRMLTest extends ORBasePlatformTestCase { + public void test_basic_file() { + configureCode("Dimensions.re", "let space = 5;"); + configureCode("Comp.re", "Dimensions"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Dimensions.re", ((PsiQualifiedNamedElement) e).getName()); + } + + public void test_interface_implementation() { + configureCode("A.rei", "type t;"); + configureCode("A.re", "type t;"); + configureCode("B.re", "A"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.re", ((PsiNamedElement) e).getName()); + } + + public void test_let_alias() { + configureCode("Dimensions.re", "let space = 5;"); + configureCode("Comp.re", "let s = Dimensions.space"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Dimensions.re", ((PsiQualifiedNamedElement) elementAtCaret).getName()); + } + + public void test_alias() { + configureCode("A1.re", "module A11 = {};"); + configureCode("A.re", "module A1 = {};"); + configureCode("B.re", "module X = A; X.A1;"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.A1", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_alias_path_no_resolution() { + configureCode("A.re", "module X = { module Y = { let z = 1; }; };"); + configureCode("B.re", "module C = A.X; C.Y"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("B.C", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_alias_path_resolution() { + configureCode("A.re", "module X = { module Y = { let z = 1; }; };"); + configureCode("B.re", "module C = A.X; C.Y"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X.Y", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_local_alias() { + configureCode("Belt.re", "let x = 1;"); + configureCode("A.re", "module B = Belt; B"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("A.B", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_alias_interface() { + configureCode("C.rei", "module A1 = {};"); + configureCode("D.re", "module X = C; X.A1;"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("C.A1", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_open() { + configureCode("Belt.re", "module Option = {}"); + configureCode("Dummy.re", "open Belt.Option;"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Belt.Option", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + assertEquals("Belt.re", elementAtCaret.getContainingFile().getName()); + } + + public void test_include_path() { + configureCode("Css_Core.rei", "let display: string => rule"); + configureCode("Css.re", "include Css_Core; include Css_Core.Make({})"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Css_Core", ((PsiQualifiedNamedElement) elementAtCaret).getQualifiedName()); + } + + public void test_include_alias() { + configureCode("Css_AtomicTypes.rei", "module Color = { type t; };"); + configureCode("Css_Core.rei", "module Types = Css_AtomicTypes;"); + configureCode("Css.re", "include Css_Core;"); + configureCode("A.re", "Css.Types.Color"); + + PsiElement elementAtCaret = myFixture.getElementAtCaret(); + assertEquals("Css_AtomicTypes.Color", ((PsiQualifiedNamedElement) elementAtCaret.getParent()).getQualifiedName()); + } + + public void test_variant_with_path() { + configureCode("A.re", "type a = | Variant;"); + configureCode("B.re", "type b = | Variant;"); + configureCode("C.re", "A.Variant"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_variant_module_alias() { + configureCode("Aaa.re", "type t = | Test;"); + configureCode("Bbb.re", "module A = Aaa; A.Test"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Aaa.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_variant_module_alias_inner() { + configureCode("Aaa.re", "module Option = { type t = | Test; }"); + configureCode("Bbb.re", "module A = Aaa; A.Option.Test"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Aaa.Option.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_variant_constructor() { + configureCode("A.re", "type a = | Variant(int);"); + configureCode("B.re", "let _ = A.Variant(1)"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); + } + + public void test_exception() { + myFixture.configureByText("A.re", "exception ExceptionName; raise(ExceptionName);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.ExceptionName", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_belt_alias() { + configureCode("String.re", "type t;"); + configureCode("Belt_MapString.re", "type t;"); + configureCode("Belt_Map.re", "module String = Belt_MapString;"); + configureCode("Belt.re", "module Map = Belt_Map;"); + configureCode("A.re", "Belt.Map.String"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt_Map.String", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_open_belt_alias() { + configureCode("String.re", "type t;"); + configureCode("Belt_MapString.re", "type t;"); + configureCode("Belt_Map.re", "module String = Belt_MapString;"); + configureCode("Belt.re", "module Map = Belt_Map;"); + configureCode("A.re", "open Belt; open Map; String"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt_Map.String", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_pipe_first() { + configureCode("X.re", "let fn = () => ();"); + configureCode("B.re", "module C = { module X = { let fn = () => (); }; };"); + configureCode("D.re", "B.C.X.fn()->X.fn"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("X", ((PsiQualifiedNamedElement) e).getQualifiedName()); + } + + public void test_pipe_last() { + configureCode("A.re", "module X = {};"); + configureCode("B.re", "module C = { module X = { let fn = () => (); }; };"); + configureCode("D.re", "B.C.X.fn() |> A.X.fn"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("A.X", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_no_resolution_1() { + configureCode("Belt_MapString.mli", "val get: 'v t -> key -> 'v option"); + configureCode("Belt_Map.ml", "module String = Belt_MapString;"); + configureCode("Belt_Option.mli", "val flatMap : 'a option -> ('a -> 'b option) -> 'b option"); + configureCode("Belt.re", "module Option = Belt_Option; module Map = Belt_Map;"); + configureCode("A.re", "let x = (dict, locale) => locale->Belt.Option.flatMap(dict->Belt.Map.String.get);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt.Option", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_no_resolution_2() { + configureCode("Belt_MapString.mli", "val get: 'v t -> key -> 'v option"); + configureCode("Belt_Map.ml", "module String = Belt_MapString;"); + configureCode("Belt_Option.mli", "val flatMap : 'a option -> ('a -> 'b option) -> 'b option"); + configureCode("Belt.re", "module Option = Belt_Option; module Map = Belt_Map;"); + configureCode("A.re", "let x = (dict, locale) => locale->Belt.Option.flatMap(dict->Belt.Map.String.get);"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("Belt.Map", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + /* + public void test_functor_inside() { + configureCode("F.re", "module type S = {module X: {};};\n" + + "module M = () : S => { module X = {}; };\n" + + "module A = M({});\n" + + "module X2 = { module X1 = { module X = {}; }; };\n" + + "module V = A.X"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("F.S.X", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + + public void test_functor_outside() { + configureCode("F.re", "module type S = {module X: {};};\n" + + "module M = () : S => { module X = {}; };\n" + + "module A = M({});"); + configureCode("B.re", "module X2 = { module X1 = { module X = {}; }; }; module V = F.A.X"); + + PsiElement e = myFixture.getElementAtCaret(); + assertEquals("F.S.X", ((PsiQualifiedNamedElement) e.getParent()).getQualifiedName()); + } + */ +} diff --git a/tests/com/reason/ide/reference/ResolveVariantElementTest.java b/tests/com/reason/ide/reference/ResolveVariantElementTest.java deleted file mode 100644 index 613d2a781..000000000 --- a/tests/com/reason/ide/reference/ResolveVariantElementTest.java +++ /dev/null @@ -1,91 +0,0 @@ -package com.reason.ide.reference; - -import com.intellij.psi.PsiElement; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.lang.core.psi.PsiVariantDeclaration; - -public class ResolveVariantElementTest extends ORBasePlatformTestCase { - - public void test_Ns_withPath() { - configureCode("A.res", "type a = | Variant;"); - configureCode("B.res", "type b = | Variant;"); - configureCode("C.res", "A.Variant"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void test_Rml_withPath() { - configureCode("A.re", "type a = | Variant;"); - configureCode("B.re", "type b = | Variant;"); - configureCode("C.re", "A.Variant"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void test_Ocl_withPath() { - configureCode("A.ml", "type a = | Variant"); - configureCode("B.ml", "type b = | Variant"); - configureCode("C.ml", "A.Variant"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void testRml_withModuleAlias() { - configureCode("Aaa.re", "type t = | Test;"); - configureCode("Bbb.re", "module A = Aaa; A.Test"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("Aaa.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void testOcl_withModuleAlias() { - configureCode("Aaa.ml", "type t = | Test"); - configureCode("Bbb.ml", "module A = Aaa \nlet _ = A.Test"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("Aaa.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void testRml_withModuleAliasInner() { - configureCode("Aaa.re", "module Option = { type t = | Test; }"); - configureCode("Bbb.re", "module A = Aaa; A.Option.Test"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("Aaa.Option.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void testOcl_withModuleAliasInner() { - configureCode("Aaa.ml", "module Option = struct type t = | Test end"); - configureCode("Bbb.ml", "module A = Aaa \nlet _ = A.Option.Test"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("Aaa.Option.t.Test", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void test_Ns_constructor() { - configureCode("A.res", "type a = | Variant(int);"); - configureCode("B.res", "A.Variant(1)"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void test_Rml_constructor() { - configureCode("A.re", "type a = | Variant(int);"); - configureCode("B.re", "let _ = A.Variant(1)"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } - - public void test_Ocl_constructor() { - configureCode("A.ml", "type a = | Variant(int)"); - configureCode("B.ml", "A.Variant(1)"); - - PsiElement e = myFixture.getElementAtCaret(); - assertEquals("A.a.Variant", ((PsiVariantDeclaration) e.getParent()).getQualifiedName()); - } -} diff --git a/tests/com/reason/ide/structure/StructureOCLTest.java b/tests/com/reason/ide/structure/StructureOCLTest.java new file mode 100644 index 000000000..c6b5a43cd --- /dev/null +++ b/tests/com/reason/ide/structure/StructureOCLTest.java @@ -0,0 +1,103 @@ +package com.reason.ide.structure; + +import com.intellij.ide.structureView.*; +import com.intellij.ide.util.treeView.smartTree.*; +import com.intellij.navigation.*; +import com.reason.ide.*; +import com.reason.ide.files.*; +import icons.*; +import org.jetbrains.annotations.*; + +import javax.swing.*; + +public class StructureOCLTest extends ORBasePlatformTestCase { + public void test_let() { + FileBase a = configureCode("A.ml", "let x = 1"); + StructureViewModel model = new ORStructureViewModel(a); + + TreeElement x = model.getRoot().getChildren()[0]; + ItemPresentation pres = x.getPresentation(); + assertEquals("x", pres.getPresentableText()); + } + + public void test_val() { + FileBase a = configureCode("A.mli", "val x: int"); + StructureViewModel model = new ORStructureViewModel(a); + + TreeElement x = model.getRoot().getChildren()[0]; + assertPresentation("x", "int", ORIcons.VAL, x.getPresentation()); + } + + public void test_type_record() { + FileBase a = configureCode("A.ml", "type x = { a: int; b: string list }"); + StructureViewModel model = new ORStructureViewModel(a); + + TreeElement e = model.getRoot().getChildren()[0]; + assertPresentation("x", null, ORIcons.TYPE, e.getPresentation()); + TreeElement c1 = e.getChildren()[0]; + assertPresentation("a", "int", ORIcons.VAL, c1.getPresentation()); + TreeElement c2 = e.getChildren()[1]; + assertPresentation("b", "string list", ORIcons.VAL, c2.getPresentation()); + } + + public void test_module_type() { + FileBase a = configureCode("A.ml", "module type I = sig val x : bool end"); + StructureViewModel model = new ORStructureViewModel(a); + + TreeElement i = model.getRoot().getChildren()[0]; + assertPresentation("I", "", ORIcons.MODULE_TYPE, i.getPresentation()); + TreeElement x = i.getChildren()[0]; + assertPresentation("x", "bool", ORIcons.VAL, x.getPresentation()); + } + + public void test_module_type_extraction() { + configureCode("A.mli", "module type S = sig\n end"); + FileBase b = configureCode("B.ml", "module X : module type of A.S"); + StructureViewModel model = new ORStructureViewModel(b); + + TreeElement e = model.getRoot().getChildren()[0]; + assertPresentation("X", "", ORIcons.INNER_MODULE, e.getPresentation()); + TreeElement ee = e.getChildren()[0]; + assertPresentation("S", "A.mli", ORIcons.MODULE_TYPE, ee.getPresentation()); + } + + public void test_module_type_extraction_functor() { + configureCode("A.mli", "module type S = sig\n module Branch : sig type t end\n end\n module Make() : S\n module Vcs = Make()"); + FileBase b = configureCode("B.ml", "module X : module type of A.Vcs.Branch"); + StructureViewModel model = new ORStructureViewModel(b); + + TreeElement e = model.getRoot().getChildren()[0]; + assertPresentation("X", "", ORIcons.INNER_MODULE, e.getPresentation()); + TreeElement ee = e.getChildren()[0]; +// zzz assertPresentation("A.Vcs.Branch", "", ORIcons.MODULE_TYPE, ee.getPresentation()); + } + + // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/274 + // omit () in structure panel + public void test_GH_274() { + FileBase a = configureCode("A.ml", "let () = 1 + 2"); + StructureViewModel model = new ORStructureViewModel(a); + + assertEmpty(model.getRoot().getChildren()); + } + + // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/190 + // nested functions + public void test_GH_190() { + FileBase e = configureCode("A.ml", "let fn a b = let open Pp in let fn1 = 1 in let fn2 = 2"); + StructureViewModel model = new ORStructureViewModel(e); + + TreeElement fn = model.getRoot().getChildren()[0]; + assertPresentation("fn", null, ORIcons.FUNCTION, fn.getPresentation()); + TreeElement fn1 = fn.getChildren()[0]; + assertPresentation("fn1", null, ORIcons.LET, fn1.getPresentation()); + TreeElement fn2 = fn.getChildren()[1]; + assertPresentation("fn2", null, ORIcons.LET, fn2.getPresentation()); + } + + private void assertPresentation(String name, String location, @Nullable Icon icon, ItemPresentation pres) { + assertEquals("Incorrect name", name, pres.getPresentableText()); + assertEquals("Incorrect location", location, pres.getLocationString()); + assertEquals("Incorrect icon", icon, pres.getIcon(false)); + } +} diff --git a/tests/com/reason/ide/structure/StructureTest.java b/tests/com/reason/ide/structure/StructureTest.java deleted file mode 100644 index b137c499b..000000000 --- a/tests/com/reason/ide/structure/StructureTest.java +++ /dev/null @@ -1,104 +0,0 @@ -package com.reason.ide.structure; - -import com.intellij.ide.structureView.StructureViewModel; -import com.intellij.ide.util.treeView.smartTree.TreeElement; -import com.intellij.navigation.ItemPresentation; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.ide.files.FileBase; -import icons.ORIcons; -import javax.swing.*; -import org.jetbrains.annotations.Nullable; - -public class StructureTest extends ORBasePlatformTestCase { - public void test_OCL_let() { - FileBase a = configureCode("A.ml", "let x = 1"); - StructureViewModel model = new ORStructureViewModel(a); - - TreeElement x = model.getRoot().getChildren()[0]; - ItemPresentation pres = x.getPresentation(); - assertEquals("x", pres.getPresentableText()); - } - - public void test_OCL_val() { - FileBase a = configureCode("A.mli", "val x: int"); - StructureViewModel model = new ORStructureViewModel(a); - - TreeElement x = model.getRoot().getChildren()[0]; - assertPresentation("x", "int", ORIcons.VAL, x.getPresentation()); - } - - public void test_OCL_type_record() { - FileBase a = configureCode("A.ml", "type x = { a: int; b: string list }"); - StructureViewModel model = new ORStructureViewModel(a); - - TreeElement e = model.getRoot().getChildren()[0]; - assertPresentation("x", null, ORIcons.TYPE, e.getPresentation()); - TreeElement c1 = e.getChildren()[0]; - assertPresentation("a", "int", ORIcons.VAL, c1.getPresentation()); - TreeElement c2 = e.getChildren()[1]; - assertPresentation("b", "string list", ORIcons.VAL, c2.getPresentation()); - } - - public void test_OCL_module_type() { - FileBase a = configureCode("A.ml", "module type I = sig val x : bool end"); - StructureViewModel model = new ORStructureViewModel(a); - - TreeElement i = model.getRoot().getChildren()[0]; - assertPresentation("I", "", ORIcons.MODULE_TYPE, i.getPresentation()); - TreeElement x = i.getChildren()[0]; - assertPresentation("x", "bool", ORIcons.VAL, x.getPresentation()); - } - - public void test_OCL_module_type_extraction() { - configureCode("A.mli", "module type S = sig\n end"); - FileBase b = configureCode("B.ml", "module X : module type of A.S"); - StructureViewModel model = new ORStructureViewModel(b); - - TreeElement e = model.getRoot().getChildren()[0]; - assertPresentation("X", "", ORIcons.INNER_MODULE, e.getPresentation()); - TreeElement ee = e.getChildren()[0]; - assertPresentation("S", "A.mli", ORIcons.MODULE_TYPE, ee.getPresentation()); - } - - public void test_OCL_module_type_extraction_functor() { - configureCode( - "A.mli", - "module type S = sig\n module Branch : sig type t end\n end\n module Make() : S\n module Vcs = Make()"); - FileBase b = configureCode("B.ml", "module X : module type of A.Vcs.Branch"); - StructureViewModel model = new ORStructureViewModel(b); - - TreeElement e = model.getRoot().getChildren()[0]; - assertPresentation("X", "", ORIcons.INNER_MODULE, e.getPresentation()); - TreeElement ee = e.getChildren()[0]; - assertPresentation("A.Vcs.Branch", "", ORIcons.MODULE_TYPE, ee.getPresentation()); - } - - // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/274 - // omit () in structure panel - public void test_GH_274() { - FileBase a = configureCode("A.ml", "let () = 1 + 2"); - StructureViewModel model = new ORStructureViewModel(a); - - assertEmpty(model.getRoot().getChildren()); - } - - // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/190 - // nested functions - public void test_OCL_GH_190() { - FileBase e = configureCode("A.ml", "let fn a b = let open Pp in let fn1 = 1 in let fn2 = 2"); - StructureViewModel model = new ORStructureViewModel(e); - - TreeElement fn = model.getRoot().getChildren()[0]; - assertPresentation("fn", null, ORIcons.FUNCTION, fn.getPresentation()); - TreeElement fn1 = fn.getChildren()[0]; - assertPresentation("fn1", null, ORIcons.LET, fn1.getPresentation()); - TreeElement fn2 = fn.getChildren()[1]; - assertPresentation("fn2", null, ORIcons.LET, fn2.getPresentation()); - } - - private void assertPresentation(String name, String location, @Nullable Icon icon, ItemPresentation pres) { - assertEquals("Incorrect name", name, pres.getPresentableText()); - assertEquals("Incorrect location", location, pres.getLocationString()); - assertEquals("Incorrect icon", icon, pres.getIcon(false)); - } -} diff --git a/tests/com/reason/lang/core/ORUtilTest.java b/tests/com/reason/lang/core/ORUtilTest.java index 38d08519e..d3e3ba402 100644 --- a/tests/com/reason/lang/core/ORUtilTest.java +++ b/tests/com/reason/lang/core/ORUtilTest.java @@ -1,44 +1,44 @@ package com.reason.lang.core; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.ide.ORBasePlatformTestCase; -import com.reason.ide.files.FileBase; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.impl.PsiFakeModule; +import com.intellij.psi.util.*; +import com.reason.*; +import com.reason.ide.*; +import com.reason.ide.files.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; public class ORUtilTest extends ORBasePlatformTestCase { - public void testModuleNameToFileNameWhenEmpty() { - assertEquals("", ORUtil.moduleNameToFileName("")); - } - - public void testModuleNameToFileName() { - assertEquals("testLower", ORUtil.moduleNameToFileName("TestLower")); - } - - public void testFileNameToModuleNameWhenEmpty() { - assertEquals("", ORUtil.fileNameToModuleName("")); - assertEquals("", ORUtil.fileNameToModuleName(".ml")); - } - - public void testFileNameToModuleName() { - assertEquals("Lower", ORUtil.fileNameToModuleName("lower.ml")); - assertEquals("Upper", ORUtil.fileNameToModuleName("Upper.ml")); - } - - public void test_Rml_letQualifiedPath() { - FileBase f = configureCode("A.re", "let make = () => { let x = 1; }"); - PsiLet e = PsiTreeUtil.findChildOfType(f, PsiFakeModule.class).getLetExpression("x"); - - String qPath = ORUtil.getQualifiedPath(e); - assertEquals("A.make", qPath); - } - - public void test_Rml_letDestructuredQualifiedPath() { - FileBase f = configureCode("A.re", "module M = { let make = () => { let (x, y) = other; }; }"); - PsiLet letExpression = - PsiTreeUtil.findChildOfType(f, PsiFakeModule.class).getLetExpression("(x, y)"); - String qualifiedPath = ORUtil.getQualifiedPath(letExpression); - assertEquals("A.M.make", qualifiedPath); - } + public void testModuleNameToFileNameWhenEmpty() { + assertEquals("", ORUtil.moduleNameToFileName("")); + } + + public void testModuleNameToFileName() { + assertEquals("testLower", ORUtil.moduleNameToFileName("TestLower")); + } + + public void testFileNameToModuleNameWhenEmpty() { + assertEquals("", ORUtil.fileNameToModuleName("")); + assertEquals("", ORUtil.fileNameToModuleName(".ml")); + } + + public void testFileNameToModuleName() { + assertEquals("Lower", ORUtil.fileNameToModuleName("lower.ml")); + assertEquals("Upper", ORUtil.fileNameToModuleName("Upper.ml")); + } + + public void test_Rml_letQualifiedPath() { + FileBase f = configureCode("A.re", "let make = () => { let x = 1; }"); + PsiLet e = PsiTreeUtil.findChildOfType(f, PsiFakeModule.class).getLetExpression("x"); + + String qPath = Joiner.join(".", ORUtil.getQualifiedPath(e)); + assertEquals("A.make", qPath); + } + + public void test_Rml_letDestructuredQualifiedPath() { + FileBase f = configureCode("A.re", "module M = { let make = () => { let (x, y) = other; }; }"); + PsiLet letExpression = PsiTreeUtil.findChildOfType(f, PsiFakeModule.class).getLetExpression("(x, y)"); + String qualifiedPath = Joiner.join(".", ORUtil.getQualifiedPath(letExpression)); + assertEquals("A.M.make", qualifiedPath); + } } diff --git a/tests/com/reason/lang/core/psi/reference/ResolutionTest.java b/tests/com/reason/lang/core/psi/reference/ResolutionTest.java new file mode 100644 index 000000000..f69cb79ab --- /dev/null +++ b/tests/com/reason/lang/core/psi/reference/ResolutionTest.java @@ -0,0 +1,63 @@ +package com.reason.lang.core.psi.reference; + +import com.intellij.testFramework.*; +import com.reason.lang.core.*; +import com.reason.lang.core.psi.*; + +public class ResolutionTest extends LightPlatformTestCase { + public void test_path_traversal() { + Resolution resolution = new Resolution(new String[]{"A", "B", "C"}, crateLowerElement()); + + assertEquals("C", resolution.getCurrentName()); + resolution.updateCurrentWeight(1); + assertEquals("B", resolution.getCurrentName()); + resolution.updateCurrentWeight(1); + assertEquals("A", resolution.getCurrentName()); + resolution.updateCurrentWeight(1); + assertNull(resolution.getCurrentName()); + } + + public void test_alternate_path_traversal() { + Resolution resolution = new Resolution(new String[]{"A", "B", "C"}, crateLowerElement()); + Resolution altResolution = Resolution.createAlternate(resolution, new String[]{"X", "Y"}); + + assertEquals("C", altResolution.getCurrentName()); + altResolution.updateCurrentWeight(1); + assertEquals("B", altResolution.getCurrentName()); + altResolution.updateCurrentWeight(1); + assertEquals("Y", altResolution.getCurrentName()); + altResolution.updateCurrentWeight(1); + assertEquals("X", altResolution.getCurrentName()); + altResolution.updateCurrentWeight(1); + assertTrue(altResolution.myIsComplete); + } + + public void test_join_path() { + Resolution resolution = new Resolution(new String[]{"A", "B", "C"}, crateLowerElement()); + Resolution altResolution = Resolution.createAlternate(resolution, new String[]{"X", "Y"}); + + assertEquals("A.B.C", resolution.joinPath()); + assertEquals("X.Y.B.C", altResolution.joinPath()); + } + + public void test_module_name() { + Resolution resolution = new Resolution(new String[]{"A", "B", "C"}, crateLowerElement()); + Resolution altResolution = Resolution.createAlternate(resolution, new String[]{"X", "Y"}); + + assertEquals("A", resolution.getTopModuleName()); + assertEquals("X", altResolution.getTopModuleName()); + } + + public void test_path_equality() { + Resolution resolution = new Resolution(new String[]{"A", "B", "C"}, crateLowerElement()); + Resolution altResolution = Resolution.createAlternate(resolution, new String[]{"X", "Y"}); + + assertTrue(resolution.isPathEqualTo(new String[]{"A", "B", "C"})); + assertTrue(altResolution.isPathEqualTo(new String[]{"X", "Y", "B", "C"})); + } + + @SuppressWarnings("ConstantConditions") + private PsiType crateLowerElement() { + return (PsiType) ORCodeFactory.createTypeName(getProject(), "t").getParent(); + } +} diff --git a/tests/com/reason/lang/napkin/IncludeParsingTest.java b/tests/com/reason/lang/napkin/IncludeParsingTest.java index e144f35b5..558ccf10d 100644 --- a/tests/com/reason/lang/napkin/IncludeParsingTest.java +++ b/tests/com/reason/lang/napkin/IncludeParsingTest.java @@ -5,18 +5,18 @@ public class IncludeParsingTest extends NsParsingTestCase { public void test_one() { PsiInclude e = first(includeExpressions(parseCode("include Belt"))); - assertEquals("Belt", e.getPath()); + assertEquals("Belt", e.getIncludePath()); } public void test_path() { PsiInclude e = first(includeExpressions(parseCode("include Belt.Array"))); - assertEquals("Belt.Array", e.getPath()); + assertEquals("Belt.Array", e.getIncludePath()); } public void test_functor() { PsiInclude e = first(includeExpressions(parseCode("include A.Make({ type t })"))); assertTrue(e.useFunctor()); - assertEquals("A.Make", e.getPath()); + assertEquals("A.Make", e.getIncludePath()); } } diff --git a/tests/com/reason/lang/napkin/LetParsingTest.java b/tests/com/reason/lang/napkin/LetParsingTest.java index fd4f6f47e..9fa79e4d0 100644 --- a/tests/com/reason/lang/napkin/LetParsingTest.java +++ b/tests/com/reason/lang/napkin/LetParsingTest.java @@ -149,7 +149,7 @@ public void test_alias() { public void test_deconstruction() { PsiLet e = first(letExpressions(parseCode("let (a, b) = x"))); - assertTrue(e.isDeconsruction()); + assertTrue(e.isDeconstruction()); List names = e.getDeconstructedElements(); assertSize(2, names); assertEquals("a", names.get(0).getText()); @@ -184,7 +184,6 @@ public void test_braces() { // assertEquals("try", e.getName()); // } - // zzz DEPRECATED ? // public void testIssue105() { // FileBase file = parseCode("let string = \"x\""); // PsiLet e = first(letExpressions(file)); diff --git a/tests/com/reason/lang/ocaml/FunctorParsingTest.java b/tests/com/reason/lang/ocaml/FunctorParsingTest.java index c3c8e43a1..04076d7a3 100644 --- a/tests/com/reason/lang/ocaml/FunctorParsingTest.java +++ b/tests/com/reason/lang/ocaml/FunctorParsingTest.java @@ -1,107 +1,117 @@ package com.reason.lang.ocaml; -import com.intellij.psi.PsiFile; -import com.intellij.psi.PsiNamedElement; -import com.intellij.psi.tree.IElementType; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.lang.core.psi.PsiFunctor; -import com.reason.lang.core.psi.PsiInnerModule; +import com.intellij.psi.*; +import com.intellij.psi.tree.*; +import com.intellij.psi.util.*; import com.reason.lang.core.psi.PsiParameter; -import com.reason.lang.core.psi.PsiUpperSymbol; -import com.reason.lang.core.psi.impl.PsiConstraint; -import com.reason.lang.core.psi.impl.PsiFunctorCall; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; + import java.util.*; import java.util.stream.*; @SuppressWarnings("ConstantConditions") public class FunctorParsingTest extends OclParsingTestCase { - public void test_basic() { - PsiNamedElement e = first(expressions(parseCode("module Make (M:Def) : S = struct end"))); - - PsiFunctor f = (PsiFunctor) e; - assertEquals("struct end", f.getBinding().getText()); - assertEquals("S", f.getReturnType().getText()); - List uTypes = - PsiTreeUtil.findChildrenOfType(e, PsiUpperSymbol.class) - .stream() - .map(psi -> psi.getFirstChild().getNode().getElementType()) - .collect(Collectors.toList()); - assertDoesntContain(uTypes, m_types.VARIANT_NAME); - } - - public void test_implicitResult() { - PsiNamedElement e = first(expressions(parseCode("module Make (M:Def) = struct end"))); - - PsiFunctor f = (PsiFunctor) e; - assertEquals("struct end", f.getBinding().getText()); - } - - public void test_withConstraints() { - Collection expressions = - expressions( - parseCode( - "module Make (M: Input) : S with type +'a t = 'a M.t and type b = M.b = struct end")); - - assertEquals(1, expressions.size()); - PsiFunctor f = (PsiFunctor) first(expressions); - - assertEquals("M: Input", first(f.getParameters()).getText()); - assertEquals("S", f.getReturnType().getText()); - - List constraints = new ArrayList<>(f.getConstraints()); - assertEquals(2, constraints.size()); - assertEquals("type +'a t = 'a M.t", constraints.get(0).getText()); - assertEquals("type b = M.b", constraints.get(1).getText()); - assertEquals("struct end", f.getBinding().getText()); - } - - public void test_signature() { - Collection functors = - functorExpressions( - parseCode( // - "module GlobalBindings (M : sig\n" - + // - "val relation_classes : string list\n" - + // - "val morphisms : string list\n" - + // - "val arrow : evars -> evars * constr\n" - + // - "end) = struct open M end")); - - assertEquals(1, functors.size()); - PsiFunctor functor = first(functors); - assertEquals("GlobalBindings", functor.getName()); - assertEquals("Dummy.GlobalBindings", functor.getQualifiedName()); - Collection parameters = functor.getParameters(); - assertSize(1, parameters); - assertEquals("M", first(parameters).getName()); - assertNotNull(functor.getBinding()); - } - - public void test_functorInstanciation() { - PsiInnerModule module = - (PsiInnerModule) - first( - moduleExpressions( - parseCode("module Printing = Make (struct let encode = encode_record end)"))); - - assertNull(module.getBody()); - PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); - assertNotNull(call); - assertEquals("Make (struct let encode = encode_record end)", call.getText()); - } - - public void test_functorInstanciationChaining() { - PsiFile file = parseCode("module KeyTable = Hashtbl.Make(KeyHash)\ntype infos"); - List expressions = new ArrayList<>(expressions(file)); - - assertEquals(2, expressions.size()); - - PsiInnerModule module = (PsiInnerModule) expressions.get(0); - assertNull(module.getBody()); - PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); - assertNotNull(call); - assertEquals("Hashtbl.Make(KeyHash)", call.getText()); - } + public void test_basic() { + PsiNamedElement e = first(expressions(parseCode("module Make (M:Def) : S = struct end"))); + + PsiFunctor f = (PsiFunctor) e; + assertEquals("struct end", f.getBinding().getText()); + assertEquals("S", f.getReturnType().getText()); + List uTypes = + PsiTreeUtil.findChildrenOfType(e, PsiUpperSymbol.class) + .stream() + .map(psi -> psi.getFirstChild().getNode().getElementType()) + .collect(Collectors.toList()); + assertDoesntContain(uTypes, m_types.VARIANT_NAME); + } + + public void test_struct() { + PsiNamedElement e = first(expressions(parseCode("module Make (struct type t end) : S = struct end"))); + + PsiFunctor f = (PsiFunctor) e; + assertEquals("struct end", f.getBinding().getText()); + assertEquals("S", f.getReturnType().getText()); + List uTypes = + PsiTreeUtil.findChildrenOfType(e, PsiUpperSymbol.class) + .stream() + .map(psi -> psi.getFirstChild().getNode().getElementType()) + .collect(Collectors.toList()); + assertDoesntContain(uTypes, m_types.VARIANT_NAME); + } + + public void test_implicit_result() { + PsiNamedElement e = first(expressions(parseCode("module Make (M:Def) = struct end"))); + + PsiFunctor f = (PsiFunctor) e; + assertEquals("struct end", f.getBinding().getText()); + } + + public void test_withConstraints() { + Collection expressions = + expressions( + parseCode( + "module Make (M: Input) : S with type +'a t = 'a M.t and type b = M.b = struct end")); + + assertEquals(1, expressions.size()); + PsiFunctor f = (PsiFunctor) first(expressions); + + assertEquals("M: Input", first(f.getParameters()).getText()); + assertEquals("S", f.getReturnType().getText()); + + List constraints = new ArrayList<>(f.getConstraints()); + assertEquals(2, constraints.size()); + assertEquals("type +'a t = 'a M.t", constraints.get(0).getText()); + assertEquals("type b = M.b", constraints.get(1).getText()); + assertEquals("struct end", f.getBinding().getText()); + } + + public void test_signature() { + Collection functors = + functorExpressions( + parseCode( // + "module GlobalBindings (M : sig\n" + + // + "val relation_classes : string list\n" + + // + "val morphisms : string list\n" + + // + "val arrow : evars -> evars * constr\n" + + // + "end) = struct open M end")); + + assertEquals(1, functors.size()); + PsiFunctor functor = first(functors); + assertEquals("GlobalBindings", functor.getName()); + assertEquals("Dummy.GlobalBindings", functor.getQualifiedName()); + Collection parameters = functor.getParameters(); + assertSize(1, parameters); + assertEquals("M", first(parameters).getName()); + assertNotNull(functor.getBinding()); + } + + public void test_functorInstanciation() { + PsiInnerModule module = (PsiInnerModule) first(moduleExpressions(parseCode("module Printing = Make (struct let encode = encode_record end)"))); + + assertNull(module.getBody()); + PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); + assertEquals("Make (struct let encode = encode_record end)", call.getText()); + + Collection parameters = call.getParameters(); + assertSize(1, parameters); + assertEquals("Dummy.Printing.Make[0]", first(parameters).getQualifiedName()); + } + + public void test_functorInstanciationChaining() { + PsiFile file = parseCode("module KeyTable = Hashtbl.Make(KeyHash)\ntype infos"); + List expressions = new ArrayList<>(expressions(file)); + + assertEquals(2, expressions.size()); + + PsiInnerModule module = (PsiInnerModule) expressions.get(0); + assertNull(module.getBody()); + PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); + assertNotNull(call); + assertEquals("Hashtbl.Make(KeyHash)", call.getText()); + } } diff --git a/tests/com/reason/lang/ocaml/IncludeParsingTest.java b/tests/com/reason/lang/ocaml/IncludeParsingTest.java index 6ce171f8d..a0deae13c 100644 --- a/tests/com/reason/lang/ocaml/IncludeParsingTest.java +++ b/tests/com/reason/lang/ocaml/IncludeParsingTest.java @@ -6,33 +6,33 @@ public class IncludeParsingTest extends OclParsingTestCase { public void test_one() { PsiInclude e = first(includeExpressions(parseCode("include Belt"))); - assertEquals("Belt", e.getPath()); + assertEquals("Belt", e.getIncludePath()); } public void test_path() { PsiInclude e = first(includeExpressions(parseCode("include Belt.Array"))); - assertEquals("Belt.Array", e.getPath()); + assertEquals("Belt.Array", e.getIncludePath()); } public void test_functor() { PsiInclude e = first(includeExpressions(parseCode("include A.Make(struct type t end)"))); assertTrue(e.useFunctor()); - assertEquals("A.Make", e.getPath()); + assertEquals("A.Make", e.getIncludePath()); } public void test_withType() { PsiInclude e = first(includeExpressions(parseCode("include S with type t = Tok.t"))); - assertEquals("S", e.getPath()); + assertEquals("S", e.getIncludePath()); assertEquals("include S with type t = Tok.t", e.getText()); } public void test_withPathType() { PsiInclude e = first(includeExpressions(parseCode("include Grammar.S with type te = Tok.t and type 'c pattern = 'c Tok.p\ntype t"))); // Coq: pcoq.ml - assertEquals("Grammar.S", e.getPath()); + assertEquals("Grammar.S", e.getIncludePath()); assertEquals("include Grammar.S with type te = Tok.t and type 'c pattern = 'c Tok.p", e.getText()); } } diff --git a/tests/com/reason/lang/ocaml/LetParsingTest.java b/tests/com/reason/lang/ocaml/LetParsingTest.java index 485214a43..6492fb7ac 100644 --- a/tests/com/reason/lang/ocaml/LetParsingTest.java +++ b/tests/com/reason/lang/ocaml/LetParsingTest.java @@ -144,7 +144,7 @@ public void test_qualifiedName() { public void test_deconstruction() { PsiLet e = first(letExpressions(parseCode("let (a, b) = x"))); - assertTrue(e.isDeconsruction()); + assertTrue(e.isDeconstruction()); List names = e.getDeconstructedElements(); assertSize(2, names); assertEquals("a", names.get(0).getText()); diff --git a/tests/com/reason/lang/reason/FunctionParsingTest.java b/tests/com/reason/lang/reason/FunctionParsingTest.java index 740028a58..3b6283dc8 100644 --- a/tests/com/reason/lang/reason/FunctionParsingTest.java +++ b/tests/com/reason/lang/reason/FunctionParsingTest.java @@ -1,208 +1,195 @@ package com.reason.lang.reason; -import com.intellij.psi.util.PsiTreeUtil; -import com.reason.ide.files.FileBase; -import com.reason.lang.core.psi.PsiFunction; -import com.reason.lang.core.psi.PsiFunctionCallParams; -import com.reason.lang.core.psi.PsiLet; -import com.reason.lang.core.psi.PsiParameter; -import com.reason.lang.core.psi.PsiSwitch; -import com.reason.lang.core.psi.impl.PsiFunctionBody; -import com.reason.lang.core.psi.impl.PsiLowerIdentifier; +import com.intellij.psi.util.*; +import com.reason.ide.files.*; +import com.reason.lang.core.psi.*; +import com.reason.lang.core.psi.impl.*; + import java.util.*; @SuppressWarnings("ConstantConditions") public class FunctionParsingTest extends RmlParsingTestCase { - public void test_anonymous_function() { - PsiLet e = first(letExpressions(parseCode("let _ = Belt.map(items, (. item) => value)"))); - - PsiFunction function = PsiTreeUtil.findChildOfType(e, PsiFunction.class); - assertSize(1, function.getParameters()); - assertEquals("item", first(function.getParameters()).getText()); - assertInstanceOf(first(function.getParameters()).getNameIdentifier(), PsiLowerIdentifier.class); - assertEquals("value", function.getBody().getText()); - } - - public void test_braceFunction() { - PsiLet e = first(letExpressions(parseCode("let x = (x, y) => { x + y; }"))); - - PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); - assertSize(2, function.getParameters()); - assertEquals("(x, y) => { x + y; }", function.getText()); - assertNotNull(function.getBody()); - } - - public void test_destructuration() { - PsiLet e = first(letExpressions(parseCode("let _ = (a, {b, _}) => b;"))); - - assertTrue(e.isFunction()); - assertSize(2, e.getFunction().getParameters()); - } - - public void test_parenlessFunction() { - PsiLet e = first(letExpressions(parseCode("let _ = x => x + 10;"))); - - assertTrue(e.isFunction()); - PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); - - assertSize(1, function.getParameters()); - assertInstanceOf(first(function.getParameters()), PsiParameter.class); - assertNotNull(function.getBody()); - } - - public void test_dotFunction() { - PsiLet e = first(letExpressions(parseCode("let _ = (. x) => x;"))); - - assertTrue(e.isFunction()); - PsiFunction function = e.getFunction(); - - assertSize(1, function.getParameters()); - assertEquals("x", first(function.getParameters()).getText()); - assertEquals("x", function.getBody().getText()); - } - - public void test_innerFunction() { - PsiLet e = - first( - letExpressions( - parseCode( - "let _ = error => Belt.Array.mapU(errors, (. error) => error##message);"))); - - PsiFunction functionOuter = (PsiFunction) e.getBinding().getFirstChild(); - assertEquals( - "Belt.Array.mapU(errors, (. error) => error##message)", functionOuter.getBody().getText()); - - PsiFunction functionInner = PsiTreeUtil.findChildOfType(functionOuter, PsiFunction.class); - assertEquals("error##message", functionInner.getBody().getText()); - } - - public void test_innerFunctionBraces() { - PsiLet e = - first( - letExpressions( - parseCode( - "let _ = error => { Belt.Array.mapU(errors, (. error) => error##message); };"))); - - PsiFunction functionOuter = (PsiFunction) e.getBinding().getFirstChild(); - assertEquals( - "{ Belt.Array.mapU(errors, (. error) => error##message); }", - functionOuter.getBody().getText()); - - PsiFunction functionInner = PsiTreeUtil.findChildOfType(functionOuter, PsiFunction.class); - assertEquals("error##message", functionInner.getBody().getText()); - } - - public void test_innerFunctionNoParens() { - PsiLet e = first(letExpressions(parseCode("let _ = funcall(result => 2);"))); - - PsiFunction functionInner = PsiTreeUtil.findChildOfType(e, PsiFunction.class); - assertEquals("2", functionInner.getBody().getText()); - } - - public void test_parameterAnonFunction() { - FileBase e = parseCode("describe('a', () => test('b', () => true));"); - - List funcs = new ArrayList<>(PsiTreeUtil.findChildrenOfType(e, PsiFunction.class)); - assertSize(2, funcs); - assertEquals("() => test('b', () => true)", funcs.get(0).getText()); - assertEquals("() => true", funcs.get(1).getText()); - } - - public void test_parametersNamedSymbols() { - PsiLet e = - first( - letExpressions( - parseCode( - "let make = (~id:string, ~values: option(Js.t('a)), children) => null;"))); - - PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); - List parameters = new ArrayList<>(function.getParameters()); - assertSize(3, parameters); - - assertEquals("id", parameters.get(0).getName()); - assertEquals("values", parameters.get(1).getName()); - assertEquals("children", parameters.get(2).getName()); - } - - public void test_parametersNamedSymbols2() { - PsiLet e = - first( - letExpressions( - parseCode( - "let make = (~text, ~id=?, ~values=?, ~className=\"\", ~tag=\"span\", ~transform=\"unset\", ~marginLeft=\"0\", ~onClick=?, ~onKeyPress=?, _children, ) => {}"))); - - PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); - assertSize(10, function.getParameters()); - } - - public void test_parenFunction() { - PsiLet e = first(letExpressions(parseCode("let _ = (x,y) => x + y;"))); - - assertTrue(e.isFunction()); - PsiFunction function = e.getFunction(); - - assertSize(2, function.getParameters()); - assertEquals("x", first(function.getParameters()).getText()); - assertEquals("y", second(function.getParameters()).getText()); - assertEquals("x + y", function.getBody().getText()); - } - - public void test_unitFunction() { - PsiLet e = first(letExpressions(parseCode("let _ = () => 1;"))); - - assertTrue(e.isFunction()); - PsiFunction function = e.getFunction(); - - assertSize(0, function.getParameters()); - assertEquals("1", function.getBody().getText()); - } - - public void test_parametersLIdent() { - PsiLet e = first(letExpressions(parseCode("let make = (id, values, children) => null;"))); - - PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); - List parameters = new ArrayList<>(function.getParameters()); - assertSize(3, parameters); - - assertEquals("id", parameters.get(0).getName()); - assertEquals("values", parameters.get(1).getName()); - assertEquals("children", parameters.get(2).getName()); - } - - public void test_recordFunction() { - PsiLet e = - first( - letExpressions( - parseCode("let make = (children) => { ...component, render: self =>
, }"))); - PsiFunctionBody body = e.getFunction().getBody(); - PsiFunction innerFunction = PsiTreeUtil.findChildOfType(body, PsiFunction.class); - - assertSize(1, innerFunction.getParameters()); - assertEquals("self", first(innerFunction.getParameters()).getName()); - assertEquals("
", innerFunction.getBody().getText()); - } - - public void test_underscore() { - PsiLet e = - first( - letExpressions( - parseCode("let onCancel = _ => { setUpdatedAttribute(_ => initialAttribute); };"))); - - assertEquals("_ => { setUpdatedAttribute(_ => initialAttribute); }", e.getBinding().getText()); - assertEquals( - "(_ => initialAttribute)", - PsiTreeUtil.findChildOfType(e.getBinding(), PsiFunctionCallParams.class).getText()); - } - - // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/113 - public void test_GH_113() { - PsiFunction e = - (PsiFunction) firstElement(parseCode("() => switch (isBuggy()) { | _ => \"buggy\" };")); - - assertSize(0, e.getParameters()); - PsiFunctionBody b = e.getBody(); - assertInstanceOf(b.getFirstChild(), PsiSwitch.class); - PsiSwitch s = (PsiSwitch) b.getFirstChild(); - assertEquals("(isBuggy())", s.getCondition().getText()); - } + public void test_anonymous_function() { + PsiLet e = first(letExpressions(parseCode("let _ = Belt.map(items, (. item) => value)"))); + + PsiFunction function = PsiTreeUtil.findChildOfType(e, PsiFunction.class); + assertSize(1, function.getParameters()); + assertEquals("item", first(function.getParameters()).getText()); + assertInstanceOf(first(function.getParameters()).getNameIdentifier(), PsiLowerIdentifier.class); + assertEquals("value", function.getBody().getText()); + } + + public void test_braceFunction() { + PsiLet e = first(letExpressions(parseCode("let x = (x, y) => { x + y; }"))); + + PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); + assertSize(2, function.getParameters()); + assertEquals("(x, y) => { x + y; }", function.getText()); + assertNotNull(function.getBody()); + } + + public void test_destructuration() { + PsiLet e = first(letExpressions(parseCode("let _ = (a, {b, _}) => b;"))); + + assertTrue(e.isFunction()); + assertSize(2, e.getFunction().getParameters()); + } + + public void test_parenlessFunction() { + PsiLet e = first(letExpressions(parseCode("let _ = x => x + 10;"))); + + assertTrue(e.isFunction()); + PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); + + assertSize(1, function.getParameters()); + assertInstanceOf(first(function.getParameters()), PsiParameter.class); + assertNotNull(function.getBody()); + } + + public void test_dotFunction() { + PsiLet e = first(letExpressions(parseCode("let _ = (. x) => x;"))); + + assertTrue(e.isFunction()); + PsiFunction function = e.getFunction(); + + assertSize(1, function.getParameters()); + assertEquals("x", first(function.getParameters()).getText()); + assertEquals("x", function.getBody().getText()); + } + + public void test_innerFunction() { + PsiLet e = + first( + letExpressions( + parseCode( + "let _ = error => Belt.Array.mapU(errors, (. error) => error##message);"))); + + PsiFunction functionOuter = (PsiFunction) e.getBinding().getFirstChild(); + assertEquals( + "Belt.Array.mapU(errors, (. error) => error##message)", functionOuter.getBody().getText()); + + PsiFunction functionInner = PsiTreeUtil.findChildOfType(functionOuter, PsiFunction.class); + assertEquals("error##message", functionInner.getBody().getText()); + } + + public void test_innerFunctionBraces() { + PsiLet e = + first( + letExpressions( + parseCode( + "let _ = error => { Belt.Array.mapU(errors, (. error) => error##message); };"))); + + PsiFunction functionOuter = (PsiFunction) e.getBinding().getFirstChild(); + assertEquals( + "{ Belt.Array.mapU(errors, (. error) => error##message); }", + functionOuter.getBody().getText()); + + PsiFunction functionInner = PsiTreeUtil.findChildOfType(functionOuter, PsiFunction.class); + assertEquals("error##message", functionInner.getBody().getText()); + } + + public void test_innerFunctionNoParens() { + PsiLet e = first(letExpressions(parseCode("let _ = funcall(result => 2);"))); + + PsiFunction functionInner = PsiTreeUtil.findChildOfType(e, PsiFunction.class); + assertEquals("2", functionInner.getBody().getText()); + } + + public void test_parameterAnonFunction() { + FileBase e = parseCode("describe('a', () => test('b', () => true));"); + + List funcs = new ArrayList<>(PsiTreeUtil.findChildrenOfType(e, PsiFunction.class)); + assertSize(2, funcs); + assertEquals("() => test('b', () => true)", funcs.get(0).getText()); + assertEquals("() => true", funcs.get(1).getText()); + } + + public void test_parametersNamedSymbols() { + PsiLet e = + first( + letExpressions( + parseCode( + "let make = (~id:string, ~values: option(Js.t('a)), children) => null;"))); + + PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); + List parameters = new ArrayList<>(function.getParameters()); + assertSize(3, parameters); + + assertEquals("id", parameters.get(0).getName()); + assertEquals("values", parameters.get(1).getName()); + assertEquals("children", parameters.get(2).getName()); + } + + public void test_parametersNamedSymbols2() { + PsiLet e = + first( + letExpressions( + parseCode( + "let make = (~text, ~id=?, ~values=?, ~className=\"\", ~tag=\"span\", ~transform=\"unset\", ~marginLeft=\"0\", ~onClick=?, ~onKeyPress=?, _children, ) => {}"))); + + PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); + assertSize(10, function.getParameters()); + } + + public void test_parenFunction() { + PsiLet e = first(letExpressions(parseCode("let _ = (x,y) => x + y;"))); + + assertTrue(e.isFunction()); + PsiFunction function = e.getFunction(); + + assertSize(2, function.getParameters()); + assertEquals("x", first(function.getParameters()).getText()); + assertEquals("y", second(function.getParameters()).getText()); + assertEquals("x + y", function.getBody().getText()); + } + + public void test_unitFunction() { + PsiLet e = first(letExpressions(parseCode("let _ = () => 1;"))); + + assertTrue(e.isFunction()); + PsiFunction function = e.getFunction(); + + assertSize(0, function.getParameters()); + assertEquals("1", function.getBody().getText()); + } + + public void test_parametersLIdent() { + PsiLet e = first(letExpressions(parseCode("let make = (id, values, children) => null;"))); + + PsiFunction function = (PsiFunction) e.getBinding().getFirstChild(); + List parameters = new ArrayList<>(function.getParameters()); + assertSize(3, parameters); + + assertEquals("id", parameters.get(0).getName()); + assertEquals("values", parameters.get(1).getName()); + assertEquals("children", parameters.get(2).getName()); + } + + public void test_recordFunction() { + PsiLet e = first(letExpressions(parseCode("let make = (children) => { ...component, render: self =>
, }"))); + PsiFunctionBody body = e.getFunction().getBody(); + PsiFunction innerFunction = PsiTreeUtil.findChildOfType(body, PsiFunction.class); + + assertSize(1, innerFunction.getParameters()); + assertEquals("self", first(innerFunction.getParameters()).getName()); + assertEquals("
", innerFunction.getBody().getText()); + } + + public void test_underscore() { + PsiLet e = first(letExpressions(parseCode("let onCancel = _ => { setUpdatedAttribute(_ => initialAttribute); };"))); + + assertEquals("_ => { setUpdatedAttribute(_ => initialAttribute); }", e.getBinding().getText()); + assertEquals("(_ => initialAttribute)", PsiTreeUtil.findChildOfType(e.getBinding(), PsiFunctionCallParams.class).getText()); + } + + // https://github.com/reasonml-editor/reasonml-idea-plugin/issues/113 + public void test_GH_113() { + PsiFunction e = (PsiFunction) firstElement(parseCode("() => switch (isBuggy()) { | _ => \"buggy\" };")); + + assertSize(0, e.getParameters()); + PsiFunctionBody b = e.getBody(); + assertInstanceOf(b.getFirstChild(), PsiSwitch.class); + PsiSwitch s = (PsiSwitch) b.getFirstChild(); + assertEquals("(isBuggy())", s.getCondition().getText()); + } } diff --git a/tests/com/reason/lang/reason/FunctorCallParsingTest.java b/tests/com/reason/lang/reason/FunctorCallParsingTest.java index d57737d60..4948e8a38 100644 --- a/tests/com/reason/lang/reason/FunctorCallParsingTest.java +++ b/tests/com/reason/lang/reason/FunctorCallParsingTest.java @@ -9,28 +9,29 @@ @SuppressWarnings("ConstantConditions") public class FunctorCallParsingTest extends RmlParsingTestCase { - public void test_instanciation() { - PsiInnerModule module = (PsiInnerModule) first(moduleExpressions( - parseCode("module Printing = Make({ let encode = encode_record; });"))); + public void test_instanciation() { + PsiInnerModule e = (PsiInnerModule) first(moduleExpressions(parseCode("module Printing = Make({ let encode = encode_record; });"))); - assertNull(module.getBody()); - PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); - assertNotNull(call); - assertEquals("Make({ let encode = encode_record; })", call.getText()); - PsiLet let = PsiTreeUtil.findChildOfType(module, PsiLet.class); - assertEquals("Dummy.Printing.Make[0].encode", let.getQualifiedName()); - } + assertTrue(e.isFunctorCall()); + assertNull(e.getBody()); + PsiFunctorCall call = PsiTreeUtil.findChildOfType(e, PsiFunctorCall.class); + assertNotNull(call); + assertEquals("Make({ let encode = encode_record; })", call.getText()); + PsiLet let = PsiTreeUtil.findChildOfType(e, PsiLet.class); + assertEquals("Dummy.Printing.Make[0].encode", let.getQualifiedName()); + } - public void test_chaining() { - PsiFile file = parseCode("module KeyTable = Hashtbl.Make(KeyHash);\ntype infos;"); - List expressions = new ArrayList<>(expressions(file)); + public void test_chaining() { + PsiFile file = parseCode("module KeyTable = Hashtbl.Make(KeyHash);\ntype infos;"); + List es = new ArrayList<>(expressions(file)); - assertEquals(2, expressions.size()); + assertEquals(2, es.size()); - PsiInnerModule module = (PsiInnerModule) expressions.get(0); - assertNull(module.getBody()); - PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); - assertNotNull(call); - assertEquals("Hashtbl.Make(KeyHash)", call.getText()); - } + PsiInnerModule module = (PsiInnerModule) es.get(0); + assertTrue(module.isFunctorCall()); + assertNull(module.getBody()); + PsiFunctorCall call = PsiTreeUtil.findChildOfType(module, PsiFunctorCall.class); + assertNotNull(call); + assertEquals("Hashtbl.Make(KeyHash)", call.getText()); + } } diff --git a/tests/com/reason/lang/reason/IncludeParsingTest.java b/tests/com/reason/lang/reason/IncludeParsingTest.java index 71c7a9659..0fd3edccc 100644 --- a/tests/com/reason/lang/reason/IncludeParsingTest.java +++ b/tests/com/reason/lang/reason/IncludeParsingTest.java @@ -6,19 +6,19 @@ public class IncludeParsingTest extends RmlParsingTestCase { public void test_one() { PsiInclude e = first(includeExpressions(parseCode("include Belt;"))); - assertEquals("Belt", e.getPath()); + assertEquals("Belt", e.getIncludePath()); } public void test_path() { PsiInclude e = first(includeExpressions(parseCode("include Belt.Array;"))); - assertEquals("Belt.Array", e.getPath()); + assertEquals("Belt.Array", e.getIncludePath()); } public void test_functor() { PsiInclude e = first(includeExpressions(parseCode("include A.Make({ type t; })"))); assertTrue(e.useFunctor()); - assertEquals("A.Make", e.getPath()); + assertEquals("A.Make", e.getIncludePath()); } } diff --git a/tests/com/reason/lang/reason/LetParsingTest.java b/tests/com/reason/lang/reason/LetParsingTest.java index 63efea868..3e9dd8fac 100644 --- a/tests/com/reason/lang/reason/LetParsingTest.java +++ b/tests/com/reason/lang/reason/LetParsingTest.java @@ -149,7 +149,7 @@ public void test_alias() { public void test_deconstruction() { PsiLet e = first(letExpressions(parseCode("let (a, b) = x;"))); - assertTrue(e.isDeconsruction()); + assertTrue(e.isDeconstruction()); List names = e.getDeconstructedElements(); assertSize(2, names); assertEquals("a", names.get(0).getText()); diff --git a/tests/com/reason/lang/reason/SignatureParsingTest.java b/tests/com/reason/lang/reason/SignatureParsingTest.java index 32148b090..e1fbec979 100644 --- a/tests/com/reason/lang/reason/SignatureParsingTest.java +++ b/tests/com/reason/lang/reason/SignatureParsingTest.java @@ -75,11 +75,7 @@ public void test_unitFunParameter() { } public void test_jsObject() { - PsiType psiType = - first( - typeExpressions( - parseCode( - "type props = { [@bs.optional] dangerouslySetInnerHTML: {. \"__html\": string} };"))); + PsiType psiType = first(typeExpressions(parseCode("type props = { [@bs.optional] dangerouslySetInnerHTML: {. \"__html\": string} };"))); PsiRecord record = (PsiRecord) psiType.getBinding().getFirstChild(); List fields = new ArrayList<>(record.getFields()); @@ -89,10 +85,7 @@ public void test_jsObject() { } public void test_externalFun() { - PsiExternal e = - first( - externalExpressions( - parseCode("external refToJsObj : reactRef => Js.t({..}) = \"%identity\";"))); + PsiExternal e = first(externalExpressions(parseCode("external refToJsObj : reactRef => Js.t({..}) = \"%identity\";"))); PsiSignature signature = e.getSignature(); assertSize(2, ORUtil.findImmediateChildrenOfClass(e.getSignature(), PsiSignatureItem.class));