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

The following examples show how to use org.eclipse.wst.validation.internal.operations.LocalizedMessage. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TypeScriptReporterCollector.java    From typescript.java with MIT License 6 votes vote down vote up
@Override
public void addError(String file, Location startLoc, Location endLoc, Severity severity, String code,
		String failure) {
	IResource resource = tsFile.getResource();
	int start = startLoc.getPosition();
	int end = endLoc.getPosition();
	if (start == end) {
		if (start == 0) {
			end = 1;
		} else {
			start = start - 1;
		}
	}
	// TODO: severity
	// String severity = null;
	LocalizedMessage message = new LocalizedMessage(getSeverity(severity), failure, resource);
	message.setOffset(start);
	message.setLength(end - start);
	message.setAttribute(CHAR_START, start);
	message.setAttribute(CHAR_END, end);
	message.setLineNo(startLoc.getLine());
	reporter.addMessage(validator, message);

}
 
Example #2
Source File: XmlSourceValidator.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a message from a given {@link ElementProblem}.
 */
@VisibleForTesting
void createMessage(IReporter reporter, ElementProblem problem, int offset) {
  IMessage message = new LocalizedMessage(problem.getIMessageSeverity(), problem.getMessage());
  message.setTargetObject(this);
  message.setMarkerId(problem.getMarkerId());
  // TODO offset by line
  int lineNumber = problem.getStart().getLineNumber() + 1;
  message.setLineNo(lineNumber);
  message.setOffset(offset);
  message.setLength(problem.getLength());
  message.setAttribute(IQuickAssistProcessor.class.getName(), problem.getQuickAssistProcessor());
  reporter.addMessage(this, message);
}
 
Example #3
Source File: TypeScriptReporterCollector.java    From typescript.java with MIT License 5 votes vote down vote up
public void addDiagnostic(String event, String file, String text, int startLine, int startOffset, int endLine,
		int endOffset, DiagnosticCategory category, Integer code) {
	try {
		IIDETypeScriptFile tsFile = file != null ? (IIDETypeScriptFile) this.tsFile.getProject().getOpenedFile(file)
				: this.tsFile;
		IResource resource = tsFile.getResource();
		int start = tsFile.getPosition(startLine, startOffset);
		int end = tsFile.getPosition(endLine, endOffset);
		if (start == end) {
			if (start == 0) {
				end = 1;
			} else {
				start = start - 1;
			}
		}
		LocalizedMessage message = new LocalizedMessage(getSeverity(category), text, resource);
		message.setOffset(start);
		message.setLength(end - start);
		message.setAttribute(CHAR_START, start);
		message.setAttribute(CHAR_END, end);
		message.setLineNo(startLine - 1);
		if (code != null) {
			message.setAttribute("tsCode", code);
		}
		reporter.addMessage(validator, message);
	} catch (TypeScriptException e) {
		Trace.trace(Trace.SEVERE, "Error while reporting error", e);
	}
}
 
Example #4
Source File: ReporterMessagePlacementStrategy.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
public IMessage placeValidationResult(IResource resource, IDocument document,
    IRegion position, String message, int severity) {
  IMessage validationMessage = new LocalizedMessage(
      severityFromIMarkerSeverity(severity), message);
  validationMessage.setLength(position.getLength());
  validationMessage.setOffset(position.getOffset());

  reporter.addMessage(validator, validationMessage);
  return validationMessage;
}