Skip to content

Commit aeec5de

Browse files
authored
Merge pull request #12 from Deftu/main
Fix reported issues
2 parents 0456cae + 69aa9db commit aeec5de

5 files changed

Lines changed: 42 additions & 30 deletions

File tree

src/main/kotlin/org/polyfrost/intelliprocessor/editor/PreprocessorNewLineHandler.kt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ class PreprocessorNewLineHandler : EnterHandlerDelegateAdapter(), DumbAware {
4444
}
4545

4646
val conditionals = findEnclosingConditionalBlock(comment)
47+
if (conditionals.isEmpty()) {
48+
return Result.Continue
49+
}
50+
4751
val currentVersion = MainProject.comparable(file)
4852
if (currentVersion != null && isInsideActiveBlock(conditionals, currentVersion)) {
4953
return Result.Continue
@@ -126,7 +130,6 @@ class PreprocessorNewLineHandler : EnterHandlerDelegateAdapter(), DumbAware {
126130
is PreprocessorDirective.If, is PreprocessorDirective.IfDef -> {
127131
if (nesting == 0) {
128132
block.add(0, directive)
129-
return block
130133
} else {
131134
nesting--
132135
}
@@ -143,7 +146,7 @@ class PreprocessorNewLineHandler : EnterHandlerDelegateAdapter(), DumbAware {
143146
sibling = sibling.prevSibling
144147
}
145148

146-
return emptyList()
149+
return block
147150
}
148151

149152
}

src/main/kotlin/org/polyfrost/intelliprocessor/editor/PreprocessorSyntaxHighlight.kt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ import com.intellij.openapi.project.DumbAware
1717
import com.intellij.openapi.project.Project
1818
import com.intellij.psi.PsiElement
1919
import com.intellij.psi.PsiFile
20+
import com.intellij.psi.PsiRecursiveElementWalkingVisitor
2021
import com.intellij.psi.impl.source.tree.PsiCommentImpl
2122
import org.polyfrost.intelliprocessor.ALLOWED_FILE_TYPES
2223
import org.polyfrost.intelliprocessor.Scope
2324
import java.util.ArrayDeque
24-
import java.util.Deque
2525
import java.util.Locale
2626

2727
val BOLD_ATTRIBUTE = TextAttributes(null, null, null, null, java.awt.Font.BOLD)
@@ -68,7 +68,13 @@ class PreprocessorSyntaxHighlight(private val project: Project) : HighlightVisit
6868
this.commenter = LanguageCommenters.INSTANCE.forLanguage(file.language)
6969
this.highlighter = SyntaxHighlighterFactory.getSyntaxHighlighter(file.language, file.project, file.virtualFile)
7070
this.stack = ArrayDeque()
71-
action.run()
71+
file.accept(object : PsiRecursiveElementWalkingVisitor() {
72+
override fun visitElement(element: PsiElement) {
73+
visit(element)
74+
super.visitElement(element)
75+
}
76+
})
77+
7278
return true
7379
}
7480

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<idea-plugin>
2+
<extensions defaultExtensionNs="com.intellij">
3+
<lang.foldingBuilder
4+
language="JAVA"
5+
implementationClass="org.polyfrost.intelliprocessor.editor.PreprocessorFolding"
6+
order="first"
7+
/>
8+
9+
<completion.contributor
10+
language="JAVA"
11+
implementationClass="org.polyfrost.intelliprocessor.editor.PreprocessorKeywordCompletion"
12+
/>
13+
14+
<lang.importOptimizer
15+
language="JAVA"
16+
implementationClass="org.polyfrost.intelliprocessor.PreprocessorImport"
17+
order="first"
18+
/>
19+
</extensions>
20+
</idea-plugin>

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

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<idea-plugin>
2+
<!-- Tell the IDE that we support Kotlin K2 mode -->
3+
<extensions defaultExtensionNs="org.jetbrains.kotlin">
4+
<supportsKotlinPluginMode supportsK2="true" />
5+
</extensions>
6+
27
<extensions defaultExtensionNs="com.intellij">
38
<lang.foldingBuilder
49
language="kotlin"
@@ -11,8 +16,4 @@
1116
implementationClass="org.polyfrost.intelliprocessor.editor.PreprocessorKeywordCompletion"
1217
/>
1318
</extensions>
14-
15-
<extensions defaultExtensionNs="org.jetbrains.kotlin">
16-
<supportsKotlinPluginMode supportsK2="true" />
17-
</extensions>
1819
</idea-plugin>

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

Lines changed: 4 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,17 @@
44
<vendor url="https://github.com/Polyfrost">Polyfrost</vendor>
55

66
<depends>com.intellij.modules.platform</depends>
7-
<depends>com.intellij.modules.java</depends>
7+
<depends optional="true" config-file="java-plugin.xml">com.intellij.modules.java</depends>
88
<depends optional="true" config-file="kotlin-plugin.xml">org.jetbrains.kotlin</depends>
99
<depends>com.intellij.gradle</depends>
1010

11+
<!-- General editor additions -->
1112
<extensions defaultExtensionNs="com.intellij">
12-
<lang.foldingBuilder
13-
language="JAVA"
14-
implementationClass="org.polyfrost.intelliprocessor.editor.PreprocessorFolding"
15-
order="first"
16-
/>
17-
1813
<highlightVisitor implementation="org.polyfrost.intelliprocessor.editor.PreprocessorSyntaxHighlight" />
19-
20-
<completion.contributor
21-
language="JAVA"
22-
implementationClass="org.polyfrost.intelliprocessor.editor.PreprocessorKeywordCompletion"
23-
/>
24-
2514
<enterHandlerDelegate implementation="org.polyfrost.intelliprocessor.editor.PreprocessorNewLineHandler" />
2615

27-
<lang.importOptimizer
28-
language="JAVA"
29-
implementationClass="org.polyfrost.intelliprocessor.PreprocessorImport"
30-
order="first"
31-
/>
32-
33-
<defaultLiveTemplates file="/liveTemplates/Preprocessor.xml" />
34-
35-
<notificationGroup displayType="BALLOON" id="Jump Failure" />
16+
<defaultLiveTemplates file="/liveTemplates/Preprocessor.xml" />
17+
<notificationGroup displayType="BALLOON" id="Jump Failure" />
3618
</extensions>
3719

3820
<actions>

0 commit comments

Comments
 (0)