use of org.eclipse.xtext.ui.editor.model.IXtextDocument in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method applyProposal.
public ContentAssistProcessorTestBuilder applyProposal(int position, String proposalString) throws Exception {
IXtextDocument document = getDocument(getModel());
Shell shell = new Shell();
try {
ICompletionProposal[] proposals = computeCompletionProposals(document, position, shell);
ICompletionProposal proposal = findProposal(proposalString, proposals);
return applyProposal(proposal, position, document);
} finally {
shell.dispose();
}
}
use of org.eclipse.xtext.ui.editor.model.IXtextDocument in project xtext-eclipse by eclipse.
the class AbstractHyperlinkingTest method hyperlinkingOn.
protected IHyperlink[] hyperlinkingOn(IFile dslFile, int offset) {
XtextEditor editor = openInEditor(dslFile);
IXtextDocument document = xtextDocumentUtil.getXtextDocument(editor.getInternalSourceViewer());
XtextResource resource = document.readOnly((state) -> state);
return hyperlinkHelper.createHyperlinksByOffset(resource, offset, true);
}
use of org.eclipse.xtext.ui.editor.model.IXtextDocument in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method getDocument.
public IXtextDocument getDocument(final XtextResource xtextResource, final String model) {
XtextDocument document = get(XtextDocument.class);
document.set(model);
document.setInput(xtextResource);
DocumentPartitioner partitioner = get(DocumentPartitioner.class);
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
return document;
}
use of org.eclipse.xtext.ui.editor.model.IXtextDocument in project xtext-eclipse by eclipse.
the class ContentAssistProcessorTestBuilder method appendAndApplyProposal.
public ContentAssistProcessorTestBuilder appendAndApplyProposal(String model, int position, String proposalString) throws Exception {
IXtextDocument document = getDocument(getModel());
Shell shell = new Shell();
try {
XtextSourceViewerConfiguration configuration = get(XtextSourceViewerConfiguration.class);
ISourceViewer sourceViewer = getSourceViewer(shell, document, configuration);
ICompletionProposal[] proposals = computeCompletionProposals(document, position, shell);
ICompletionProposal proposal = findProposal(proposalString, proposals);
return appendAndApplyProposal(proposal, sourceViewer, model, position);
} finally {
shell.dispose();
}
}
use of org.eclipse.xtext.ui.editor.model.IXtextDocument in project xtext-eclipse by eclipse.
the class ReplAutoEdit method customizeDocumentCommand.
@Override
public void customizeDocumentCommand(final IDocument document, final DocumentCommand command) {
if (!isLineDelimiter(document, command)) {
return;
}
try {
IXtextDocument doc = xtextDocumentUtil.getXtextDocument(document);
String result = doc.tryReadOnly(new IUnitOfWork<String, XtextResource>() {
@Override
public String exec(XtextResource resource) throws Exception {
return computeResultText(document, command, resource);
}
});
if (result == null)
return;
command.text = result;
} catch (Exception e) {
e.printStackTrace();
}
}
Aggregations