mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
highlighting level per file state wont save correctly (was depending on the PsiFile.getPsiRoots() order)
This commit is contained in:
@@ -509,6 +509,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
public PsiFile[] getPsiRoots() {
|
||||
final FileViewProvider viewProvider = getViewProvider();
|
||||
final Set<Language> languages = viewProvider.getLanguages();
|
||||
|
||||
final PsiFile[] roots = new PsiFile[languages.size()];
|
||||
int i = 0;
|
||||
for (Language language : languages) {
|
||||
@@ -518,8 +519,17 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
}
|
||||
roots[i++] = psi;
|
||||
}
|
||||
if (roots.length > 1) {
|
||||
Arrays.sort(roots, FILE_BY_LANGUAGE_ID);
|
||||
}
|
||||
return roots;
|
||||
}
|
||||
private static final Comparator<PsiFile> FILE_BY_LANGUAGE_ID = new Comparator<PsiFile>() {
|
||||
@Override
|
||||
public int compare(PsiFile o1, PsiFile o2) {
|
||||
return o1.getLanguage().getID().compareTo(o2.getLanguage().getID());
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean isPhysical() {
|
||||
|
||||
@@ -55,6 +55,7 @@ import javax.swing.plaf.basic.BasicSliderUI;
|
||||
import java.awt.*;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* User: anna
|
||||
@@ -83,7 +84,13 @@ public class HectorComponent extends JPanel {
|
||||
final boolean notInLibrary =
|
||||
!fileIndex.isInLibrarySource(virtualFile) && !fileIndex.isInLibraryClasses(virtualFile) || fileIndex.isInContent(virtualFile);
|
||||
final FileViewProvider viewProvider = myFile.getViewProvider();
|
||||
final Set<Language> languages = viewProvider.getLanguages();
|
||||
List<Language> languages = new ArrayList<Language>(viewProvider.getLanguages());
|
||||
Collections.sort(languages, new Comparator<Language>() {
|
||||
@Override
|
||||
public int compare(Language o1, Language o2) {
|
||||
return o1.getID().compareTo(o2.getID());
|
||||
}
|
||||
});
|
||||
for (Language language : languages) {
|
||||
@SuppressWarnings("UseOfObsoleteCollectionType")
|
||||
final Hashtable<Integer, JLabel> sliderLabels = new Hashtable<Integer, JLabel>();
|
||||
|
||||
-20
@@ -25,7 +25,6 @@ import com.intellij.psi.FileViewProvider;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -181,31 +180,12 @@ class MoverWrapper {
|
||||
int line1 = editor.offsetToLogicalPosition(range.getStartOffset()).line;
|
||||
int line2 = editor.offsetToLogicalPosition(range.getEndOffset()).line;
|
||||
|
||||
/* if (PsiUtil.isInJspFile(file)) {
|
||||
// This version is slow because of each moved line cause commit
|
||||
// and right now we unable to fix JSP formatter quickly
|
||||
// TODO: remove this code
|
||||
for (int line = line1; line <= line2; line++) {
|
||||
if (lineContainsNonSpaces(document, line)) {
|
||||
int lineStart = document.getLineStartOffset(line);
|
||||
codeStyleManager.adjustLineIndent(document, lineStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {*/
|
||||
|
||||
while (!lineContainsNonSpaces(document, line1) && line1 <= line2) line1++;
|
||||
while (!lineContainsNonSpaces(document, line2) && line2 > line1) line2--;
|
||||
|
||||
try {
|
||||
final FileViewProvider provider = file.getViewProvider();
|
||||
PsiFile rootToAdjustIndentIn = provider.getPsi(provider.getBaseLanguage());
|
||||
codeStyleManager.adjustLineIndent(rootToAdjustIndentIn, new TextRange(document.getLineStartOffset(line1), document.getLineStartOffset(line2)));
|
||||
}
|
||||
catch (IncorrectOperationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
/* } */
|
||||
}
|
||||
|
||||
private static boolean lineContainsNonSpaces(final Document document, final int line) {
|
||||
|
||||
Reference in New Issue
Block a user