Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 21
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '21'
java-version: '17'
distribution: 'temurin'

- name: Build 2023.1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/on_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Set up JDK 21
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '21'
java-version: '17'
distribution: 'temurin'

- name: Publish 2023.1
Expand Down
14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ data class BuildData(

val buildDataList = listOf(
BuildData(
ideaSDKShortVersion = "2025.3",
ideaSDKVersion = "253.28086.51",
sinceBuild = "253",
untilBuild = "253.*",
ideaSDKShortVersion = "2025.2",
ideaSDKVersion = "252.23892.409",
sinceBuild = "252",
untilBuild = "252.*",
bunch = "212",
targetCompatibilityLevel = JavaVersion.VERSION_21,
jvmTarget = "21"
targetCompatibilityLevel = JavaVersion.VERSION_17,
jvmTarget = "17"
)
)

Expand Down Expand Up @@ -164,7 +164,7 @@ project(":") {
implementation("org.eclipse.mylyn.github:org.eclipse.egit.github.core:2.1.5")
implementation("com.jgoodies:forms:1.2.1")
intellijPlatform {
intellijIdeaUltimate(buildVersionData.ideaSDKVersion)
intellijIdeaCommunity(buildVersionData.ideaSDKShortVersion)
bundledModule("intellij.spellchecker")
}
}
Expand Down
84 changes: 83 additions & 1 deletion gen/com/tang/intellij/lua/psi/impl/LuaCallExprImpl.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@

distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ abstract class EmmyDebugProcessBase(session: XDebugSession) : LuaDebugProcess(se

override fun sessionInitialized() {
super.sessionInitialized()
session.setPauseActionSupported(true)
ApplicationManager.getApplication().executeOnPooledThread {
setupTransporter()
}
Expand All @@ -68,6 +69,7 @@ abstract class EmmyDebugProcessBase(session: XDebugSession) : LuaDebugProcess(se
registerBreakpoint(position, breakpoint)
}
}
session.setPauseActionSupported(true);
// send ready
transporter?.send(Message(MessageCMD.ReadyReq))
}
Expand Down Expand Up @@ -209,7 +211,6 @@ abstract class EmmyDebugProcessBase(session: XDebugSession) : LuaDebugProcess(se
override fun getEditorsProvider(): XDebuggerEditorsProvider {
return editorsProvider
}

fun addEvalResultHandler(handler: IEvalResultHandler) {
evalHandlers.add(handler)
}
Expand Down
174 changes: 167 additions & 7 deletions src/main/java/com/tang/intellij/lua/psi/LuaPsiImplUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import com.tang.intellij.lua.comment.psi.LuaDocTagVararg
import com.tang.intellij.lua.comment.psi.api.LuaComment
import com.tang.intellij.lua.lang.LuaIcons
import com.tang.intellij.lua.lang.type.LuaString
import com.tang.intellij.lua.psi.impl.*
import com.tang.intellij.lua.search.SearchContext
import com.tang.intellij.lua.stubs.LuaClassMemberStub
import com.tang.intellij.lua.stubs.LuaFuncBodyOwnerStub
Expand Down Expand Up @@ -188,26 +189,137 @@ fun guessParentType(callExpr: LuaCallExpr, context: SearchContext): ITy {
return callExpr.expr.guessType(context)
}

fun getStringValue(valueExpr: PsiElement): String {
if (valueExpr is LuaLiteralExprImpl)
{
return valueExpr.stringValue
}
else
{
if (valueExpr is LuaNameExpr)
{
val declaration = resolve(valueExpr as LuaNameExpr, SearchContext.get(valueExpr.project))
if (declaration is LuaNameExprImpl)
{
return declaration.text
}
else if(declaration is LuaNameDefImpl)
{
val exp = declaration?.parent?.parent?.lastChild?.lastChild
if (exp != null)
{
return getStringValue(exp)
}
}
}
else if (valueExpr is LuaIndexExpr)
{
val declaration = resolve(valueExpr as LuaIndexExpr, SearchContext.get(valueExpr.project))
if (declaration is LuaTableFieldImpl)
{
val strExp = declaration?.lastChild
if (strExp != null)
{
return getStringValue(strExp)
}
}
else if (declaration is LuaIndexExprImpl)
{
val exp = declaration?.parent?.parent?.lastChild?.lastChild
if (exp != null)
{
return getStringValue(exp)
}
}
}
}

return "";
}

fun getParamStringValue(valueExpr: PsiElement): String {
if (valueExpr is LuaNameExpr)
{
return valueExpr.text;
}
else if(valueExpr is LuaIndexExpr)
{
return valueExpr.lastChild.text;
}
return "";
}

fun getParamAllStringValue(valueExpr: PsiElement): String {
if (valueExpr is LuaNameExpr)
{
return valueExpr.text;
}
else if(valueExpr is LuaIndexExpr)
{
return valueExpr.text;
}
return "";
}

/**
* 获取第n个字符串参数
* @param callExpr callExpr
* *
* @return String PsiElement
*/
fun getStringArgByIndex(callExpr: LuaCallExpr, index: Int): PsiElement? {
val args = callExpr.args
var path: PsiElement? = null

when (args) {
is LuaSingleArg -> {
val expr = args.expr
if (expr is LuaLiteralExpr && index == 0) path = expr
}
is LuaListArgs -> args.exprList.let { list ->
if (list.isNotEmpty() && list.size > index) {
if (list[index] is LuaLiteralExpr) {
val valueExpr = list[index] as LuaLiteralExpr
if (valueExpr.kind == LuaLiteralKind.String)
path = valueExpr
}
else {
val context = SearchContext.get(callExpr.project)
if (list[index].guessType((context)).displayName == "string")
{
path = list[index]
}
}
}
}
}
return path
}

/**
* 获取第一个字符串参数
* 获取第n个参数的名字
* @param callExpr callExpr
* *
* @return String PsiElement
*/
fun getFirstStringArg(callExpr: LuaCallExpr): PsiElement? {
fun getParamNameByIndex(callExpr: LuaCallExpr, index: Int): PsiElement? {
val args = callExpr.args
var path: PsiElement? = null

when (args) {
is LuaSingleArg -> {
val expr = args.expr
if (expr is LuaLiteralExpr) path = expr
if (expr is LuaNameExpr && index == 0) path = expr
if (expr is LuaIndexExpr && index == 0) path = expr
}
is LuaListArgs -> args.exprList.let { list ->
if (list.isNotEmpty() && list[0] is LuaLiteralExpr) {
val valueExpr = list[0] as LuaLiteralExpr
if (valueExpr.kind == LuaLiteralKind.String)
path = valueExpr
if (list.isNotEmpty() && list.size > index) {
if (list[index] is LuaNameExpr) {
path = list[index]
}
else if (list[index] is LuaIndexExpr) {
path = list[index]
}
}
}
}
Expand Down Expand Up @@ -257,6 +369,54 @@ fun guessTypeAt(list: LuaExprList, context: SearchContext): ITy {
return Ty.UNKNOWN
}

fun getStringValue(typeName: LuaLiteralExpr): String {
return typeName.stringValue;
}

fun getNameExprStringValue(valueExpr: PsiElement): String {
val tree = LuaDeclarationTree.get(valueExpr.containingFile)
val declaration = tree.find(valueExpr as LuaExpr)?.firstDeclaration?.psi
val exp = declaration?.parent?.parent
if (exp != null)
{
val strExp = exp.lastChild.lastChild
if(strExp is LuaLiteralExprImpl)
{
val str = strExp.text
return str.substring(1, str.length - 1)
}
else
{
return getNameExprStringValue(strExp)
}

}
return "";
}

fun newType(typeName: String, ty: ITy, sourceStr: String, targetStr: String): ITy {
if (ty is TyArray) {
val t = typeName.substringBefore('[').trim()
val ty = TyLazyClass(t)
return TyArray(ty);
}
else if(ty is TySerializedGeneric){
val list = mutableListOf<ITy>();
ty.params.forEach {
var name = it.displayName
if(name.contains(sourceStr))
{
name = name.replace(sourceStr, targetStr)
}
list.add(newType(name, it, sourceStr, targetStr))
}
return TySerializedGeneric(list.toTypedArray(), ty.base)
}
else {
return TyLazyClass(typeName);
}
}

fun guessParentType(indexExpr: LuaIndexExpr, context: SearchContext): ITy {
val expr = PsiTreeUtil.getStubChildOfType(indexExpr, LuaExpr::class.java)
return expr?.guessType(context) ?: Ty.UNKNOWN
Expand Down
Loading