public String apply(String contents) { final TextEdit edit = codeFormatter.format( CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, contents, 0, contents.length(), 0, Constants.LINE_SEPARATOR); if (edit == null) { // TODO log a fatal or warning here. Throwing an exception is causing the actual freemarker error to be lost return contents; } IDocument document = new Document(contents); try { edit.apply(document); } catch (Exception e) { throw new RuntimeException( "Failed to format the generated source code.", e); } return document.get(); } }
public PDESourceViewer(PDEFormPage page) { // Create the underlying document fDocument = new Document(); fPage = page; }
public void connect(Object source) throws CoreException { try { if (source instanceof FileEditorInput) { FileEditorInput input = (FileEditorInput) source; File file = input.getPath().toFile(); doc = new Document(print(file)); } } catch (Exception e) { throw new RuntimeException(e); } }
@Override public void setInformation(String content) { if (content == null) { fViewer.setInput(null); return; } IDocument doc= new Document(content); fViewer.setInput(doc); }
public void setCode(final String code) { final IDocument document = new Document(code); format(document); setInput(document); }
protected static String getSourceFormatted(String unformattedJavaSource, IJavaProject settings, IProgressMonitor monitor, IWorkingCopyManager workingCopyManager) throws CoreException { SourceFormatOperation op = new SourceFormatOperation(settings, new Document(unformattedJavaSource)); op.validate(); op.run(monitor, workingCopyManager); return op.getDocument().get(); }
@Override protected void doSetInput(Object input) { if (input instanceof IDocument) fViewer.setInput(input); else if (input == null) fViewer.setInput(new Document("")); //$NON-NLS-1$ else { IDocument document= new Document(input.toString()); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING); fViewer.setInput(document); } }
@Override public void setInput(Object input) { if (input instanceof IStreamContentAccessor) { Document document= new Document(getString(input)); JavaCompareUtilities.setupPropertiesFileDocument(document); fSourceViewer.setDocument(document); } fInput= input; }
public void setInput(Object input) { if (input instanceof IStreamContentAccessor) { Document document= new Document(getString(input)); JavaCompareUtilities.setupPropertiesFileDocument(document); fSourceViewer.setDocument(document); } fInput= input; }
public ISelection getSelection() { if (fControl instanceof StyledText) { IDocument document= new Document(((StyledText)fControl).getSelectionText()); return new TextSelection(document, 0, document.getLength()); } else { // FIXME: see https://bugs.eclipse.org/bugs/show_bug.cgi?id=63022 return StructuredSelection.EMPTY; } }
public void setInput(Object input) { if (input instanceof IStreamContentAccessor) { Document document= new Document(getString(input)); JavaCompareUtilities.setupDocument(document); fSourceViewer.setDocument(document); } fInput= input; }
@Override public void setInput(Object input) { if (input instanceof IStreamContentAccessor) { Document document= new Document(getString(input)); JavaCompareUtilities.setupDocument(document); fSourceViewer.setDocument(document); } fInput= input; }
public void setHtml(String htmlText) { ParseResult result = parse(htmlText); textPresentation = result.textPresentation; if (configuration != null) { configuration.setTextPresentation(textPresentation); } setDocumentNoMarkup(new Document(result.text), result.annotationModel); }
public static CompilationUnit getCompilationUnit(final Path path) { final StringBuilder builder = GlobalUtils.readTextFile(path); final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(new Document(builder.toString()).get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
public static CompilationUnit getCompilationUnit(final String content) { final ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setResolveBindings(true); parser.setSource(new Document(content).get().toCharArray()); return (CompilationUnit) parser.createAST(null); }
private void format() { if (commit == null) { setDocument(new Document("")); //$NON-NLS-1$ return; } if (formatJob != null && formatJob.getState() != Job.NONE) formatJob.cancel(); scheduleFormatJob(); }
@Override public Control createControl(Composite parent) { fTextViewer = new TextViewer(parent, SWT.READ_ONLY); fTextViewer.setDocument(new Document()); StyledText styleText = fTextViewer.getTextWidget(); styleText.setText("\r\n\r\n" + DebugUIMessages.EmptyViewTab_Unable_to_create + "\n" + getRenderingName() + "\n\n" + DebugUIMessages.ErrorRendering_0 + fException.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ return fTextViewer.getControl(); }
public void setInformation(String content) { if (content == null) { fViewer.setInput(null); return; } IDocument doc= new Document(content); JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(doc, IJavaPartitions.JAVA_PARTITIONING); fViewer.setInput(doc); }
private void createSourceViewer(Composite c) { IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); fSourceViewer= new JavaSourceViewer(c, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store); fSourceViewer.configure(new JavaSourceViewerConfiguration(getJavaTextTools().getColorManager(), store, null, null)); fSourceViewer.setEditable(false); fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); Document document= new Document(); getJavaTextTools().setupJavaDocumentPartitioner(document); fSourceViewer.setDocument(document); }
private void createSourceViewer(Composite c) { IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore(); fSourceViewer= new JavaSourceViewer(c, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION, store); fSourceViewer.configure(new JavaSourceViewerConfiguration(getJavaTextTools().getColorManager(), store, null, null)); fSourceViewer.setEditable(false); fSourceViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); fSourceViewer.getControl().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); Document document= new Document(); getJavaTextTools().setupJavaDocumentPartitioner(document); fSourceViewer.setDocument(document); }