From f44c642d406c2ad9ca6d679ca1b336e68ff28853 Mon Sep 17 00:00:00 2001 From: Rawi01 Date: Mon, 27 Jul 2020 13:37:59 +0200 Subject: Use enum instead of Boolean; switch to synchronized map --- src/core/lombok/eclipse/TransformEclipseAST.java | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/lombok/eclipse/TransformEclipseAST.java b/src/core/lombok/eclipse/TransformEclipseAST.java index f7b6976f..59a0709e 100644 --- a/src/core/lombok/eclipse/TransformEclipseAST.java +++ b/src/core/lombok/eclipse/TransformEclipseAST.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009-2019 The Project Lombok Authors. + * Copyright (C) 2009-2020 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -24,6 +24,8 @@ package lombok.eclipse; import static lombok.eclipse.handlers.EclipseHandlerUtil.*; import java.lang.reflect.Field; +import java.util.Collections; +import java.util.Map; import java.util.WeakHashMap; import lombok.ConfigurationKeys; @@ -64,7 +66,7 @@ public class TransformEclipseAST { public static boolean disableLombok = false; private static final HistogramTracker lombokTracker; - private static WeakHashMap completlyHandled = new WeakHashMap(); + private static Map transformationStates = Collections.synchronizedMap(new WeakHashMap()); static { String v = System.getProperty("lombok.histogram"); @@ -143,14 +145,14 @@ public class TransformEclipseAST { * @return true if this AST was already handled by lombok. */ public static boolean alreadyTransformed(CompilationUnitDeclaration ast) { - Boolean state = completlyHandled.get(ast); - if (state != null) { - if (state) return true; + State state = transformationStates.get(ast); + + if (state == State.FULL) return true; + if (state == State.DIET) { if (!EclipseAST.isComplete(ast)) return true; - - completlyHandled.put(ast, Boolean.TRUE); + transformationStates.put(ast, State.FULL); } else { - completlyHandled.put(ast, Boolean.FALSE); + transformationStates.put(ast, State.DIET); } return false; } @@ -270,4 +272,9 @@ public class TransformEclipseAST { nextPriority = Math.min(nextPriority, handlers.handleAnnotation(top, annotationNode, annotation, priority)); } } + + private static enum State { + DIET, + FULL + } } -- cgit