Skip to content

Commit

Permalink
v1.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Haoxiqiang committed Jun 30, 2023
1 parent b4b29d8 commit 059645e
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 60 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

### Fixed
- upgrade since version 193->203 for intellij api.
- fix sql distant bugs.

## 1.2.1

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ works to solve the psi problem. Who with relevant practical experience can help

## Build

* get lsf files by: git lfs fetch --all
* get the latest aosp git repo and add the path to the environment variable as AOSP_PATH
* run the test code generator the versions/mapping...
* run the build command
Expand Down
6 changes: 3 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ fun properties(key: String) = project.findProperty(key).toString()

plugins {
id("java")
id("org.jetbrains.intellij") version "1.12.0"
id("org.jetbrains.intellij") version "1.14.2"
id("org.jetbrains.changelog") version "2.0.0"
id("org.jetbrains.kotlin.jvm") version "1.7.21"
id("org.jetbrains.kotlin.jvm") version "1.8.21"
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("com.diffplug.spotless")
id("com.squareup.sqldelight")
Expand All @@ -24,7 +24,7 @@ dependencies {
testImplementation("org.eclipse.jgit:org.eclipse.jgit:6.5.0.202303070854-r")

implementation("org.jetbrains:annotations:24.0.1")
implementation(kotlin("bom", version = "1.7.21"))
implementation(kotlin("bom", version = "1.8.21"))

implementation("com.squareup.sqldelight:sqlite-driver:1.5.5")
implementation("com.squareup.sqldelight:runtime:1.5.5")
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ platformType=IC
platformVersion=2023.1.3
platformPlugins=com.intellij.java
javaVersion=11
gradleVersion=7.3
gradleVersion=7.6
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import com.intellij.openapi.actionSystem.LangDataKeys
import com.intellij.openapi.ui.showOkNoDialog
import com.quickref.plugin.App
import com.quickref.plugin.Notifier
import com.quickref.plugin.PluginLogger
import com.quickref.plugin.download.DownloadTask
import com.quickref.plugin.extension.downloadFile
import com.quickref.plugin.extension.guessFileName
Expand Down
12 changes: 4 additions & 8 deletions src/main/kotlin/com/quickref/plugin/config/QRCacheMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package com.quickref.plugin.config

import com.intellij.ide.plugins.newui.HorizontalLayout
import com.intellij.openapi.application.ApplicationManager
import com.intellij.ui.IdeBorderFactory
import com.intellij.ui.TitledSeparator
Expand Down Expand Up @@ -38,7 +37,8 @@ internal object QRCacheMenu {
.addComponent(cacheSize)
.addComponent(cleanCache)
.panel.apply {
layout = HorizontalLayout(IdeBorderFactory.TITLED_BORDER_INDENT)
@Suppress("UnstableApiUsage")
layout = ListLayout.horizontal()
calCacheSize()
})
.setVerticalGap(IdeBorderFactory.TITLED_BORDER_INDENT)
Expand All @@ -52,15 +52,11 @@ internal object QRCacheMenu {
}
}

fun applyState(quickReferenceConfigStorage: QuickReferenceConfigStorage) {
fun applyState() {
calCacheSize()
}

fun loadState(quickReferenceConfigStorage: QuickReferenceConfigStorage) {

}

fun checkNotModified(quickReferenceConfigStorage: QuickReferenceConfigStorage): Boolean {
fun checkNotModified(): Boolean {
return true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,18 @@ class QRConfigurationForm {

fun apply() {
QRSearchMenu.applyState(quickReferenceConfigStorage)
QRCacheMenu.applyState(quickReferenceConfigStorage)
QRCacheMenu.applyState()
QRVersionsMenu.applyState(quickReferenceConfigStorage)

}

fun reset() {
QRSearchMenu.loadState(quickReferenceConfigStorage)
QRCacheMenu.loadState(quickReferenceConfigStorage)
QRVersionsMenu.loadState(quickReferenceConfigStorage)
}

val isNotModified: Boolean
get() = (QRSearchMenu.checkNotModified(quickReferenceConfigStorage)
&& QRVersionsMenu.checkNotModified(quickReferenceConfigStorage)
&& QRCacheMenu.checkNotModified(quickReferenceConfigStorage)
)
&& QRCacheMenu.checkNotModified())
}
73 changes: 36 additions & 37 deletions src/main/kotlin/com/quickref/plugin/extension/PluginExtensions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,47 +15,43 @@ import com.quickref.plugin.PluginLogger
fun AnActionEvent.guessFileName(): String {
val element = getData(LangDataKeys.PSI_ELEMENT) ?: return ""
// base on field,we check it whether a psiclass

val name = element.containingFile.name
val fileName = if (name.endsWith(".class")) {
name.replace(".class", ".java")
} else if (name.endsWith(".java")) {
name
} else {
// guess file name
// if var element, try to fill the package name.
val varPackageName = tryGetVarPackageName(this, element, name)
val target = varPackageName.ifEmpty {
name
val extension = if (name.endsWith(".class")) {
if ("java".equals(element.containingFile.originalFile.language.id, true)) {
".java"
} else {
".kt"
}
target + element.containingFile.fileType.defaultExtension
} else {
name.substring(name.lastIndexOf("."))
}
return fileName
}

private fun tryGetVarPackageName(e: AnActionEvent, element: PsiElement, name: String): String {
if (element is PsiVariable) {
// origin file import analysis.
val psiFile = e.getData(LangDataKeys.PSI_FILE)
if (psiFile is PsiJavaFile) {
val imports =
psiFile.importList?.children?.filterIsInstance<PsiImportStatement>()?.filter { psiImportStatement ->
psiImportStatement.qualifiedName == name
}
// in the list use the import
return "${
if (imports?.isNotEmpty() == true) {
imports[0].qualifiedName
} else {
// use the parent package
psiFile.packageName
}
}.$name"
}
}
return ""
return name.substring(0, name.lastIndexOf(".")) + extension
}

//private fun tryGetVarPackageName(e: AnActionEvent, element: PsiElement, name: String): String {
// if (element is PsiVariable) {
// // origin file import analysis.
// val psiFile = e.getData(LangDataKeys.PSI_FILE)
// if (psiFile is PsiJavaFile) {
// val imports =
// psiFile.importList?.children?.filterIsInstance<PsiImportStatement>()?.filter { psiImportStatement ->
// psiImportStatement.qualifiedName == name
// }
// // in the list use the import
// return "${
// if (imports?.isNotEmpty() == true) {
// imports[0].qualifiedName
// } else {
// // use the parent package
// psiFile.packageName
// }
// }.$name"
// }
// }
// return ""
//}

fun AnActionEvent.packageName(): String? {
val element = getData(LangDataKeys.PSI_FILE)
if (element is PsiClassOwner) {
Expand All @@ -65,8 +61,8 @@ fun AnActionEvent.packageName(): String? {
}

fun PsiElement?.pathname(): String? {
if(this == null){
return ""
if (this == null) {
return ""
}
val element = this

Expand All @@ -82,11 +78,13 @@ fun PsiElement?.pathname(): String? {
}
PluginLogger.debug("PsiClass's class:$name")
}

is PsiMethod -> {
val method = element.containingClass?.qualifiedName
PluginLogger.debug("PsiMethod's method:${element.name}#$method")
name = method
}

is PsiVariable -> {
name = element.type.canonicalText
// 去除泛型
Expand All @@ -95,6 +93,7 @@ fun PsiElement?.pathname(): String? {
PluginLogger.debug("PsiVariable's text: pre:${element.type.canonicalText} after:$name")
}
}

else -> {
PluginLogger.debug("cls = " + element.javaClass)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ CREATE INDEX JavaFileMapping_path ON JavaFileMapping(psiFile,version);
selectAll:
SELECT psiFile,version,path FROM JavaFileMapping;

count:
SELECT count(*) FROM JavaFileMapping;

getJavaFile:
SELECT path FROM JavaFileMapping WHERE psiFile=:file AND version <=:version ORDER BY version DESC LIMIT 1;
SELECT path FROM JavaFileMapping WHERE psiFile=:file AND version >=:version ORDER BY version ASC LIMIT 1;
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@ CREATE INDEX NativeFileMapping_path ON NativeFileMapping(psiFile,version);
selectAll:
SELECT psiFile,version,path FROM NativeFileMapping;

count:
SELECT count(*) FROM JavaFileMapping;

getNativeFile:
SELECT path FROM NativeFileMapping WHERE psiFile=:file AND version <=:version ORDER BY version DESC LIMIT 1;
SELECT path FROM NativeFileMapping WHERE psiFile=:file AND version <=:version ORDER BY version DESC LIMIT 1;
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,8 @@ CREATE INDEX NativeMapping_line ON NativeMethodMapping(file,jniMethod,nativeMeth
getNativeMethod:
SELECT * FROM NativeMethodMapping WHERE file=:key AND jniMethod=:method AND version <=:version ORDER BY version DESC LIMIT 1;

count:
SELECT count(*) FROM JavaFileMapping;

getNativeMethodByName:
SELECT * FROM NativeMethodMapping WHERE jniMethod=:name LIMIT 1;
SELECT * FROM NativeMethodMapping WHERE jniMethod=:name LIMIT 1;
15 changes: 12 additions & 3 deletions src/test/java/com/quickref/plugin/db/DBGenerator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,11 @@ class DBGenerator {
selectAll:
SELECT psiFile,version,path FROM JavaFileMapping;
count:
SELECT count(*) FROM JavaFileMapping;
getJavaFile:
SELECT path FROM JavaFileMapping WHERE psiFile=:file AND version <=:version ORDER BY version DESC LIMIT 1;
SELECT path FROM JavaFileMapping WHERE psiFile=:file AND version >=:version ORDER BY version ASC LIMIT 1;
""".trimIndent()

Expand All @@ -48,8 +51,11 @@ class DBGenerator {
selectAll:
SELECT psiFile,version,path FROM NativeFileMapping;
count:
SELECT count(*) FROM NativeFileMapping;
getNativeFile:
SELECT path FROM NativeFileMapping WHERE psiFile=:file AND version <=:version ORDER BY version DESC LIMIT 1;
SELECT path FROM NativeFileMapping WHERE psiFile=:file AND version >=:version ORDER BY version ASC LIMIT 1;
""".trimIndent()

val nativeMethodTable = """
Expand All @@ -65,7 +71,10 @@ class DBGenerator {
CREATE INDEX NativeMapping_line ON NativeMethodMapping(file,jniMethod,nativeMethod,version,jniLine,defLine);
getNativeMethod:
SELECT * FROM NativeMethodMapping WHERE file=:key AND jniMethod=:method AND version <=:version ORDER BY version DESC LIMIT 1;
SELECT * FROM NativeMethodMapping WHERE file=:key AND jniMethod=:method AND version >=:version ORDER BY version ASC LIMIT 1;
count:
SELECT count(*) FROM NativeMethodMapping;
getNativeMethodByName:
SELECT * FROM NativeMethodMapping WHERE jniMethod=:name LIMIT 1;
Expand Down

0 comments on commit 059645e

Please sign in to comment.