Skip to content

Commit

Permalink
SLE-372 Execute quick fixes in the UI thread when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
henryju committed Jul 21, 2020
1 parent baf3ed2 commit 6a2ed51
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import org.eclipse.jface.text.source.IAnnotationModel;
import org.eclipse.jface.text.source.IAnnotationModelExtension;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IEditorReference;
Expand Down Expand Up @@ -70,16 +71,18 @@ public String getLabel() {

@Override
public void run(IMarker marker) {
try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editorPart = IDE.openEditor(page, marker);
if (editorPart instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) editorPart;
toggleAnnotations(marker, textEditor);
Display.getDefault().asyncExec(() -> {
try {
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IEditorPart editorPart = IDE.openEditor(page, marker);
if (editorPart instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) editorPart;
toggleAnnotations(marker, textEditor);
}
} catch (Exception e) {
SonarLintLogger.get().error("Unable to show issue locations", e);
}
} catch (Exception e) {
SonarLintLogger.get().error("Unable to show issue locations", e);
}
});
}

private static void updateLocationsView(IMarker marker) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.eclipse.core.resources.IMarker;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IMarkerResolution2;
import org.eclipse.ui.PlatformUI;
import org.sonarlint.eclipse.core.SonarLintLogger;
Expand Down Expand Up @@ -48,12 +49,14 @@ public String getLabel() {

@Override
public void run(IMarker marker) {
try {
RuleDescriptionWebView view = (RuleDescriptionWebView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RuleDescriptionWebView.ID);
view.setInput(marker);
} catch (Exception e) {
SonarLintLogger.get().error("Unable to open rule description view", e);
}
Display.getDefault().asyncExec(() -> {
try {
RuleDescriptionWebView view = (RuleDescriptionWebView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RuleDescriptionWebView.ID);
view.setInput(marker);
} catch (Exception e) {
SonarLintLogger.get().error("Unable to open rule description view", e);
}
});
}

@Override
Expand Down

0 comments on commit 6a2ed51

Please sign in to comment.