Skip to content

Commit

Permalink
Remove usage of deprecated API
Browse files Browse the repository at this point in the history
  • Loading branch information
oowekyala committed Sep 19, 2020
1 parent f0b9e68 commit 1ab21da
Show file tree
Hide file tree
Showing 13 changed files with 52 additions and 63 deletions.
2 changes: 1 addition & 1 deletion changelog.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p>What's new:
<ul>
<li>Parser support for annotations on production parameters (#16)
<li>Upgrade to Intellij 2020.1
<li>Upgrade to Intellij 2020.1 as minimum version
</ul>


Expand Down
16 changes: 8 additions & 8 deletions sandbox/Java.jjt
Original file line number Diff line number Diff line change
Expand Up @@ -2000,12 +2000,6 @@ void TypeAnnotationList() #void:
(TypeAnnotation())*
}

void AnnotatedType() #void:
{}
{
TypeAnnotationList() Type()
}


void AnnotatedRefType() #void:
{}
Expand Down Expand Up @@ -2515,6 +2509,12 @@ void MemberSelector() #void :
| ("." {jjtree.extendLeft();} <IDENTIFIER> {setLastTokenImage(jjtThis);}) #FieldAccess
}

void AnnotatedType() #void:
{}
{
TypeAnnotationList() AnnotatedType()
}

void MethodReference(): // LHS is injected
{checkForBadMethodReferenceUsage();}
{
Expand Down Expand Up @@ -3122,8 +3122,8 @@ void AnnotationTypeMemberDeclaration():
modifiers = Modifiers()
(
LOOKAHEAD(Type() <IDENTIFIER> "(") AnnotationMethodDeclaration(modifiers)
|
ClassOrInterfaceDeclaration(modifiers)
//|
// ClassOrInterfaceDeclaration(modifiers)
|
LOOKAHEAD(3) EnumDeclaration(modifiers)
|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@ import com.intellij.psi.PsiFile
* @author Clément Fournier
* @since 1.0
*/
abstract class JccTemplateContextBase(id: String,
displayName: String,
baseContextType: Class<out TemplateContextType>)
: TemplateContextType("JAVACC_$id", displayName, baseContextType) {
abstract class JccTemplateContextBase(
id: String,
displayName: String,
baseContextType: Class<out TemplateContextType>
) : TemplateContextType("JAVACC_$id", displayName, baseContextType) {

override fun isInContext(file: PsiFile, offset: Int): Boolean {
return file is JccFile && isInContext(file, offset)
Expand Down

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/kotlin/com/github/oowekyala/ijcc/JccFileTypeFactory.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ object JccUsageTypeProvider : UsageTypeProviderEx {


override fun getUsageType(element: PsiElement): UsageType? =
JccUsageTypeProvider.getUsageType(element, UsageTarget.EMPTY_ARRAY)
getUsageType(element, UsageTarget.EMPTY_ARRAY)

object JccUsageTypes {

val NONTERMINAL_REFERENCE = UsageType("Non-terminal reference")
val JJTREE_NODE_PARTIAL_DECLARATION = UsageType("JJTree node partial declaration")
val IMPLICIT_STRING_TOKEN_REFERENCE = UsageType("String token implicit reference")
val EXPLICIT_TOKEN_REFERENCE = UsageType("Token explicit reference")
val NONTERMINAL_REFERENCE = UsageType { "Non-terminal reference" }
val JJTREE_NODE_PARTIAL_DECLARATION = UsageType { "JJTree node partial declaration" }
val IMPLICIT_STRING_TOKEN_REFERENCE = UsageType { "String token implicit reference" }
val EXPLICIT_TOKEN_REFERENCE = UsageType { "Token explicit reference" }

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ object JccRecursiveProductionLineMarkerProvider : LineMarkerProviderDescriptor()
element.nameIdentifier.leaf,
element.nameIdentifier.textRange,
JccIcons.GUTTER_RECURSION,
Pass.LINE_MARKERS,
FunctionUtil.constant("Recursive call"),
null,
GutterIconRenderer.Alignment.RIGHT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import com.intellij.psi.PsiResolveHelper
* @author Clément Fournier
* @since 1.0
*/
class InjectedJavaHighlightVisitor(private val resolveHelper: PsiResolveHelper) : HighlightVisitorImpl(resolveHelper) {
class InjectedJavaHighlightVisitor : HighlightVisitorImpl() {

override fun suitableForFile(file: PsiFile): Boolean =
InjectedLanguageManager.getInstance(file.project).let { manager ->
Expand All @@ -24,6 +24,6 @@ class InjectedJavaHighlightVisitor(private val resolveHelper: PsiResolveHelper)
}

override fun clone(): HighlightVisitorImpl =
InjectedJavaHighlightVisitor(resolveHelper)
InjectedJavaHighlightVisitor()

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ open class JccHighlightVisitor : JccVisitor(), HighlightVisitor, DumbAware {

override fun visit(element: PsiElement) = element.accept(this)

override fun order(): Int = 0

private var myHolderImpl: HighlightInfoHolder? = null
private val myHolder: HighlightInfoHolder // never null during analysis
get() = myHolderImpl!!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package com.github.oowekyala.ijcc.ide.intentions

import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ModalityState
import com.intellij.openapi.application.ReadAction
import com.intellij.openapi.application.TransactionGuard
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.editor.event.DocumentEvent
import com.intellij.openapi.editor.event.DocumentListener
import com.intellij.openapi.editor.ex.EditorEx
Expand Down Expand Up @@ -78,14 +80,16 @@ class CheckTokenRegexForm(private val regex: Regex,
}

fun update() {
val transactionId = TransactionGuard.getInstance().contextTransaction

val modalityState = ModalityState.defaultModalityState()
updater!!.cancelAllRequests()
if (!updater!!.isDisposed) {
updater!!.addRequest(
{
val result = isMatchingText(regex, mySampleText.text)
TransactionGuard.getInstance()
.submitTransaction(project, transactionId, Runnable { setBalloonState(result) })
invokeLater(modalityState) {
setBalloonState(result)
}
}, 200
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ object HtmlUtil {
@Language("HTML")
fun link(target: String, text: String) = "<a href=\"$target\">$text</a>"

fun escapeHtml(text: String) = StringUtil.escapeXml(text)
fun escapeHtml(text: String) = StringUtil.escapeXmlEntities(text)

/**
* Kotlin wrapper around [DocumentationManager.createHyperlink]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,11 @@ object JccRenameProcessor : RenamePsiElementProcessor() {
}
}

override fun findReferences(element: PsiElement): MutableCollection<PsiReference> {
override fun findReferences(
element: PsiElement,
searchScope: SearchScope,
searchInCommentsAndStrings: Boolean
): MutableCollection<PsiReference> {

val file = element.containingFile

Expand Down
21 changes: 18 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<!-- @formatter:off -->
<idea-plugin>
<idea-plugin require-restart="false">
<id>com.github.oowekyala.javacc</id>
<name>JavaCC</name>
<description><![CDATA[
Expand Down Expand Up @@ -74,7 +74,22 @@
implementationClass="com.github.oowekyala.ijcc.ide.highlight.JavaccSyntaxHighlighterFactory"/>

<!-- LANGUAGE -->
<fileTypeFactory implementation="com.github.oowekyala.ijcc.JavaccFileTypeFactory"/>

<fileType name="JAVACC_GRAMMAR"
language="JavaCC"
extensions="jj"
implementationClass="com.github.oowekyala.ijcc.JavaccFileType" />

<fileType name="JJTREE_GRAMMAR"
language="JavaCC"
extensions="jjt"
implementationClass="com.github.oowekyala.ijcc.JjtreeFileType" />

<fileType name="JAVACC21_GRAMMAR"
language="JavaCC"
extensions="javacc"
implementationClass="com.github.oowekyala.ijcc.Javacc21FileType" />

<lang.parserDefinition
language="JavaCC" implementationClass="com.github.oowekyala.ijcc.JavaccParserDefinition"/>

Expand All @@ -98,7 +113,7 @@

<!-- LIVE TEMPLATES -->

<defaultLiveTemplatesProvider implementation="com.github.oowekyala.ijcc.JavaccTemplatesProvider"/>
<defaultLiveTemplates file="/com/github/oowekyala/ijcc/liveTemplates/JavaCC" />
<liveTemplateContext implementation="com.github.oowekyala.ijcc.JccTemplateContextBase$Companion$Generic"/>
<liveTemplateContext implementation="com.github.oowekyala.ijcc.JccTemplateContextBase$Companion$OptionsCtx"/>
<liveTemplateContext implementation="com.github.oowekyala.ijcc.JccTemplateContextBase$Companion$ParserDeclCtx"/>
Expand Down

0 comments on commit 1ab21da

Please sign in to comment.