Skip to content

Commit

Permalink
Ide compatibility. refine code.
Browse files Browse the repository at this point in the history
  • Loading branch information
maozhen committed Aug 7, 2024
1 parent 5283b62 commit dd081b4
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ protected void actionPerformed(Project project, Editor editor, String selectedTe
&& PsiFileUtil.isCaretInWebClass(project, editor)) {
data.put(ADDITIONAL_MOCK_PROMPT, PromptConst.MOCK_WEB_MVC);
}
UtFrameworkProvider utFrameworkProvider = UtFrameworkProviderFactory.create(language);
if (language != null && "java".equalsIgnoreCase(language.getLanguageName())) {
UtFrameworkProvider utFrameworkProvider = UtFrameworkProviderFactory.create("java");
if (utFrameworkProvider != null) {
UtFrameTypeEnum utFramework = utFrameworkProvider.getUTFramework(project, editor);
data.put(TEST_FRAMEWORK, utFramework.getUtFrameType());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
package com.zhongan.devpilot.provider.ut;

import com.zhongan.devpilot.provider.ut.java.JavaUtFrameworkProvider;
import com.zhongan.devpilot.util.LanguageUtil;

import java.util.Locale;

public class UtFrameworkProviderFactory {

public static UtFrameworkProvider create(String language) {
switch (language) {
public static UtFrameworkProvider create(LanguageUtil.Language language) {

if (language == null) {
return null;
}

switch (language.getLanguageName().toLowerCase(Locale.ROOT)) {
case "java":
return new JavaUtFrameworkProvider();
return JavaUtFrameworkProvider.INSTANCE;
case "go":
case "python":
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ public class JavaUtFrameworkProvider implements UtFrameworkProvider {

private static final String JUNIT4_GROUP_ID = "junit";

public static final JavaUtFrameworkProvider INSTANCE = new JavaUtFrameworkProvider();

private JavaUtFrameworkProvider() {
}

@Override
public UtFrameTypeEnum getUTFramework(Project project, Editor editor) {
try {
if (project == null || project.getBasePath() == null) {
Expand Down

0 comments on commit dd081b4

Please sign in to comment.