mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Migration to PsiFile-based CodeStyle API
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.javadoc;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.CaretModel;
|
||||
@@ -26,7 +27,6 @@ import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.psi.javadoc.PsiDocTag;
|
||||
import com.intellij.psi.javadoc.PsiDocTagValue;
|
||||
@@ -107,7 +107,7 @@ public class JavadocHelper {
|
||||
}
|
||||
}
|
||||
|
||||
final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getInstance(psiFile.getProject()).getCurrentSettings();
|
||||
final CodeStyleSettings codeStyleSettings = CodeStyle.getSettings(psiFile);
|
||||
int column;
|
||||
if (codeStyleSettings.getCustomSettings(JavaCodeStyleSettings.class).JD_ALIGN_PARAM_COMMENTS) {
|
||||
column = Math.max(descriptionStartColumn, parameterNameEndColumn);
|
||||
|
||||
+3
-3
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -31,7 +32,6 @@ import com.intellij.openapi.util.text.CharFilter;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
@@ -108,7 +108,7 @@ public class CopyPasteIndentProcessor extends CopyPastePostProcessor<IndentTrans
|
||||
@Override
|
||||
public void run() {
|
||||
final boolean useTabs =
|
||||
CodeStyleSettingsManager.getSettings(project).useTabCharacter(psiFile.getFileType());
|
||||
CodeStyle.getSettings(psiFile).useTabCharacter(psiFile.getFileType());
|
||||
CharFilter NOT_INDENT_FILTER = new CharFilter() {
|
||||
@Override
|
||||
public boolean accept(char ch) {
|
||||
@@ -156,7 +156,7 @@ public class CopyPasteIndentProcessor extends CopyPastePostProcessor<IndentTrans
|
||||
int indent = toIndent - fromIndent;
|
||||
if (useTabs) // indent is counted in tab units
|
||||
indent *=
|
||||
CodeStyleSettingsManager.getSettings(project).getTabSize(psiFile.getFileType());
|
||||
CodeStyle.getSettings(psiFile).getTabSize(psiFile.getFileType());
|
||||
// don't indent single-line text
|
||||
if (!StringUtil.startsWithWhitespace(pastedText) && !StringUtil.endsWithLineBreak(pastedText) &&
|
||||
!(StringUtil.splitByLines(pastedText).length > 1))
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CodeInsightSettings;
|
||||
import com.intellij.codeInsight.editorActions.enter.EnterHandlerDelegate;
|
||||
@@ -43,7 +44,6 @@ import com.intellij.openapi.util.UserDataHolder;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.lineIndent.LineIndentProvider;
|
||||
import com.intellij.psi.formatter.FormatterUtil;
|
||||
import com.intellij.psi.impl.source.PostprocessReformattingAspect;
|
||||
@@ -447,7 +447,7 @@ public class EnterHandler extends BaseEnterHandler {
|
||||
}
|
||||
|
||||
if (myForceIndent && indentInsideJavadoc != null) {
|
||||
int indentSize = CodeStyleSettingsManager.getSettings(myProject).getIndentSize(myFile.getFileType());
|
||||
int indentSize = CodeStyle.getSettings(myFile).getIndentSize(myFile.getFileType());
|
||||
myDocument.insertString(myOffset + 1, StringUtil.repeatSymbol(' ', indentSize));
|
||||
myCaretAdvance += indentSize;
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.codeInsight.editorActions;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.lang.Commenter;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageCommenters;
|
||||
@@ -11,7 +12,6 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.util.DocumentUtil;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -41,7 +41,7 @@ public class LineCommentCopyPastePreProcessor implements CopyPastePreProcessor {
|
||||
if (offset < (firstNonWsLineOffset + lineCommentPrefix.length()) ||
|
||||
!CharArrayUtil.regionMatches(chars, firstNonWsLineOffset, lineCommentPrefix)) return text;
|
||||
|
||||
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(project);
|
||||
CodeStyleSettings codeStyleSettings = CodeStyle.getSettings(file);
|
||||
String lineStartReplacement = "\n" + chars.subSequence(lineStartOffset, firstNonWsLineOffset + lineCommentPrefix.length()) +
|
||||
(codeStyleSettings.getCommonSettings(language).LINE_COMMENT_ADD_SPACE ? " " : "");
|
||||
return StringUtil.trimTrailing(text, '\n').replace("\n", lineStartReplacement);
|
||||
|
||||
+2
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.editorActions.enter;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageFormatting;
|
||||
import com.intellij.openapi.actionSystem.CommonDataKeys;
|
||||
@@ -35,7 +36,6 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
@@ -192,7 +192,7 @@ public class BaseIndentEnterHandler extends EnterHandlerDelegateAdapter {
|
||||
final boolean usesSpacesForIndentation = nonEmptyIndent.length() > 0 && nonEmptyIndent.charAt(nonEmptyIndent.length() - 1) == ' ';
|
||||
final boolean firstIndent = nonEmptyIndent.length() == 0;
|
||||
|
||||
final CodeStyleSettings currentSettings = CodeStyleSettingsManager.getSettings(file.getProject());
|
||||
final CodeStyleSettings currentSettings = CodeStyle.getSettings(file);
|
||||
final CommonCodeStyleSettings.IndentOptions indentOptions = currentSettings.getIndentOptions(file.getFileType());
|
||||
if (firstIndent && indentOptions.USE_TAB_CHARACTER || !firstIndent && !usesSpacesForIndentation) {
|
||||
int nTabsToIndent = indentOptions.INDENT_SIZE / indentOptions.TAB_SIZE;
|
||||
|
||||
+2
-2
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.codeInsight.generation;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.codeInsight.CodeInsightBundle;
|
||||
import com.intellij.codeInsight.CommentUtil;
|
||||
import com.intellij.codeInsight.actions.MultiCaretCodeInsightActionHandler;
|
||||
@@ -38,7 +39,6 @@ import com.intellij.openapi.util.Couple;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.Indent;
|
||||
import com.intellij.psi.templateLanguages.MultipleLangCommentProvider;
|
||||
@@ -419,7 +419,7 @@ public class CommentByBlockCommentHandler extends MultiCaretCodeInsightActionHan
|
||||
if (startOffset == 0 || chars.charAt(startOffset - 1) == '\n') {
|
||||
if (endOffset == myDocument.getTextLength() || endOffset > 0 && chars.charAt(endOffset - 1) == '\n') {
|
||||
CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(myProject);
|
||||
CommonCodeStyleSettings settings = CodeStyleSettingsManager.getSettings(myProject).getCommonSettings(myFile.getLanguage());
|
||||
CommonCodeStyleSettings settings = CodeStyle.getLanguageSettings(myFile);
|
||||
String space;
|
||||
if (!settings.BLOCK_COMMENT_AT_FIRST_COLUMN) {
|
||||
final FileType fileType = myFile.getFileType();
|
||||
|
||||
+2
-2
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.psi.codeStyle.arrangement.engine;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
@@ -27,7 +28,6 @@ import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
import com.intellij.psi.codeStyle.arrangement.*;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementMatchRule;
|
||||
import com.intellij.psi.codeStyle.arrangement.match.ArrangementSectionRule;
|
||||
@@ -110,7 +110,7 @@ public class ArrangementEngine {
|
||||
return;
|
||||
}
|
||||
|
||||
final CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(file.getProject()).getCurrentSettings();
|
||||
final CodeStyleSettings settings = CodeStyle.getSettings(file);
|
||||
ArrangementSettings arrangementSettings = settings.getCommonSettings(file.getLanguage()).getArrangementSettings();
|
||||
if (arrangementSettings == null && rearranger instanceof ArrangementStandardSettingsAware) {
|
||||
arrangementSettings = ((ArrangementStandardSettingsAware)rearranger).getDefaultSettings();
|
||||
|
||||
Reference in New Issue
Block a user