Package org.eclipse.wst.xml.core.internal.document

Examples of org.eclipse.wst.xml.core.internal.document.AttrImpl


    for (int i = 0; i < nodes.getLength(); i++) {
      Node item = nodes.item(i);
      if (BeansSchemaConstants.ELEM_BEAN.equals(item.getNodeName())) {
        if (item.getAttributes() != null) {
          AttrImpl attr = (AttrImpl) item.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_NAME);
          if (attr != null) {
            if (beanName.equals(attr.getNodeValue())) {
              return (IDOMNode) item;
            }
          }

          attr = (AttrImpl) item.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_ID);
          if (attr != null) {
            if (beanName.equals(attr.getNodeValue())) {
              return (IDOMNode) item;
            }
          }
        }
      }
View Full Code Here


  private NodeInfo findNodeInfo(IDOMNode node, String attrName, String attrValue) {
    if (node != null) {
      NamedNodeMap attributes = node.getAttributes();
      if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); i++) {
          AttrImpl attribute = (AttrImpl) attributes.item(i);
          if (attrName == null || attrName.equals(attribute.getNodeName())) {
            if (attrValue != null && attrValue.equals(attribute.getNodeValue())) {
              int offset = attribute.getValueRegionStartOffset();

              // increase offset if value starts with
              // "
              if (attribute.getValueRegion().getLength() > attrValue.length()) {
                offset++;
              }
              int length = attribute.getNodeValue() == null ? 0 : attribute.getNodeValue().length();
              return new NodeInfo(node, offset, length);
            }
          }
        }
      }
View Full Code Here

  }

  public void testAddConfigSet() {
    IDOMNode beanNode = QuickfixTestUtil.getNode(BeansSchemaConstants.ELEM_BEAN, "addToConfigSetTest",
        beansNode.getChildNodes());
    AttrImpl parentAttr = (AttrImpl) beanNode.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_PARENT);
    ITextRegion valueRegion = parentAttr.getValueRegion();

    int offset = getOffset(valueRegion, beanNode);
    int length = getLength(valueRegion, false);

    IFile configFile = (IFile) project.findMember("src/import-test.xml");
    IBeansConfig config = BeansCorePlugin.getModel().getConfig(configFile);
    IBean importBean = BeansModelUtils.getBean(parentAttr.getValue(), config);

    BeansProject beanProject = (BeansProject) BeansCorePlugin.getModel().getProject(project);
    IBeansConfigSet configSet = beanProject.getConfigSet("AddConfigSetTest");
    assertNull("Expects no config set", configSet);
View Full Code Here

    List<String> constructorParamClassNames = new ArrayList<String>();
    for (int i = 0; i < constructorParamCount; i++) {
      constructorParamClassNames.add("Object");
    }

    AttrImpl classAttr = (AttrImpl) beanNode.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_CLASS);
    ITextRegion valueRegion = classAttr.getValueRegion();

    int offset = getOffset(valueRegion, beanNode);
    int length = getLength(valueRegion, false);

    IJavaProject javaProject = JavaCore.create(project);
View Full Code Here

  private AttrImpl getAttrAndApplyClassRenamingProposal(String beanName, String newClassName,
      boolean isMissingEndQuote) {
    IDOMNode beanNode = QuickfixTestUtil.getNode(BeansSchemaConstants.ELEM_BEAN, beanName,
        beansNode.getChildNodes());
    AttrImpl classAttr = (AttrImpl) beanNode.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_CLASS);
    ITextRegion valueRegion = classAttr.getValueRegion();

    int offset = getOffset(valueRegion, beanNode);
    int length = getLength(valueRegion, isMissingEndQuote);

    RenameToSimilarNameQuickFixProposal proposal = new RenameToSimilarNameQuickFixProposal(newClassName, offset,
View Full Code Here

      boolean isMissingEndQuote) {
    IDOMNode beanNode = QuickfixTestUtil.getNode(BeansSchemaConstants.ELEM_BEAN, beanName,
        beansNode.getChildNodes());
    IDOMNode propertyNode = QuickfixTestUtil.getFirstNode(BeansSchemaConstants.ELEM_PROPERTY,
        beanNode.getChildNodes());
    AttrImpl nameAttr = (AttrImpl) propertyNode.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_NAME);
    ITextRegion valueRegion = nameAttr.getValueRegion();

    int offset = getOffset(valueRegion, propertyNode);
    int length = getLength(valueRegion, isMissingEndQuote);

    RenameToSimilarNameQuickFixProposal proposal = new RenameToSimilarNameQuickFixProposal("account", offset,
View Full Code Here

    super.setUp();
  }

  public void testRenameClassAttribute() throws Exception {
    openBeanEditor("src/rename-proposals-class.xml");
    AttrImpl classAttr = getAttrAndApplyClassRenamingProposal("renameTest1", "com.test.Account", false);
    assertEquals("Expects class attribute = com.test.Account", "com.test.Account", classAttr.getValue());
  }
View Full Code Here

    assertEquals("Expects class attribute = com.test.Account", "com.test.Account", classAttr.getValue());
  }

  public void testRenameClassAttributeWithMissingEndQuote() throws Exception {
    openBeanEditor("src/rename-proposals-class.xml");
    AttrImpl classAttr = getAttrAndApplyClassRenamingProposal("renameTest2", "com.test.Account", true);
    assertEquals("Expects class attribute = com.test.Account", "com.test.Account", classAttr.getValue());
  }
View Full Code Here

    assertEquals("Expects class attribute = com.test.Account", "com.test.Account", classAttr.getValue());
  }

  public void testRenamePropertyName() throws Exception {
    openBeanEditor("src/rename-proposals-attribute.xml");
    AttrImpl nameAttr = getAttrAndApplyPropertyNameRenamingProposal("renameTest3", "account", false);
    assertEquals("Expects property name = account", "account", nameAttr.getValue());
  }
View Full Code Here

    assertEquals("Expects property name = account", "account", nameAttr.getValue());
  }

  public void testRenamePropertyNameWithMissingEndQuote() throws Exception {
    openBeanEditor("src/rename-proposals-attribute.xml");
    AttrImpl nameAttr = getAttrAndApplyPropertyNameRenamingProposal("renameTest4", "account", true);
    assertEquals("Expects property name = account", "account", nameAttr.getValue());
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.document.AttrImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.