Skip to content

Commit e61712c

Browse files
committed
more warnings
1 parent 309eb80 commit e61712c

File tree

11 files changed

+38
-42
lines changed

11 files changed

+38
-42
lines changed

changelog.html

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
<p>What's new:
2-
3-
<ul>
4-
<li>TODO</li>
5-
</ul>
6-
71
<p>What's changed:
2+
83
<ul>
9-
<li>TODO</li>
4+
<li>Bump required IntelliJ version to 2023.1</li>
105
</ul>
116

127
<p>What's fixed:
138
<ul>
149
<li>#25 - NoSuchElementException: Sequence contains no element matching the predicate</li>
1510
<li>#20 - Undefined token errors with user token manager. Undefined tokens are now ignored if the USER_TOKEN_MANAGER option is present.</li>
16-
<li>#27 - INCLUDE is not lexed as an identifier</li>
11+
<li>#27 - INCLUDE is not lexed as an identifier anymore.</li>
12+
<li>Dependency updates</li>
1713
</ul>

gradle.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ kotlin.code.style=official
22
org.gradle.jvmargs=-Xmx2G
33
#https://plugins.jetbrains.com/docs/intellij/using-kotlin.html#incremental-compilation
44
kotlin.incremental.useClasspathSnapshot=false
5+
kotlin.stdlib.default.dependency = false

src/main/kotlin/com/github/oowekyala/ijcc/JavaccTemplateContextType.kt

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ package com.github.oowekyala.ijcc
22

33
import com.github.oowekyala.ijcc.lang.psi.JccFile
44
import com.intellij.codeInsight.template.EverywhereContextType
5+
import com.intellij.codeInsight.template.TemplateActionContext
56
import com.intellij.codeInsight.template.TemplateContextType
6-
import com.intellij.psi.PsiFile
77

88
/**
99
* Context for live templates.
@@ -17,49 +17,49 @@ abstract class JccTemplateContextBase(
1717
baseContextType: Class<out TemplateContextType>
1818
) : TemplateContextType("JAVACC_$id", displayName, baseContextType) {
1919

20-
override fun isInContext(file: PsiFile, offset: Int): Boolean {
21-
return file is JccFile && isInContext(file, offset)
22-
20+
override fun isInContext(ctx: TemplateActionContext): Boolean {
21+
return ctx.file is JccFile
22+
&& isInJccContext(ctx.file as JccFile, ctx)
2323
}
2424

25-
abstract fun isInContext(file: JccFile, offset: Int): Boolean
25+
abstract fun isInJccContext(file: JccFile, ctx: TemplateActionContext): Boolean
2626

2727
companion object {
2828

2929
class Generic : JccTemplateContextBase("CODE", JavaccLanguage.displayName, EverywhereContextType::class.java) {
3030

31-
override fun isInContext(file: JccFile, offset: Int): Boolean = true
31+
override fun isInJccContext(file: JccFile, ctx: TemplateActionContext): Boolean = true
3232
}
3333

3434
class OptionsCtx : JccTemplateContextBase("OPTIONS", "Options declaration", Generic::class.java) {
3535

3636

37-
override fun isInContext(file: JccFile, offset: Int): Boolean {
37+
override fun isInJccContext(file: JccFile, ctx: TemplateActionContext): Boolean {
3838

3939
val pdeclOffset = file.parserDeclaration?.textOffset ?: Int.MAX_VALUE
4040

41-
return file.options == null && offset < pdeclOffset
41+
return file.options == null && ctx.endOffset < pdeclOffset
4242
}
4343
}
4444

4545
class ParserDeclCtx : JccTemplateContextBase("PARSER_DECL", "Parser declaration", Generic::class.java) {
4646

4747

48-
override fun isInContext(file: JccFile, offset: Int): Boolean {
48+
override fun isInJccContext(file: JccFile, ctx: TemplateActionContext): Boolean {
4949

5050
val optionsEnd = file.options?.let { it.textOffset + it.textLength } ?: 0
5151

52-
return file.parserDeclaration == null && offset > optionsEnd
52+
return file.parserDeclaration == null && ctx.startOffset > optionsEnd
5353
}
5454
}
5555

5656
class ProductionCtx :
5757
JccTemplateContextBase("PRODUCTION_DECLS", "Production declarations", Generic::class.java) {
5858

59-
override fun isInContext(file: JccFile, offset: Int): Boolean {
59+
override fun isInJccContext(file: JccFile, ctx: TemplateActionContext): Boolean {
6060
val parserEnd = file.parserDeclaration?.let { it.textOffset + it.textLength } ?: 0
6161

62-
return offset > parserEnd
62+
return ctx.startOffset > parserEnd
6363
}
6464
}
6565
}

src/main/kotlin/com/github/oowekyala/ijcc/ide/quickdoc/JccDocumentationProvider.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import com.intellij.psi.PsiManager
1414
* @author Clément Fournier
1515
* @since 1.0
1616
*/
17-
object JccDocumentationProvider : AbstractDocumentationProvider() {
17+
class JccDocumentationProvider : AbstractDocumentationProvider() {
1818

1919
private val stopTypes = arrayOf(
2020
JccProduction::class.java,

src/main/kotlin/com/github/oowekyala/ijcc/lang/psi/JavaccAstFactory.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package com.github.oowekyala.ijcc.lang.psi
22

33
import com.intellij.lang.ASTFactory
44
import com.intellij.lang.DefaultASTFactory
5-
import com.intellij.openapi.components.ServiceManager
5+
import com.intellij.openapi.application.ApplicationManager
66
import com.intellij.psi.impl.source.tree.CompositeElement
77
import com.intellij.psi.impl.source.tree.FileElement
88
import com.intellij.psi.impl.source.tree.LeafElement
@@ -16,19 +16,21 @@ import com.intellij.psi.tree.IFileElementType
1616
* @author Clément Fournier
1717
* @since 1.0
1818
*/
19-
object JavaccAstFactory : ASTFactory() {
19+
class JavaccAstFactory : ASTFactory() {
2020

21-
private val myDefaultASTFactory = ServiceManager.getService(DefaultASTFactory::class.java)
22-
23-
override fun createComposite(type: IElementType): CompositeElement? {
21+
override fun createComposite(type: IElementType): CompositeElement {
2422
return if (type is IFileElementType) {
2523
FileElement(type, null)
2624
} else CompositeElement(type)
2725
}
2826

29-
override fun createLeaf(type: IElementType, text: CharSequence): LeafElement? {
27+
override fun createLeaf(type: IElementType, text: CharSequence): LeafElement {
3028
return when {
31-
JccTypesExt.CommentTypeSet.contains(type) -> myDefaultASTFactory.createComment(type, text)
29+
JccTypesExt.CommentTypeSet.contains(type) -> {
30+
val default = ApplicationManager.getApplication().getService(DefaultASTFactory::class.java)
31+
default.createComment(type, text)
32+
}
33+
3234
else -> LeafPsiElement(type, text)
3335
}
3436
}

src/main/kotlin/com/github/oowekyala/ijcc/lang/psi/impl/JccElementFactory.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ open class JccElementFactory(val project: Project) {
3131

3232

3333
fun insertEolCommentBefore(anchor: PsiElement, name: String) {
34-
val parserFacade = PsiParserFacade.SERVICE.getInstance(project)
34+
val parserFacade = PsiParserFacade.getInstance(project)
3535

3636
val comment = parserFacade.createLineCommentFromText(JavaccFileType(), name)
3737
anchor.parent.addBefore(comment, anchor)
@@ -141,7 +141,7 @@ open class JccElementFactory(val project: Project) {
141141
.let { it as JccBnfProduction }
142142
.expansion
143143
.let { it as JccAssignedExpansionUnit }
144-
.let { it.javaAssignmentLhs }
144+
.javaAssignmentLhs
145145
}
146146

147147

src/main/kotlin/com/github/oowekyala/ijcc/lang/psi/stubs/StubIndexService.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
package com.github.oowekyala.ijcc.lang.psi.stubs
22

3-
import com.intellij.openapi.components.ServiceManager
3+
import com.intellij.openapi.application.ApplicationManager
44
import com.intellij.psi.stubs.IndexSink
55

66
/**
@@ -15,7 +15,8 @@ open class StubIndexService protected constructor() {
1515

1616
companion object {
1717
@JvmStatic
18-
fun getInstance(): StubIndexService = ServiceManager.getService(StubIndexService::class.java) ?: NO_INDEX
18+
fun getInstance(): StubIndexService =
19+
ApplicationManager.getApplication().getService(StubIndexService::class.java) ?: NO_INDEX
1920

2021
private val NO_INDEX = StubIndexService()
2122
}

src/main/kotlin/com/github/oowekyala/ijcc/settings/JavaccAppSettingsService.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.github.oowekyala.ijcc.settings
22

3+
import com.intellij.openapi.application.ApplicationManager
34
import com.intellij.openapi.components.PersistentStateComponent
45
import com.intellij.openapi.components.ServiceManager
56
import com.intellij.openapi.components.State
@@ -12,7 +13,7 @@ import com.intellij.openapi.components.Storage
1213
* @since 1.0
1314
*/
1415
@State(name = "JavaccAppSettings", storages = [Storage("javacc-plugin.xml")])
15-
object JavaccAppSettingsService : PersistentStateComponent<JccGlobalSettingsState> {
16+
class JavaccAppSettingsService : PersistentStateComponent<JccGlobalSettingsState> {
1617

1718
override fun loadState(state: JccGlobalSettingsState) {
1819
myState = state.copy()
@@ -28,7 +29,8 @@ object JavaccAppSettingsService : PersistentStateComponent<JccGlobalSettingsStat
2829
* App-level settings of the plugin.
2930
*/
3031
val globalPluginSettings: JccGlobalSettingsState
31-
get() = ServiceManager.getService(JavaccAppSettingsService::class.java).state
32+
get() = ApplicationManager.getApplication()
33+
.getService(JavaccAppSettingsService::class.java).state
3234

3335

3436
data class JccGlobalSettingsState(

src/main/kotlin/com/github/oowekyala/ijcc/settings/JavaccProjectSettingsService.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ interface JavaccProjectSettingsService {
4848

4949
/** Gets the instance of [JavaccProjectSettingsService] for this project. */
5050
val Project.javaccSettings: JavaccProjectSettingsService
51-
get() = getService(this, JavaccProjectSettingsService::class.java)
51+
get() = getService(JavaccProjectSettingsService::class.java)
5252
?: error("Failed to get JavaccProjectSettingsService for $this")
5353

5454
/** Gets the project-specific settings of the plugin. */

src/main/kotlin/com/github/oowekyala/ijcc/settings/PluginSettingsPage.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class PluginSettingsPage(initialState: JccSettingsState) : Disposable {
6666

6767
@Language("HTML")
6868
private val injectionLabelText = """
69-
<html lang='en'>
69+
<html>
7070
Tune the level of sophistication of the Java injection in Java code fragments embedded in a grammar.
7171
By default, this is set to <b>${JavaccProjectSettingsService.defaultInjectionSupportLevel.displayName}</b>,
7272
which offers great code insight for a reasonable performance trade-off. The level <b>${InjectionSupportLevel.FULL.displayName}</b>

0 commit comments

Comments
 (0)