本文整理匯總了Java中org.eclipse.jface.text.Document.set方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.set方法的具體用法?Java Document.set怎麽用?Java Document.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jface.text.Document
的用法示例。
在下文中一共展示了Document.set方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRecoveredAST
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
private CompilationUnit getRecoveredAST(IDocument document, int offset, Document recoveredDocument) {
CompilationUnit ast = SharedASTProvider.getInstance().getAST(fCompilationUnit, null);
if (ast != null) {
recoveredDocument.set(document.get());
return ast;
}
char[] content= document.get().toCharArray();
// clear prefix to avoid compile errors
int index= offset - 1;
while (index >= 0 && Character.isJavaIdentifierPart(content[index])) {
content[index]= ' ';
index--;
}
recoveredDocument.set(new String(content));
final ASTParser parser= ASTParser.newParser(IASTSharedValues.SHARED_AST_LEVEL);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setSource(content);
parser.setUnitName(fCompilationUnit.getElementName());
parser.setProject(fCompilationUnit.getJavaProject());
return (CompilationUnit) parser.createAST(new NullProgressMonitor());
}
示例2: testWillSaveWaitUntil
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
@Test
public void testWillSaveWaitUntil() throws Exception {
URI srcUri = project.getFile("src/java/Foo4.java").getRawLocationURI();
ICompilationUnit cu = JDTUtils.resolveCompilationUnit(srcUri);
StringBuilder buf = new StringBuilder();
buf.append("package java;\n");
buf.append("\n");
buf.append("public class Foo4 {\n");
buf.append("}\n");
WillSaveTextDocumentParams params = new WillSaveTextDocumentParams();
TextDocumentIdentifier document = new TextDocumentIdentifier();
document.setUri(srcUri.toString());
params.setTextDocument(document);
List<TextEdit> result = handler.willSaveWaitUntil(params, monitor);
Document doc = new Document();
doc.set(cu.getSource());
assertEquals(TextEditUtil.apply(doc, result), buf.toString());
}
示例3: evaluateCodeActionCommand
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
private String evaluateCodeActionCommand(Command c)
throws BadLocationException, JavaModelException {
Assert.assertEquals(CodeActionHandler.COMMAND_ID_APPLY_EDIT, c.getCommand());
Assert.assertNotNull(c.getArguments());
Assert.assertTrue(c.getArguments().get(0) instanceof WorkspaceEdit);
WorkspaceEdit we = (WorkspaceEdit) c.getArguments().get(0);
Iterator<Entry<String, List<TextEdit>>> editEntries = we.getChanges().entrySet().iterator();
Entry<String, List<TextEdit>> entry = editEntries.next();
assertNotNull("No edits generated", entry);
assertEquals("More than one resource modified", false, editEntries.hasNext());
ICompilationUnit cu = JDTUtils.resolveCompilationUnit(entry.getKey());
assertNotNull("CU not found: " + entry.getKey(), cu);
Document doc = new Document();
doc.set(cu.getSource());
return TextEditUtil.apply(doc, entry.getValue());
}
示例4: test
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
@Test
public void test() {
Document document = new Document();
DocumentLineList lineList = new DocumentLineList(document);
System.err.println(lineList.getSize());
document.set("var");
//document.set("var\nv");
System.err.println(lineList.getSize());
}
示例5: getOrganizeImportResult
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
private String getOrganizeImportResult(ICompilationUnit cu, WorkspaceEdit we) throws BadLocationException, CoreException {
List<TextEdit> change = we.getChanges().get(JDTUtils.getFileURI(cu));
Document doc = new Document();
doc.set(cu.getSource());
return TextEditUtil.apply(doc, change);
}
示例6: writeToMarkFile
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
void writeToMarkFile() {
File markfile = getRealFile("Ԥ����");
if (markfile != null && markfile.exists()) {
ioThread io = new ioThread(b);
if (marktextIsChanged) {
Document docu = new Document();
docu.set(marktext);
io.writeBlackFile(markfile, docu, null);
marktextIsChanged = false;
}
File statfile = new File(b.projectFile.getParentFile().getAbsolutePath() + "\\Settings\\markstat");
if (!statfile.exists()) {
if (!statfile.getParentFile().exists())
statfile.getParentFile().mkdir();
try {
statfile.createNewFile();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
getMessageBox("�����Ƶ����", "����Ԥ�����ļ���Ƶ����ʱ����");
}
}
if (markstat.size() > 0 && markstatIsChanged) {
io.writeObjFile(statfile, markstat);
}
}
}
示例7: createFullContentsDocument
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
/**
* Creates a document containing the full Xtext and diagram contents.
*
* @return a new document with Xtext and diagram contents.
*/
@Override
public IDocument createFullContentsDocument() {
Document result = new Document();
result.set(this.get() + myResource.getDiagramText(), this.getModificationStamp());
return result;
}
示例8: getRecoveredAST
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
private CompilationUnit getRecoveredAST(
IDocument document, int offset, Document recoveredDocument) {
CompilationUnit ast =
SharedASTProvider.getAST(fCompilationUnit, SharedASTProvider.WAIT_ACTIVE_ONLY, null);
if (ast != null) {
recoveredDocument.set(document.get());
return ast;
}
char[] content = document.get().toCharArray();
// clear prefix to avoid compile errors
int index = offset - 1;
while (index >= 0 && Character.isJavaIdentifierPart(content[index])) {
content[index] = ' ';
index--;
}
recoveredDocument.set(new String(content));
final CheASTParser parser = CheASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
parser.setResolveBindings(true);
parser.setStatementsRecovery(true);
parser.setSource(content);
parser.setUnitName(fCompilationUnit.getElementName());
parser.setProject(fCompilationUnit.getJavaProject());
return (CompilationUnit) parser.createAST(new NullProgressMonitor());
}
示例9: createPartControl
import org.eclipse.jface.text.Document; //導入方法依賴的package包/類
public void createPartControl(Composite parent)
{
int VERTICAL_RULER_WIDTH = 12;
int styles = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
ISharedTextColors sharedColors = EditorsPlugin.getDefault().getSharedTextColors();
IOverviewRuler overviewRuler = new OverviewRuler(null, VERTICAL_RULER_WIDTH, sharedColors);
CompositeRuler ruler = new CompositeRuler(VERTICAL_RULER_WIDTH);
_document = new Document();
_document.set(_docString);
_annotationModel = new AnnotationModel();
_annotationModel.connect(_document);
_sourceViewer = new SourceViewer(parent, ruler, overviewRuler, true, styles);
_sourceViewer.configure(new SourceViewerConfiguration());
_sds = new SourceViewerDecorationSupport(_sourceViewer, overviewRuler, null, sharedColors);
AnnotationPreference ap = new AnnotationPreference();
ap.setColorPreferenceKey(ANNO_KEY_COLOR);
ap.setHighlightPreferenceKey(ANNO_KEY_HIGHLIGHT);
ap.setVerticalRulerPreferenceKey(ANNO_KEY_VERTICAL);
ap.setOverviewRulerPreferenceKey(ANNO_KEY_OVERVIEW);
ap.setTextPreferenceKey(ANNO_KEY_TEXT);
ap.setAnnotationType(ANNO_TYPE);
_sds.setAnnotationPreference(ap);
// _sds.install(EditorsPlugin.getDefault().getPreferenceStore());
_sourceViewer.setDocument(_document, _annotationModel);
_sourceViewer.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
ruler.addDecorator(0, new LineNumberRulerColumn());
Annotation annotation = new Annotation(false);
annotation.setType(ANNO_TYPE);
Position position = new Position(0, 4);
_annotationModel.addAnnotation(annotation, position);
parent.layout();
}