@Override public void formatterStarts(final IFormattingContext context) { @SuppressWarnings("unchecked") Map<String, String> prefs= (Map<String, String>) context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES); fPreferences.addLast(prefs); }
@Override public IFormattingContext createFormattingContext() { // it's ok to use instance preferences here as subclasses replace // with project dependent versions (see CompilationUnitEditor.AdaptedSourceViewer) IFormattingContext context= new JavaFormattingContext(); Map<String, String> map= new HashMap<>(JavaCore.getOptions()); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, map); return context; }
context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE); context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM, document); JavaPlugin.log(e); } finally { context.dispose();
return; Object region = context.getProperty(FormattingContextProperties.CONTEXT_REGION); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(region == null)); extension.format(document, context); context.dispose();
@Override public final void format(final IDocument medium, final IFormattingContext context) { context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM, medium); final Boolean document= (Boolean)context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT); if (document == null || !document.booleanValue()) { final IRegion region= (IRegion)context.getProperty(FormattingContextProperties.CONTEXT_REGION); if (region != null) { try { formatMaster(context, medium, region.getOffset(), region.getLength()); } finally { formatSlaves(context, medium, region.getOffset(), region.getLength()); } } } else { try { formatMaster(context, medium, 0, medium.getLength()); } finally { formatSlaves(context, medium, 0, medium.getLength()); } } }
prefs.put(JavaCore.JAVA_FORMATTER, fFormatterId); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, prefs); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true)); extension.format(fPreviewDocument, context); } else JavaPlugin.log(status); } finally { context.dispose(); fSourceViewer.setRedraw(true);
return; Object region = context.getProperty(FormattingContextProperties.CONTEXT_REGION); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(region == null)); extension.format(document, context); context.dispose();
@Override public final void format(final IDocument medium, final IFormattingContext context) { context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM, medium); final Boolean document= (Boolean)context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT); if (document == null || !document.booleanValue()) { final IRegion region= (IRegion)context.getProperty(FormattingContextProperties.CONTEXT_REGION); if (region != null) { try { formatMaster(context, medium, region.getOffset(), region.getLength()); } finally { formatSlaves(context, medium, region.getOffset(), region.getLength()); } } } else { try { formatMaster(context, medium, 0, medium.getLength()); } finally { formatSlaves(context, medium, 0, medium.getLength()); } } }
private void doFormat(IDocument document, Map options) { final IFormattingContext context = new CommentFormattingContext(); try { context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, options); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true)); final MultiPassContentFormatter formatter= new MultiPassContentFormatter(IJavaPartitions.JAVA_PARTITIONING, IDocument.DEFAULT_CONTENT_TYPE); formatter.setMasterStrategy(new JavaFormattingStrategy()); formatter.setSlaveStrategy(new CommentFormattingStrategy(), IJavaPartitions.JAVA_DOC); formatter.setSlaveStrategy(new CommentFormattingStrategy(), IJavaPartitions.JAVA_SINGLE_LINE_COMMENT); formatter.setSlaveStrategy(new CommentFormattingStrategy(), IJavaPartitions.JAVA_MULTI_LINE_COMMENT); try { startSequentialRewriteMode(document); formatter.format(document, context); } finally { stopSequentialRewriteMode(document); } } finally { context.dispose(); } }
@Override public void formatterStarts(final IFormattingContext context) { @SuppressWarnings("unchecked") Map<String, String> prefs= (Map<String, String>) context.getProperty(FormattingContextProperties.CONTEXT_PREFERENCES); fPreferences.addLast(prefs); }
public IFormattingContext createFormattingContext() { // it's ok to use instance preferences here as subclasses replace // with project dependent versions (see CompilationUnitEditor.AdaptedSourceViewer) IFormattingContext context= new CommentFormattingContext(); Map map= new HashMap(JavaCore.getOptions()); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, map); return context; }
protected void doFormatPreview() { if (fPreviewText == null) { fPreviewDocument.set(""); //$NON-NLS-1$ return; } fPreviewDocument.set(fPreviewText); fSourceViewer.setRedraw(false); final IFormattingContext context = new CommentFormattingContext(); try { final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer); if (formatter instanceof IContentFormatterExtension) { final IContentFormatterExtension extension = (IContentFormatterExtension) formatter; context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, fWorkingValues); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true)); extension.format(fPreviewDocument, context); } else formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength())); } catch (Exception e) { final IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, FormatterMessages.JavaPreview_formatter_exception, e); JavaPlugin.log(status); } finally { context.dispose(); fSourceViewer.setRedraw(true); } }
@Override public void formatterStarts(final IFormattingContext context) { super.formatterStarts(context); fPartitions.addLast((TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION)); fDocuments.addLast((IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM)); fPaths.addLast((String) context.getProperty(JavaFormattingContext.KEY_SOURCE_PATH)); }
@Override public IFormattingContext createFormattingContext() { // it's ok to use instance preferences here as subclasses replace // with project dependent versions (see CompilationUnitEditor.AdaptedSourceViewer) IFormattingContext context= new JavaFormattingContext(); Map<String, String> map= new HashMap<>(JavaCore.getOptions()); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, map); return context; }
private void format(String text) { if (text == null) { fPreviewDocument.set(""); //$NON-NLS-1$ return; } fPreviewDocument.set(text); if (!fFormat) return; fSourceViewer.setRedraw(false); final IFormattingContext context = new CommentFormattingContext(); try { final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer); if (formatter instanceof IContentFormatterExtension) { final IContentFormatterExtension extension = (IContentFormatterExtension) formatter; context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, JavaCore.getOptions()); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true)); extension.format(fPreviewDocument, context); } else formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength())); } catch (Exception e) { final IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, MultiFixMessages.CleanUpRefactoringWizard_formatterException_errorMessage, e); JavaPlugin.log(status); } finally { context.dispose(); fSourceViewer.setRedraw(true); } }
@Override public void formatterStarts(final IFormattingContext context) { super.formatterStarts(context); fPartitions.addLast((TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION)); fDocuments.addLast((IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM)); }
@Override public IFormattingContext createFormattingContext() { IFormattingContext context= new JavaFormattingContext(); Map<String, String> preferences; IJavaElement inputJavaElement= getInputJavaElement(); IJavaProject javaProject= inputJavaElement != null ? inputJavaElement.getJavaProject() : null; if (javaProject == null) preferences= new HashMap<>(JavaCore.getOptions()); else preferences= FormatterProfileManager.getProjectSettings(javaProject); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences); context.setProperty(JavaFormattingContext.KEY_SOURCE_PATH, inputJavaElement != null ? inputJavaElement.getPath().toString() : null); return context; } }
if (formatter instanceof IContentFormatterExtension) { final IContentFormatterExtension extension = (IContentFormatterExtension) formatter; context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, JavaCore.getOptions()); context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true)); extension.format(fPreviewDocument, context); } else JavaPlugin.log(status); } finally { context.dispose(); fSourceViewer.setRedraw(true);
public void formatterStarts(IFormattingContext context) { super.formatterStarts(context); fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION)); fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM)); }
public IFormattingContext createFormattingContext() { IFormattingContext context= new CommentFormattingContext(); Map preferences; IJavaElement inputJavaElement= getInputJavaElement(); IJavaProject javaProject= inputJavaElement != null ? inputJavaElement.getJavaProject() : null; if (javaProject == null) preferences= new HashMap(JavaCore.getOptions()); else preferences= new HashMap(javaProject.getOptions(true)); context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences); return context; } }