1 11 package org.eclipse.pde.internal.core.text.plugin; 12 13 import org.eclipse.pde.internal.core.text.IDocumentAttribute; 14 import org.eclipse.pde.internal.core.text.IDocumentNode; 15 import org.xml.sax.Attributes ; 16 import org.xml.sax.SAXException ; 17 18 public class NodeOffsetHandler extends AbstractPluginDocumentHandler { 19 20 23 public NodeOffsetHandler(PluginModelBase model) { 24 super(model); 25 } 26 27 30 public void startElement(String uri, String localName, String qName, 31 Attributes attributes) throws SAXException { 32 super.startElement(uri, localName, qName, attributes); 33 IDocumentNode node = (IDocumentNode)fDocumentNodeStack.peek(); 34 IDocumentAttribute[] attrs = node.getNodeAttributes(); 35 for (int i = 0; i < attrs.length; i++) { 36 } 39 } 40 43 protected IDocumentNode getDocumentNode(String name, IDocumentNode parent) { 44 IDocumentNode node = null; 45 if (parent == null) { 46 node = (IDocumentNode)getModel().getPluginBase(); 47 node.setOffset(-1); 48 node.setLength(-1); 49 } else { 50 IDocumentNode[] children = parent.getChildNodes(); 51 for (int i = 0; i < children.length; i++) { 52 if (children[i].getOffset() < 0) { 53 node = children[i]; 54 break; 55 } 56 } 57 } 58 59 IDocumentAttribute[] attrs = node.getNodeAttributes(); 60 for (int i = 0; i < attrs.length; i++) { 61 attrs[i].setNameOffset(-1); 62 attrs[i].setNameLength(-1); 63 attrs[i].setValueOffset(-1); 64 attrs[i].setValueLength(-1); 65 } 66 67 for (int i = 0; i < node.getChildNodes().length; i++) { 68 IDocumentNode child = node.getChildAt(i); 69 child.setOffset(-1); 70 child.setLength(-1); 71 } 72 73 return node; 74 } 75 76 79 protected void appendChildToParent(IDocumentNode parent, IDocumentNode child) { 80 } 81 82 85 protected IDocumentAttribute getDocumentAttribute(String name, 86 String value, IDocumentNode parent) { 87 return parent.getDocumentAttribute(name); 88 } 89 90 } 91 | Popular Tags |