コード例 #1
0
 protected void addMessages(
     IJSONObjectHelper helper,
     JsonArray messages,
     TernLintQuery query,
     ITernLintCollector collector) {
   String messageId = null;
   String message = null;
   String severity = null;
   String file = null;
   JsonObject messageObject = null;
   for (JsonValue value : messages) {
     messageObject = (JsonObject) value;
     messageId = helper.getText(messageObject.get(MESSAGE_ID_FIELD));
     message = query.formatMessage(helper.getText(messageObject.get(MESSAGE_FIELD)));
     severity = helper.getText(messageObject.get(MESSAGE_FIELD));
     severity = helper.getText(messageObject.get(SEVERITY_FIELD));
     Long startCh = helper.getCh(messageObject, FROM_FIELD);
     Long endCh = helper.getCh(messageObject, TO_FIELD);
     Long line = helper.getCh(messageObject, LINE_NUMBER_FIELD);
     file = helper.getText(messageObject.get(FILE_FIELD));
     collector.addMessage(
         messageId, message, startCh, endCh, line, severity, file, messageObject, helper);
   }
 }
コード例 #2
0
  @Override
  public void process(
      TernDoc doc,
      IJSONObjectHelper jsonObjectHelper,
      Object jsonObject,
      ITernLintCollector collector) {
    if (!(jsonObject instanceof JsonObject)) {
      // TODO: support for Rhino server
      return;
    }
    JsonArray messages = (JsonArray) ((JsonObject) jsonObject).get(MESSAGES_FIELD); // $NON-NLS-1$
    if (messages != null) {
      TernLintQuery query = (TernLintQuery) doc.getQuery();
      if (query.isGroupByFiles()) {
        JsonObject filesObject = null;
        String file = null;
        for (JsonValue files : messages) {
          filesObject = (JsonObject) files;
          file = jsonObjectHelper.getText(filesObject.get(FILE_FIELD)); // $NON-NLS-1$

          try {
            collector.startLint(file);

            JsonArray messagesFile = (JsonArray) filesObject.get(MESSAGES_FIELD); // $NON-NLS-1$
            if (messagesFile != null) {
              addMessages(jsonObjectHelper, messagesFile, query, collector);
            }
          } finally {
            collector.endLint(file);
          }
        }
      } else {
        String file = doc.getQuery().getFile();
        try {
          collector.startLint(file);
          addMessages(jsonObjectHelper, messages, query, collector);
        } finally {
          collector.endLint(file);
        }
      }
    }
  }