use of org.eclipse.core.filebuffers.ITextFileBufferManager in project titan.EclipsePlug-ins by eclipse.
the class ParserMarkerSupport method createOnTheFlySyntacticMarker.
public static void createOnTheFlySyntacticMarker(final IFile file, final SyntacticErrorStorage errorStorage, final int severity) {
if (!file.isAccessible()) {
return;
}
int lineNumber = errorStorage.lineNumber;
int charStart = errorStorage.charStart;
int charEnd = errorStorage.charEnd;
String message = errorStorage.message;
boolean justDoIt = errorStorage.exceptionType == SyntacticErrorStorage.ExceptionType.LEXER_NOVIABLEALT_EXCEPTION;
try {
if (justDoIt && lineNumber >= 0) {
IDocument document = null;
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
IPath fullPath = file.getFullPath();
if (manager != null) {
manager.connect(fullPath, LocationKind.IFILE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(fullPath, LocationKind.IFILE);
document = buffer.getDocument();
}
try {
if (document != null && lineNumber > 0 && lineNumber <= document.getNumberOfLines()) {
charStart = document.getLineOffset(lineNumber - 1);
charEnd = document.getLineOffset(lineNumber - 1);
charStart += errorStorage.charStart;
charEnd += errorStorage.charEnd;
}
} catch (BadLocationException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Location location = new Location(file, lineNumber, charStart, charEnd);
location.reportSingularExternalProblem(message, severity, GeneralConstants.ONTHEFLY_SYNTACTIC_MARKER);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
use of org.eclipse.core.filebuffers.ITextFileBufferManager in project titan.EclipsePlug-ins by eclipse.
the class ParserMarkerSupport method createOnTheFlyMixedMarker.
/**
* Places an on-the-fly error marker on the provided file. If the file
* is being edited in an editor the marker is reported and must be
* placed on the document edited, not on the file in the file system. In
* this form it is possible to provide a location as a region that was
* originally housing the erroneous location. This is used as syntactic marker
* but placed during semantic check
*
* @param file
* the file which seems to be erroneous
* @param errorStorage
* the info extracted from the caught exception(s)
* @param severity
* the severity level of the error
*/
public static void createOnTheFlyMixedMarker(final IFile file, final SyntacticErrorStorage errorStorage, final int severity) {
if (!file.isAccessible()) {
return;
}
int lineNumber = errorStorage.lineNumber;
int charStart = errorStorage.charStart;
int charEnd = errorStorage.charEnd;
String message = errorStorage.message;
boolean justDoIt = errorStorage.exceptionType == SyntacticErrorStorage.ExceptionType.LEXER_NOVIABLEALT_EXCEPTION;
try {
if (justDoIt && lineNumber >= 0) {
IDocument document = null;
ITextFileBufferManager manager = FileBuffers.getTextFileBufferManager();
IPath fullPath = file.getFullPath();
if (manager != null) {
manager.connect(fullPath, LocationKind.IFILE, null);
ITextFileBuffer buffer = manager.getTextFileBuffer(fullPath, LocationKind.IFILE);
document = buffer.getDocument();
}
try {
if (document != null && lineNumber > 0 && lineNumber <= document.getNumberOfLines()) {
charStart = document.getLineOffset(lineNumber - 1);
charEnd = document.getLineOffset(lineNumber - 1);
charStart += errorStorage.charStart;
charEnd += errorStorage.charEnd;
}
} catch (BadLocationException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Location location = new Location(file, lineNumber, charStart, charEnd);
location.reportSingularExternalProblem(message, severity, GeneralConstants.ONTHEFLY_MIXED_MARKER);
} catch (CoreException e) {
ErrorReporter.logExceptionStackTrace(e);
}
}
Aggregations