diff --git a/org.sonarlint.eclipse.core/src/org/sonarlint/eclipse/core/internal/backend/SonarLintBackendService.java b/org.sonarlint.eclipse.core/src/org/sonarlint/eclipse/core/internal/backend/SonarLintBackendService.java index 65a9c9372..83c2d72e9 100644 --- a/org.sonarlint.eclipse.core/src/org/sonarlint/eclipse/core/internal/backend/SonarLintBackendService.java +++ b/org.sonarlint.eclipse.core/src/org/sonarlint/eclipse/core/internal/backend/SonarLintBackendService.java @@ -62,8 +62,6 @@ import org.sonarsource.sonarlint.core.rpc.protocol.backend.binding.GetSharedConnectedModeConfigFileParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.binding.GetSharedConnectedModeConfigFileResponse; import org.sonarsource.sonarlint.core.rpc.protocol.backend.branch.DidVcsRepositoryChangeParams; -import org.sonarsource.sonarlint.core.rpc.protocol.backend.branch.GetMatchedSonarProjectBranchParams; -import org.sonarsource.sonarlint.core.rpc.protocol.backend.branch.GetMatchedSonarProjectBranchResponse; import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.config.DidChangeCredentialsParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.projects.GetAllProjectsParams; import org.sonarsource.sonarlint.core.rpc.protocol.backend.connection.projects.SonarProjectDto; @@ -328,14 +326,6 @@ public void didVcsRepositoryChange(ISonarLintProject project) { .didVcsRepositoryChange(new DidVcsRepositoryChangeParams(ConfigScopeSynchronizer.getConfigScopeId(project))); } - public GetMatchedSonarProjectBranchResponse getMatchedSonarProjectBranch(ISonarLintProject project) - throws InterruptedException, ExecutionException { - return getBackend() - .getSonarProjectBranchService() - .getMatchedSonarProjectBranch(new GetMatchedSonarProjectBranchParams(ConfigScopeSynchronizer.getConfigScopeId(project))) - .get(); - } - public void credentialsChanged(ConnectionFacade connection) { getBackend().getConnectionService().didChangeCredentials(new DidChangeCredentialsParams(connection.getId())); } diff --git a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/AbstractOpenInEclipseJob.java b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/AbstractOpenInEclipseJob.java index fcfad5382..c62b1bf63 100644 --- a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/AbstractOpenInEclipseJob.java +++ b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/AbstractOpenInEclipseJob.java @@ -20,7 +20,6 @@ package org.sonarlint.eclipse.ui.internal.job; import java.util.Optional; -import java.util.concurrent.ExecutionException; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicReference; import org.eclipse.core.runtime.CoreException; @@ -32,16 +31,12 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.ui.PlatformUI; import org.sonarlint.eclipse.core.SonarLintLogger; -import org.sonarlint.eclipse.core.documentation.SonarLintDocumentation; import org.sonarlint.eclipse.core.internal.backend.ConfigScopeSynchronizer; -import org.sonarlint.eclipse.core.internal.backend.SonarLintBackendService; import org.sonarlint.eclipse.core.internal.jobs.AnalysisReadyStatusCache; -import org.sonarlint.eclipse.core.internal.vcs.VcsService; import org.sonarlint.eclipse.core.resource.ISonarLintFile; import org.sonarlint.eclipse.core.resource.ISonarLintProject; import org.sonarlint.eclipse.ui.internal.SonarLintUiPlugin; import org.sonarlint.eclipse.ui.internal.dialog.AwaitProjectConnectionReadyDialog; -import org.sonarlint.eclipse.ui.internal.util.BrowserUtils; import org.sonarlint.eclipse.ui.internal.util.MessageDialogUtils; /** @@ -55,15 +50,12 @@ public abstract class AbstractOpenInEclipseJob extends Job { protected final ISonarLintProject project; private final boolean skipAnalysisReadyCheck; - private final boolean skipBranchCheck; - protected AbstractOpenInEclipseJob(String name, ISonarLintProject project, boolean skipAnalysisReadyCheck, - boolean skipBranchCheck) { + protected AbstractOpenInEclipseJob(String name, ISonarLintProject project, boolean skipAnalysisReadyCheck) { super(name); this.project = project; this.skipAnalysisReadyCheck = skipAnalysisReadyCheck; - this.skipBranchCheck = skipBranchCheck; } @Override @@ -116,15 +108,6 @@ protected IStatus run(IProgressMonitor monitor) { return Status.CANCEL_STATUS; } file = fileOpt.get(); - - /** - * Due to the Git logic moving slowly to SLCORE to be IDE-independant, this check might already been done on - * their side based on the feature using this logic. On the long run this is going to be removed as the branch - * check will be done completely on SLCORE side for every feature. - */ - if (!skipBranchCheck && !tryMatchBranches()) { - return Status.CANCEL_STATUS; - } } try { @@ -158,48 +141,6 @@ private Optional tryGetLocalFile() { return fileOpt; } - /** - * Branch check: Local and remote information should match (if no local branch found, at least try your best). - * - * As mentioned above, this might not be needed by every feature building on-top of this class and will eventually - * be removed. That is also the reason for the constructor flag! - */ - private boolean tryMatchBranches() { - var branch = getBranch(); - if (branch == null) { - return false; - } - - // In case SLCORE is not yet ready for the SonarProjectBranchService, we also check via this plug-ins VcsService - // using the JGit dependency coming bundled from SLCORE. This should yield a result when actually in a Git - // repository but if not, it is no problem as it is only used in case of the Open in IDE with automatic Connected - // Mode setup. - Optional localBranch = Optional.empty(); - try { - var response = SonarLintBackendService.get().getMatchedSonarProjectBranch(project); - localBranch = Optional.ofNullable(response.getMatchedSonarProjectBranch()); - } catch (InterruptedException | ExecutionException err) { - SonarLintLogger.get().debug("Cannot get matched branch from backend, trying local VCS service", err); - } - if (localBranch.isEmpty()) { - localBranch = VcsService.getCachedSonarProjectBranch(project); - } - - if (localBranch.isEmpty()) { - // This error message may be misleading to COBOL / ABAP developers but that is okay for now :> - MessageDialogUtils.branchNotAvailable("The local branch of the project '" + project.getName() - + "' could not be determined. SonarLint now can only try to find the matching local issue!"); - } else if (!branch.equals(localBranch.get())) { - MessageDialogUtils.branchMismatch("The local branch '" + localBranch.get() + "' of the project '" - + project.getName() + "' does not match the remote branch '" + branch + "'. " - + "Please checkout the correct branch and invoke the requested action once again!"); - BrowserUtils.openExternalBrowser(SonarLintDocumentation.BRANCH_AWARENESS, Display.getDefault()); - return false; - } - - return true; - } - /** * The actual feature specific logic after everything is set up accordingly and the base checks are done. * @@ -210,13 +151,4 @@ private boolean tryMatchBranches() { /** As we work per "ISonarLintFile" we want to get the IDE (project relative) path from a file on the server */ abstract String getIdeFilePath(); - - /** - * This is needed to get the branch from the specific feature information, shouldn't be overwritten by sub-classes - * that have "skipBranchCheck" set to "true"! - */ - @Nullable - protected String getBranch() { - return null; - } } diff --git a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenFixSuggestionInEclipseJob.java b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenFixSuggestionInEclipseJob.java index a5b142573..0a90e6ddc 100644 --- a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenFixSuggestionInEclipseJob.java +++ b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenFixSuggestionInEclipseJob.java @@ -52,7 +52,7 @@ public class OpenFixSuggestionInEclipseJob extends AbstractOpenInEclipseJob { private final FixSuggestionDto fixSuggestion; public OpenFixSuggestionInEclipseJob(FixSuggestionDto fixSuggestion, ISonarLintProject project) { - super("Open fix suggestion in IDE", project, true, true); + super("Open fix suggestion in IDE", project, true); this.fixSuggestion = fixSuggestion; } diff --git a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenIssueInEclipseJob.java b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenIssueInEclipseJob.java index 2bc9cdbba..119973c6b 100644 --- a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenIssueInEclipseJob.java +++ b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/job/OpenIssueInEclipseJob.java @@ -61,7 +61,7 @@ public class OpenIssueInEclipseJob extends AbstractOpenInEclipseJob { private final boolean askedForPreferenceChangeAlready; public OpenIssueInEclipseJob(OpenIssueContext context) { - super(context.getName(), context.getProject(), false, false); + super(context.getName(), context.getProject(), false); this.name = context.getName(); this.issueDetails = context.getIssueDetails(); @@ -80,11 +80,6 @@ protected String getIdeFilePath() { return issueDetails.getIdeFilePath().toString(); } - @Override - protected String getBranch() { - return issueDetails.getBranch(); - } - /** Handle normal issues: They can be present as On-the-fly / Report markers */ private IStatus handleNormalIssue() throws CoreException { // Check with possible On-The-Fly markers of that file diff --git a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/util/MessageDialogUtils.java b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/util/MessageDialogUtils.java index f564f94ea..516b5c798 100644 --- a/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/util/MessageDialogUtils.java +++ b/org.sonarlint.eclipse.ui/src/org/sonarlint/eclipse/ui/internal/util/MessageDialogUtils.java @@ -45,19 +45,10 @@ public static void dialogCancelled(String message) { showError("Dialog cancelled", message); } - public static void branchMismatch(String message) { - showError("Branch does not match", message); - } - public static void openInEclipseFailed(String message) { showError("Open in Eclipse failed", message); } - public static void branchNotAvailable(String message) { - Display.getDefault().syncExec(() -> MessageDialog.openInformation( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Branch not matchable", message)); - } - /** For the "Open in IDE" feature we want to display a yes/no question for the user to answer */ public static void openInIdeQuestion(String message, Runnable yesHandler) { Display.getDefault().asyncExec(() -> { diff --git a/pom.xml b/pom.xml index 8fcba79d5..3577ffc63 100644 --- a/pom.xml +++ b/pom.xml @@ -77,7 +77,7 @@ 4.0.8 - 10.11.0.79652 + 10.11.0.79687 11 diff --git a/target-platforms/commons-build.target b/target-platforms/commons-build.target index c30b28f28..6fb6a885a 100644 --- a/target-platforms/commons-build.target +++ b/target-platforms/commons-build.target @@ -12,7 +12,7 @@ org.sonarsource.sonarlint.core sonarlint-java-client-osgi - 10.11.0.79652 + 10.11.0.79687 jar