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

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


      // offsets AND if it possesses a value
      boolean attrAtLocationHasValue = false;
      boolean proposalNeedsSpace = false;
      NamedNodeMap attrs = node.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion name = existingAttr.getNameRegion();
       
        if (name != null && (sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) &&
            (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) &&
            (existingAttr.getValueRegion() != null)) {
          // selected region is attribute name
          if (cursorOffset >= sdRegion.getStartOffset(name) && contentAssistRequest.getReplacementLength() != 0)
            attrAtLocationHasValue = true;
          // propose new attribute, cursor is at the start of another attribute name
          else if (cursorOffset == sdRegion.getStartOffset(name))
            proposalNeedsSpace = true;
          break;
        }
      }

      // only add proposals for the attributes whose names begin with the matchstring
      if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); i++) {
          CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);

          if(validModelQueryNode(attrDecl)) {
            int isRequired = 0;
            if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
              isRequired = XMLRelevanceConstants.R_REQUIRED;
            }
 
            boolean showAttribute = true;
            showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
            AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
            ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
            // nameRegion.getEndOffset() + 1 is required to allow for
            // matches against the full name of an existing Attr
            showAttribute = showAttribute && ((attr == null) || nameRegion == null ||
                ((nameRegion != null) &&
                    (sdRegion.getStartOffset(nameRegion) <
View Full Code Here


    if (notifier instanceof IDOMNode) {

      switch (eventType) {
        case INodeNotifier.CHANGE :
          if (changedFeature instanceof AttrImpl) {
            AttrImpl attribute = (AttrImpl) changedFeature;
            String name = attribute.getName();
            if (name.equals("contentType")) { //$NON-NLS-1$
              // using concrete class below, since "changed" is something of an internal method
              PageDirectiveAdapterImpl pageDirectiveAdapter = (PageDirectiveAdapterImpl) ((IDOMDocument) targetElement.getOwnerDocument()).getAdapterFor(PageDirectiveAdapter.class);
              pageDirectiveAdapter.changedContentType(((IndexedRegion) targetElement).getStartOffset(), (String) newValue);
            }
View Full Code Here

      int attrLength = attributes.getLength();
      int lastUndefinedRegionOffset = 0;
      boolean startTagSpansOver1Line = false;

      for (int i = 0; i < attrLength; i++) {
        AttrImpl attr = (AttrImpl) attributes.item(i);
        ITextRegion nameRegion = attr.getNameRegion();
        ITextRegion equalRegion = attr.getEqualRegion();
        ITextRegion valueRegion = attr.getValueRegion();

        // append undefined regions
        String undefinedRegion = getUndefinedRegions(node, lastUndefinedRegionOffset, attr.getStartOffset() - lastUndefinedRegionOffset);
        stringBuffer.append(undefinedRegion);
        lastUndefinedRegionOffset = attr.getStartOffset();

        // 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
View Full Code Here

      // check whether an attribute really exists for the replacement
      // offsets AND if it possesses a value
      boolean attrAtLocationHasValue = false;
      NamedNodeMap attrs = node.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion name = existingAttr.getNameRegion();

        if ((sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) && (existingAttr.getValueRegion() != null)) {
          attrAtLocationHasValue = true;
          break;
        }
      }

      // only add proposals for the attributes whose names begin with
      // the matchstring
      if (attributes != null) {
        for (int i = 0; i < attributes.getLength(); i++) {
          CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);

          int isRequired = 0;
          if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
            isRequired = XMLRelevanceConstants.R_REQUIRED;
          }

          boolean showAttribute = true;
          showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
          AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
          ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
          // nameRegion.getEndOffset() + 1 is required to allow for
          // matches against the full name of an existing Attr
          showAttribute = showAttribute && (attr == null || nameRegion == null || (nameRegion != null && (sdRegion.getStartOffset(nameRegion) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength())));
          if (showAttribute) {
            Image attrImage = CMImageUtil.getImage(attrDecl);
View Full Code Here

  @SuppressWarnings("restriction")
  protected ContentAssistRequest computeAttributeValueProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
    if ("field".equals(node.getNodeName()) || "a".equals(node.getNodeName()) || "b".equals(node.getNodeName())) {
      NamedNodeMap attrs = nodeAtOffset.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion valueRegion = existingAttr.getValueRegion();
        String attrName = existingAttr.getName();
        if (completionRegion.getStart() >= valueRegion.getStart() &&
              completionRegion.getEnd() <= valueRegion.getEnd()) {
           
          //the first " in matchstring must be deleted for search
          if ("custom-converter".equals(attrName)) {
View Full Code Here

    ValidationRuleDefinition ruleDefinition = getValidationRule(project, BeanFactoryRule.class);
    BeanFactoryRule rule = (BeanFactoryRule) (ruleDefinition != null ? ruleDefinition.getRule() : null);
    BeanHelper parentBean = new BeanHelper(parent, file, project);
    parentBean.getBeanDefinition().setFactoryMethodName(text);

    AttrImpl factoryBeanAttr = (AttrImpl) parent.getAttributes().getNamedItem(
        BeansSchemaConstants.ATTR_FACTORY_BEAN);
    if (factoryBeanAttr != null) {
      parentBean.getBeanDefinition().setFactoryBeanName(factoryBeanAttr.getNodeValue());
    }

    BeansValidationContextHelper context = new BeansValidationContextHelper(attribute, parent, contextElement,
        project, reporter, validator, QuickfixProcessorFactory.FACTORY_METHOD, false, reportError, config);
View Full Code Here

    for (int i = 0; i < attributes.getLength(); i++) {
      Node attribute = attributes.item(i);

      if (attribute instanceof AttrImpl) {
        AttrImpl attrImpl = (AttrImpl) attribute;

        errorFound |= QuickfixUtils.validateAttribute(config, contextElement, attrImpl, node, reporter,
            reportError, editorValidator);
      }
    }
View Full Code Here

      // offsets AND if it possesses a value
      IStructuredDocumentRegion sdRegion = request.getDocumentRegion();
      boolean attrAtLocationHasValue = false;
      NamedNodeMap attrs = attributeNode.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion name = existingAttr.getNameRegion();
        if (sdRegion.getStartOffset(name) <= request.getReplacementBeginPosition()
            && sdRegion.getStartOffset(name) + name.getLength() >= request.getReplacementBeginPosition()
                + request.getReplacementLength() && existingAttr.getValueRegion() != null) {
          attrAtLocationHasValue = true;
          break;
        }
      }

      if (prefix != null) {
        prefix = BeansEditorUtils.attributeNameToPropertyName(prefix);
      }

      List classNames = BeansEditorUtils.getClassNamesOfBean(BeansEditorUtils.getFile(request), attributeNode);
      addPropertyNameAttributeNameProposals(request, prefix, "", attributeNode, classNames,
          attrAtLocationHasValue, namespacePrefix);
    }
    else if ("http://www.springframework.org/schema/c".equals(namespace)) {
      IStructuredDocumentRegion sdRegion = request.getDocumentRegion();
      boolean attrAtLocationHasValue = false;
      NamedNodeMap attrs = attributeNode.getAttributes();
      for (int i = 0; i < attrs.getLength(); i++) {
        AttrImpl existingAttr = (AttrImpl) attrs.item(i);
        ITextRegion name = existingAttr.getNameRegion();
        if (sdRegion.getStartOffset(name) <= request.getReplacementBeginPosition()
            && sdRegion.getStartOffset(name) + name.getLength() >= request.getReplacementBeginPosition()
                + request.getReplacementLength() && existingAttr.getValueRegion() != null) {
          attrAtLocationHasValue = true;
          break;
        }
      }
     
View Full Code Here

    Set<OccurrenceLocation> result = new HashSet<OccurrenceLocation>();

    NamedNodeMap attributes = node.getAttributes();
    if (attributes != null) {
      for (int i = 0; i < attributes.getLength(); i++) {
        AttrImpl attribute = (AttrImpl) attributes.item(i);
        result.addAll(findBeanReferences(beanName, attribute, node, context));
      }
    }

    NodeList nodes = node.getChildNodes();
View Full Code Here

  private String getBeanName(IDOMNode node, int offset, BeansValidationContext context) {
    NamedNodeMap attributes = node.getAttributes();
    if (attributes != null) {
      for (int i = 0; i < attributes.getLength(); i++) {
        AttrImpl attribute = (AttrImpl) attributes.item(i);

        if (attribute != null && attribute.getStartOffset() <= offset && attribute.getEndOffset() >= offset) {
          if (context != null) {
            List<ToolAnnotationData> toolAnnotations = context.getToolAnnotation(node,
                attribute.getLocalName());
            for (ToolAnnotationData toolAnnotation : toolAnnotations) {
              if ("ref".equals(toolAnnotation.getKind())) { //$NON-NLS-1$
                return attribute.getNodeValue();
              }
            }
          }

          for (String attributeName : ATTRIBUTES_TO_CHECK) {
            if (attributeName.equals(attribute.getNodeName())) {
              return attribute.getNodeValue();
            }
          }
        }
      }
    }
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.