@@ -42,7 +42,7 @@ public class AnnotationsHolder implements PropertyChangeListener {
4242
4343 private static final Logger LOGGER = Logger .getLogger (AnnotationsHolder .class .getName ());
4444 private static final RequestProcessor WORKER = new RequestProcessor (AnnotationsHolder .class .getName (), 1 , false , false );
45- private static final Map <DataObject , AnnotationsHolder > file2Annotations = new HashMap <DataObject , AnnotationsHolder >();
45+ private static final Map <DataObject , AnnotationsHolder > file2Annotations = new HashMap <>();
4646
4747 public static synchronized AnnotationsHolder get (FileObject file ) {
4848 try {
@@ -59,12 +59,11 @@ public static synchronized AnnotationsHolder get(FileObject file) {
5959 return null ;
6060 }
6161
62- file2Annotations . put ( od , a = new AnnotationsHolder (od , ec ) );
63-
62+ a = new AnnotationsHolder (od , ec );
63+ file2Annotations . put ( od , a );
6464 return a ;
6565 } catch (IOException ex ) {
6666 LOGGER .log (Level .INFO , null , ex );
67-
6867 return null ;
6968 }
7069 }
@@ -75,19 +74,16 @@ public static synchronized AnnotationsHolder get(FileObject file) {
7574 private AnnotationsHolder (DataObject file , EditorCookie .Observable ec ) {
7675 this .file = file ;
7776 this .ec = ec ;
78- this .annotations = new ArrayList <IsOverriddenAnnotation >();
77+ this .annotations = new ArrayList <>();
7978
8079 ec .addPropertyChangeListener (this );
8180
82- SwingUtilities .invokeLater (new Runnable () {
83- public void run () {
84- checkForReset ();
85- }
86- });
81+ SwingUtilities .invokeLater (this ::checkForReset );
8782
8883 Logger .getLogger ("TIMER" ).log (Level .FINE , "Overridden AnnotationsHolder" , new Object [] {file .getPrimaryFile (), this }); //NOI18N
8984 }
9085
86+ @ Override
9187 public void propertyChange (PropertyChangeEvent evt ) {
9288 if (EditorCookie .Observable .PROP_OPENED_PANES .endsWith (evt .getPropertyName ()) || evt .getPropertyName () == null ) {
9389 checkForReset ();
@@ -111,26 +107,24 @@ private void checkForReset() {
111107 private final List <IsOverriddenAnnotation > annotations ;
112108
113109 public void setNewAnnotations (final List <IsOverriddenAnnotation > as ) {
114- Runnable doAttachDetach = new Runnable () {
115- public void run () {
116- final List <IsOverriddenAnnotation > toRemove ;
117- final List <IsOverriddenAnnotation > toAdd ;
118-
119- synchronized (AnnotationsHolder .this ) {
120- toRemove = new ArrayList <IsOverriddenAnnotation >(annotations );
121- toAdd = new ArrayList <IsOverriddenAnnotation >(as );
122-
123- annotations .clear ();
124- annotations .addAll (as );
125- }
126-
127- for (IsOverriddenAnnotation a : toRemove ) {
128- a .detachImpl ();
129- }
110+ Runnable doAttachDetach = () -> {
111+ List <IsOverriddenAnnotation > toRemove ;
112+ List <IsOverriddenAnnotation > toAdd ;
113+
114+ synchronized (AnnotationsHolder .this ) {
115+ toRemove = new ArrayList <>(annotations );
116+ toAdd = new ArrayList <>(as );
130117
131- for (IsOverriddenAnnotation a : toAdd ) {
132- a .attach ();
133- }
118+ annotations .clear ();
119+ annotations .addAll (as );
120+ }
121+
122+ for (IsOverriddenAnnotation a : toRemove ) {
123+ a .detachImpl ();
124+ }
125+
126+ for (IsOverriddenAnnotation a : toAdd ) {
127+ a .attach ();
134128 }
135129 };
136130
@@ -140,6 +134,6 @@ public void run() {
140134 }
141135
142136 public synchronized List <IsOverriddenAnnotation > getAnnotations () {
143- return new ArrayList <IsOverriddenAnnotation >(annotations );
137+ return new ArrayList <>(annotations );
144138 }
145139}
0 commit comments