mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Migration to PsiFile-based Code Style API
This commit is contained in:
+1
-7
@@ -27,8 +27,6 @@ import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
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.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedCaret;
|
||||
import com.intellij.psi.util.PsiUtilBase;
|
||||
@@ -46,14 +44,12 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHandler {
|
||||
private Project myProject;
|
||||
|
||||
private final List<Block> myBlocks = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
// first pass - adjacent carets are grouped into blocks
|
||||
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull Caret caret, @NotNull PsiFile file) {
|
||||
myProject = project;
|
||||
file = file.getViewProvider().getPsi(file.getViewProvider().getBaseLanguage());
|
||||
|
||||
PsiElement context = InjectedLanguageManager.getInstance(file.getProject()).getInjectionHost(file);
|
||||
@@ -135,8 +131,6 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
public void postInvoke() {
|
||||
FeatureUsageTracker.getInstance().triggerFeatureUsed("codeassists.comment.line");
|
||||
|
||||
CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(myProject);
|
||||
|
||||
// second pass - determining whether we need to comment or to uncomment
|
||||
boolean allLinesCommented = true;
|
||||
for (Block block : myBlocks) {
|
||||
@@ -158,7 +152,7 @@ public class CommentByLineCommentHandler extends MultiCaretCodeInsightActionHand
|
||||
|
||||
block.blockSuitableCommenter = getBlockSuitableCommenter(psiFile, offset, endOffset);
|
||||
Language lineStartLanguage = getLineStartLanguage(block.editor, psiFile, startLine);
|
||||
CommonCodeStyleSettings languageSettings = codeStyleSettings.getCommonSettings(lineStartLanguage);
|
||||
CommonCodeStyleSettings languageSettings = CodeStyle.getLanguageSettings(psiFile, lineStartLanguage);
|
||||
block.commentWithIndent = !languageSettings.LINE_COMMENT_AT_FIRST_COLUMN;
|
||||
block.addSpace = languageSettings.LINE_COMMENT_ADD_SPACE;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user