Skip to content

Commit

Permalink
Handle not set workspace target in TargetDefinitionActivationCodeMining
Browse files Browse the repository at this point in the history
  • Loading branch information
HannesWell committed Oct 16, 2024
1 parent f6bcbe3 commit e294d7d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.ui.workbench.texteditor,
org.eclipse.core.expressions,
org.eclipse.core.filebuffers,
org.eclipse.core.filesystem,
org.eclipse.core.resources
Bundle-RequiredExecutionEnvironment: JavaSE-17
Bundle-Vendor: %providerName
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/********************************************************************************
* Copyright (c) 2018, 2019 vogella GmbH and others
* Copyright (c) 2018, 2024 vogella GmbH and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
Expand All @@ -19,7 +19,6 @@

import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
Expand Down Expand Up @@ -67,11 +66,10 @@ protected CompletableFuture<Void> doResolve(ITextViewer viewer, IProgressMonitor
}
boolean isCurrent = false;
try {
ITargetPlatformService service = acquireTargetPlatformService();
String memento = service.getWorkspaceTargetHandle().getMemento();
ITargetHandle targetHandle = getTargetHandle();
String targetMemento = targetHandle.getMemento();
isCurrent = Objects.equals(memento, targetMemento);
ITargetHandle workspaceTarget = acquireTargetPlatformService().getWorkspaceTargetHandle();
if (workspaceTarget != null) {
isCurrent = Objects.equals(workspaceTarget.getMemento(), getTargetHandle().getMemento());
}
} catch (CoreException e) {
// Caught with default message shown
}
Expand Down Expand Up @@ -104,14 +102,12 @@ private ITargetHandle getTargetHandle() {
if (!file.exists()) {
file = root.getFileForLocation(path);
}
ITargetHandle handle;
ITargetPlatformService service = acquireTargetPlatformService();
if (file != null) {
handle = service.getTarget(file);
return service.getTarget(file);
} else {
handle = service.getTarget(URIUtil.toURI(path));
return service.getTarget(path.toPath().toUri());
}
return handle;
}

private ITargetPlatformService acquireTargetPlatformService() {
Expand Down

0 comments on commit e294d7d

Please sign in to comment.