1 19 package org.netbeans.spi.editor.hints; 20 21 import java.util.List ; 22 import javax.swing.text.Document ; 23 import javax.swing.text.Position ; 24 import org.netbeans.modules.editor.hints.HintsControllerImpl; 25 import org.netbeans.modules.editor.hints.StaticFixList; 26 import org.openide.filesystems.FileObject; 27 import org.openide.loaders.DataObject; 28 import org.openide.text.Line; 29 30 34 public class ErrorDescriptionFactory { 35 36 37 private ErrorDescriptionFactory() { 38 } 39 40 42 public static ErrorDescription createErrorDescription(Severity severity, String description, Document doc, int lineNumber) { 43 return createErrorDescription(severity, description, new StaticFixList(), doc, lineNumber); 44 } 45 46 48 public static ErrorDescription createErrorDescription(Severity severity, String description, List <Fix> fixes, Document doc, int lineNumber) { 49 return createErrorDescription(severity, description, new StaticFixList(fixes), doc, lineNumber); 50 } 51 52 54 public static ErrorDescription createErrorDescription(Severity severity, String description, LazyFixList fixes, Document doc, int lineNumber) { 55 DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty); 56 FileObject file = od != null ? od.getPrimaryFile() : null; 57 58 return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.fullLine(doc, lineNumber)); 59 } 60 61 63 public static ErrorDescription createErrorDescription(Severity severity, String description, Document doc, Position start, Position end) { 64 return createErrorDescription(severity, description, new StaticFixList(), doc, start, end); 65 } 66 67 69 public static ErrorDescription createErrorDescription(Severity severity, String description, List <Fix> fixes, Document doc, Position start, Position end) { 70 return createErrorDescription(severity, description, new StaticFixList(fixes), doc, start, end); 71 } 72 73 75 public static ErrorDescription createErrorDescription(Severity severity, String description, LazyFixList fixes, Document doc, Position start, Position end) { 76 DataObject od = (DataObject) doc.getProperty(Document.StreamDescriptionProperty); 77 FileObject file = od != null ? od.getPrimaryFile() : null; 78 79 return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(doc, start, end)); 80 } 81 82 84 public static ErrorDescription createErrorDescription(Severity severity, String description, FileObject file, int start, int end) { 85 return createErrorDescription(severity, description, new StaticFixList(), file, start, end); 86 } 87 88 90 public static ErrorDescription createErrorDescription(Severity severity, String description, List <Fix> fixes, FileObject file, int start, int end) { 91 return createErrorDescription(severity, description, new StaticFixList(fixes), file, start, end); 92 } 93 94 96 public static ErrorDescription createErrorDescription(Severity severity, String description, LazyFixList fixes, FileObject file, int start, int end) { 97 return new ErrorDescription(file, description, severity, fixes, HintsControllerImpl.linePart(file, start, end)); 98 } 99 100 public static LazyFixList lazyListForFixes(List <Fix> fixes) { 101 return new StaticFixList(fixes); 102 } 103 104 public static LazyFixList lazyListForDelegates(List <LazyFixList> delegates) { 105 return new HintsControllerImpl.CompoundLazyFixList(delegates); 106 } 107 } 108 | Popular Tags |