mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-85591 Avoid exception on opening code style settings from the welcome screen
Temporary workaround for the disabled PSI -> document synchronisation for default project
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.formatting;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.TextChange;
|
||||
@@ -27,6 +28,7 @@ import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
|
||||
import com.intellij.psi.formatter.DocumentBasedFormattingModel;
|
||||
import com.intellij.psi.formatter.PsiBasedFormattingModel;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import gnu.trove.TIntObjectHashMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -1408,6 +1410,16 @@ class FormatProcessor {
|
||||
|
||||
if (done) {
|
||||
myModel.commitChanges();
|
||||
|
||||
// TODO [cdr] remove when IDEA-85591 is done
|
||||
if (myModel instanceof PsiBasedFormattingModel) {
|
||||
PsiBasedFormattingModel psiModel = ((PsiBasedFormattingModel)myModel);
|
||||
final ASTNode rootNode = psiModel.getRootNode();
|
||||
final Document document = psiModel.getDocumentModel().getDocument();
|
||||
if (rootNode != null && !document.getText().equals(rootNode.getText())) {
|
||||
document.setText(rootNode.getText());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -134,6 +134,11 @@ public class PsiBasedFormattingModel implements FormattingModel {
|
||||
public Block getRootBlock() {
|
||||
return myRootBlock;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ASTNode getRootNode() {
|
||||
return myASTNode;
|
||||
}
|
||||
|
||||
public void canModifyAllWhiteSpaces() {
|
||||
myCanModifyAllWhiteSpaces = true;
|
||||
|
||||
Reference in New Issue
Block a user