Commit a20af2bf authored by peter's avatar peter
Browse files

checkPsiMatchesTextIgnoringNonCode: ignore outers, make diffs shorter

parent 42ef47c6
Showing with 15 additions and 2 deletions
+15 -2
......@@ -18,6 +18,7 @@ import com.intellij.psi.impl.source.SourceTreeToPsiMap;
import com.intellij.psi.impl.source.tree.*;
import com.intellij.psi.stubs.ObjectStubSerializer;
import com.intellij.psi.stubs.Stub;
import com.intellij.psi.templateLanguages.OuterLanguageElement;
import com.intellij.psi.tree.IElementType;
import com.intellij.psi.util.PsiUtilCore;
import com.intellij.util.*;
......@@ -404,7 +405,8 @@ public class DebugUtil {
@Override
protected boolean shouldSkipNode(TreeElement node) {
return super.shouldSkipNode(node) || node instanceof PsiErrorElement || node instanceof PsiComment ||
node instanceof LeafPsiElement && StringUtil.isEmptyOrSpaces(node.getText());
node instanceof LeafPsiElement && StringUtil.isEmptyOrSpaces(node.getText()) ||
node instanceof OuterLanguageElement;
}
@Override
......
......@@ -224,7 +224,18 @@ public class PsiTestUtil {
String psiTree = StringUtil.join(file.getViewProvider().getAllFiles(), fun, "\n");
String reparsedTree = StringUtil.join(dummyFile.getViewProvider().getAllFiles(), fun, "\n");
if (!psiTree.equals(reparsedTree)) {
Assert.assertEquals("Re-created from text:\n" + reparsedTree, "PSI structure:\n" + psiTree);
String[] psiLines = StringUtil.splitByLines(psiTree);
String[] reparsedLines = StringUtil.splitByLines(reparsedTree);
for (int i = 0; ; i++) {
if (i >= psiLines.length || i >= reparsedLines.length || !psiLines[i].equals(reparsedLines[i])) {
psiLines[Math.min(i, psiLines.length - 1)] += " // in PSI structure";
reparsedLines[Math.min(i, reparsedLines.length - 1)] += " // re-created from text";
break;
}
}
psiTree = StringUtil.join(psiLines, "\n");
reparsedTree = StringUtil.join(reparsedLines, "\n");
Assert.assertEquals(reparsedTree, psiTree);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment