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

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


  private void applyProposal(String beanName, String className, int constructorArgCount, Set<String> properties)
      throws Exception {
    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, false);

    CreateNewClassQuickFixProposal proposal = new CreateNewClassQuickFixProposal(offset, length, className, false,
View Full Code Here


public class RemoveConstructorArgQuickFixProposalTest extends AbstractBeanFileQuickfixTestCase {

  private IDOMNode getBeanAndApplyProposal(String beanName, int removal, int original) {
    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, false);

    RemoveConstructorArgQuickFixProposal proposal = new RemoveConstructorArgQuickFixProposal(offset, length, false,
View Full Code Here

  private IType getTypeAndApplyProposal(String beanName, int addition, int original, String className)
      throws JavaModelException {
    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, false);

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

  public void testRenameProposal() throws Exception {
    IDOMNode beanNode = QuickfixTestUtil.getNode(BeansSchemaConstants.ELEM_BEAN, "renamePropertyTest", 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, false);

    String className = "com.test.Restaurant";
View Full Code Here

  private boolean hasError(String beanName) {
    NodeList children = beansNode.getChildNodes();
    IDOMNode node = QuickfixTestUtil.getNode(BeansSchemaConstants.ELEM_BEAN, beanName, children);

    AttrImpl classAttr = (AttrImpl) node.getAttributes().getNamedItem(BeansSchemaConstants.ATTR_CLASS);

    String className = classAttr.getNodeValue();

    IBeansConfig config = BeansCorePlugin.getModel().getConfig(file);
    Set<IResourceModelElement> contextElements = getContextElements(config);
    for (IResourceModelElement contextElement : contextElements) {
      if (classAttrValidator.validateAttributeWithConfig(config, contextElement, file, classAttr, node, reporter,
View Full Code Here

        NamedNodeMap attributes = node.getAttributes();
        int attributeCount = attributes.getLength();

        for (int i = 0; i < attributeCount; i++) {
          AttrImpl attribute = (AttrImpl) attributes.item(i);
          String attributeName = attribute.getNodeName();
          if (attributeName != null && attributeName.startsWith(attributeNameStart)) {
            if (attributeName.equals(attributeNameStart + argumentName)
                || attributeName.equals(attributeNameStart + argumentName + optionalAttributeNameEnd)) {
              List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
              if (element.getParent() != null && element.getParent() instanceof IMethod && types.contains(((IMethod) element.getParent()).getDeclaringType())) {
                int offset = attribute.getNameRegionStartOffset() + attributeNameStart.length();
                result.add(new ReplaceEdit(offset, argumentName.length(), newName));
              }
            }
          }
        }
View Full Code Here

          if ("property".equals(child.getLocalName()) && BeansEditorUtils.hasAttribute(child, "name")) {
            String propertyName = BeansEditorUtils.getAttribute(child, "name");
            if (methodName.equals(propertyName)) {
              List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
              if (types.contains(((IMethod) element).getDeclaringType())) {
                AttrImpl attr = (AttrImpl) child.getAttributes().getNamedItem("name");
                int offset = attr.getValueRegionStartOffset() + 1;
                if (offset >= 0) {
                  result.add(new ReplaceEdit(offset, propertyName.length(), newName));
                }
              }
            }
          }
        }
       
        // p-namespace references to the properties that belong to the changed method
        if (node.hasAttributes()) {
          String attributeNameStart = "p:";
          String optionalAttributeNameEnd = "-ref";
         
          NamedNodeMap attributes = node.getAttributes();
          int attributeCount = attributes.getLength();
         
          for (int i = 0; i < attributeCount; i++) {
            AttrImpl attribute = (AttrImpl) attributes.item(i);
            String attributeName = attribute.getNodeName();
            if (attributeName != null && attributeName.startsWith(attributeNameStart)) {
              if (attributeName.equals(attributeNameStart + methodName)
                  || attributeName.equals(attributeNameStart + methodName + optionalAttributeNameEnd)) {
                List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
                if (types.contains(((IMethod) element).getDeclaringType())) {
                  int offset = attribute.getNameRegionStartOffset() + attributeNameStart.length();
                  result.add(new ReplaceEdit(offset, methodName.length(), newName));
                }
              }
            }
          }
View Full Code Here

  private IJavaProject javaProject;

  private void applyProposal(String beanName, int removal, int original, String className) throws JavaModelException {
    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, false);

    IType type = javaProject.findType(className);
View Full Code Here

    if (BeansEditorUtils.hasAttribute(node, attrName)) {
      String attrMethodName = BeansEditorUtils.getAttribute(node, attrName);
      if (methodName.equals(attrMethodName)) {
        List<IType> types = BeansEditorUtils.getClassNamesOfBean(file, node);
        if (types.contains(((IMethod) element).getDeclaringType())) {
          AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(attrName);
          int offset = attr.getValueRegionStartOffset() + 1;
          if (offset >= 0) {
            return new ReplaceEdit(offset, attrMethodName.length(), newName);
          }
        }
      }
View Full Code Here

      return null;
    }

    String id = BeansEditorUtils.getAttribute(node, "id");
    if (oldBeanId.equals(id)) {
      AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem("id");
      int offset = attr.getValueRegionStartOffset() + 1;
      if (offset >= 0) {
        return new ReplaceEdit(offset, oldBeanId.length(), newBeanId);
      }
    }
    return null;
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.