Skip to content

Commit 540658f

Browse files
committed
java2kt
1 parent 1471968 commit 540658f

File tree

8 files changed

+244
-294
lines changed

8 files changed

+244
-294
lines changed

src/main/java/com/tang/intellij/lua/debugger/LuaDebuggerEditorsProvider.java

Lines changed: 0 additions & 54 deletions
This file was deleted.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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.lua.debugger
18+
19+
import com.intellij.openapi.editor.Document
20+
import com.intellij.openapi.fileTypes.FileType
21+
import com.intellij.openapi.project.Project
22+
import com.intellij.psi.PsiDocumentManager
23+
import com.intellij.xdebugger.XSourcePosition
24+
import com.intellij.xdebugger.evaluation.EvaluationMode
25+
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider
26+
import com.tang.intellij.lua.lang.LuaFileType
27+
import com.tang.intellij.lua.psi.LuaElementFactory
28+
29+
/**
30+
*
31+
* Created by TangZX on 2016/12/30.
32+
*/
33+
class LuaDebuggerEditorsProvider : XDebuggerEditorsProvider() {
34+
override fun getFileType(): FileType {
35+
return LuaFileType.INSTANCE
36+
}
37+
38+
override fun createDocument(project: Project,
39+
s: String,
40+
xSourcePosition: XSourcePosition?,
41+
evaluationMode: EvaluationMode): Document {
42+
val file = LuaElementFactory.createFile(project, s)
43+
return PsiDocumentManager.getInstance(project).getDocument(file)!!
44+
}
45+
}

src/main/java/com/tang/intellij/lua/psi/LuaElementFactory.java

Lines changed: 0 additions & 76 deletions
This file was deleted.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
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.lua.psi
18+
19+
import com.intellij.openapi.project.Project
20+
import com.intellij.psi.PsiElement
21+
import com.intellij.psi.PsiFileFactory
22+
import com.intellij.psi.util.PsiTreeUtil
23+
import com.tang.intellij.lua.comment.psi.LuaDocFieldDef
24+
import com.tang.intellij.lua.lang.LuaLanguage
25+
26+
/**
27+
*
28+
* Created by TangZX on 2016/11/24.
29+
*/
30+
object LuaElementFactory {
31+
fun createFile(project: Project, content: String): LuaFile {
32+
val name = "dummy.lua"
33+
return PsiFileFactory.getInstance(project).createFileFromText(name, LuaLanguage.INSTANCE, content) as LuaFile
34+
}
35+
36+
fun createIdentifier(project: Project, name: String): PsiElement {
37+
val content = "local $name = 0"
38+
val file = createFile(project, content)
39+
val def = PsiTreeUtil.findChildOfType(file, LuaNameDef::class.java)!!
40+
return def.firstChild
41+
}
42+
43+
fun createLiteral(project: Project, value: String): LuaLiteralExpr {
44+
val content = "local a = " + value
45+
val file = createFile(project, content)
46+
return PsiTreeUtil.findChildOfType(file, LuaLiteralExpr::class.java)!!
47+
}
48+
49+
fun createName(project: Project, name: String): PsiElement {
50+
val element = createWith(project, name + " = 1")
51+
return PsiTreeUtil.findChildOfType(element, LuaNameExpr::class.java)!!
52+
}
53+
54+
fun newLine(project: Project): PsiElement {
55+
return createWith(project, "\n")
56+
}
57+
58+
fun createWith(project: Project, code: String): PsiElement {
59+
val file = createFile(project, code)
60+
return file.firstChild
61+
}
62+
63+
fun createDocIdentifier(project: Project, name: String): PsiElement {
64+
val element = createWith(project, "---@field $name string")
65+
val fieldDef = PsiTreeUtil.findChildOfType(element, LuaDocFieldDef::class.java)!!
66+
return fieldDef.id!!
67+
}
68+
}

src/main/java/com/tang/intellij/lua/reference/LuaIndexReference.java

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)