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

Merge user-guided implementation onto branch in central repo #17

Merged
merged 4 commits into from
Aug 23, 2023
Merged
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
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ repositories {
dependencies {
testImplementation("junit:junit:4.12")
implementation(fileTree(mapOf("dir" to "src/main/resources/dspot", "include" to listOf("*.jar"))))
implementation(fileTree(mapOf("dir" to "src/main/resources/plantuml", "include" to listOf("*.jar"))))
}

// Configure Gradle IntelliJ Plugin - read more: https://github.com/JetBrains/gradle-intellij-plugin
Expand Down
Binary file added dspot-3.1.1-SNAPSHOT-jar-with-dependencies.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

import com.intellij.codeInsight.TestFrameworks;
import com.intellij.execution.lineMarker.RunLineMarkerContributor;
import com.intellij.openapi.application.ReadAction;
import com.intellij.openapi.roots.ProjectFileIndex;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiClass;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiIdentifier;
import com.intellij.psi.PsiMethod;
import com.intellij.psi.impl.source.PsiClassImpl;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.testIntegration.TestFramework;
import com.intellij.util.Function;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.testshift.testcube.icons.TestCubeIcons;
import com.intellij.testIntegration.TestFinderHelper;
import com.intellij.testIntegration.LanguageTestCreators;

import java.util.Objects;
import java.util.*;

public class AmplifyTestMarkerContributor extends RunLineMarkerContributor {

Expand All @@ -41,7 +45,41 @@ public class AmplifyTestMarkerContributor extends RunLineMarkerContributor {
*/
PsiClass containingClass = PsiTreeUtil.getParentOfType(parent, PsiClass.class);
if (!isTestMethod(containingClass, (PsiMethod) parent)) {
return null;
PsiClass targetClass = Objects.requireNonNull(((PsiMethod) parent).getContainingClass());

// //the selected class
// PsiElement sourceElement = TestFinderHelper.findSourceElement(element);
// //the test class
// Collection<PsiElement> testClasses = ReadAction.compute(() -> TestFinderHelper.findTestsForClass(sourceElement));
// final List<PsiElement> candidates = Collections.synchronizedList(new ArrayList<>());
// candidates.addAll(testClasses);
// PsiClass testClass = null;
// PsiMethod testMethod = null;
// // test class exist
// if(candidates.size()>0) {
// testClass = (PsiClass) candidates.get(0);
// PsiMethod[] testMethods = testClass.getAllMethods();
// // consider use which method as Start or all
// if(testMethods.length>0) {
// testMethod = testMethods[0];
// }
// }

VirtualFile file = parent.getContainingFile().getVirtualFile();
if (file != null) {
VirtualFile moduleRoot = ProjectFileIndex.SERVICE.getInstance(parent.getProject())
.getContentRootForFile(file);
String moduleRootPath;
if (moduleRoot == null) {
moduleRootPath = parent.getProject().getBasePath();
} else {
moduleRootPath = moduleRoot.getPath();
}
return new Info(TestCubeIcons.AMPLIFY_TEST, tooltipProvider,
new ShowCFGAction("generate test " +
"cases for '" + element.getText() +"()'", targetClass,
(PsiMethod)parent, moduleRootPath));
}
}
// test method
String testMethodName = ((PsiMethod) parent).getName();
Expand Down
Loading
Loading