未验证 提交 0eba5ffb 编写于 作者: S ShadelessFox 提交者: GitHub

dbeaver/dbeaver-ee#1321 Remove markers of the active query (#15737)

* dbeaver/dbeaver-ee#1321 Properly remove markers of the active query

* dbeaver/dbeaver-ee#1321 Show `Problems` view without activating it

* dbeaver/dbeaver-ee#1321 Code cleanup
上级 d32ba73f
......@@ -2614,7 +2614,7 @@ public class SQLEditor extends SQLEditorBase implements
extraPresentation = null;
}
// Release ds container
clearProblems();
clearProblems(null);
releaseContainer();
closeAllJobs();
......@@ -3791,7 +3791,7 @@ public class SQLEditor extends SQLEditorBase implements
if (getActivePreferenceStore().getBoolean(SQLPreferenceConstants.MAXIMIZE_EDITOR_ON_SCRIPT_EXECUTE)) {
resultsSash.setMaximizedControl(sqlEditorPanel);
}
clearProblems();
clearProblems(null);
});
} finally {
if (extListener != null) extListener.onStartScript();
......@@ -3806,6 +3806,9 @@ public class SQLEditor extends SQLEditorBase implements
UIUtils.asyncExec(() -> {
setTitleImage(DBeaverIcons.getImage(UIIcon.SQL_SCRIPT_EXECUTE));
updateDirtyFlag();
if (!scriptMode) {
clearProblems(query);
}
});
}
queryProcessor.curJobRunning.incrementAndGet();
......@@ -4003,7 +4006,7 @@ public class SQLEditor extends SQLEditorBase implements
}
try {
UIUtils.getActiveWorkbenchWindow().getActivePage().showView(IPageLayout.ID_PROBLEM_VIEW);
UIUtils.getActiveWorkbenchWindow().getActivePage().showView(IPageLayout.ID_PROBLEM_VIEW, null, IWorkbenchPage.VIEW_VISIBLE);
} catch (PartInitException e) {
log.debug("Error opening problem view", e);
}
......@@ -4011,24 +4014,35 @@ public class SQLEditor extends SQLEditorBase implements
return true;
}
private void clearProblems() {
final IResource resource = GeneralUtils.adapt(getEditorInput(), IResource.class);
final IAnnotationModel annotationModel = getAnnotationModel();
private void clearProblems(@Nullable SQLQuery query) {
if (query == null) {
final IResource resource = GeneralUtils.adapt(getEditorInput(), IResource.class);
if (resource != null) {
try {
resource.deleteMarkers(SQLProblemAnnotation.MARKER_TYPE, false, IResource.DEPTH_ONE);
} catch (CoreException e) {
log.error("Error deleting problem markers", e);
if (resource != null) {
try {
resource.deleteMarkers(SQLProblemAnnotation.MARKER_TYPE, false, IResource.DEPTH_ONE);
} catch (CoreException e) {
log.error("Error deleting problem markers", e);
}
}
}
} else {
final IAnnotationModel annotationModel = getAnnotationModel();
if (annotationModel != null) {
for (Iterator<Annotation> it = annotationModel.getAnnotationIterator(); it.hasNext(); ) {
final Annotation annotation = it.next();
if (annotationModel != null) {
for (Iterator<Annotation> it = annotationModel.getAnnotationIterator(); it.hasNext(); ) {
final Annotation annotation = it.next();
if (annotation instanceof SQLProblemAnnotation) {
final Position position = annotationModel.getPosition(annotation);
if (annotation instanceof SQLProblemAnnotation) {
annotationModel.removeAnnotation(annotation);
if (position.overlapsWith(query.getOffset(), query.getLength())) {
try {
((SQLProblemAnnotation) annotation).getMarker().delete();
} catch (CoreException e) {
log.error("Error deleting problem marker", e);
}
}
}
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册