-
Notifications
You must be signed in to change notification settings - Fork 3
/
plugin-dev.ad
129 lines (83 loc) · 3.93 KB
/
plugin-dev.ad
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
= Plugin Development
:toc:
- https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started.html
- link:https://intellij-support.jetbrains.com/hc/en-us/community/topics/200366979-IntelliJ-IDEA-Open-API-and-Plugin-Development[IntelliJ IDEA Open API and Plugin Development – IDEs Support (IntelliJ Platform) | JetBrains]
- link:https://intellij-support.jetbrains.com/hc/en-us/community/posts/360006494439--ANN-JetBrains-Platform-Slack-for-plugin-developers[[ANN\] JetBrains Platform Slack for plugin developers – IDEs Support (IntelliJ Platform) | JetBrains]
** `#intellij-platform`. Plugin development for IntelliJ Platform.
** TODO read all
- link:https://github.com/JetBrains/intellij-sdk-docs/tree/master/code_samples[intellij-sdk-docs/code_samples at master · JetBrains/intellij-sdk-docs]
** TODO read all
`VirtualFile` represents real file, there may exist multiple VirtualFile, but hashCode is equal.
`com.intellij.testFramework.LightVirtualFile`: In-memory implementation of `VirtualFile`.
fileType
com.intellij.psi.impl.file.impl.FileManagerImpl.createFileViewProvider
com.intellij.openapi.fileTypes.impl.FileTypeManagerImpl.getFileTypeByFile(com.intellij.openapi.vfs.VirtualFile, byte[])
== Deployment / Publishing
- link:https://github.com/JetBrains/intellij-plugin-verifier[JetBrains/intellij-plugin-verifier: Compatibility verification tool for IntelliJ Platform plugins]
== PSI
PsiFile
- Groovy: GroovyFile
== Snippets
[source,java]
.com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
----
private static void copyContent(File sourceFile, VirtualFile targetFile) {
try {
WriteAction.runAndWait(() -> {
targetFile.setBinaryContent(FileUtil.loadFileBytes(sourceFile));
// update the document now, otherwise MemoryDiskConflictResolver will do it later at unexpected moment of time
FileDocumentManager.getInstance().reloadFiles(targetFile);
});
}
catch (IOException e) {
throw new RuntimeException(e);
}
}
----
== Groovy
`plugins/groovy/src/META-INF/plugin.xml`
Groovy Test, no entry for groovy
FileType type = myPatternsTable.findAssociatedFileType(fileName);
filled by platform/platform-resources/src/defaultFileTypes.xml
no groovy
is added by
----
extension = {FileTypeExtensionPoint@8228}
filetype = "Groovy"
implementationClass = "org.jetbrains.plugins.groovy.highlighter.GroovyTodoIndexer"
pluginDescriptor = {IdeaPluginDescriptorImpl@8230} "PluginDescriptor(name=Groovy, classpath=/home/mhofmannsobik/.gradle/caches/modules-2/files-2.1/com.jetbrains.intellij.idea/ideaIC/2019.3.3/4c54deba9ff34a615b3072cd2def3558ff462987/ideaIC-2019.3.3/plugins/Groovy)"
instance = null
----
Groovy Plugin
org.jetbrains.plugins.groovy.GroovyFileType
register
see link:https://www.jetbrains.org/intellij/sdk/docs/tutorials/custom_language_support/language_and_filetype.html[2. Language and File Type]
[source, xml]
.plugins/groovy/src/META-INF/plugin.xml
----
<extensions defaultExtensionNs="com.intellij">
<fileType name="Groovy" language="Groovy" extensions="groovy;gy" hashBangs="groovy"
implementationClass="org.jetbrains.plugins.groovy.GroovyFileType" fieldName="GROOVY_FILE_TYPE"/>
----
=== PSI Snippets
[source,java]
.method and annotations
----
method.name // "beforeClass"
// works in test and production
method.annotations.first().text // "@BeforeClass"
// works only in production otherwise null
method.modifierList?.findAnnotation("org.junit.BeforeClass") // {GrAnnotationImpl@45019} "Annotation"
// same with helper method
PsiImplUtil.getAnnotation(method, "org.junit.BeforeClass")
GrModifierListImpl
+ addAnnotation
// in test is qualifiedName empty (this = GrAnnotationImpl)
this.qualifiedName
----
=== Inspections
`<localInspection>`
eigener Groovy Visitor
GroovyListGetCanBeKeyedAccessInspection
durch `registerMethodCallError` wird Fehler festgehalten -> weitere `register*` Methoden
Fix durch `GroovyFix` mit `doFix()` was dann `replaceExpression` aufruft