Skip to content

Commit

Permalink
Rename type_identifier to identifier_declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
jzbrooks committed Jan 6, 2022
1 parent f9d3aab commit 8babc33
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 65 deletions.
40 changes: 20 additions & 20 deletions src/main/gen/io/github/facilityapi/intellij/parser/FsdParser.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions src/main/gen/io/github/facilityapi/intellij/psi/FsdTypes.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import com.intellij.psi.PsiComment
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiWhiteSpace
import com.intellij.psi.presentation.java.SymbolPresentationUtil
import io.github.facilityapi.intellij.psi.FsdTypeIdentifier
import io.github.facilityapi.intellij.psi.FsdIdentifierDeclaration

class FsdDocumentationProvider : AbstractDocumentationProvider() {
override fun generateDoc(element: PsiElement?, originalElement: PsiElement?): String? {
if (element is FsdTypeIdentifier) {
if (element is FsdIdentifierDeclaration) {
return render(
element,
element.parent.firstChild.text, // data, method, enum, errors
Expand All @@ -21,7 +21,7 @@ class FsdDocumentationProvider : AbstractDocumentationProvider() {
return super.generateDoc(element, originalElement)
}

private fun render(type: FsdTypeIdentifier, kind: String, file: String, docComment: String) = buildString {
private fun render(type: FsdIdentifierDeclaration, kind: String, file: String, docComment: String) = buildString {
append(DocumentationMarkup.DEFINITION_START)
append(kind)
append(' ')
Expand All @@ -41,7 +41,7 @@ class FsdDocumentationProvider : AbstractDocumentationProvider() {
}

companion object {
fun findDocumentationComment(type: FsdTypeIdentifier): String {
fun findDocumentationComment(type: FsdIdentifierDeclaration): String {
val result = mutableListOf<String>()
var element = type.parent.parent.prevSibling
while (element is PsiComment || element is PsiWhiteSpace) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import io.github.facilityapi.intellij.lexer.FsdLexerAdapter
import io.github.facilityapi.intellij.psi.FsdDataSpec
import io.github.facilityapi.intellij.psi.FsdEnumSpec
import io.github.facilityapi.intellij.psi.FsdErrorSetSpec
import io.github.facilityapi.intellij.psi.FsdTypeIdentifier
import io.github.facilityapi.intellij.psi.FsdIdentifierDeclaration
import io.github.facilityapi.intellij.psi.FsdTypes

class FsdFindUsagesProvider : FindUsagesProvider {
override fun getHelpId(psiElement: PsiElement): String? = null

override fun getWordsScanner(): WordsScanner = DefaultWordsScanner(
FsdLexerAdapter(),
TokenSet.create(FsdTypes.TYPE_IDENTIFIER),
TokenSet.create(FsdTypes.IDENTIFIER_DECLARATION),
TokenSet.create(FsdTypes.COMMENT),
TokenSet.EMPTY
)
Expand All @@ -32,13 +32,10 @@ class FsdFindUsagesProvider : FindUsagesProvider {
else -> "type"
}

override fun getDescriptiveName(element: PsiElement) = when (element) {
is FsdTypeIdentifier -> element.name
else -> ""
}
override fun getDescriptiveName(element: PsiElement) = (element as? FsdIdentifierDeclaration)?.name ?: ""

override fun getNodeText(element: PsiElement, useFullName: Boolean): String = when (element) {
is FsdTypeIdentifier -> element.text
is FsdIdentifierDeclaration -> element.text
else -> ""
}
}
10 changes: 5 additions & 5 deletions src/main/kotlin/io/github/facilityapi/intellij/fsd.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ decorated_service_item ::= attribute_list* service_item
private service_item ::= (enum_spec | data_spec | method_spec | error_set_spec) { recoverWhile=service_item_recover }
private service_item_recover ::= !('[' | '}' | enum | data | errors | method)

method_spec ::= method type_identifier '{' decorated_field* '}' (':' '{' decorated_field* '}') { pin=1 }
method_spec ::= method identifier_declaration '{' decorated_field* '}' (':' '{' decorated_field* '}') { pin=1 }

data_spec ::= data type_identifier '{' decorated_field* '}' { pin=1 }
data_spec ::= data identifier_declaration '{' decorated_field* '}' { pin=1 }

enum_spec ::= enum type_identifier enum_value_list { pin=1 }
enum_spec ::= enum identifier_declaration enum_value_list { pin=1 }
enum_value_list ::= '{' [ decorated_enum_value (',' (decorated_enum_value | &'}'))* ] '}' { pin(".*")=1 }
decorated_enum_value ::= attribute_list* enum_value
enum_value ::= identifier

error_set_spec ::= errors type_identifier error_list { pin=1 }
error_set_spec ::= errors identifier_declaration error_list { pin=1 }
error_list ::= '{' [ decorated_error_spec (',' (decorated_error_spec | &'}'))* ] '}' { pin(".*")=1 }
decorated_error_spec ::= attribute_list* error_spec
error_spec ::= identifier

type_identifier ::= identifier
identifier_declaration ::= identifier
{
mixin="io.github.facilityapi.intellij.psi.FsdNamedElementImpl"
implements="io.github.facilityapi.intellij.psi.FsdNamedElement"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import io.github.facilityapi.intellij.reference.createTypeDefinition

object FsdPsiImplUtil {
@JvmStatic
fun FsdTypeIdentifier.getName(): String = identifier.text
fun FsdIdentifierDeclaration.getName(): String = identifier.text

@JvmStatic
fun FsdTypeIdentifier.setName(name: String): PsiElement {
fun FsdIdentifierDeclaration.setName(name: String): PsiElement {
val declType = parent.node.firstChildNode.text
val newDefinition = createTypeDefinition(project, name, declType)
val newNode = newDefinition.node
Expand All @@ -21,7 +21,7 @@ object FsdPsiImplUtil {
}

@JvmStatic
fun FsdTypeIdentifier.getNameIdentifier(): PsiElement {
fun FsdIdentifierDeclaration.getNameIdentifier(): PsiElement {
return identifier
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ package io.github.facilityapi.intellij.reference

import com.intellij.lang.refactoring.RefactoringSupportProvider
import com.intellij.psi.PsiElement
import io.github.facilityapi.intellij.psi.FsdIdentifierDeclaration
import io.github.facilityapi.intellij.psi.FsdReferenceType
import io.github.facilityapi.intellij.psi.FsdTypeIdentifier

class FsdRefactoringSupportProvider : RefactoringSupportProvider() {
override fun isMemberInplaceRenameAvailable(
elementToRename: PsiElement,
context: PsiElement?
) = elementToRename is FsdTypeIdentifier || elementToRename is FsdReferenceType
) = elementToRename is FsdIdentifierDeclaration || elementToRename is FsdReferenceType
}

0 comments on commit 8babc33

Please sign in to comment.