Package org.eclipse.wst.validation.internal.operations

Examples of org.eclipse.wst.validation.internal.operations.LocalizedMessage


    if ( XMLCorePlugin.getDefault().getPluginPreferences().getBoolean(XMLCorePreferenceNames.MARKUP_VALIDATION)){
      IReporter reporter = executeMarkupValidator(uri);
      if (reporter != null){
        List msgList = reporter.getMessages();
        for (int i = 0;i < msgList.size();i++){
          LocalizedMessage msg = (LocalizedMessage)msgList.get(i);
          if (msg.getSeverity() == 2)
            valinfo.addError(msg.getLocalizedMessage(), msg.getLineNumber(), msg.getOffset(),valinfo.getFileURI(),"null",getMsgArguments(msg) ); //$NON-NLS-1$
          else if (msg.getSeverity() == 1)
            valinfo.addWarning(msg.getLocalizedMessage(), msg.getLineNumber(), msg.getOffset(),valinfo.getFileURI(),"null", getMsgArguments(msg)); //$NON-NLS-1$
        }
      }
    }
   
    return valinfo;
View Full Code Here


    if (sdRegion.isDeleted()) {
      return;
    }

    int lineNo = getLineNumber(start);
    LocalizedMessage message = new LocalizedMessage(messageSeverity, messageText);
    message.setOffset(start);
    message.setLength(length);
    message.setLineNo(lineNo);


    if (reporter instanceof IncrementalReporter) {
      MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
      processor.setProblemId(problemId);
      processor.setAdditionalFixInfo(attributeValueText);
      message.setAttribute(QUICKASSISTPROCESSOR, processor);
      AnnotationInfo info = new AnnotationInfo(message);
      ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
    }
    else {
      reporter.addMessage(this, message);
View Full Code Here

    }
    // create one error for all attributes in the end tag
    if (errorCount > 0) {
      // Position p = new Position(start, end - start);
      String messageText = XMLUIMessages.End_tag_has_attributes;
      LocalizedMessage message = new LocalizedMessage(SEVERITY_END_TAG_WITH_ATTRIBUTES, messageText);
      message.setOffset(start);
      message.setLength(end - start);
      message.setLineNo(getLineNumber(start));

      if (reporter instanceof IncrementalReporter) {
        MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
        processor.setProblemId(ProblemIDsXML.AttrsInEndTag);
        message.setAttribute(QUICKASSISTPROCESSOR, processor);

        AnnotationInfo info = new AnnotationInfo(message);
        ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
      }
      else {
View Full Code Here

      int start = structuredDocumentRegion.getStartOffset();
      int length = structuredDocumentRegion.getText().trim().length();
      int lineNo = getLineNumber(start);

      LocalizedMessage message = new LocalizedMessage(SEVERITY_MISSING_CLOSING_BRACKET , messageText);
      message.setOffset(start);
      message.setLength(length);
      message.setLineNo(lineNo);

      if (reporter instanceof IncrementalReporter) {
        MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
        processor.setProblemId(ProblemIDsXML.MissingClosingBracket);
        message.setAttribute(QUICKASSISTPROCESSOR, processor);

        AnnotationInfo info = new AnnotationInfo(message);
        ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
      }
      else {
View Full Code Here

        String messageText = XMLUIMessages.ReconcileStepForMarkup_3;
        int start = structuredDocumentRegion.getStartOffset();
        int length = structuredDocumentRegion.getLength();
        int lineNo = getLineNumber(start);

        LocalizedMessage message = new LocalizedMessage(SEVERITY_TAG_NAME_MISSING , messageText);
        message.setOffset(start);
        message.setLength(length);
        message.setLineNo(lineNo);

        if (reporter instanceof IncrementalReporter) {
          MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
          processor.setProblemId(ProblemIDsXML.EmptyTag);
          message.setAttribute(QUICKASSISTPROCESSOR, processor);

          AnnotationInfo info = new AnnotationInfo(message);
          ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
        }
        else {
View Full Code Here

            int start = structuredDocumentRegion.getStartOffset(nameRegion);
            int end = structuredDocumentRegion.getEndOffset();
            int lineNo = getLineNumber(start);
            int textLength = structuredDocumentRegion.getText(nameRegion).trim().length();

            LocalizedMessage message = new LocalizedMessage(SEVERITY_ATTRIBUTE_HAS_NO_VALUE , messageText);
            message.setOffset(start);
            message.setLength(textLength);
            message.setLineNo(lineNo);

            // quick fix info
            ITextRegion equalsRegion = textRegions.get(i - 2 + 1);
            int insertOffset = structuredDocumentRegion.getTextEndOffset(equalsRegion) - end;
            Object[] additionalFixInfo = {structuredDocumentRegion.getText(nameRegion), new Integer(insertOffset)};

            if (reporter instanceof IncrementalReporter) {
              MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
              processor.setProblemId(ProblemIDsXML.MissingAttrValue);
              processor.setAdditionalFixInfo(additionalFixInfo);
              message.setAttribute(QUICKASSISTPROCESSOR, processor);

              AnnotationInfo info = new AnnotationInfo(message);
              ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
            }
            else {
              reporter.addMessage(this, message);
            }
            errorCount++;
          }
        }
        // name but no '=' (XML only)
        else if ((attrState == 1) && (i >= 1)) {
          // create annotation
          ITextRegion previousRegion = textRegions.get(i - 1);
          if (!(previousRegion instanceof ITextRegionContainer)) {
            Object[] args = {structuredDocumentRegion.getText(previousRegion)};
            String messageText = NLS.bind(XMLUIMessages.Attribute__has_no_value, args);
            int start = structuredDocumentRegion.getStartOffset(previousRegion);
            int textLength = structuredDocumentRegion.getText(previousRegion).trim().length();
            int lineNo = getLineNumber(start);

            LocalizedMessage message = new LocalizedMessage(SEVERITY_ATTRIBUTE_HAS_NO_VALUE, messageText);
            message.setOffset(start);
            message.setLength(textLength);
            message.setLineNo(lineNo);

            if (reporter instanceof IncrementalReporter) {
              MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
              processor.setProblemId(ProblemIDsXML.NoAttrValue);
              processor.setAdditionalFixInfo(structuredDocumentRegion.getText(previousRegion));
              message.setAttribute(QUICKASSISTPROCESSOR, processor);

              AnnotationInfo info = new AnnotationInfo(message);
              ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
            }
            else {
View Full Code Here

          String messageText = XMLUIMessages.ReconcileStepForMarkup_2;
          int start = structuredDocumentRegion.getStartOffset();
          // find length of whitespace
          int length = sdRegionText.trim().equals("") ? sdRegionText.length() : sdRegionText.indexOf(sdRegionText.trim()); //$NON-NLS-1$

          LocalizedMessage message = new LocalizedMessage(SEVERITY_INVALID_WHITESPACE_BEFORE_TAGNAME , messageText);
          message.setOffset(start);
          message.setLength(length);
          message.setLineNo(getLineNumber(start));

          if (reporter instanceof IncrementalReporter) {
            MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
            processor.setProblemId(ProblemIDsXML.SpacesBeforeTagName);
            message.setAttribute(QUICKASSISTPROCESSOR, processor);

            AnnotationInfo info = new AnnotationInfo(message);
            ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
          }
          else {
View Full Code Here

        if (index != -1) {
          String messageText = XMLUIMessages.ReconcileStepForMarkup_4;
          int start = structuredDocumentRegion.getStartOffset(r) + index;
          int length = piText.trim().length() - index;

          LocalizedMessage message = new LocalizedMessage(SEVERITY_NAMESPACE_IN_PI_TARGET , messageText);
          message.setOffset(start);
          message.setLength(length);
          message.setLineNo(getLineNumber(start));

          if (reporter instanceof IncrementalReporter) {
            MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
            processor.setProblemId(ProblemIDsXML.NamespaceInPI);
            message.setAttribute(QUICKASSISTPROCESSOR, processor);

            AnnotationInfo info = new AnnotationInfo(message);
            ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
          }
          else {
View Full Code Here

            Object[] args = {tagName};
            String messageText = NLS.bind(XMLUIMessages.Missing_end_tag_, args);

            int lineNumber = getLineNumber(start);

            IMessage message = new LocalizedMessage(SEVERITY_MISSING_END_TAG , messageText);
            message.setOffset(start);
            message.setLength(length);
            message.setLineNo(lineNumber);

            if (reporter instanceof IncrementalReporter) {
              Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);

              MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
              processor.setProblemId(ProblemIDsXML.MissingEndTag);
              processor.setAdditionalFixInfo(additionalFixInfo);
              message.setAttribute(QUICKASSISTPROCESSOR, processor);

              AnnotationInfo info = new AnnotationInfo(message);

              ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
            }
            else {
              reporter.addMessage(this, message);
            }
          }
        }
      }
      else {
        IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
        if (startRegion == null || startRegion.isDeleted()) {
          // analyze the tag (check self closing)
          ITextRegionList regions = endRegion.getRegions();
          ITextRegion r = null;
          int start = sdRegion.getStart();
          int length = sdRegion.getTextLength();
          for (int i = 0; i < regions.size(); i++) {
            r = regions.get(i);
            if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
              tagName = sdRegion.getText(r);
              start = sdRegion.getStartOffset(r);
              length = r.getTextLength();
            }
          }

          if (tagName != null) {
            Object[] args = {tagName};
            String messageText = NLS.bind(XMLUIMessages.Missing_start_tag_, args);

            int lineNumber = getLineNumber(start);

            IMessage message = new LocalizedMessage(SEVERITY_MISSING_START_TAG, messageText);
            message.setOffset(start);
            message.setLength(length);
            message.setLineNo(lineNumber);

            if (reporter instanceof IncrementalReporter) {
              Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);

              MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
              processor.setProblemId(ProblemIDsXML.MissingStartTag);
              processor.setAdditionalFixInfo(additionalFixInfo);
              message.setAttribute(QUICKASSISTPROCESSOR, processor);

              AnnotationInfo info = new AnnotationInfo(message);

              ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
            }
            else {
              reporter.addMessage(this, message);
            }
          }
        }
      }

    }
    /*
     * Check for an end tag that has no start tag
     */
    else {
      IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
      if (startRegion == null) {
        IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion();
        if (!endRegion.isDeleted()) {
          // get name
          ITextRegionList regions = endRegion.getRegions();
          ITextRegion r = null;
          for (int i = 0; i < regions.size(); i++) {
            r = regions.get(i);
            if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
              tagName = sdRegion.getText(r);
            }
          }

          if (!selfClosed && (tagName != null)) {
            String messageText = XMLUIMessages.Indicate_no_grammar_specified_severities_error;

            int start = sdRegion.getStart();
            int lineNumber = getLineNumber(start);

            // SEVERITY_STRUCTURE == IMessage.HIGH_SEVERITY
            IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText);
            message.setOffset(start);
            message.setLength(sdRegion.getTextLength());
            message.setLineNo(lineNumber);

            reporter.addMessage(this, message);
          }
        }
      }
View Full Code Here

      if (prev.getType() == DOMRegionContext.XML_CONTENT) {
        String messageText = XMLUIMessages.ReconcileStepForMarkup_5;
        int start = prev.getStartOffset();
        int length = prev.getLength();

        LocalizedMessage message = new LocalizedMessage(SEVERITY_WHITESPACE_AT_START , messageText);
        message.setOffset(start);
        message.setLength(length);
        message.setLineNo(getLineNumber(start));

        if (reporter instanceof IncrementalReporter) {
          MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
          processor.setProblemId(ProblemIDsXML.SpacesBeforePI);
          message.setAttribute(QUICKASSISTPROCESSOR, processor);
 
          AnnotationInfo info = new AnnotationInfo(message);
          ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
        }
        else {
View Full Code Here

TOP

Related Classes of org.eclipse.wst.validation.internal.operations.LocalizedMessage

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.