1 19 20 package org.netbeans.modules.java; 21 22 import org.netbeans.modules.javacore.internalapi.GuardedResolver; 23 import org.netbeans.modules.javacore.internalapi.JavaMetamodel; 24 import org.openide.text.PositionBounds; 25 26 30 public final class DocumentGuardedResolver implements GuardedResolver { 31 32 33 private DocumentGuardedResolver() { 34 } 35 36 private static DocumentGuardedResolver instance = null; 37 38 public static synchronized DocumentGuardedResolver getDefault() { 39 if (instance == null) { 40 instance = new DocumentGuardedResolver(); 41 } 42 return instance; 43 } 44 45 public final boolean isSectionGuarded(org.netbeans.jmi.javamodel.Resource resource, org.openide.text.PositionBounds bounds) { 46 JavaEditor editor = (JavaEditor) JavaMetamodel.getManager().getDataObject(resource).getCookie(JavaEditor.class); 47 PositionBounds begin = new PositionBounds(bounds.getBegin(), bounds.getBegin()); 48 PositionBounds end = new PositionBounds(bounds.getEnd(), bounds.getEnd()); 49 return !editor.testOverlap(begin) || !editor.testOverlap(end); 50 } 51 } 52 | Popular Tags |