Package org.eclipse.wst.validation.internal.provisional.core

Examples of org.eclipse.wst.validation.internal.provisional.core.IMessage


     * @return a diagnostic indicating that the app config model in use is too
     * new for the selected JSF runtime version.
     */
    public static IMessage create_APP_CONFIG_IS_NEWER_THAN_JSF_VERSION(IFile file)
    {
        final IMessage message = new MyLocalizedMessage(IMessage.HIGH_SEVERITY,
            Messages.APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID
                ,null, APP_CONFIG_IS_NEWER_THAN_JSF_VERSION_ID);
        message.setTargetObject(file);
        return message;
    }
View Full Code Here


     * @return a diagnostic indicating that the app config model in use is older
     * than the selected JSF runtime version.
     */
    public static IMessage create_APP_CONFIG_IS_OLDER_THAN_JSF_VERSION(IFile file, String appConfigVersion, String projectVersion)
    {
        final IMessage message = new MyLocalizedMessage(IMessage.NORMAL_SEVERITY,
            MessageFormat.format(
                Messages.APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID,
                    new Object[] {appConfigVersion, projectVersion})
            ,null, APP_CONFIG_IS_OLDER_THAN_JSF_VERSION_ID);
        message.setTargetObject(file);
        return message;
    }
View Full Code Here

     * @return a diagnostic indicating that the locale format does
     * not match what is expected
     */
    public static IMessage create_LOCALE_FORMAT_NOT_VALID()
    {
        IMessage message = new MyLocalizedMessage(IMessage.NORMAL_SEVERITY,
                    Messages.LOCALE_FORMAT_NOT_VALID_ID
                ,null, LOCALE_FORMAT_NOT_VALID_ID);
        return message;
    }
View Full Code Here

              JSPTranslation jspTranslation = ((JSPTranslation) translation);
              Position[] jspPositions = (Position[]) jspTranslation.getJsp2JavaMap().keySet().toArray(new Position[jspTranslation.getJsp2JavaMap().size()]);
              for (int i = 0; i < jspPositions.length; i++) {
                sourceStart = Math.max(sourceStart, jspPositions[i].getOffset());
              }
              IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);
              m.setOffset(sourceStart);
              m.setLength(1);
              return m;
            }
            else {
              return null;
            }
          }
      }
    }
    if (sev == ValidationMessage.IGNORE) {
      return null;
    }

    // line number for marker starts @ 1
    // line number from document starts @ 0
    int lineNo = structuredDoc.getLineOfOffset(sourceStart) + 1;

    IMessage m = new LocalizedMessage(sev, problem.getMessage(), f);

    m.setLineNo(lineNo);
    m.setOffset(sourceStart);
    m.setLength((sourceEnd >= sourceStart) ? (sourceEnd - sourceStart + 1) : 0);

    // need additional adjustment for problems from
    // indirect (included) files
    // https://bugs.eclipse.org/bugs/show_bug.cgi?id=119633
    if (translation.isIndirect(problem.getSourceStart())) {
View Full Code Here

        translation.reconcileCompilationUnit();
        List problems = translation.getProblems();
        // add new messages
        for (int i = 0; i < problems.size() && !reporter.isCancelled(); i++) {
          IProblem problem = (IProblem) problems.get(i);
          IMessage m = createMessageFromProblem(problem, f, translation, domModel.getStructuredDocument());
          if (m != null) {
            if (problem.getID() == IProblem.Task) {
              if (updateJavaTasks) {
                // add new Java task marker
                try {
                  IMarker task = f.createMarker(JAVA_TASK_MARKER_TYPE);
                  task.setAttribute(IMarker.LINE_NUMBER, new Integer(m.getLineNumber()));
                  task.setAttribute(IMarker.CHAR_START, new Integer(m.getOffset()));
                  task.setAttribute(IMarker.CHAR_END, new Integer(m.getOffset() + m.getLength()));
                  task.setAttribute(IMarker.MESSAGE, m.getText());
                  task.setAttribute(IMarker.USER_EDITABLE, Boolean.FALSE);

                  switch (m.getSeverity()) {
                    case IMessage.HIGH_SEVERITY: {
                      task.setAttribute(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_HIGH));
                      task.setAttribute(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_ERROR));
                    }
                      break;
View Full Code Here

    //sets line number and reports message
    private void reportProblems(final IReporter reporter, final List messages, final IStructuredModel model) {
        for (final Iterator it = messages.iterator(); it.hasNext();)
        {
            final IMessage message = (IMessage) it.next();
            if (model != null) {
              final int line = model.getStructuredDocument().getLineOfOffset(message.getOffset());
        if (line >= 0)
          message.setLineNo(line + 1);
            }
            reporter.addMessage(this, message);
        }
    }
View Full Code Here

        protected void doValidate(EObject object, List messages, IFile file)
        {
            if (object instanceof FromActionType)
            {
                final FromActionType actionType = (FromActionType) object;
                IMessage message = AppConfigValidationUtil.validateELExpression
                    (actionType.getTextContent());
                addMessageInfo(messages, message, actionType, file);
            }
        }
View Full Code Here

                || "".equals(propertyClass.trim())) //$NON-NLS-1$
        {
            return;
        }
       
        IMessage message = null;
        EObject eObj = null;
        if (managedPropertyType.getMapEntries() != null)
        {
            eObj = managedPropertyType.getMapEntries();
            message =
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

    List annotations = new ArrayList();
    for (int i = 0; i < infos.length; i++) {

      AnnotationInfo info = infos[i];

      IMessage validationMessage = info.getMessage();
      int offset = validationMessage.getOffset();
      if (offset < 0)
        continue;

      String messageText = null;
      try {
        messageText = validationMessage.getText(validationMessage.getClass().getClassLoader());
      }
      catch (Exception t) {
        Logger.logException("exception reporting message from validator", t); //$NON-NLS-1$
        continue;
      }
      String type = getSeverity(validationMessage);
      // this position seems like it would be possibly be the wrong
      // length
      int length = validationMessage.getLength();
      if (length >= 0) {

        Position p = new Position(offset, length);
        ReconcileAnnotationKey key = createKey(getPartitionType(getDocument(), offset), getScope());

        // create an annotation w/ problem ID and fix info
        TemporaryAnnotation annotation = new TemporaryAnnotation(p, type, messageText, key);
        Object extraInfo = info.getAdditionalFixInfo();
        // https://bugs.eclipse.org/bugs/show_bug.cgi?id=170988
        // add quick fix information
        if (extraInfo == null) {
          extraInfo = validationMessage.getAttribute(QUICKASSISTPROCESSOR);
        }
        annotation.setAdditionalFixInfo(extraInfo);
        annotation.setAttributes(validationMessage.getAttributes());
        annotations.add(annotation);
      }
    }
    return (IReconcileResult[]) annotations.toArray(new IReconcileResult[annotations.size()]);
  }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.validation.internal.provisional.core.IMessage

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.