function parseDiag(cxDiag) {
  const severity = libclang.clang_getDiagnosticSeverity(cxDiag);
  const messageText = libclang.clang_getDiagnosticSpelling(cxDiag);

  const message = {
    type: diagSeverityString(severity),
    text: libclang.clang_getCString(messageText)
  };

  const numRanges = libclang.clang_getDiagnosticNumRanges(cxDiag);

  if (numRanges > 0) {
    const sourceRange = libclang.clang_getDiagnosticRange(cxDiag, 0);
    const rangeStart =
      getSourceLocation(libclang.clang_getRangeStart(sourceRange));
    const rangeEnd = getSourceLocation(libclang.clang_getRangeEnd(sourceRange));

    const l = rangeEnd.location;
    let end;
    if (l[0] === -1 && l[1] === -1) {
      end = rangeStart.location;
    } else {
      end = l;
    }

    message.filePath = rangeStart.filePath;
    message.range = [rangeStart.location, end];
  }
  if (!message.filePath) {
    const location =
      getSourceLocation(libclang.clang_getDiagnosticLocation(cxDiag));

    message.filePath = location.filePath;
    message.range = [location.location, location.location.slice()];
    message.range[1][1] += 1;
  }

  log.debug('diag severity: ' + message.type + ', text: ' + message.text +
            ', range: ' + JSON.stringify(message.range) + ', file: ' +
            message.filePath);

  libclang.clang_disposeString(messageText);

  return message;
}
/**
 * Convert a libclang cxDiagnostic into a JSON message for atom Linter
 */
Convert a libclang cxDiagnostic into a JSON message for atom Linter
Convert a libclang cxDiagnostic into a JSON message for atom Linter
function parseDiag(cxDiag) {
  const severity = libclang.clang_getDiagnosticSeverity(cxDiag);
  const messageText = libclang.clang_getDiagnosticSpelling(cxDiag);
  const message = {
    type: diagSeverityString(severity),
    text: libclang.clang_getCString(messageText)
  };
  const numRanges = libclang.clang_getDiagnosticNumRanges(cxDiag);
  if (numRanges > 0) {
    const sourceRange = libclang.clang_getDiagnosticRange(cxDiag, 0);
    const rangeStart =
      getSourceLocation(libclang.clang_getRangeStart(sourceRange));
    const rangeEnd = getSourceLocation(libclang.clang_getRangeEnd(sourceRange));
    const l = rangeEnd.location;
    let end;
    if (l[0] === -1 && l[1] === -1) {
      end = rangeStart.location;
    } else {
      end = l;
    }
    message.filePath = rangeStart.filePath;
    message.range = [rangeStart.location, end];
  }
  if (!message.filePath) {
    const location =
      getSourceLocation(libclang.clang_getDiagnosticLocation(cxDiag));
    message.filePath = location.filePath;
    message.range = [location.location, location.location.slice()];
    message.range[1][1] += 1;
  }
  log.debug('diag severity: ' + message.type + ', text: ' + message.text +
            ', range: ' + JSON.stringify(message.range) + ', file: ' +
            message.filePath);
  libclang.clang_disposeString(messageText);
  return message;
}
function parseDiag ( cxDiag ) { const severity = libclang . clang_getDiagnosticSeverity ( cxDiag ) ; const messageText = libclang . clang_getDiagnosticSpelling ( cxDiag ) ; const message = { type : diagSeverityString ( severity ) , text : libclang . clang_getCString ( messageText ) } ; const numRanges = libclang . clang_getDiagnosticNumRanges ( cxDiag ) ; if ( numRanges > 0 ) { const sourceRange = libclang . clang_getDiagnosticRange ( cxDiag , 0 ) ; const rangeStart = getSourceLocation ( libclang . clang_getRangeStart ( sourceRange ) ) ; const rangeEnd = getSourceLocation ( libclang . clang_getRangeEnd ( sourceRange ) ) ; const l = rangeEnd . location ; let end ; if ( l [ 0 ] === - 1 && l [ 1 ] === - 1 ) { end = rangeStart . location ; } else { end = l ; } message . filePath = rangeStart . filePath ; message . range = [ rangeStart . location , end ] ; } if ( ! message . filePath ) { const location = getSourceLocation ( libclang . clang_getDiagnosticLocation ( cxDiag ) ) ; message . filePath = location . filePath ; message . range = [ location . location , location . location . slice ( ) ] ; message . range [ 1 ] [ 1 ] += 1 ; } log . debug ( 'diag severity: ' + message . type + ', text: ' + message . text + ', range: ' + JSON . stringify ( message . range ) + ', file: ' + message . filePath ) ; libclang . clang_disposeString ( messageText ) ; return message ; }
Convert a libclang cxDiagnostic into a JSON message for atom Linter
Convert a libclang cxDiagnostic into a JSON message for atom Linter