-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
148 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/co/anbora/labs/firebase/ide/style/FirebaseCodeStyleConfigurable.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package co.anbora.labs.firebase.ide.style | ||
|
||
import co.anbora.labs.firebase.lang.FirebaseRulesLanguage | ||
import com.intellij.application.options.CodeStyleAbstractConfigurable | ||
import com.intellij.application.options.CodeStyleAbstractPanel | ||
import com.intellij.psi.codeStyle.CodeStyleSettings | ||
|
||
class FirebaseCodeStyleConfigurable( | ||
settings: CodeStyleSettings, | ||
originalSettings: CodeStyleSettings? | ||
): CodeStyleAbstractConfigurable(settings, originalSettings, FirebaseRulesLanguage.LANGUAGE_NAME) { | ||
|
||
override fun createPanel( | ||
settings: CodeStyleSettings | ||
): CodeStyleAbstractPanel = FirebaseCodeStyleMainPanel(currentSettings, settings) | ||
|
||
override fun getHelpTopic(): String? = null | ||
} |
16 changes: 16 additions & 0 deletions
16
src/main/kotlin/co/anbora/labs/firebase/ide/style/FirebaseCodeStyleMainPanel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package co.anbora.labs.firebase.ide.style | ||
|
||
import co.anbora.labs.firebase.lang.FirebaseRulesLanguage | ||
import com.intellij.application.options.TabbedLanguageCodeStylePanel | ||
import com.intellij.psi.codeStyle.CodeStyleSettings | ||
|
||
class FirebaseCodeStyleMainPanel( | ||
currentSettings: CodeStyleSettings, | ||
settings: CodeStyleSettings | ||
): TabbedLanguageCodeStylePanel(FirebaseRulesLanguage, currentSettings, settings) { | ||
|
||
override fun initTabs(settings: CodeStyleSettings?) { | ||
addIndentOptionsTab(settings) | ||
addSpacesTab(settings) | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/kotlin/co/anbora/labs/firebase/ide/style/FirebaseCodeStyleSettings.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package co.anbora.labs.firebase.ide.style | ||
|
||
import com.intellij.psi.codeStyle.CodeStyleSettings | ||
import com.intellij.psi.codeStyle.CustomCodeStyleSettings | ||
|
||
class FirebaseCodeStyleSettings( | ||
container: CodeStyleSettings? | ||
): CustomCodeStyleSettings("FirebaseCodeStyleSettings", container) |
21 changes: 21 additions & 0 deletions
21
src/main/kotlin/co/anbora/labs/firebase/ide/style/FirebaseCodeStyleSettingsProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package co.anbora.labs.firebase.ide.style | ||
|
||
import co.anbora.labs.firebase.lang.FirebaseRulesLanguage.LANGUAGE_NAME | ||
import com.intellij.openapi.options.Configurable | ||
import com.intellij.psi.codeStyle.CodeStyleSettings | ||
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider | ||
import com.intellij.psi.codeStyle.CustomCodeStyleSettings | ||
|
||
object FirebaseCodeStyleSettingsProvider: CodeStyleSettingsProvider() { | ||
|
||
override fun createCustomSettings( | ||
settings: CodeStyleSettings? | ||
): CustomCodeStyleSettings = FirebaseCodeStyleSettings(settings) | ||
|
||
override fun getConfigurableDisplayName(): String = LANGUAGE_NAME | ||
|
||
override fun createSettingsPage( | ||
settings: CodeStyleSettings, | ||
originalSettings: CodeStyleSettings? | ||
): Configurable = FirebaseCodeStyleConfigurable(settings, originalSettings) | ||
} |
33 changes: 33 additions & 0 deletions
33
...main/kotlin/co/anbora/labs/firebase/ide/style/FirebaseLanguageCodeStyleSettingProvider.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package co.anbora.labs.firebase.ide.style | ||
|
||
import co.anbora.labs.firebase.lang.FirebaseRulesLanguage | ||
import co.anbora.labs.firebase.lang.FirebaseRulesLanguage.LANGUAGE_DEMO_TEXT | ||
import com.intellij.application.options.IndentOptionsEditor | ||
import com.intellij.application.options.SmartIndentOptionsEditor | ||
import com.intellij.lang.Language | ||
import com.intellij.psi.codeStyle.CodeStyleSettingsCustomizable | ||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings | ||
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider | ||
|
||
object FirebaseLanguageCodeStyleSettingProvider: LanguageCodeStyleSettingsProvider() { | ||
|
||
override fun getLanguage(): Language = FirebaseRulesLanguage | ||
|
||
override fun getCodeSample(settingsType: SettingsType): String = LANGUAGE_DEMO_TEXT | ||
|
||
override fun customizeSettings(consumer: CodeStyleSettingsCustomizable, settingsType: SettingsType) { | ||
if (settingsType == SettingsType.SPACING_SETTINGS) { | ||
consumer.showStandardOptions("SPACE_AFTER_COMMA") | ||
consumer.showStandardOptions("SPACE_BEFORE_COMMA") | ||
} else if (settingsType == SettingsType.BLANK_LINES_SETTINGS) { | ||
consumer.showStandardOptions("KEEP_BLANK_LINES_IN_CODE") | ||
} | ||
} | ||
|
||
override fun customizeDefaults(commonSettings: CommonCodeStyleSettings, indentOptions: CommonCodeStyleSettings.IndentOptions) { | ||
indentOptions.INDENT_SIZE = 4 | ||
commonSettings.KEEP_BLANK_LINES_IN_CODE = 0 | ||
} | ||
|
||
override fun getIndentOptionsEditor(): IndentOptionsEditor = SmartIndentOptionsEditor() | ||
} |
5 changes: 3 additions & 2 deletions
5
src/main/kotlin/co/anbora/labs/firebase/lang/FirebaseFileType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters