public Reformatter(Source source, Context context) { this.source = source; this.context = context; this.doc = context.document(); }
@Override public Preferences forFile(FileObject file, String mimeType) { return INSTANCE.forFile(file, mimeType); }
@Override public Preferences forDocument(Document doc, String mimeType) { return INSTANCE.forDocument(doc, mimeType); }
public void reformat(Context context, ParserResult info) { Document document = context.document(); int startOffset = context.startOffset(); int endOffset = context.endOffset(); if (codeStyle != null) { reindent(context, document, startOffset, endOffset, info, false); } else { RubyFormatter f = new RubyFormatter(CodeStyle.get(document), -1); f.reindent(context, document, startOffset, endOffset, info, false); } }
@Override public int hangingIndentSize() { return CodeStylePreferences.get((Document) null).getPreferences().getInt("continuationIndentSize", 4); }
private void modifyUnderWriteLock(Context context) { try { context.modifyIndent(Utilities.getRowStart((BaseDocument) context.document(), context.caretOffset()), indentation); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } }
private int getColumn(Tree tree) throws BadLocationException { int startOffset = getStartPosition(tree); if (startOffset < 0) { return -1; } int lineStartOffset = context.lineStartOffset(startOffset); return getCol(context.document().getText(lineStartOffset, startOffset - lineStartOffset)); }
private LinkedList<Integer> getStartOffsets(Region region) throws BadLocationException { LinkedList<Integer> offsets = new LinkedList<Integer>(); int offset = region.getEndOffset(); int lso; while (offset > 0 && (lso = context.lineStartOffset(offset)) >= region.getStartOffset()) { offsets.addFirst(lso); offset = lso - 1; } return offsets; }
public void reindent(Context context) { Document document = context.document(); int startOffset = context.startOffset(); int endOffset = context.endOffset(); if (codeStyle != null) { // Make sure we're not reindenting HTML content reindent(context, document, startOffset, endOffset, null, true); } else { RubyFormatter f = new RubyFormatter(CodeStyle.get(document), -1); f.reindent(context, document, startOffset, endOffset, null, true); } }
public static CodeStyle get(Document doc) { return new CodeStyle(CodeStylePreferences.get(doc).getPreferences()); }
public FortranIndentTask(Context context) { this.context = context; doc = context.document(); }
public static CodeStyle get(Document doc) { return new CodeStyle(CodeStylePreferences.get(doc).getPreferences()); }
public FortranReformatter(Context context) { this.context = context; this.doc = context.document(); }
/** * Gets <code>CodeStyle</code> for the given document. This is the preferred * method of getting <code>CodeStyle</code>. If you don't have a document * you can use {@link #getDefault(org.openide.filesystems.FileObject)} method instead. * * @param doc The document to get the <code>CodeStyle</code> for. * @return The current code style used by a document. This is the code style that * will be used when formatting the document or generating new code. * * @since 0.39 */ public synchronized static CodeStyle getDefault(Document doc) { Preferences prefs = CodeStylePreferences.get(doc, JavacParser.MIME_TYPE).getPreferences(); return FmtOptions.codeStyleProducer.create(prefs); }
public CppIndentTask(Context context) { this.context = context; doc = context.document(); }
/** * Gets <code>CodeStyle</code> for the given file. If you have a document * instance you should use the {@link #getDefault(javax.swing.text.Document)} * method. * * @param file The file to get the <code>CodeStyle</code> for. * @return The current code style that would be used by a document if the * <code>file</code> were opened in the editor. * * @since 0.39 */ public synchronized static CodeStyle getDefault(FileObject file) { Preferences prefs = CodeStylePreferences.get(file, JavacParser.MIME_TYPE).getPreferences(); return FmtOptions.codeStyleProducer.create(prefs); }
public Reformatter(Context context) { this.context = context; this.doc = context.document(); }
@Override public void modify(final Context context) { assert context != null; context.document().render(new Runnable() { @Override public void run() { modifyUnderWriteLock(context); } }); }
public ReformatTask createTask(Context context) { Source source = Source.forDocument(context.document()); return source != null ? new GsfReformatTask(source, context) : null; } }
public ReformatTask createTask(Context context) { Source source = Source.create(context.document()); return source != null ? new Reformatter(source, context) : null; } }