Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Issue #399 - fix JumpToStepDefinition and StepHyperlinkDetector for multi-project #411

Open
wants to merge 3 commits into
base: v1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package cucumber.eclipse.editor.editors.jumpto;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -29,9 +31,18 @@ public static StepDefinition findStepDefinitionMatch(int selectionLineNumber, IF
.getAttribute(MarkerFactory.STEP_DEFINITION_MATCH_JDT_HANDLE_IDENTIFIER_ATTRIBUTE);
//Search step in repository
if (id != null) {
StepDefinitionsRepository repository = StepDefinitionsStorage.INSTANCE
.getOrCreate(gherkinFile.getProject(), null);
Set<StepDefinition> stepDefinitions = repository.getAllStepDefinitions();
Set<StepDefinition> stepDefinitions = new HashSet<>();
for (IProject project : gherkinFile.getProject().getWorkspace().getRoot().getProjects()) {
try {
if (project.isOpen()) {
StepDefinitionsRepository repository = StepDefinitionsStorage.INSTANCE
.getOrCreate(project, null);
stepDefinitions.addAll(repository.getAllStepDefinitions());
}
} catch (Exception e) {
e.printStackTrace();
}
}
for (StepDefinition step : stepDefinitions) {
if (id.equals(step.getId())) {
return step;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package cucumber.eclipse.editor.editors.jumpto;

import java.util.HashSet;
import java.util.Set;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;
Expand Down Expand Up @@ -59,9 +61,18 @@ public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boo
.getAttribute(MarkerFactory.STEP_DEFINITION_MATCH_JDT_HANDLE_IDENTIFIER_ATTRIBUTE);
//Search step in repository
if (id != null) {
StepDefinitionsRepository repository = StepDefinitionsStorage.INSTANCE
.getOrCreate(gherkinFile.getProject(), null);
Set<StepDefinition> stepDefinitions = repository.getAllStepDefinitions();
Set<StepDefinition> stepDefinitions = new HashSet<>();
for (IProject project : gherkinFile.getProject().getWorkspace().getRoot().getProjects()) {
try {
if (project.isOpen()) {
StepDefinitionsRepository repository = StepDefinitionsStorage.INSTANCE
.getOrCreate(project, null);
stepDefinitions.addAll(repository.getAllStepDefinitions());
}
} catch (Exception e) {
e.printStackTrace();
}
}
for (StepDefinition stepDefinition : stepDefinitions) {
if (id.equals(stepDefinition.getId())) {
// define the hyperlink region
Expand Down