Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 43569 Details for
Bug 115716
XML formatter produces wrong output, and hang up on huge files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
org.eclipse.wst.xml.core.patch
org.eclipse.wst.xml.core.patch (text/plain), 7.58 KB, created by
Amy Wu
on 2006-06-06 03:16:23 EDT
(
hide
)
Description:
org.eclipse.wst.xml.core.patch
Filename:
MIME Type:
Creator:
Amy Wu
Created:
2006-06-06 03:16:23 EDT
Size:
7.58 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.xml.core >Index: src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java,v >retrieving revision 1.10 >diff -u -r1.10 NodeFormatter.java >--- src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java 27 Mar 2006 01:52:23 -0000 1.10 >+++ src/org/eclipse/wst/xml/core/internal/provisional/format/NodeFormatter.java 6 Jun 2006 06:45:44 -0000 >@@ -161,7 +161,8 @@ > > protected void formatIndentationAfterNode(IDOMNode node, IStructuredFormatContraints formatContraints) { > // [111674] If inside xml:space="preserve" element, we bail >- if (formatContraints.getInPreserveSpaceElement()) return; >+ if (formatContraints.getInPreserveSpaceElement()) >+ return; > if (node != null) { > IDOMNode nextSibling = (IDOMNode) node.getNextSibling(); > IStructuredDocument doc = node.getModel().getStructuredDocument(); >@@ -169,13 +170,15 @@ > String lineDelimiter = doc.getLineDelimiter(); > try { > lineDelimiter = doc.getLineDelimiter(line); >- if (lineDelimiter == null) >- lineDelimiter = ""; //$NON-NLS-1$ > } > catch (BadLocationException e) { > // log for now, unless we find reason not to > Logger.log(Logger.INFO, e.getMessage()); > } >+ // BUG115716: if cannot get line delimiter from current line, just >+ // use default line delimiter >+ if (lineDelimiter == null) >+ lineDelimiter = doc.getLineDelimiter(); > > if (node.getParentNode() != null) { > if (node.getParentNode().getNodeType() == Node.DOCUMENT_NODE) >@@ -232,8 +235,11 @@ > insertAfterNode(lastChild, lineDelimiter + lineIndent); > } > else { >- // append indentation >- insertAfterNode(lastChild, lineDelimiter + lineIndent); >+ // as long as not at the end of the document >+ IStructuredDocumentRegion endRegion = node.getLastStructuredDocumentRegion(); >+ if (endRegion != null && endRegion.getNext() != null) >+ // append indentation >+ insertAfterNode(lastChild, lineDelimiter + lineIndent); > } > } > } >@@ -243,7 +249,8 @@ > > protected void formatIndentationBeforeNode(IDOMNode node, IStructuredFormatContraints formatContraints) { > // [111674] If inside xml:space="preserve" element, we bail >- if (formatContraints.getInPreserveSpaceElement()) return; >+ if (formatContraints.getInPreserveSpaceElement()) >+ return; > if (node != null) { > IDOMNode previousSibling = (IDOMNode) node.getPreviousSibling(); > IStructuredDocument doc = node.getModel().getStructuredDocument(); >@@ -252,14 +259,16 @@ > try { > if (line > 0) { > lineDelimiter = doc.getLineDelimiter(line - 1); >- if (lineDelimiter == null) >- lineDelimiter = ""; //$NON-NLS-1$ > } > } > catch (BadLocationException e) { > // log for now, unless we find reason not to > Logger.log(Logger.INFO, e.getMessage()); > } >+ // BUG115716: if cannot get line delimiter from current line, just >+ // use default line delimiter >+ if (lineDelimiter == null) >+ lineDelimiter = doc.getLineDelimiter(); > String lineIndent = formatContraints.getCurrentIndent(); > > if (node.getParentNode() != null) { >@@ -328,7 +337,8 @@ > */ > protected void formatTrailingText(IDOMNode node, IStructuredFormatContraints formatContraints) { > // [111674] If inside xml:space="preserve" element, we bail >- if (formatContraints.getInPreserveSpaceElement()) return; >+ if (formatContraints.getInPreserveSpaceElement()) >+ return; > > String lineDelimiter = node.getModel().getStructuredDocument().getLineDelimiter(); > String lineIndent = formatContraints.getCurrentIndent(); >Index: src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java >=================================================================== >RCS file: /cvsroot/webtools/wst/components/xml/plugins/org.eclipse.wst.xml.core/src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java,v >retrieving revision 1.6 >diff -u -r1.6 ElementNodeFormatter.java >--- src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java 27 Feb 2006 09:08:14 -0000 1.6 >+++ src/org/eclipse/wst/xml/core/internal/provisional/format/ElementNodeFormatter.java 6 Jun 2006 06:45:44 -0000 >@@ -129,8 +129,10 @@ > } > > formatContraints.setInPreserveSpaceElement(currentlyInXmlSpacePreserve); >- // format indentation after node >- formatIndentationAfterNode(newNode, formatContraints); >+ // only indent if not at last node >+ if (newNode != null && newNode.getNextSibling() != null) >+ // format indentation after node >+ formatIndentationAfterNode(newNode, formatContraints); > } > } > >@@ -170,7 +172,7 @@ > int attrLength = attributes.getLength(); > int lastUndefinedRegionOffset = 0; > boolean sawXmlSpace = false; >- >+ > for (int i = 0; i < attrLength; i++) { > AttrImpl attr = (AttrImpl) attributes.item(i); > ITextRegion nameRegion = attr.getNameRegion(); >@@ -185,9 +187,11 @@ > // check for xml:space attribute > if (flatNode.getText(nameRegion).compareTo(XML_SPACE) == 0) { > if (valueRegion == null) { >- // [111674] If nothing has been written yet, treat as preserve, but only as hint >+ // [111674] If nothing has been written yet, treat as >+ // preserve, but only as hint > formatContraints.setInPreserveSpaceElement(true); >- // Note we don't set 'sawXmlSpace', so that default or fixed DTD/XSD values may override. >+ // Note we don't set 'sawXmlSpace', so that default or >+ // fixed DTD/XSD values may override. > } > else { > ISourceGenerator generator = node.getModel().getGenerator(); >@@ -327,27 +331,27 @@ > } > } > >- >+ > replace(structuredDocument, offset, length, stringBuffer.toString()); > >- // If we didn't see a xml:space attribute above, we'll look for one in the DTD. >+ // If we didn't see a xml:space attribute above, we'll look for >+ // one in the DTD. > // We do not check for a conflict between a DTD's 'fixed' value >- // and the attribute value found in the instance document, we leave that to the validator. >- if (! sawXmlSpace) >- { >+ // and the attribute value found in the instance document, we >+ // leave that to the validator. >+ if (!sawXmlSpace) { > ModelQueryAdapter adapter = (ModelQueryAdapter) ((IDOMDocument) node.getOwnerDocument()).getAdapterFor(ModelQueryAdapter.class); > CMElementDeclaration elementDeclaration = (CMElementDeclaration) adapter.getModelQuery().getCMNode(node); >- if (elementDeclaration != null) >- { >+ if (elementDeclaration != null) { > CMNamedNodeMap cmAttributes = elementDeclaration.getAttributes(); > // Check implied values from the DTD way. > CMAttributeDeclaration attributeDeclaration = (CMAttributeDeclaration) cmAttributes.getNamedItem(XML_SPACE); >- if (attributeDeclaration != null) >- { >+ if (attributeDeclaration != null) { > // CMAttributeDeclaration found, check it out. > String defaultValue = attributeDeclaration.getAttrType().getImpliedValue(); >- >- // xml:space="preserve" means preserve space, everything else means back to default. >+ >+ // xml:space="preserve" means preserve space, >+ // everything else means back to default. > if (defaultValue.compareTo(PRESERVE) == 0) > formatContraints.setInPreserveSpaceElement(true); > else
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 115716
:
29650
|
43550
| 43569 |
43570