Replace CodeStyleSettingsManager.getSettings with CodeStyle.getSettings
This commit is contained in:
+2
-1
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.core.formatter;
|
package org.jetbrains.kotlin.idea.core.formatter;
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle;
|
||||||
import com.intellij.openapi.application.ApplicationManager;
|
import com.intellij.openapi.application.ApplicationManager;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.util.InvalidDataException;
|
import com.intellij.openapi.util.InvalidDataException;
|
||||||
@@ -90,7 +91,7 @@ public class KotlinCodeStyleSettings extends CustomCodeStyleSettings {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static KotlinCodeStyleSettings getInstance(Project project) {
|
public static KotlinCodeStyleSettings getInstance(Project project) {
|
||||||
return CodeStyleSettingsManager.getSettings(project).getCustomSettings(KotlinCodeStyleSettings.class);
|
return CodeStyle.getSettings(project).getCustomSettings(KotlinCodeStyleSettings.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("MethodDoesntCallSuperMethod")
|
@SuppressWarnings("MethodDoesntCallSuperMethod")
|
||||||
|
|||||||
+2
-2
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.completion
|
package org.jetbrains.kotlin.idea.completion
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.codeInsight.completion.*
|
import com.intellij.codeInsight.completion.*
|
||||||
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
|
import com.intellij.codeInsight.completion.impl.CamelHumpMatcher
|
||||||
import com.intellij.codeInsight.lookup.*
|
import com.intellij.codeInsight.lookup.*
|
||||||
@@ -245,8 +246,7 @@ class VariableOrParameterNameWithTypeCompletion(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val settings =
|
val settings = CodeStyle.getCustomSettings(context.file, KotlinCodeStyleSettings::class.java)
|
||||||
CodeStyleSettingsManager.getInstance(context.project).currentSettings.getCustomSettings(KotlinCodeStyleSettings::class.java)
|
|
||||||
val spaceBefore = if (settings.SPACE_BEFORE_TYPE_COLON) " " else ""
|
val spaceBefore = if (settings.SPACE_BEFORE_TYPE_COLON) " " else ""
|
||||||
val spaceAfter = if (settings.SPACE_AFTER_TYPE_COLON) " " else ""
|
val spaceAfter = if (settings.SPACE_AFTER_TYPE_COLON) " " else ""
|
||||||
|
|
||||||
|
|||||||
+5
-5
@@ -16,15 +16,15 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.completion.handlers
|
package org.jetbrains.kotlin.idea.completion.handlers
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.codeInsight.AutoPopupController
|
import com.intellij.codeInsight.AutoPopupController
|
||||||
import com.intellij.codeInsight.completion.InsertionContext
|
import com.intellij.codeInsight.completion.InsertionContext
|
||||||
import com.intellij.codeInsight.lookup.Lookup
|
import com.intellij.codeInsight.lookup.Lookup
|
||||||
import com.intellij.codeInsight.lookup.LookupElement
|
import com.intellij.codeInsight.lookup.LookupElement
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.PsiDocumentManager
|
import com.intellij.psi.PsiDocumentManager
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
import com.intellij.psi.PsiFile
|
||||||
import org.jetbrains.kotlin.idea.completion.LambdaSignatureTemplates
|
import org.jetbrains.kotlin.idea.completion.LambdaSignatureTemplates
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||||
import org.jetbrains.kotlin.idea.util.CallType
|
import org.jetbrains.kotlin.idea.util.CallType
|
||||||
@@ -145,7 +145,7 @@ sealed class KotlinFunctionInsertHandler(callType: CallType<*>) : KotlinCallable
|
|||||||
context.setAddCompletionChar(false)
|
context.setAddCompletionChar(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isInsertSpacesInOneLineFunctionEnabled(project)) {
|
if (isInsertSpacesInOneLineFunctionEnabled(context.file)) {
|
||||||
document.insertString(offset, " { }")
|
document.insertString(offset, " { }")
|
||||||
inBracketsShift = 1
|
inBracketsShift = 1
|
||||||
} else {
|
} else {
|
||||||
@@ -199,8 +199,8 @@ sealed class KotlinFunctionInsertHandler(callType: CallType<*>) : KotlinCallable
|
|||||||
return inputValueArguments || lambdaInfo != null
|
return inputValueArguments || lambdaInfo != null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun isInsertSpacesInOneLineFunctionEnabled(project: Project) =
|
private fun isInsertSpacesInOneLineFunctionEnabled(file: PsiFile) =
|
||||||
CodeStyleSettingsManager.getSettings(project).getCustomSettings(KotlinCodeStyleSettings::class.java)!!.INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD
|
CodeStyle.getCustomSettings(file, KotlinCodeStyleSettings::class.java).INSERT_WHITESPACES_IN_SIMPLE_ONE_LINE_METHOD
|
||||||
}
|
}
|
||||||
|
|
||||||
object Infix : KotlinFunctionInsertHandler(CallType.INFIX) {
|
object Infix : KotlinFunctionInsertHandler(CallType.INFIX) {
|
||||||
|
|||||||
+6
-9
@@ -5,10 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.completion.test.handlers
|
package org.jetbrains.kotlin.idea.completion.test.handlers
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.codeInsight.completion.CompletionType
|
import com.intellij.codeInsight.completion.CompletionType
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage
|
|
||||||
import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils
|
import org.jetbrains.kotlin.idea.completion.test.ExpectedCompletionUtils
|
||||||
import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile
|
import org.jetbrains.kotlin.idea.completion.test.configureWithExtraFile
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings
|
||||||
@@ -28,9 +27,8 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
|||||||
protected open fun doTest(testPath: String) {
|
protected open fun doTest(testPath: String) {
|
||||||
setUpFixture(testPath)
|
setUpFixture(testPath)
|
||||||
|
|
||||||
val settingManager = CodeStyleSettingsManager.getInstance(project)
|
val tempSettings = CodeStyle.getSettings(project).clone()
|
||||||
val tempSettings = settingManager.currentSettings.clone()
|
CodeStyle.setTemporarySettings(project, tempSettings)
|
||||||
settingManager.setTemporarySettings(tempSettings)
|
|
||||||
try {
|
try {
|
||||||
val fileText = FileUtil.loadFile(File(testPath))
|
val fileText = FileUtil.loadFile(File(testPath))
|
||||||
assertTrue("\"<caret>\" is missing in file \"$testPath\"", fileText.contains("<caret>"));
|
assertTrue("\"<caret>\" is missing in file \"$testPath\"", fileText.contains("<caret>"));
|
||||||
@@ -49,7 +47,7 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
|||||||
val completionType = ExpectedCompletionUtils.getCompletionType(fileText) ?: defaultCompletionType
|
val completionType = ExpectedCompletionUtils.getCompletionType(fileText) ?: defaultCompletionType
|
||||||
|
|
||||||
val kotlinStyleSettings = KotlinCodeStyleSettings.getInstance(project)
|
val kotlinStyleSettings = KotlinCodeStyleSettings.getInstance(project)
|
||||||
val commonStyleSettings = CodeStyleSettingsManager.getSettings(project).getCommonSettings(KotlinLanguage.INSTANCE)
|
val commonStyleSettings = CodeStyle.getLanguageSettings(file)
|
||||||
for (line in InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, CODE_STYLE_SETTING_PREFIX)) {
|
for (line in InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, CODE_STYLE_SETTING_PREFIX)) {
|
||||||
val index = line.indexOfOrNull('=') ?: error("Invalid code style setting '$line': '=' expected")
|
val index = line.indexOfOrNull('=') ?: error("Invalid code style setting '$line': '=' expected")
|
||||||
val settingName = line.substring(0, index).trim()
|
val settingName = line.substring(0, index).trim()
|
||||||
@@ -68,9 +66,8 @@ abstract class AbstractCompletionHandlerTest(private val defaultCompletionType:
|
|||||||
}
|
}
|
||||||
|
|
||||||
doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, File(testPath).name + ".after")
|
doTestWithTextLoaded(completionType, invocationCount, lookupString, itemText, tailText, completionChar, File(testPath).name + ".after")
|
||||||
}
|
} finally {
|
||||||
finally {
|
CodeStyle.dropTemporarySettings(project)
|
||||||
settingManager.dropTemporarySettings()
|
|
||||||
tearDownFixture()
|
tearDownFixture()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.maven
|
package org.jetbrains.kotlin.idea.maven
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.openapi.application.Result
|
import com.intellij.openapi.application.Result
|
||||||
import com.intellij.openapi.application.WriteAction
|
import com.intellij.openapi.application.WriteAction
|
||||||
import com.intellij.openapi.projectRoots.JavaSdk
|
import com.intellij.openapi.projectRoots.JavaSdk
|
||||||
@@ -276,7 +277,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun testImportObsoleteCodeStyle() {
|
fun testImportObsoleteCodeStyle() {
|
||||||
Assert.assertNull(CodeStyleSettingsManager.getSettings(myProject).kotlinCodeStyleDefaults())
|
Assert.assertNull(CodeStyle.getSettings(myProject).kotlinCodeStyleDefaults())
|
||||||
|
|
||||||
importProject(
|
importProject(
|
||||||
"""
|
"""
|
||||||
@@ -292,12 +293,12 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
|
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
KotlinObsoleteCodeStyle.CODE_STYLE_ID,
|
KotlinObsoleteCodeStyle.CODE_STYLE_ID,
|
||||||
CodeStyleSettingsManager.getSettings(myProject).kotlinCodeStyleDefaults()
|
CodeStyle.getSettings(myProject).kotlinCodeStyleDefaults()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun testImportOfficialCodeStyle() {
|
fun testImportOfficialCodeStyle() {
|
||||||
Assert.assertNull(CodeStyleSettingsManager.getSettings(myProject).kotlinCodeStyleDefaults())
|
Assert.assertNull(CodeStyle.getSettings(myProject).kotlinCodeStyleDefaults())
|
||||||
|
|
||||||
importProject(
|
importProject(
|
||||||
"""
|
"""
|
||||||
@@ -313,7 +314,7 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
|
|
||||||
Assert.assertEquals(
|
Assert.assertEquals(
|
||||||
KotlinStyleGuideCodeStyle.CODE_STYLE_ID,
|
KotlinStyleGuideCodeStyle.CODE_STYLE_ID,
|
||||||
CodeStyleSettingsManager.getSettings(myProject).kotlinCodeStyleDefaults()
|
CodeStyle.getSettings(myProject).kotlinCodeStyleDefaults()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.editor
|
package org.jetbrains.kotlin.idea.editor
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.codeInsight.CodeInsightSettings
|
import com.intellij.codeInsight.CodeInsightSettings
|
||||||
import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegate.Result
|
import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegate.Result
|
||||||
import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegateAdapter
|
import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegateAdapter
|
||||||
@@ -25,16 +26,13 @@ import com.intellij.openapi.editor.Document
|
|||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.editor.actionSystem.EditorActionHandler
|
import com.intellij.openapi.editor.actionSystem.EditorActionHandler
|
||||||
import com.intellij.openapi.editor.ex.EditorEx
|
import com.intellij.openapi.editor.ex.EditorEx
|
||||||
import com.intellij.openapi.project.Project
|
|
||||||
import com.intellij.openapi.util.Ref
|
import com.intellij.openapi.util.Ref
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.openapi.util.text.StringUtil
|
import com.intellij.openapi.util.text.StringUtil
|
||||||
import com.intellij.psi.PsiDocumentManager
|
import com.intellij.psi.PsiDocumentManager
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
|
||||||
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
import com.intellij.psi.impl.source.tree.LeafPsiElement
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
|
||||||
import org.jetbrains.kotlin.idea.refactoring.hostEditor
|
import org.jetbrains.kotlin.idea.refactoring.hostEditor
|
||||||
import org.jetbrains.kotlin.idea.refactoring.project
|
import org.jetbrains.kotlin.idea.refactoring.project
|
||||||
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
||||||
@@ -136,7 +134,7 @@ class KotlinMultilineStringEnterHandler : EnterHandlerDelegateAdapter() {
|
|||||||
getMarginCharFromTrimMarginCallsInChain(literal) ?: getMarginCharFromLiteral(literal)
|
getMarginCharFromTrimMarginCallsInChain(literal) ?: getMarginCharFromLiteral(literal)
|
||||||
|
|
||||||
runWriteAction {
|
runWriteAction {
|
||||||
val settings = MultilineSettings(file.project)
|
val settings = MultilineSettings(file)
|
||||||
|
|
||||||
val caretMarker = document.createRangeMarker(offset, offset)
|
val caretMarker = document.createRangeMarker(offset, offset)
|
||||||
caretMarker.isGreedyToRight = true
|
caretMarker.isGreedyToRight = true
|
||||||
@@ -247,9 +245,8 @@ class KotlinMultilineStringEnterHandler : EnterHandlerDelegateAdapter() {
|
|||||||
|
|
||||||
const val MULTILINE_QUOTE = "\"\"\""
|
const val MULTILINE_QUOTE = "\"\"\""
|
||||||
|
|
||||||
class MultilineSettings(project: Project) {
|
class MultilineSettings(file: PsiFile) {
|
||||||
private val kotlinIndentOptions =
|
private val kotlinIndentOptions = CodeStyle.getIndentOptions(file)
|
||||||
CodeStyleSettingsManager.getInstance(project).currentSettings.getIndentOptions(KotlinFileType.INSTANCE)
|
|
||||||
|
|
||||||
private val useTabs = kotlinIndentOptions.USE_TAB_CHARACTER
|
private val useTabs = kotlinIndentOptions.USE_TAB_CHARACTER
|
||||||
private val tabSize = kotlinIndentOptions.TAB_SIZE
|
private val tabSize = kotlinIndentOptions.TAB_SIZE
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.editor
|
package org.jetbrains.kotlin.idea.editor
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.lang.SmartEnterProcessorWithFixers
|
import com.intellij.lang.SmartEnterProcessorWithFixers
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
@@ -103,7 +104,7 @@ class KotlinSmartEnterHandler : SmartEnterProcessorWithFixers() {
|
|||||||
CharArrayUtil.regionMatches(chars, caretOffset - "{\n}".length, "{\n}")
|
CharArrayUtil.regionMatches(chars, caretOffset - "{\n}".length, "{\n}")
|
||||||
) {
|
) {
|
||||||
commit(editor)
|
commit(editor)
|
||||||
val settings = CodeStyleSettingsManager.getSettings(file.project)
|
val settings = CodeStyle.getLanguageSettings(file)
|
||||||
val old = settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE
|
val old = settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE
|
||||||
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false
|
settings.KEEP_SIMPLE_BLOCKS_IN_ONE_LINE = false
|
||||||
val elt = file.findElementAt(caretOffset - 1)!!.getStrictParentOfType<KtBlockExpression>()
|
val elt = file.findElementAt(caretOffset - 1)!!.getStrictParentOfType<KtBlockExpression>()
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.formatter
|
package org.jetbrains.kotlin.idea.formatter
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.internal.statistic.beans.UsageDescriptor
|
import com.intellij.internal.statistic.beans.UsageDescriptor
|
||||||
import com.intellij.internal.statistic.utils.getEnumUsage
|
import com.intellij.internal.statistic.utils.getEnumUsage
|
||||||
import com.intellij.openapi.project.Project
|
import com.intellij.openapi.project.Project
|
||||||
@@ -18,7 +19,7 @@ class KotlinFormatterUsageCollector {
|
|||||||
fun getProjectUsages(project: Project): Set<UsageDescriptor> {
|
fun getProjectUsages(project: Project): Set<UsageDescriptor> {
|
||||||
val usedFormatter = getKotlinFormatterKind(project)
|
val usedFormatter = getKotlinFormatterKind(project)
|
||||||
|
|
||||||
val settings = CodeStyleSettingsManager.getSettings(project)
|
val settings = CodeStyle.getSettings(project)
|
||||||
val kotlinCommonSettings = settings.kotlinCommonSettings
|
val kotlinCommonSettings = settings.kotlinCommonSettings
|
||||||
val kotlinCustomSettings = settings.kotlinCustomSettings
|
val kotlinCustomSettings = settings.kotlinCustomSettings
|
||||||
|
|
||||||
@@ -54,7 +55,7 @@ class KotlinFormatterUsageCollector {
|
|||||||
val isProject = CodeStyleSettingsManager.getInstance(project).USE_PER_PROJECT_SETTINGS
|
val isProject = CodeStyleSettingsManager.getInstance(project).USE_PER_PROJECT_SETTINGS
|
||||||
val isDefaultOfficialCodeStyle = isDefaultOfficialCodeStyle
|
val isDefaultOfficialCodeStyle = isDefaultOfficialCodeStyle
|
||||||
|
|
||||||
val settings = CodeStyleSettingsManager.getSettings(project)
|
val settings = CodeStyle.getSettings(project)
|
||||||
val kotlinCommonSettings = settings.kotlinCommonSettings
|
val kotlinCommonSettings = settings.kotlinCommonSettings
|
||||||
val kotlinCustomSettings = settings.kotlinCustomSettings
|
val kotlinCustomSettings = settings.kotlinCustomSettings
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.intentions
|
package org.jetbrains.kotlin.idea.intentions
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.openapi.editor.Editor
|
import com.intellij.openapi.editor.Editor
|
||||||
import com.intellij.psi.codeStyle.CodeStyleManager
|
import com.intellij.psi.codeStyle.CodeStyleManager
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
||||||
@@ -29,7 +30,7 @@ class IndentRawStringIntention : SelfTargetingIntention<KtStringTemplateExpressi
|
|||||||
override fun applyTo(element: KtStringTemplateExpression, editor: Editor?) {
|
override fun applyTo(element: KtStringTemplateExpression, editor: Editor?) {
|
||||||
val file = element.containingKtFile
|
val file = element.containingKtFile
|
||||||
val project = file.project
|
val project = file.project
|
||||||
val indentOptions = CodeStyleSettingsManager.getInstance(project).currentSettings.getIndentOptions(KotlinFileType.INSTANCE)
|
val indentOptions = CodeStyle.getIndentOptions(file)
|
||||||
val parentIndent = CodeStyleManager.getInstance(project).getLineIndent(file, element.parent.startOffset) ?: ""
|
val parentIndent = CodeStyleManager.getInstance(project).getLineIndent(file, element.parent.startOffset) ?: ""
|
||||||
val indent = if (indentOptions.USE_TAB_CHARACTER) "$parentIndent\t" else "$parentIndent${" ".repeat(indentOptions.INDENT_SIZE)}"
|
val indent = if (indentOptions.USE_TAB_CHARACTER) "$parentIndent\t" else "$parentIndent${" ".repeat(indentOptions.INDENT_SIZE)}"
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.parameterInfo
|
package org.jetbrains.kotlin.idea.parameterInfo
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.codeInsight.hints.InlayInfo
|
import com.intellij.codeInsight.hints.InlayInfo
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
import org.jetbrains.kotlin.descriptors.*
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||||
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
|
||||||
@@ -101,9 +101,7 @@ fun provideTypeHint(element: KtCallableDeclaration, offset: Int): List<InlayInfo
|
|||||||
}
|
}
|
||||||
|
|
||||||
return if (isUnclearType(type, element)) {
|
return if (isUnclearType(type, element)) {
|
||||||
val settings = CodeStyleSettingsManager.getInstance(element.project).currentSettings
|
val settings = CodeStyle.getCustomSettings(element.containingFile, KotlinCodeStyleSettings::class.java)
|
||||||
.getCustomSettings(KotlinCodeStyleSettings::class.java)
|
|
||||||
|
|
||||||
val declString = buildString {
|
val declString = buildString {
|
||||||
append(TYPE_INFO_PREFIX)
|
append(TYPE_INFO_PREFIX)
|
||||||
if (settings.SPACE_BEFORE_TYPE_COLON) {
|
if (settings.SPACE_BEFORE_TYPE_COLON) {
|
||||||
|
|||||||
@@ -16,13 +16,13 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.projectView;
|
package org.jetbrains.kotlin.idea.projectView;
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle;
|
||||||
import com.intellij.ide.projectView.PresentationData;
|
import com.intellij.ide.projectView.PresentationData;
|
||||||
import com.intellij.ide.projectView.ViewSettings;
|
import com.intellij.ide.projectView.ViewSettings;
|
||||||
import com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode;
|
import com.intellij.ide.projectView.impl.nodes.AbstractPsiBasedNode;
|
||||||
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
import com.intellij.ide.util.treeView.AbstractTreeNode;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
|
|
||||||
@@ -54,7 +54,7 @@ public class KtDeclarationTreeNode extends AbstractPsiBasedNode<KtDeclaration> {
|
|||||||
String text = declaration instanceof KtAnonymousInitializer ? CLASS_INITIALIZER : declaration.getName();
|
String text = declaration instanceof KtAnonymousInitializer ? CLASS_INITIALIZER : declaration.getName();
|
||||||
if (text == null) return;
|
if (text == null) return;
|
||||||
|
|
||||||
KotlinCodeStyleSettings settings = CodeStyleSettingsManager.getInstance(getProject()).getCurrentSettings()
|
KotlinCodeStyleSettings settings = CodeStyle.getSettings(getProject())
|
||||||
.getCustomSettings(KotlinCodeStyleSettings.class);
|
.getCustomSettings(KotlinCodeStyleSettings.class);
|
||||||
|
|
||||||
if (declaration instanceof KtProperty) {
|
if (declaration instanceof KtProperty) {
|
||||||
|
|||||||
@@ -5,10 +5,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.formatter;
|
package org.jetbrains.kotlin.formatter;
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle;
|
||||||
import com.intellij.openapi.editor.CaretModel;
|
import com.intellij.openapi.editor.CaretModel;
|
||||||
import com.intellij.openapi.util.io.FileUtil;
|
import com.intellij.openapi.util.io.FileUtil;
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
|
||||||
import com.intellij.testFramework.EditorTestUtil;
|
import com.intellij.testFramework.EditorTestUtil;
|
||||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@@ -61,7 +61,7 @@ public abstract class AbstractTypingIndentationTestBase extends LightCodeInsight
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CodeStyleSettings getSettings() {
|
public static CodeStyleSettings getSettings() {
|
||||||
return CodeStyleSettingsManager.getSettings(getProject());
|
return CodeStyle.getSettings(getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.formatter;
|
package org.jetbrains.kotlin.formatter;
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle;
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
|
||||||
import com.intellij.testFramework.LightPlatformTestCase;
|
import com.intellij.testFramework.LightPlatformTestCase;
|
||||||
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
import org.jetbrains.kotlin.idea.KotlinLanguage;
|
||||||
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
|
import org.jetbrains.kotlin.idea.core.formatter.KotlinCodeStyleSettings;
|
||||||
@@ -17,7 +17,7 @@ public class FormatSettingsUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static CodeStyleSettings getSettings() {
|
public static CodeStyleSettings getSettings() {
|
||||||
return CodeStyleSettingsManager.getSettings(LightPlatformTestCase.getProject());
|
return CodeStyle.getSettings(LightPlatformTestCase.getProject());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SettingsConfigurator createConfigurator(String fileText, CodeStyleSettings settings) {
|
public static SettingsConfigurator createConfigurator(String fileText, CodeStyleSettings settings) {
|
||||||
|
|||||||
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.editor
|
package org.jetbrains.kotlin.idea.editor
|
||||||
|
|
||||||
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
|
||||||
import com.intellij.testFramework.EditorTestUtil
|
import com.intellij.testFramework.EditorTestUtil
|
||||||
import org.jetbrains.kotlin.idea.KotlinFileType
|
import org.jetbrains.kotlin.idea.KotlinFileType
|
||||||
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
import org.jetbrains.kotlin.idea.test.KotlinLightCodeInsightFixtureTestCase
|
||||||
@@ -50,19 +50,17 @@ abstract class AbstractMultiLineStringIndentTest : KotlinLightCodeInsightFixture
|
|||||||
|
|
||||||
val settingsFileText = FileUtil.loadFile(settingsFile, true)
|
val settingsFileText = FileUtil.loadFile(settingsFile, true)
|
||||||
try {
|
try {
|
||||||
val indentOptions = CodeStyleSettingsManager.getInstance(project).currentSettings.getIndentOptions(KotlinFileType.INSTANCE)
|
val indentOptions = CodeStyle.getSettings(project).getIndentOptions(KotlinFileType.INSTANCE)
|
||||||
val configurator = SettingsConfigurator(settingsFileText, indentOptions)
|
val configurator = SettingsConfigurator(settingsFileText, indentOptions)
|
||||||
if (!inverted) {
|
if (!inverted) {
|
||||||
configurator.configureSettings()
|
configurator.configureSettings()
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
configurator.configureInvertedSettings()
|
configurator.configureInvertedSettings()
|
||||||
}
|
}
|
||||||
|
|
||||||
action()
|
action()
|
||||||
}
|
} finally {
|
||||||
finally {
|
CodeStyle.getSettings(file).clearCodeStyleSettings()
|
||||||
CodeStyleSettingsManager.getSettings(myFixture.project).clearCodeStyleSettings()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.idea.editor
|
package org.jetbrains.kotlin.idea.editor
|
||||||
|
|
||||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager
|
import com.intellij.application.options.CodeStyle
|
||||||
import com.intellij.testFramework.EditorTestUtil
|
import com.intellij.testFramework.EditorTestUtil
|
||||||
import com.intellij.testFramework.LightCodeInsightTestCase
|
import com.intellij.testFramework.LightCodeInsightTestCase
|
||||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
|
import com.intellij.testFramework.LightPlatformCodeInsightTestCase
|
||||||
@@ -874,7 +874,7 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
|
|||||||
|
|
||||||
private fun enableSmartEnterWithTabs(): () -> Unit = {
|
private fun enableSmartEnterWithTabs(): () -> Unit = {
|
||||||
val project = LightPlatformTestCase.getProject()
|
val project = LightPlatformTestCase.getProject()
|
||||||
val indentOptions = CodeStyleSettingsManager.getInstance(project).currentSettings.getIndentOptions(KotlinFileType.INSTANCE)
|
val indentOptions = CodeStyle.getSettings(project).getIndentOptions(KotlinFileType.INSTANCE)
|
||||||
indentOptions.USE_TAB_CHARACTER = true
|
indentOptions.USE_TAB_CHARACTER = true
|
||||||
indentOptions.SMART_TABS = true
|
indentOptions.SMART_TABS = true
|
||||||
}
|
}
|
||||||
@@ -897,7 +897,7 @@ class TypedHandlerTest : LightCodeInsightTestCase() {
|
|||||||
} finally {
|
} finally {
|
||||||
if (settingsModifier != null) {
|
if (settingsModifier != null) {
|
||||||
val project = LightPlatformTestCase.getProject()
|
val project = LightPlatformTestCase.getProject()
|
||||||
CodeStyleSettingsManager.getSettings(project).clearCodeStyleSettings()
|
CodeStyle.getSettings(project).clearCodeStyleSettings()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user