Skip to content
This repository was archived by the owner on Apr 10, 2024. It is now read-only.

Commit c06ce45

Browse files
committed
opt: 优化url前缀后缀的选择
1 parent f2af7ef commit c06ce45

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

Plugin/src/com/ciy/plugin/ui/SelectApiDialog.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.ciy.plugin.Constants;
44
import com.ciy.plugin.ShowInputDialogAction;
55
import com.ciy.plugin.modle.*;
6+
import com.ciy.plugin.utils.URLConstantGenerate;
67
import com.google.gson.Gson;
78
import com.google.gson.reflect.TypeToken;
89
import com.intellij.openapi.module.Module;
@@ -208,7 +209,8 @@ private void readSelectApi() {
208209
}
209210
String sourceText = sb.toString();
210211
if (!sourceText.isEmpty()) {
211-
Pattern pattern = Pattern.compile("\\$PREFIX(.+?)\\$SUFFIX");
212+
Pattern pattern = Pattern.compile("\\$" + URLConstantGenerate.INSTANCE.getPrefixPropertyName() +
213+
"(.+?)\\$" + URLConstantGenerate.INSTANCE.getSuffixPropertyName());
212214
Matcher matcher = pattern.matcher(sourceText);
213215
List<String> urlList = new ArrayList<>();
214216
while (matcher.find()) {

Plugin/src/com/ciy/plugin/utils/URLConstantGenerate.kt

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ import java.io.File
66

77
object URLConstantGenerate {
88

9+
val prefixPropertyName = "PREFIX"
10+
val suffixPropertyName = "SUFFIX"
11+
912
val propertyMap = HashMap<ApiInfoBean, PropertySpec>()
1013

1114
/**
@@ -45,8 +48,6 @@ object URLConstantGenerate {
4548
className: String,
4649
urlConstantBuild: TypeSpec.Builder
4750
): Pair<PropertySpec, PropertySpec> {
48-
val prefixPropertyName = "PREFIX"
49-
val suffixPropertyName = "SUFFIX"
5051
val prefixPropertyValue =
5152
getClassPropertyValue(getClassFile(rootDir, packName, "$className.kt"), prefixPropertyName, "\"\"")
5253
val suffixPropertyValue =

0 commit comments

Comments
 (0)