From 0a2fec2436076793bc1800e45505023ca4b0bd29 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Mon, 20 Nov 2017 17:29:18 +0100 Subject: [PATCH] fix read access assertion --- .../compiler/impl/MessagesContainer.java | 49 ++++++++++--------- 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/MessagesContainer.java b/java/compiler/impl/src/com/intellij/compiler/impl/MessagesContainer.java index 76c4381fa5b0..a387fa8fad80 100644 --- a/java/compiler/impl/src/com/intellij/compiler/impl/MessagesContainer.java +++ b/java/compiler/impl/src/com/intellij/compiler/impl/MessagesContainer.java @@ -73,31 +73,32 @@ public class MessagesContainer { // javac uses hard-coded tab size 8 chars. So recalculate only if project's codestyle is different final VirtualFile file = m.getVirtualFile(); if (file != null && file.isValid()) { - final Document doc = FileDocumentManager.getInstance().getDocument(file); - if (doc != null) { - final int tabCount = ApplicationManager.getApplication().runReadAction((Computable)() -> { - final CharSequence seq = doc.getCharsSequence(); - int tcount = 0; - final int start = doc.getLineStartOffset(line); - final int end = doc.getLineEndOffset(line); - int charsExpanded = 0; - for (int i = start; i< end; i++) { - if (seq.charAt(i) == '\t') { - charsExpanded += JAVAC_TAB_SIZE; - tcount++; - } - else { - charsExpanded += 1; - } - if (charsExpanded >= col) { - break; // consider only those tabs that are located before the given column number - } - } - return tcount; - }); - if (tabCount > 0) { - return Math.max(0, col + tabCount * (myTabSize - JAVAC_TAB_SIZE)); + final int tabCount = ApplicationManager.getApplication().runReadAction((Computable)() -> { + final Document doc = FileDocumentManager.getInstance().getDocument(file); + if (doc == null) { + return 0; } + int tcount = 0; + final CharSequence seq = doc.getCharsSequence(); + final int start = doc.getLineStartOffset(line); + final int end = doc.getLineEndOffset(line); + int charsExpanded = 0; + for (int i = start; i< end; i++) { + if (seq.charAt(i) == '\t') { + charsExpanded += JAVAC_TAB_SIZE; + tcount++; + } + else { + charsExpanded += 1; + } + if (charsExpanded >= col) { + break; // consider only those tabs that are located before the given column number + } + } + return tcount; + }); + if (tabCount > 0) { + return Math.max(0, col + tabCount * (myTabSize - JAVAC_TAB_SIZE)); } } }