public static final CodeStyle getCodeStyle(CompilationInfo info) { if (info != null) { try { Document doc = info.getDocument(); if (doc != null) { CodeStyle cs = (CodeStyle)doc.getProperty(CodeStyle.class); return cs != null ? cs : CodeStyle.getDefault(doc); } } catch (IOException ioe) { // ignore } FileObject file = info.getFileObject(); if (file != null) { return CodeStyle.getDefault(file); } } return CodeStyle.getDefault((Document)null); }
importsProcesor.addImport(info.getDocument(), fqn);
private void addAnnotation( CdiAnalysisResult result, Element element , CDIAnnotaitonType type ) { if ( element == null ){ return; } Tree var = result.getInfo().getTrees().getTree( element ); if ( var == null ){ return; } List<Integer> position = CdiEditorAnalysisFactory.getElementPosition( result.getInfo(), var ); Document document; try { document = result.getInfo().getDocument(); if ( !( document instanceof StyledDocument) ){ return; } } catch (IOException e) { return; } int start = position.get(0); Line line = NbEditorUtilities.getLine( document , start, false); Part part = line.createPart( NbDocument.findLineColumn((StyledDocument) document, start), position.get( 1 ) -start); result.addAnnotation( new CDIAnnotation( type, part)); }