mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
syntax: add WhitespaceOrCommentBindingPolicy and OpaqueElementPolicy to LanguageSyntaxDefinition
GitOrigin-RevId: 11481d8826e981dd2a0484ea23a8c5b59af48216
This commit is contained in:
committed by
intellij-monorepo-bot
parent
adfad913d3
commit
a50b4cd5c0
+1
-5
@@ -7,8 +7,4 @@ import com.intellij.platform.syntax.lexer.Lexer
|
||||
import com.intellij.platform.syntax.LanguageSyntaxDefinition
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
|
||||
internal class JavaSyntaxDefinitionExtension : LanguageSyntaxDefinition {
|
||||
override fun getLexer(): Lexer = JavaSyntaxDefinition.createLexer(LanguageLevel.HIGHEST)
|
||||
|
||||
override fun getCommentTokens(): SyntaxElementTypeSet = JavaSyntaxDefinition.commentSet
|
||||
}
|
||||
internal class JavaSyntaxDefinitionExtension : LanguageSyntaxDefinition by JavaSyntaxDefinition
|
||||
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.java.syntax
|
||||
|
||||
import com.intellij.java.syntax.element.JavaWhitespaceOrCommentBindingPolicy
|
||||
import com.intellij.java.syntax.element.JavaDocSyntaxElementType
|
||||
import com.intellij.java.syntax.element.JavaSyntaxTokenType
|
||||
import com.intellij.java.syntax.lexer.JavaDocLexer
|
||||
@@ -11,6 +12,7 @@ import com.intellij.platform.syntax.SyntaxElementTypeSet
|
||||
import com.intellij.platform.syntax.SyntaxLanguage
|
||||
import com.intellij.platform.syntax.element.SyntaxTokenTypes
|
||||
import com.intellij.platform.syntax.lexer.Lexer
|
||||
import com.intellij.platform.syntax.parser.WhitespaceOrCommentBindingPolicy
|
||||
import com.intellij.platform.syntax.syntaxElementTypeSetOf
|
||||
import com.intellij.pom.java.LanguageLevel
|
||||
import kotlin.jvm.JvmStatic
|
||||
@@ -40,4 +42,6 @@ object JavaSyntaxDefinition : LanguageSyntaxDefinition {
|
||||
override fun getCommentTokens(): SyntaxElementTypeSet = commentSet
|
||||
|
||||
override fun getWhitespaceTokens(): SyntaxElementTypeSet = whitespaces
|
||||
|
||||
override fun getWhitespaceOrCommentBindingPolicy(): WhitespaceOrCommentBindingPolicy = JavaWhitespaceOrCommentBindingPolicy
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ import com.intellij.platform.syntax.element.SyntaxTokenTypes
|
||||
import com.intellij.platform.syntax.parser.WhitespaceOrCommentBindingPolicy
|
||||
import com.intellij.platform.syntax.syntaxElementTypeSetOf
|
||||
|
||||
internal object JavaBindingPolicy : WhitespaceOrCommentBindingPolicy {
|
||||
internal object JavaWhitespaceOrCommentBindingPolicy : WhitespaceOrCommentBindingPolicy {
|
||||
private val leftBoundTokens = syntaxElementTypeSetOf(
|
||||
SyntaxTokenTypes.ERROR_ELEMENT, // todo move somewhere?
|
||||
JavaSyntaxElementType.TYPE_PARAMETER_LIST,
|
||||
@@ -3,6 +3,8 @@
|
||||
*:com.intellij.platform.syntax.LanguageSyntaxDefinition
|
||||
- a:getCommentTokens():com.intellij.platform.syntax.SyntaxElementTypeSet
|
||||
- a:getLexer():com.intellij.platform.syntax.lexer.Lexer
|
||||
- getOpaqueElementPolicy():com.intellij.platform.syntax.parser.OpaqueElementPolicy
|
||||
- getWhitespaceOrCommentBindingPolicy():com.intellij.platform.syntax.parser.WhitespaceOrCommentBindingPolicy
|
||||
- getWhitespaceTokens():com.intellij.platform.syntax.SyntaxElementTypeSet
|
||||
*f:com.intellij.platform.syntax.LazyLexingContext
|
||||
- <init>(com.intellij.platform.syntax.tree.SyntaxNode,com.intellij.platform.syntax.CancellationProvider):V
|
||||
|
||||
+14
@@ -3,6 +3,8 @@ package com.intellij.platform.syntax
|
||||
|
||||
import com.intellij.platform.syntax.element.SyntaxTokenTypes
|
||||
import com.intellij.platform.syntax.lexer.Lexer
|
||||
import com.intellij.platform.syntax.parser.OpaqueElementPolicy
|
||||
import com.intellij.platform.syntax.parser.WhitespaceOrCommentBindingPolicy
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
@@ -28,4 +30,16 @@ interface LanguageSyntaxDefinition {
|
||||
* The set of comment token types of the language
|
||||
*/
|
||||
fun getCommentTokens(): SyntaxElementTypeSet
|
||||
|
||||
/**
|
||||
* Controls whitespace balancing behavior of [com.intellij.platform.syntax.parser.SyntaxTreeBuilder].
|
||||
* For more details see [com.intellij.platform.syntax.parser.WhitespaceOrCommentBindingPolicy]
|
||||
*/
|
||||
fun getWhitespaceOrCommentBindingPolicy(): WhitespaceOrCommentBindingPolicy? = null
|
||||
|
||||
/**
|
||||
* The policy for handling opaque elements in the syntax tree.
|
||||
* For more details see [com.intellij.platform.syntax.parser.OpaqueElementPolicy]
|
||||
*/
|
||||
fun getOpaqueElementPolicy(): OpaqueElementPolicy? = null
|
||||
}
|
||||
+1
-1
@@ -5,7 +5,7 @@ import com.intellij.platform.syntax.SyntaxElementType
|
||||
import org.jetbrains.annotations.ApiStatus
|
||||
|
||||
/**
|
||||
* this policy allows overriding the text of an element type
|
||||
* This policy allows overriding the text of an element type
|
||||
*
|
||||
* @link [com.intellij.lang.TokenWrapper] class
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user