1
1
package eu .fasten .core .utils ;
2
2
3
+ import eu .fasten .core .dbconnectors .PostgresConnector ;
4
+ import eu .fasten .core .maven .GraphMavenResolver ;
5
+ import eu .fasten .core .maven .data .Revision ;
6
+
3
7
import java .nio .charset .StandardCharsets ;
4
8
import java .util .Arrays ;
9
+ import java .util .HashMap ;
5
10
import java .util .List ;
11
+ import java .util .Set ;
6
12
import java .util .regex .Matcher ;
7
13
import java .util .regex .Pattern ;
8
14
import java .util .stream .Collectors ;
@@ -86,28 +92,29 @@ public static List<String> parsePartialFastenUri(String partialFastenUri) {
86
92
throw new IllegalArgumentException (partialUriFormatException );
87
93
88
94
// Class: `/{class}.*(`
89
- Pattern classPattern = Pattern .compile ("(?<=/)([^\\ /]+)(?=\\ . ([^./]+)\\ ()" );
95
+ Pattern classPattern = Pattern .compile ("(?<=/)([^,;. /]+? )(?=( \\ $| \\ .) ([^./]+)\\ ()" );
90
96
Matcher classMatcher = classPattern .matcher (partialFastenUri );
91
97
if (!classMatcher .find () || classMatcher .group (0 ).isEmpty ())
92
98
throw new IllegalArgumentException (partialUriFormatException );
93
99
94
100
95
101
// Method: `.{method}(`
96
- Pattern methodNamePattern = Pattern .compile ("(?<=\\ .) ([^.]+ )(?=\\ ()" );
102
+ Pattern methodNamePattern = Pattern .compile ("(?<=\\ .( \\ $?)) ([^,;./$]+? )(?=\\ ()" );
97
103
Matcher methodNameMatcher = methodNamePattern .matcher (partialFastenUri );
98
104
if (!methodNameMatcher .find () || methodNameMatcher .group (0 ).isEmpty ())
99
105
throw new IllegalArgumentException (partialUriFormatException );
100
106
101
107
102
108
// Method Args: `({args})`
103
- Pattern methodArgsPattern = Pattern .compile ("(?<=\\ ()(.*)(?=\\ ))" );
109
+ Pattern methodArgsPattern = Pattern .compile ("(?<=" + methodNameMatcher . group ( 0 ) + " \\ ()(.*? )(?=\\ ))" );
104
110
Matcher methodArgsMatcher = methodArgsPattern .matcher (partialFastenUri );
105
111
if (!methodArgsMatcher .find ())
106
112
throw new IllegalArgumentException (partialUriFormatException );
107
113
108
114
109
115
// Method Return Type: `)/{type}`
110
- Pattern methodReturnPattern = Pattern .compile ("(?<=\\ ))(.*)" );
116
+ Pattern methodReturnPattern = Pattern .compile (
117
+ "(?<=" + methodNameMatcher .group (0 ) + "\\ (" + methodArgsMatcher .group (0 ) + "\\ ))(.*)" );
111
118
Matcher methodReturnMatcher = methodReturnPattern .matcher (partialFastenUri );
112
119
if (!methodReturnMatcher .find () || methodReturnMatcher .group (0 ).isEmpty ())
113
120
throw new IllegalArgumentException (partialUriFormatException );
@@ -121,4 +128,9 @@ public static List<String> parsePartialFastenUri(String partialFastenUri) {
121
128
122
129
return List .of (namespace , className , methodName , methodArgs , methodReturnType );
123
130
}
131
+
132
+ public static void main (String [] args ) {
133
+ var partial = "/nl.tudelft.jpacman.ui/PacManUiBuilder$addStopButton%28Lnl$tudelft$jpacman$game$Game%3A%29V%3A30$Lambda.$newInstance(%2Fnl.tudelft.jpacman.game%2FGame)PacManUiBuilder$addStopButton%28Lnl$tudelft$jpacman$game$Game%3A%29V%3A30$Lambda" ;
134
+ System .out .println (parsePartialFastenUri (partial ));
135
+ }
124
136
}
0 commit comments