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

Also load classes that only contain Before/After hooks #19

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
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
Expand Up @@ -18,6 +18,8 @@
import java.io.IOException;
import java.util.*;

import static dev.bluebiscuitdesign.cucumber.dart.steps.reference.CucumberJavaAnnotationProvider.HOOK_MARKERS;

public abstract class CucumberStepIndex extends FileBasedIndexExtension<Boolean, List<Integer>> {
private static final List<String> STEP_KEYWORDS = Arrays.asList(
"Әмма", "Нәтиҗәдә", "Вә", "Әйтик", "Һәм", "Ләкин", "Әгәр", "Und",
Expand Down Expand Up @@ -138,6 +140,10 @@ protected static boolean isStepDefinitionCall(@NotNull LighterASTNode methodName
return STEP_KEYWORDS.contains(text.subSequence(methodName.getStartOffset(), methodName.getEndOffset()).toString());
}

protected static boolean isHookDefinitionCall(@NotNull LighterASTNode methodName, @NotNull CharSequence text) {
return HOOK_MARKERS.contains(text.subSequence(methodName.getStartOffset(), methodName.getEndOffset()).toString());
}

protected static boolean isStringLiteral(@NotNull LighterASTNode element, @NotNull CharSequence text) {
return text.charAt(element.getStartOffset()) == '"';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public void visitNode(@NotNull LighterASTNode element) {
return;
}
LighterASTNode methodNameNode = methodNameAndArgumentList.get(1);
if (methodNameNode != null && isStepDefinitionCall(methodNameNode, text)) {
// Include both step defs and hook methods...
if (methodNameNode != null && (isStepDefinitionCall(methodNameNode, text) || isHookDefinitionCall(methodNameNode, text))) {
LighterASTNode expressionList = methodNameAndArgumentList.get(2);
if (expressionList.getTokenType() == DartTokenTypes.ARGUMENTS) {
LighterASTNode argumentList = LightTreeUtil.firstChildOfType(lighterAst, expressionList, DartTokenTypes.ARGUMENT_LIST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private static String getImportPackage(PsiFile file, Set<VirtualFile> knownPacka
*/
private static String getImportPackage(PsiDirectory containingDir, String exportFileMatch, Set<VirtualFile> knownPackages) {
for (PsiFile dirFile : containingDir.getFiles()) {
System.out.println(knownPackages);
// System.out.println(knownPackages);
try (BufferedReader reader = new BufferedReader(new InputStreamReader(dirFile.getVirtualFile().getInputStream()))) {
String line;
while ((line = reader.readLine()) != null) {
Expand Down