1+ /*
2+ * Copyright (c) 2017. tangzx([email protected] ) 3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ package com.tang.intellij.test.completion
18+
19+ import com.intellij.openapi.fileEditor.FileDocumentManager
20+ import com.tang.intellij.test.LuaTestBase
21+ import com.tang.intellij.test.fileTreeFromText
22+
23+ class TestModule : LuaTestBase () {
24+
25+ fun `test module type` () {
26+ fileTreeFromText("""
27+ --- moduleA.lua
28+ ---@module TypeA
29+ module("TypeA")
30+
31+ name = "a"
32+
33+ --- B.lua
34+ local a ---@type TypeA
35+ a.--[[caret]]
36+ """ ).createAndOpenFileWithCaretMarker()
37+
38+ FileDocumentManager .getInstance().saveAllDocuments()
39+ myFixture.completeBasic()
40+ val elementStrings = myFixture.lookupElementStrings
41+ assertTrue(elementStrings!! .contains(" name" ))
42+ }
43+
44+
45+ fun `test module members visibility` () {
46+ fileTreeFromText("""
47+ --- moduleA.lua
48+ ---@module TypeA
49+ module("TypeA")
50+
51+ myFieldName = "a"
52+
53+ function myFunction() end
54+
55+ --- B.lua
56+ --[[caret]]
57+ """ ).createAndOpenFileWithCaretMarker()
58+
59+ FileDocumentManager .getInstance().saveAllDocuments()
60+ myFixture.completeBasic()
61+ val elementStrings = myFixture.lookupElementStrings
62+ assertFalse(elementStrings!! .containsAll(listOf (" myFieldName" , " myFunction" )))
63+ }
64+ }
0 commit comments