}
private void navigateInEditor(CompilerMessage compilerMessage, BasicTextEditor textEditor, DatabaseEditableObjectFile databaseFile) {
Editor editor = textEditor.getEditor();
Document document = editor.getDocument();
SourceCodeEditor codeEditor = (SourceCodeEditor) textEditor;
int lineShifting = document.getLineNumber(codeEditor.getHeaderEndOffset());
if (document.getLineCount() <= compilerMessage.getLine()) {
compilerMessage.setLine(0);
compilerMessage.setPosition(0);
compilerMessage.setSubjectIdentifier(null);
}
int lineStartOffset = document.getLineStartOffset(compilerMessage.getLine() + lineShifting);
int newCaretOffset = lineStartOffset + compilerMessage.getPosition();
if (document.getTextLength() > newCaretOffset) {
editor.getCaretModel().moveToOffset(newCaretOffset);
String identifier = compilerMessage.getSubjectIdentifier();
if (identifier != null) {
int lineEndOffset = document.getLineEndOffset(compilerMessage.getLine() + lineShifting);
String lineText = document.getText().substring(lineStartOffset, lineEndOffset).toUpperCase();
int selectionOffset = lineText.indexOf(identifier, compilerMessage.getPosition()) + lineStartOffset;
if (selectionOffset > -1) {
editor.getSelectionModel().setSelection(selectionOffset, selectionOffset + identifier.length());
}
}
editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
}
EditorUtil.selectEditor(databaseFile, textEditor);
VirtualFile virtualFile = DocumentUtil.getVirtualFile(textEditor.getEditor());
OpenFileDescriptor openFileDescriptor = new OpenFileDescriptor(compilerMessage.getProject(), virtualFile);
codeEditor.navigateTo(openFileDescriptor);
}