From 8d9d0a625527fea97a034d05cf7f2a994720bc6b Mon Sep 17 00:00:00 2001 From: "no_reply@jetbrains.com" Date: Thu, 3 Feb 2005 21:38:40 +0300 Subject: [PATCH] Several fixes in synchronization schema --- .../com/intellij/testFramework/ParsingTestCase.java | 2 ++ source/com/intellij/psi/impl/DebugUtil.java | 13 ++++++++++--- .../impl/source/codeStyle/CodeStyleManagerImpl.java | 4 ++-- source/com/intellij/xml/util/XmlUtil.java | 8 ++++++-- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/ExtendedApi/src/com/intellij/testFramework/ParsingTestCase.java b/ExtendedApi/src/com/intellij/testFramework/ParsingTestCase.java index da66fc6d7c0b..e5fc9e843256 100644 --- a/ExtendedApi/src/com/intellij/testFramework/ParsingTestCase.java +++ b/ExtendedApi/src/com/intellij/testFramework/ParsingTestCase.java @@ -6,6 +6,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.openapi.util.text.StringUtil; import com.intellij.psi.PsiFile; import com.intellij.psi.impl.DebugUtil; +import com.intellij.psi.impl.source.jsp.JspxFileImpl; import java.io.File; import java.io.FileNotFoundException; @@ -36,6 +37,7 @@ public abstract class ParsingTestCase extends LightIdeaTestCase { else{ toParseTreeText(file); } + if(file instanceof JspxFileImpl) ((JspxFileImpl)file).checkAllTreesEqual(); } protected void checkResult(String targetDataName, final PsiFile file) throws Exception { diff --git a/source/com/intellij/psi/impl/DebugUtil.java b/source/com/intellij/psi/impl/DebugUtil.java index 17546c8bae19..d2b585e37646 100644 --- a/source/com/intellij/psi/impl/DebugUtil.java +++ b/source/com/intellij/psi/impl/DebugUtil.java @@ -29,9 +29,15 @@ public class DebugUtil { public static String treeToString(ASTNode root, boolean skipWhitespaces) { StringBuffer buffer = new StringBuffer(); - treeToBuffer(buffer, root, 0, skipWhitespaces); + treeToBuffer(buffer, root, 0, skipWhitespaces, false); return buffer.toString(); } + public static String treeToString(ASTNode root, boolean skipWhitespaces, boolean showRanges) { + StringBuffer buffer = new StringBuffer(); + treeToBuffer(buffer, root, 0, skipWhitespaces, showRanges); + return buffer.toString(); + } + public static String treeToStringWithUserData(TreeElement root, boolean skipWhitespaces) { StringBuffer buffer = new StringBuffer(); @@ -63,7 +69,7 @@ public class DebugUtil { } } - private static void treeToBuffer(StringBuffer buffer, ASTNode root, int indent, boolean skipWhiteSpaces) { + private static void treeToBuffer(StringBuffer buffer, ASTNode root, int indent, boolean skipWhiteSpaces, boolean showRanges) { if (skipWhiteSpaces && root.getElementType() == ElementType.WHITE_SPACE) return; for (int i = 0; i < indent; i++) { @@ -85,6 +91,7 @@ public class DebugUtil { text = StringUtil.replace(text, "\t", "\\t"); buffer.append(root.toString() + "('" + text + "')"); } + if(showRanges) buffer.append(root.getTextRange()); buffer.append("\n"); if (root instanceof CompositeElement) { ChameleonTransforming.transformChildren(root); @@ -98,7 +105,7 @@ public class DebugUtil { } else { while (child != null) { - treeToBuffer(buffer, child, indent + 2, skipWhiteSpaces); + treeToBuffer(buffer, child, indent + 2, skipWhiteSpaces, false); child = child.getTreeNext(); } } diff --git a/source/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java b/source/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java index 7c20cc6de148..f86d00b57b03 100644 --- a/source/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java +++ b/source/com/intellij/psi/impl/source/codeStyle/CodeStyleManagerImpl.java @@ -251,8 +251,8 @@ public class CodeStyleManagerImpl extends CodeStyleManagerEx implements ProjectC ASTNode next = element.getTreeNext(); ASTNode space1 = Helper.splitSpaceElement((TreeElement)element, end - spaceStart, charTable); ASTNode tempElement = Factory.createSingleLeafElement( - ElementType.NEW_LINE_INDENT, "###".toCharArray(), 0, - "###".length(), charTable, null); + ElementType.NEW_LINE_INDENT, "xxx".toCharArray(), 0, + "xxx".length(), charTable, null); parent.addChild(tempElement, space1.getTreeNext()); tempElement = new IndentAdjusterFacade(getSettings(), helper).adjustIndent(tempElement); offset = tempElement.getTextRange().getStartOffset(); diff --git a/source/com/intellij/xml/util/XmlUtil.java b/source/com/intellij/xml/util/XmlUtil.java index 488ca5981182..60fb86f794d8 100644 --- a/source/com/intellij/xml/util/XmlUtil.java +++ b/source/com/intellij/xml/util/XmlUtil.java @@ -508,7 +508,8 @@ public class XmlUtil { final FileType fileType = file.getFileType(); if (fileType == StdFileTypes.HTML || - fileType == StdFileTypes.XHTML + fileType == StdFileTypes.XHTML || + fileType == StdFileTypes.JSPX ) { return XHTML_URI; } @@ -811,7 +812,10 @@ public class XmlUtil { } public static String decode(String text){ - if(text.charAt(0) != '&' || text.length() > 6 || text.length() < 3) return text; + if(text.charAt(0) != '&' || text.length() > 6 || text.length() < 3){ + if(text.indexOf('<') < 0 && text.indexOf('>') < 0) return text; + return text.replaceAll("", ""); + } if(text.equals("<")) { return "<";