@@ -117,30 +117,35 @@ public Set<String> codeChangeMethods(String gitPath, String diffBranchName) {
117
117
}
118
118
119
119
// diff
120
- PrinterConfiguration printerConfiguration = new DefaultPrinterConfiguration ()
121
- .removeOption (new DefaultConfigurationOption (DefaultPrinterConfiguration .ConfigOption .PRINT_COMMENTS ))
122
- .removeOption (new DefaultConfigurationOption (DefaultPrinterConfiguration .ConfigOption .PRINT_JAVADOC ));
123
- DefaultPrettyPrinter printer = new DefaultPrettyPrinter (printerConfiguration );
124
- Set <String > changeMethods = Sets .newHashSet ();
125
- oldMethodDeclarations .forEach ((s , methodDeclaration ) -> {
126
- MethodDeclaration newMethodDeclaration = newMethodDeclarations .get (s );
127
- if (null == newMethodDeclaration ) {
128
- changeMethods .add (s );
129
- return ;
130
- }
131
- String oldMethodBodyStr = printer .print (methodDeclaration .getBody ().get ());
132
- String newMethodBodyStr = printer .print (newMethodDeclaration .getBody ().get ());
133
- if (!StringUtils .equals (oldMethodBodyStr , newMethodBodyStr )) {
134
- changeMethods .add (s );
135
- }
136
- });
137
- return changeMethods ;
120
+ return findChangeMethods (oldMethodDeclarations , newMethodDeclarations );
138
121
} catch (Exception e ) {
139
122
log .error ("CodeDomainService getBranchFileDiffInfo error, gitPath:{}" , gitPath , e );
140
123
return Collections .emptySet ();
141
124
}
142
125
}
143
126
127
+ private static Set <String > findChangeMethods (Map <String , MethodDeclaration > oldMethodDeclarations ,
128
+ Map <String , MethodDeclaration > newMethodDeclarations ) {
129
+ PrinterConfiguration printerConfiguration = new DefaultPrinterConfiguration ()
130
+ .removeOption (new DefaultConfigurationOption (DefaultPrinterConfiguration .ConfigOption .PRINT_COMMENTS ))
131
+ .removeOption (new DefaultConfigurationOption (DefaultPrinterConfiguration .ConfigOption .PRINT_JAVADOC ));
132
+ DefaultPrettyPrinter printer = new DefaultPrettyPrinter (printerConfiguration );
133
+ Set <String > changeMethods = Sets .newHashSet ();
134
+ oldMethodDeclarations .forEach ((s , methodDeclaration ) -> {
135
+ MethodDeclaration newMethodDeclaration = newMethodDeclarations .get (s );
136
+ if (null == newMethodDeclaration ) {
137
+ changeMethods .add (s );
138
+ return ;
139
+ }
140
+ String oldMethodBodyStr = printer .print (methodDeclaration .getBody ().get ());
141
+ String newMethodBodyStr = printer .print (newMethodDeclaration .getBody ().get ());
142
+ if (!StringUtils .equals (oldMethodBodyStr , newMethodBodyStr )) {
143
+ changeMethods .add (s );
144
+ }
145
+ });
146
+ return changeMethods ;
147
+ }
148
+
144
149
private Map <String , MethodDeclaration > getAllMethodDeclaration (String projectRootPath , String path ) throws FileNotFoundException {
145
150
CompilationUnit cu = StaticJavaParser .parse (new File (projectRootPath + "/" + path ));
146
151
List <ClassOrInterfaceDeclaration > classDeclarations = cu .findAll (ClassOrInterfaceDeclaration .class );
0 commit comments