Skip to content

Commit 1f2aad0

Browse files
committed
fix(main): 修复单词字典错误;暴露索引异常,方便提交BUG
1 parent a96a106 commit 1f2aad0

7 files changed

Lines changed: 24 additions & 16 deletions

File tree

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ IntelliJ IDEA / PhpStorm Hyperf Plugin
1818

1919
# Feature
2020
## 基础适配
21-
* 重复类声明:当AOP类产生代理文件,编辑器异常报错屏蔽。如`App_User.proxy.php 处存在类 'User' 的其他声明`错误将不再显示
21+
* 重复类声明:当AOP类产生代理文件,屏蔽重复类声明的异常报错。如`App_User.proxy.php 处存在类 'User' 的其他声明`错误将不再显示
22+
* 拼写检查:屏蔽框架常用词如`hyperf``swoole``jsonrpc`等等单词的拼写错误警告。如有遗漏或补充,请提交Issue给我。
2223

2324
## debug
2425
本插件会定位`模板文件``代理文件`的断点所在行第一个`ast节点`,计算出该节点的树路径相对偏移量,得出对应文件的断点位置,尽可能让`hyperf`得以在`模板文件`内调试

src/main/java/io/maliboot/www/hyperf/extension/dic/HyperfDictionaryProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import com.intellij.spellchecker.BundledDictionaryProvider
44

55
class HyperfDictionaryProvider: BundledDictionaryProvider {
66
override fun getBundledDictionaries(): Array<String> {
7-
return arrayOf("magento.dic")
7+
return arrayOf("hyperf.dic")
88
}
99
}

src/main/java/io/maliboot/www/hyperf/lombok/codeInsight/MethodDocInlayActionHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ class MethodDocInlayActionHandler: InlayActionHandler {
1212
override fun handleClick(editor: Editor, payload: InlayActionPayload) {
1313
payload as PsiPointerInlayActionPayload
1414
val fakePsiMember = payload.pointer.element as? FakePsiPhpClassMember ?: return
15-
HintManagerImpl.getInstanceImpl().showInformationHint(editor, fakePsiMember.getDocumentation(), HintManager.RIGHT_UNDER)
15+
HintManagerImpl.getInstanceImpl().showInformationHint(editor, fakePsiMember.getDocumentation())
1616
}
1717
}

src/main/java/io/maliboot/www/hyperf/lombok/index/CustomMemberPsiGist.kt

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,7 @@ class CustomMemberPsiGist {
242242
}
243243

244244
fun getCustomMembers(psiFile: PsiFile): Map<String, MyCustomMember> {
245-
try {
246-
return resolveFromIndexValue(psiFile)
247-
} catch (processCancel: ProcessCanceledException) {
248-
throw processCancel
249-
} catch (e: Exception) {
250-
logger.warn("索引异常,请报告给开发者")
251-
logger.warn(e.message)
252-
}
253-
return emptyMap()
245+
return resolveFromIndexValue(psiFile)
254246
}
255247

256248
fun getCustomMembers(file: VirtualFile, project: Project): Map<String, MyCustomMember> {

src/main/java/io/maliboot/www/hyperf/lombok/typeProvider/CustomMemberTypeProvider.kt

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package io.maliboot.www.hyperf.lombok.typeProvider
22

33
import com.intellij.openapi.application.ReadAction
4+
import com.intellij.openapi.diagnostic.Logger
5+
import com.intellij.openapi.project.DumbService
46
import com.intellij.openapi.project.Project
57
import com.intellij.openapi.util.text.Strings
68
import com.intellij.psi.PsiElement
@@ -18,17 +20,23 @@ class CustomMemberTypeProvider : PhpTypeProvider4 {
1820

1921
companion object {
2022
const val ID = ''
23+
24+
private val logger: Logger = Logger.getInstance(CustomMemberTypeProvider::class.java)
2125
}
2226

2327
override fun getKey(): Char {
2428
return ID
2529
}
2630

2731
override fun getType(p0: PsiElement?): PhpType? {
28-
if (p0 == null || !p0.containingFile.isExcludeDir()) {
32+
if (p0 == null || DumbService.getInstance(p0.project).isDumb || !p0.containingFile.isExcludeDir()) {
2933
return null
3034
}
3135

36+
return tryType(p0)
37+
}
38+
39+
private fun tryType(p0: PsiElement): PhpType? {
3240
var isFieldReference = false
3341
val reference: MemberReference = when (p0) {
3442
is FieldReference -> {
@@ -44,14 +52,20 @@ class CustomMemberTypeProvider : PhpTypeProvider4 {
4452
} ?: return null
4553

4654
val classReference = reference.classReference ?: return null
47-
var classRefFQN = classReference.type.toString()
55+
val classRefType = classReference.type.toString()
56+
var classRefFQN = classRefType
4857
.removeSuffix("|?")
4958
.split("|")
5059
.last()
5160
.substringAfter("\\")
5261
.replace(")", "")
5362
if (classRefFQN.contains("(")) {
54-
classRefFQN = classRefFQN.substring(classRefFQN.lastIndexOf("(") + 2)
63+
classRefFQN = classRefFQN.substring(classRefFQN.lastIndexOf("(") + 1)
64+
if (!classRefFQN.startsWith("\\")) {
65+
logger.warn("类型解析异常:$classRefType")
66+
return null
67+
}
68+
classRefFQN = classRefFQN.substring(1)
5569
}
5670
when (classReference) {
5771
is Variable, is MemberReference, is FunctionReference -> {

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
implementationClass="io.maliboot.www.hyperf.lombok.codeInsight.MethodInlayProvider"
2727
language="PHP"
2828
bundle="messages.HyperfBundle"
29-
group="lombok.method.inlay.group"
29+
group="TYPES_GROUP"
3030
isEnabledByDefault="true"
3131
nameKey="lombok.method.inlay.name"
3232
providerId="lombok.method.inlay.provider.id"/>

src/main/java/io/maliboot/www/hyperf/extension/dic/hyperf.dic renamed to src/main/resources/io/maliboot/www/hyperf/extension/dic/hyperf.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
hyperf
2+
jsonrpc
23
jsonrpc-http
34
swoole
45
maliboot

0 commit comments

Comments
 (0)