Avoid exception from DocumentImpl.setInBulkUpdate in reformat inspection
#KT-21036 Fixed
This commit is contained in:
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||||
*
|
* that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.idea.formatter
|
package org.jetbrains.kotlin.idea.formatter
|
||||||
@@ -20,6 +9,7 @@ import com.intellij.formatting.Block
|
|||||||
import com.intellij.formatting.FormattingDocumentModel
|
import com.intellij.formatting.FormattingDocumentModel
|
||||||
import com.intellij.formatting.FormattingModel
|
import com.intellij.formatting.FormattingModel
|
||||||
import com.intellij.lang.ASTNode
|
import com.intellij.lang.ASTNode
|
||||||
|
import com.intellij.openapi.editor.impl.DocumentImpl
|
||||||
import com.intellij.openapi.util.Key
|
import com.intellij.openapi.util.Key
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.util.TextRange
|
||||||
import com.intellij.psi.PsiFile
|
import com.intellij.psi.PsiFile
|
||||||
@@ -61,7 +51,7 @@ fun collectFormattingChanges(file: PsiFile): Set<FormattingChange> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class CollectChangesWithoutApplyModel(val file: PsiFile, val block: Block) : FormattingModel {
|
private class CollectChangesWithoutApplyModel(val file: PsiFile, val block: Block) : FormattingModel {
|
||||||
private val documentModel = FormattingDocumentModelImpl.createOn(file)
|
private val documentModel = FormattingDocumentModelImpl(DocumentImpl(file.viewProvider.contents, true), file)
|
||||||
private val changes = HashSet<FormattingChange>()
|
private val changes = HashSet<FormattingChange>()
|
||||||
|
|
||||||
val requestedChanges: Set<FormattingChange> get() = changes
|
val requestedChanges: Set<FormattingChange> get() = changes
|
||||||
|
|||||||
Reference in New Issue
Block a user