1717import consulo .module .Module ;
1818import consulo .module .ModuleManager ;
1919import consulo .project .Project ;
20+ import consulo .util .lang .Couple ;
2021import consulo .util .lang .Pair ;
2122import consulo .util .lang .StringUtil ;
2223import jakarta .inject .Inject ;
@@ -61,7 +62,7 @@ public static JavaCompilerConfiguration getInstance(@Nonnull Project project) {
6162 private BackendCompiler myBackendCompilerCache ;
6263
6364 private final ProcessorConfigProfile myDefaultProcessorsProfile = new ProcessorConfigProfileImpl ("Default" );
64- private final List <ProcessorConfigProfile > myModuleProcessorProfiles = new ArrayList <ProcessorConfigProfile >();
65+ private final List <ProcessorConfigProfile > myModuleProcessorProfiles = new ArrayList <>();
6566
6667 // the map is calculated by module processor profiles list for faster access to module settings
6768 private Map <Module , ProcessorConfigProfile > myProcessorsProfilesMap = null ;
@@ -72,7 +73,7 @@ public static JavaCompilerConfiguration getInstance(@Nonnull Project project) {
7273
7374 @ Deprecated
7475 @ DeprecationInfo ("We used JavaModuleExtension for store info about bytecode version" )
75- private final Map <String , String > myModuleBytecodeTarget = new HashMap <String , String >();
76+ private final Map <String , String > myModuleBytecodeTarget = new HashMap <>();
7677
7778 @ Inject
7879 public JavaCompilerConfiguration (@ Nonnull Project project ) {
@@ -124,11 +125,11 @@ public BackendCompiler findCompiler(@Nonnull String className) {
124125 public Element getState () {
125126 Element parentNode = new Element ("state" );
126127
127- final Element annotationProcessingSettings = addChild (parentNode , ANNOTATION_PROCESSING );
128- final Element defaultProfileElem = addChild (annotationProcessingSettings , "profile" ).setAttribute ("default" , "true" );
128+ Element annotationProcessingSettings = addChild (parentNode , ANNOTATION_PROCESSING );
129+ Element defaultProfileElem = addChild (annotationProcessingSettings , "profile" ).setAttribute ("default" , "true" );
129130 AnnotationProcessorProfileSerializer .writeExternal (myDefaultProcessorsProfile , defaultProfileElem );
130131 for (ProcessorConfigProfile profile : myModuleProcessorProfiles ) {
131- final Element profileElem = addChild (annotationProcessingSettings , "profile" ).setAttribute ("default" , "false" );
132+ Element profileElem = addChild (annotationProcessingSettings , "profile" ).setAttribute ("default" , "false" );
132133 AnnotationProcessorProfileSerializer .writeExternal (profile , profileElem );
133134 }
134135
@@ -141,26 +142,26 @@ public Element getState() {
141142 }
142143
143144 if (!StringUtil .isEmpty (myBytecodeTargetLevel ) || !myModuleBytecodeTarget .isEmpty ()) {
144- final Element bytecodeTarget = addChild (parentNode , BYTECODE_TARGET_LEVEL );
145+ Element bytecodeTarget = addChild (parentNode , BYTECODE_TARGET_LEVEL );
145146 if (!StringUtil .isEmpty (myBytecodeTargetLevel )) {
146147 bytecodeTarget .setAttribute (TARGET_ATTRIBUTE , myBytecodeTargetLevel );
147148 }
148149 if (!myModuleBytecodeTarget .isEmpty ()) {
149- final List <String > moduleNames = new ArrayList <String >(myModuleBytecodeTarget .keySet ());
150+ List <String > moduleNames = new ArrayList <>(myModuleBytecodeTarget .keySet ());
150151 Collections .sort (moduleNames , String .CASE_INSENSITIVE_ORDER );
151152 for (String name : moduleNames ) {
152- final Element moduleElement = addChild (bytecodeTarget , MODULE );
153+ Element moduleElement = addChild (bytecodeTarget , MODULE );
153154 moduleElement .setAttribute (NAME , name );
154- final String value = myModuleBytecodeTarget .get (name );
155+ String value = myModuleBytecodeTarget .get (name );
155156 moduleElement .setAttribute (TARGET_ATTRIBUTE , value != null ? value : "" );
156157 }
157158 }
158159 }
159160 return parentNode ;
160161 }
161162
162- private static Element addChild (Element parent , final String childName ) {
163- final Element child = new Element (childName );
163+ private static Element addChild (Element parent , String childName ) {
164+ Element child = new Element (childName );
164165 parent .addContent (child );
165166 return child ;
166167 }
@@ -170,18 +171,18 @@ public void loadState(Element parentNode) {
170171 myBackendCompilerCache = findCompiler (parentNode .getAttributeValue ("compiler" ));
171172 myAddNotNullAssertions = Boolean .parseBoolean (parentNode .getAttributeValue (ADD_NOTNULL_ASSERTIONS , String .valueOf (Boolean .FALSE )));
172173
173- final Element annotationProcessingSettings = parentNode .getChild (ANNOTATION_PROCESSING );
174+ Element annotationProcessingSettings = parentNode .getChild (ANNOTATION_PROCESSING );
174175 if (annotationProcessingSettings != null ) {
175- final List profiles = annotationProcessingSettings .getChildren ("profile" );
176+ List profiles = annotationProcessingSettings .getChildren ("profile" );
176177 if (!profiles .isEmpty ()) {
177178 for (Object elem : profiles ) {
178- final Element profileElement = (Element )elem ;
179- final boolean isDefault = "true" .equals (profileElement .getAttributeValue ("default" ));
179+ Element profileElement = (Element )elem ;
180+ boolean isDefault = "true" .equals (profileElement .getAttributeValue ("default" ));
180181 if (isDefault ) {
181182 AnnotationProcessorProfileSerializer .readExternal (myDefaultProcessorsProfile , profileElement );
182183 }
183184 else {
184- final ProcessorConfigProfile profile = new ProcessorConfigProfileImpl ("" );
185+ ProcessorConfigProfile profile = new ProcessorConfigProfileImpl ("" );
185186 AnnotationProcessorProfileSerializer .readExternal (profile , profileElement );
186187 myModuleProcessorProfiles .add (profile );
187188 }
@@ -215,16 +216,16 @@ public void loadState(Element parentNode) {
215216
216217 private void loadProfilesFromOldFormat (Element processing ) {
217218 // collect data
218- final boolean isEnabled = Boolean .parseBoolean (processing .getAttributeValue (ENABLED , "false" ));
219- final boolean isUseClasspath = Boolean .parseBoolean (processing .getAttributeValue ("useClasspath" , "true" ));
220- final StringBuilder processorPath = new StringBuilder ();
221- final Set <String > optionPairs = new HashSet <String >();
222- final Set <String > processors = new HashSet <String >();
223- final List <Pair <String , String >> modulesToProcess = new ArrayList <Pair < String , String > >();
219+ boolean isEnabled = Boolean .parseBoolean (processing .getAttributeValue (ENABLED , "false" ));
220+ boolean isUseClasspath = Boolean .parseBoolean (processing .getAttributeValue ("useClasspath" , "true" ));
221+ StringBuilder processorPath = new StringBuilder ();
222+ Set <String > optionPairs = new HashSet <>();
223+ Set <String > processors = new HashSet <>();
224+ List <Pair <String , String >> modulesToProcess = new ArrayList <>();
224225
225226 for (Object child : processing .getChildren ("processorPath" )) {
226- final Element pathElement = (Element )child ;
227- final String path = pathElement .getAttributeValue ("value" , (String )null );
227+ Element pathElement = (Element )child ;
228+ String path = pathElement .getAttributeValue ("value" , (String )null );
228229 if (path != null ) {
229230 if (processorPath .length () > 0 ) {
230231 processorPath .append (File .pathSeparator );
@@ -234,26 +235,26 @@ private void loadProfilesFromOldFormat(Element processing) {
234235 }
235236
236237 for (Object child : processing .getChildren ("processor" )) {
237- final Element processorElement = (Element )child ;
238- final String proc = processorElement .getAttributeValue (NAME , (String )null );
238+ Element processorElement = (Element )child ;
239+ String proc = processorElement .getAttributeValue (NAME , (String )null );
239240 if (proc != null ) {
240241 processors .add (proc );
241242 }
242- final StringTokenizer tokenizer = new StringTokenizer (processorElement .getAttributeValue ("options" , "" ), " " , false );
243+ StringTokenizer tokenizer = new StringTokenizer (processorElement .getAttributeValue ("options" , "" ), " " , false );
243244 while (tokenizer .hasMoreTokens ()) {
244- final String pair = tokenizer .nextToken ();
245+ String pair = tokenizer .nextToken ();
245246 optionPairs .add (pair );
246247 }
247248 }
248249
249250 for (Object child : processing .getChildren ("processModule" )) {
250- final Element moduleElement = (Element )child ;
251- final String name = moduleElement .getAttributeValue (NAME , (String )null );
251+ Element moduleElement = (Element )child ;
252+ String name = moduleElement .getAttributeValue (NAME , (String )null );
252253 if (name == null ) {
253254 continue ;
254255 }
255- final String dir = moduleElement .getAttributeValue ("generatedDirName" , (String )null );
256- modulesToProcess .add (Pair . create (name , dir ));
256+ String dir = moduleElement .getAttributeValue ("generatedDirName" , (String )null );
257+ modulesToProcess .add (Couple . of (name , dir ));
257258 }
258259
259260 myDefaultProcessorsProfile .setEnabled (false );
@@ -263,7 +264,7 @@ private void loadProfilesFromOldFormat(Element processing) {
263264 }
264265 if (!optionPairs .isEmpty ()) {
265266 for (String pair : optionPairs ) {
266- final int index = pair .indexOf ("=" );
267+ int index = pair .indexOf ("=" );
267268 if (index > 0 ) {
268269 myDefaultProcessorsProfile .setOption (pair .substring (0 , index ), pair .substring (index + 1 ));
269270 }
@@ -273,21 +274,21 @@ private void loadProfilesFromOldFormat(Element processing) {
273274 myDefaultProcessorsProfile .addProcessor (processor );
274275 }
275276
276- final Map <String , Set <String >> dirNameToModulesMap = new HashMap <String , Set < String > >();
277+ Map <String , Set <String >> dirNameToModulesMap = new HashMap <>();
277278 for (Pair <String , String > moduleDirPair : modulesToProcess ) {
278- final String dir = moduleDirPair .getSecond ();
279+ String dir = moduleDirPair .getSecond ();
279280 Set <String > set = dirNameToModulesMap .get (dir );
280281 if (set == null ) {
281- set = new HashSet <String >();
282+ set = new HashSet <>();
282283 dirNameToModulesMap .put (dir , set );
283284 }
284285 set .add (moduleDirPair .getFirst ());
285286 }
286287
287288 int profileIndex = 0 ;
288289 for (Map .Entry <String , Set <String >> entry : dirNameToModulesMap .entrySet ()) {
289- final String dirName = entry .getKey ();
290- final ProcessorConfigProfile profile = new ProcessorConfigProfileImpl (myDefaultProcessorsProfile );
290+ String dirName = entry .getKey ();
291+ ProcessorConfigProfile profile = new ProcessorConfigProfileImpl (myDefaultProcessorsProfile );
291292 profile .setName ("Profile" + (++profileIndex ));
292293 profile .setEnabled (isEnabled );
293294 profile .setGeneratedSourcesDirectoryName (dirName , false );
@@ -299,18 +300,19 @@ private void loadProfilesFromOldFormat(Element processing) {
299300 }
300301
301302 @ Nonnull
303+ @ RequiredReadAction
302304 public ProcessorConfigProfile getAnnotationProcessingConfiguration (Module module ) {
303305 Map <Module , ProcessorConfigProfile > map = myProcessorsProfilesMap ;
304306 if (map == null ) {
305- map = new HashMap <Module , ProcessorConfigProfile >();
306- final Map <String , Module > namesMap = new HashMap <String , Module >();
307+ map = new HashMap <>();
308+ Map <String , Module > namesMap = new HashMap <>();
307309 for (Module m : ModuleManager .getInstance (module .getProject ()).getModules ()) {
308310 namesMap .put (m .getName (), m );
309311 }
310312 if (!namesMap .isEmpty ()) {
311313 for (ProcessorConfigProfile profile : myModuleProcessorProfiles ) {
312314 for (String name : profile .getModuleNames ()) {
313- final Module mod = namesMap .get (name );
315+ Module mod = namesMap .get (name );
314316 if (mod != null ) {
315317 map .put (mod , profile );
316318 }
@@ -319,7 +321,7 @@ public ProcessorConfigProfile getAnnotationProcessingConfiguration(Module module
319321 }
320322 myProcessorsProfilesMap = map ;
321323 }
322- final ProcessorConfigProfile profile = map .get (module );
324+ ProcessorConfigProfile profile = map .get (module );
323325 return profile != null ? profile : myDefaultProcessorsProfile ;
324326 }
325327
0 commit comments