Skip to content

Commit

Permalink
Add .editorconfig and reformat src/
Browse files Browse the repository at this point in the history
  • Loading branch information
exigow committed Jul 23, 2023
1 parent 54aefe7 commit 9f3ef76
Show file tree
Hide file tree
Showing 70 changed files with 101 additions and 89 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
root = true

[*.{kt,java}]
indent_size = 4
indent_style = space
end_of_line = lf
insert_final_newline = true
2 changes: 1 addition & 1 deletion grammar/TscnParser.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,4 @@ private primitive ::= resource_string
| FALSE
| NUMBER
private string ::= SINGLE_QUOTED_STRING | DOUBLE_QUOTED_STRING
resource_string ::= SINGLE_QUOTED_RESOURCE_STRING | DOUBLE_QUOTED_RESOURCE_STRING {methods=[getReference]}
resource_string ::= SINGLE_QUOTED_RESOURCE_STRING | DOUBLE_QUOTED_RESOURCE_STRING {methods=[getReference]}
2 changes: 1 addition & 1 deletion src/main/kotlin/common/ResourceUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ object ResourceUtil {
.firstOrNull()
}

}
}
6 changes: 3 additions & 3 deletions src/main/kotlin/error/ErrorGithubSubmitter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ class ErrorGithubSubmitter : ErrorReportSubmitter() {

private fun encodeIssue(title: String, body: String): String =
"https://github.com/exigow/intellij-gdscript/issues/new" +
"?labels=bug" +
"&title=${encode(title)}" +
"&body=${encode(body)}"
"?labels=bug" +
"&title=${encode(title)}" +
"&body=${encode(body)}"

private fun encode(text: String) =
URLEncoder.encode(text, "UTF-8")
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/gdscript/Colors.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package gdscript

import com.intellij.ide.highlighter.custom.CustomHighlighterColors
import com.intellij.openapi.editor.colors.EditorColors
import com.intellij.openapi.editor.colors.TextAttributesKey
import com.intellij.openapi.editor.DefaultLanguageHighlighterColors as DefaultColors

Expand Down Expand Up @@ -29,4 +28,4 @@ enum class Colors(fallback: TextAttributesKey) {
val key: TextAttributesKey =
TextAttributesKey.createTextAttributesKey("GDSCRIPT_$name", fallback)

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/ScriptBraceMatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ class ScriptBraceMatcher : PairedBraceMatcher {
override fun getCodeConstructStart(file: PsiFile, openingBraceOffset: Int): Int =
openingBraceOffset

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/ScriptColorSettingsPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@ class ScriptColorSettingsPage : ColorSettingsPage {

}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/ScriptCommenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class ScriptCommenter : Commenter {
override fun getBlockCommentSuffix(): String? =
null

}
}
5 changes: 5 additions & 0 deletions src/main/kotlin/gdscript/ScriptHighlighter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ class ScriptHighlighter : SyntaxHighlighterBase() {
MASTERSYNC,
PUPPETSYNC,
REMOTESYNC -> Colors.KEYWORD

LESS,
LESS_EQUAL,
GREATER,
Expand Down Expand Up @@ -98,13 +99,16 @@ class ScriptHighlighter : SyntaxHighlighterBase() {
INFER,
ARROW,
UNDERSCORE -> Colors.OPERATION_SIGN

DOUBLE_QUOTED_STRING,
SINGLE_QUOTED_STRING,
MULTILINE_DOUBLE_QUOTED_STRING,
MULTILINE_SINGLE_QUOTED_STRING -> Colors.STRING

REAL_NUMBER,
BINARY_NUMBER,
HEXADECIMAL_NUMBER -> Colors.NUMBER

IDENTIFIER -> Colors.IDENTIFIER
NODE_PATH -> Colors.NODE_PATH
AT_ONREADY,
Expand All @@ -117,6 +121,7 @@ class ScriptHighlighter : SyntaxHighlighterBase() {
AT_MASTERSYNC,
AT_PUPPETSYNC,
AT_REMOTESYNC -> Colors.ANNOTATION

LINE_COMMENT -> Colors.LINE_COMMENT
COMMA -> Colors.COMMA
COLON -> Colors.COLON
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/ScriptLanguage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package gdscript
import com.intellij.lang.Language


object ScriptLanguage: Language("GDScript")
object ScriptLanguage : Language("GDScript")
5 changes: 2 additions & 3 deletions src/main/kotlin/gdscript/ScriptReferenceContributor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ import com.intellij.psi.*
import com.intellij.util.ProcessingContext
import gdscript.psi.ScriptId
import gdscript.psi.ScriptString
import gdscript.psi.ScriptType
import gdscript.psi.reference.ScriptStringReference
import gdscript.psi.reference.ScriptIdReference
import gdscript.psi.reference.ScriptStringReference

class ScriptReferenceContributor : PsiReferenceContributor() {

Expand All @@ -26,4 +25,4 @@ class ScriptReferenceContributor : PsiReferenceContributor() {
})
}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/annotation/ClassnameAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class ClassnameAnnotator : Annotator {
return classes.any { it.name == name }
}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/annotation/ConstantAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ class ConstantAnnotator : Annotator {

}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/annotation/KeywordAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class KeywordAnnotator : Annotator {
.flatMap { it.methods }
.any { it.name == name }

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/annotation/MethodAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class MethodAnnotator : Annotator {
private fun isAfterFunc(element: PsiElement) =
PsiTreeUtil.prevVisibleLeaf(element)?.elementType == FUNC

}
}
4 changes: 2 additions & 2 deletions src/main/kotlin/gdscript/annotation/ResourceAnnotator.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ class ResourceAnnotator : Annotator {
val path: String = ResourceUtil.cleanResource(element.text)
if (VfsUtilCore.findRelativeFile(path, project) == null)
holder.newAnnotation(HighlightSeverity.WEAK_WARNING, "Cannot resolve resource '$path'")
.range(element).create()
.range(element).create()
}
}

private fun isString(element: PsiElement) =
element.elementType == DOUBLE_QUOTED_STRING || element.elementType == SINGLE_QUOTED_STRING

}
}
8 changes: 4 additions & 4 deletions src/main/kotlin/gdscript/annotation/utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.psi.PsiElement

fun AnnotationHolder.createTextAttributesAnnotation(element: PsiElement, textAttributes: TextAttributesKey) {
newAnnotation(HighlightSeverity.INFORMATION, "")
.range(element)
.textAttributes(textAttributes)
.create()
}
.range(element)
.textAttributes(textAttributes)
.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ class KeywordCompletionContributor : CompletionContributor() {

}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package gdscript.documentation
import com.intellij.lang.documentation.AbstractDocumentationProvider
import com.intellij.lang.documentation.DocumentationMarkup.*
import com.intellij.psi.PsiElement
import version.data.Argument
import version.VersionService
import version.data.Argument
import version.data.Class

class ScriptDocumentationProvider : AbstractDocumentationProvider() {
Expand All @@ -22,7 +22,7 @@ class ScriptDocumentationProvider : AbstractDocumentationProvider() {
generateDocList("Properties", clazz.fields.map { it.name + if (it.default != null) " = ${it.default}" else "" }),
generateDocList("Methods", clazz.methods.map { it.name + "(" + joinArguments(it.arguments) + ")" + if (it.type != "void") " -> ${it.type}" else "" }),
generateDocList("Constants", clazz.constants.map { it.name + " = " + it.value }),
generateDocList("Signals", clazz.signals.map { it.name + if (it.arguments.isNotEmpty()) "(" + joinArguments(it.arguments) + ")" else ""}),
generateDocList("Signals", clazz.signals.map { it.name + if (it.arguments.isNotEmpty()) "(" + joinArguments(it.arguments) + ")" else "" }),
CONTENT_END
).joinToString("")
}
Expand All @@ -49,4 +49,4 @@ class ScriptDocumentationProvider : AbstractDocumentationProvider() {
else
"<h3>$title</h3><ul>${list.joinToString("") { "<li><code>$it</code></li>" }}</ul>"

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ class ScriptGeneratedSourceFileService(
return result
}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/gdscript/psi/ScriptBaseElement.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ open class ScriptBaseElement(node: ASTNode) : ASTWrapperPsiElement(node) {
override fun getReferences(): Array<PsiReference> =
ReferenceProvidersRegistry.getReferencesFromProviders(this)

}
}
5 changes: 2 additions & 3 deletions src/main/kotlin/gdscript/psi/impl/ScriptPsiImplUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ package gdscript.psi.impl
import com.intellij.psi.PsiReference
import gdscript.psi.ScriptId
import gdscript.psi.ScriptString
import gdscript.psi.ScriptType
import gdscript.psi.reference.ScriptStringReference
import gdscript.psi.reference.ScriptIdReference
import gdscript.psi.reference.ScriptStringReference

object ScriptPsiImplUtil {

Expand All @@ -17,4 +16,4 @@ object ScriptPsiImplUtil {
fun getReference(element: ScriptId): PsiReference =
ScriptIdReference(element)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class ScriptIdReference(element: ScriptId) :
element.project.getService(ScriptGeneratedSourceFileService::class.java)
.getSourceFile(element.text)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class ScriptStringReference(element: ScriptString) :
override fun resolve(): PsiElement? =
ResourceUtil.findResource(element)

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ class ImportFileTreeStructureProvider : TreeStructureProvider {

return newChildren
}
}
}
4 changes: 3 additions & 1 deletion src/main/kotlin/run/RunConfigurationProducer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,14 @@ class RunConfigurationProducer : LazyRunConfigurationProducer<RunConfiguration>(
config.parameters = file.name
return true
}

file.extension == "gd" -> {
config.name = file.nameWithoutExtension
config.workingDirectory = file.parent.path
config.parameters = "--script ${file.name}"
return true
}

file.name == "project.godot" -> {
config.name = file.parent.name
config.workingDirectory = file.parent.path
Expand All @@ -46,4 +48,4 @@ class RunConfigurationProducer : LazyRunConfigurationProducer<RunConfiguration>(
private fun retrieveFile(context: ConfigurationContext) =
context.psiLocation?.containingFile?.virtualFile

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/run/RunConfigurationType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ class RunConfigurationType : ConfigurationType {

}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/run/console/ConsoleLinkFilter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ class ConsoleLinkFilter(
LocalFileSystem.getInstance()
.findFileByPath("$workingDirectory/$relativePath")

}
}
2 changes: 0 additions & 2 deletions src/main/kotlin/run/console/ConsoleLinkParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,4 @@ object ConsoleLinkParser {
.removePrefix("res://")
.removeSuffix(".")



}
2 changes: 1 addition & 1 deletion src/main/kotlin/settings/ApplicationSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class ApplicationSettings(
XmlSerializerUtil.copyBean(other, this)
}

}
}
5 changes: 3 additions & 2 deletions src/main/kotlin/settings/ApplicationSettingsConfigurable.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package settings

import version.VersionService
import com.intellij.openapi.components.service
import com.intellij.openapi.options.SearchableConfigurable
import com.intellij.openapi.ui.ComboBox
import com.intellij.openapi.ui.LabeledComponent
import com.intellij.openapi.ui.VerticalFlowLayout
import version.VersionService
import java.awt.BorderLayout
import javax.swing.JComponent
import javax.swing.JPanel
Expand Down Expand Up @@ -33,11 +33,12 @@ class ApplicationSettingsConfigurable : SearchableConfigurable {
panel.add(LabeledComponent.create(versionList, "API version:").also { it.labelLocation = BorderLayout.WEST })
return panel
}

private fun initVersions(): ComboBox<String> {
val allVersions = VersionService.all().map { it.versionId }.toTypedArray()
val combo = ComboBox(allVersions)
combo.selectedItem = settings.versionId
return combo
}

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/tscn/TscnBraceMatcher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ class TscnBraceMatcher : PairedBraceMatcher {
override fun getCodeConstructStart(file: PsiFile?, openingBraceOffset: Int): Int =
openingBraceOffset

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/tscn/TscnCommenter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class TscnCommenter : Commenter {
override fun getBlockCommentSuffix(): String? =
null

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/tscn/TscnFileType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ object TscnFileType : LanguageFileType(TscnLanguage) {

override fun getDescription() = name

}
}
2 changes: 1 addition & 1 deletion src/main/kotlin/tscn/TscnLanguage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package tscn
import com.intellij.lang.Language


object TscnLanguage: Language("TSCN")
object TscnLanguage : Language("TSCN")
2 changes: 1 addition & 1 deletion src/main/kotlin/tscn/TscnReferenceContributor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ class TscnReferenceContributor : PsiReferenceContributor() {
})
}

}
}

0 comments on commit 9f3ef76

Please sign in to comment.