本文整理汇总了Java中org.eclipse.xtext.ui.editor.model.XtextDocument类的典型用法代码示例。如果您正苦于以下问题:Java XtextDocument类的具体用法?Java XtextDocument怎么用?Java XtextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XtextDocument类属于org.eclipse.xtext.ui.editor.model包,在下文中一共展示了XtextDocument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: setModel
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
protected void setModel(XtextDocument document, String prefix, String editablePart, String suffix) {
if (this.insertLineBreaks) {
String delimiter = document.getDefaultLineDelimiter();
prefix = prefix + delimiter;
suffix = delimiter + suffix;
}
String model = prefix + editablePart + suffix;
document.set(model);
XtextResource resource = createResource(model);
document.setInput(resource);
AnnotationModel annotationModel = new AnnotationModel();
if (document instanceof ISynchronizable) {
Object lock = ((ISynchronizable) document).getLockObject();
if (lock == null) {
lock = new Object();
((ISynchronizable) document).setLockObject(lock);
}
((ISynchronizable) annotationModel).setLockObject(lock);
}
this.viewer.setDocument(document, annotationModel, prefix.length(), editablePart.length());
}
开发者ID:cplutte,项目名称:bts,代码行数:22,代码来源:EmbeddedEditorModelAccess.java
示例2: doScheduleInitialValidation
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
protected void doScheduleInitialValidation(XtextDocument document) {
URI uri = document.getResourceURI();
if (uri == null)
return;
IResourceDescription description = resourceDescriptions.getResourceDescription(uri);
if (description == null) {
// resource was just created - build is likely to be running in background
return;
}
Set<URI> outgoingReferences = descriptionUtils.collectOutgoingReferences(description);
for(URI outgoing: outgoingReferences) {
if (isDirty(outgoing)) {
document.checkAndUpdateAnnotations();
return;
}
}
}
开发者ID:cplutte,项目名称:bts,代码行数:18,代码来源:ValidationJobScheduler.java
示例3: uninstall
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
/**
* Uninstall this reconciler from the editor
*/
public void uninstall() {
if (presenter != null)
presenter.setCanceled(true);
if (sourceViewer.getDocument() != null) {
if (calculator != null) {
XtextDocument document = (XtextDocument) sourceViewer.getDocument();
document.removeModelListener(this);
sourceViewer.removeTextInputListener(this);
}
}
editor = null;
sourceViewer = null;
presenter = null;
}
开发者ID:cplutte,项目名称:bts,代码行数:19,代码来源:HighlightingReconciler.java
示例4: refresh
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
/**
* Refreshes the highlighting.
*/
public void refresh() {
if (calculator != null) {
new Job("calculating highlighting") {
@Override
protected IStatus run(IProgressMonitor monitor) {
((XtextDocument) sourceViewer.getDocument()).readOnly(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
modelChanged(state);
}
});
return Status.OK_STATUS;
}
}.schedule();
} else {
Display display = getDisplay();
display.asyncExec(presenter.createSimpleUpdateRunnable());
}
}
开发者ID:cplutte,项目名称:bts,代码行数:24,代码来源:HighlightingReconciler.java
示例5: run
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Override
protected IStatus run(final IProgressMonitor monitor) {
if (monitor.isCanceled() || paused)
return Status.CANCEL_STATUS;
long start = System.currentTimeMillis();
final IXtextDocument document = XtextDocumentUtil.get(textViewer);
if (document instanceof XtextDocument) {
((XtextDocument) document).internalModify(new IUnitOfWork.Void<XtextResource>() {
@Override
public void process(XtextResource state) throws Exception {
doRun(state, monitor);
}
});
}
if (log.isDebugEnabled())
log.debug("Reconciliation finished. Time required: " + (System.currentTimeMillis() - start)); //$NON-NLS-1$
return Status.OK_STATUS;
}
开发者ID:cplutte,项目名称:bts,代码行数:20,代码来源:XtextReconciler.java
示例6: addNSQualifier
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Fix(SadlJavaValidator.AMBIGUOUS_NAME)
public void addNSQualifier(final Issue issue, final IssueResolutionAcceptor acceptor) {
String[] fixes = issue.getData();
Iterator<String> itr = Splitter.on(",").split(fixes[0]).iterator();
while (itr.hasNext()) {
// loop over prefixes
final String prefix = itr.next();
acceptor.accept(issue, prefix, "Add the namespace prefix '" + prefix + "' to disambiguate name", null, new ISemanticModification() {
public void apply(EObject element, IModificationContext context)
throws Exception {
if (element instanceof ResourceByName) {
IXtextDocument xtextDocument = context.getXtextDocument();
if (xtextDocument instanceof XtextDocument) {
int insertAt = issue.getOffset();
xtextDocument.replace(insertAt, issue.getLength(), prefix);
}
}
}
});
}
}
开发者ID:crapo,项目名称:sadlos2,代码行数:22,代码来源:SadlQuickfixProvider.java
示例7: createDocument
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
/**
* Creates a new document with the contents of the given {@link XtextResource}.
*
* @param resource
* the resource to be used as input to the document
* @return the created document
*/
private ICoreXtextDocument createDocument(final XtextResource resource) {
XtextDocument document = documentProvider.get();
if (resource.getParseResult() != null && resource.getParseResult().getRootNode() != null) {
document.set(resource.getParseResult().getRootNode().getText());
}
document.setInput(resource);
return new XtextDocumentAdapter(document);
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:16,代码来源:ModificationContextRegistry.java
示例8: propertyChange
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
/**
* Performs (schedule) a "fast-only" validation job on preference changes.
*
* @param event
* the event
*/
@Override
public void propertyChange(final PropertyChangeEvent event) {
if (LOGGER.isDebugEnabled()) {
LOGGER.debug(NLS.bind("Preference Change: {0} => {1} -> {2}", new Object[] {event.getProperty(), event.getOldValue(), event.getNewValue()})); //$NON-NLS-1$
}
for (Iterator<?> i = getConnectedElements(); i.hasNext();) {
((XtextDocument) getDocument(i.next())).checkAndUpdateAnnotations();
}
}
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:17,代码来源:ResponsiveXtextDocumentProvider.java
示例9: setupDocument
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
protected void setupDocument(Object element, IDocument document) {
String content = getString(element);
document.set(content);
IDocumentPartitioner partitioner = documentPartitioner.get();
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
XtextResource resource = createResource(element);
loadResource(element, resource);
if (resource!=null) {
((XtextDocument) document).setInput(resource);
}
}
开发者ID:cplutte,项目名称:bts,代码行数:15,代码来源:StreamContentDocumentProvider.java
示例10: disposeElementInfo
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Override
protected void disposeElementInfo(Object element, ElementInfo info) {
if (info.fDocument instanceof XtextDocument) {
XtextDocument document = (XtextDocument) info.fDocument;
document.disposeInput();
}
super.disposeElementInfo(element, info);
}
开发者ID:cplutte,项目名称:bts,代码行数:9,代码来源:StreamContentDocumentProvider.java
示例11: findWord
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Override
protected IRegion findWord(IDocument document, int offset) {
if (document instanceof XtextDocument) {
Iterator<ILexerTokenRegion> tokenIterator = ((XtextDocument) document).getTokens().iterator();
ILexerTokenRegion leadingToken = null;
ILexerTokenRegion trailingToken = null;
while(tokenIterator.hasNext()) {
ILexerTokenRegion token = tokenIterator.next();
if (token.getOffset() <= offset && token.getOffset() + token.getLength() >= offset) {
if (leadingToken != null)
trailingToken = token;
else
leadingToken = token;
}
if (token.getOffset() > offset)
break;
}
if (leadingToken != null) {
try {
if (leadingToken.getLength() > 1 && (trailingToken == null || !Character.isLetter(document.getChar(trailingToken.getOffset())))) {
return new Region(leadingToken.getOffset(), leadingToken.getLength());
} else if (trailingToken != null) {
return new Region(trailingToken.getOffset(), trailingToken.getLength());
}
} catch(BadLocationException ignore) {}
}
}
return super.findWord(document, offset);
}
开发者ID:cplutte,项目名称:bts,代码行数:30,代码来源:LexerTokenAndCharacterPairAwareStrategy.java
示例12: EmbeddedEditor
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
public EmbeddedEditor(XtextDocument document, XtextSourceViewer viewer, XtextSourceViewerConfiguration configuration, IEditedResourceProvider resourceProvider, Runnable afterSetDocumet) {
this.document = document;
this.viewer = viewer;
this.configuration = configuration;
this.resourceProvider = resourceProvider;
this.afterSetDocument = afterSetDocumet;
}
开发者ID:cplutte,项目名称:bts,代码行数:8,代码来源:EmbeddedEditor.java
示例13: computeInterSection
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
/**
* @return the common region of the given partition and the changed region in the DocumentEvent based on the underlying tokens.
*/
protected IRegion computeInterSection(ITypedRegion partition, DocumentEvent e, XtextDocument document) {
Iterable<ILexerTokenRegion> tokensInPartition = Iterables.filter(document.getTokens(),Regions.overlaps(partition.getOffset(), partition.getLength()));
Iterator<ILexerTokenRegion> tokens = Iterables.filter(tokensInPartition, Regions.overlaps(e.getOffset(), e.getLength())).iterator();
if (tokens.hasNext()) {
ILexerTokenRegion first = tokens.next();
ILexerTokenRegion last = first;
while(tokens.hasNext())
last = tokens.next();
return new Region(first.getOffset(), last.getOffset()+last.getLength() -first.getOffset());
}
// this shouldn't happen, but just in case return the whole partition
return partition;
}
开发者ID:cplutte,项目名称:bts,代码行数:17,代码来源:PresentationDamager.java
示例14: setDocument
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
public void setDocument(IDocument document) {
if (!(document instanceof XtextDocument)) {
throw new IllegalArgumentException("Document must be an " + XtextDocument.class.getSimpleName());
}
if (spellingReconcileStrategy != null) {
spellingReconcileStrategy.setDocument(document);
}
}
开发者ID:cplutte,项目名称:bts,代码行数:9,代码来源:XtextDocumentReconcileStrategy.java
示例15: configure
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Override
public void configure(Binder binder) {
super.configure(binder);
binder.bind(String.class).annotatedWith(Names.named("stylesheet")).toInstance("/StextHoverStyleSheet.css");
binder.bind(XtextDocument.class).to(ParallelReadXtextDocument.class);
binder.bind(TaskMarkerCreator.class).to(SCTTaskMarkerCreator.class);
binder.bind(TaskMarkerTypeProvider.class).to(SCTTaskMarkerTypeProvider.class);
}
开发者ID:Yakindu,项目名称:statecharts,代码行数:9,代码来源:STextUiModule.java
示例16: registerGuiceBindingsUi
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
private void registerGuiceBindingsUi() {
new GuiceModuleAccess.BindingFactory()
.addTypeToType(typeRef(XtextDocument.class), typeRef(CooperateXtextDocument.class))
.addTypeToType(typeRef(XtextDocumentProvider.class), typeRef(CooperateCDOXtextDocumentProvider.class))
.addTypeToType(typeRef(IResourceSetProvider.class), typeRef(XtextLiveScopeResourceSetProvider.class))
.contributeTo(getLanguage().getEclipsePluginGenModule());
getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles()
.add("de.cooperateproject.modeling.textual.xtext.runtime.ui");
}
开发者ID:Cooperate-Project,项目名称:CooperateModelingEnvironment,代码行数:10,代码来源:CooperateResourceHandlingBindingsFragment2.java
示例17: removeDocumentStateListener
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Override
public void removeDocumentStateListener(IDocumentStateListener listener) {
if (null != listener) {
IXtextDocumentContentObserver delegatingListener = documentStateListeners.remove(listener);
if (null != delegatingListener && null != embeddedEditor) {
XtextDocument doc = embeddedEditor.getDocument();
if (null != doc) {
doc.removeXtextDocumentContentObserver(delegatingListener);
}
}
}
}
开发者ID:SSEHUB,项目名称:EASyProducer,代码行数:13,代码来源:EmbeddedXtextSourceEditor.java
示例18: addObjectPropertyDefinition
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Fix(SadlJavaValidator.OBJECTPROPERTY_NOT_DEFINED)
public void addObjectPropertyDefinition(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Add Property", "Add missing object property definition to the model", null, new ISemanticModification() {
public void apply(EObject rsrcId, IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
if (xtextDocument instanceof XtextDocument) {
Object[] fixInfo = prepareMissingConceptFix(xtextDocument, rsrcId, issue);
xtextDocument.replace(((Integer)fixInfo[1]).intValue(), 1, "." + System.getProperty("line.separator") + (fixInfo[0] != null ? fixInfo[0] : "New_Prop") + " describes .\n");
}
}
});
}
开发者ID:crapo,项目名称:sadlos2,代码行数:14,代码来源:SadlQuickfixProvider.java
示例19: addDatatypePropertyDefinition
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
@Fix(SadlJavaValidator.DATATYPEPROPERTY_NOT_DEFINED)
public void addDatatypePropertyDefinition(final Issue issue, IssueResolutionAcceptor acceptor) {
acceptor.accept(issue, "Add Property", "Add missing data property definition to the model", null, new ISemanticModification() {
public void apply(EObject rsrcId, IModificationContext context) throws BadLocationException {
IXtextDocument xtextDocument = context.getXtextDocument();
if (xtextDocument instanceof XtextDocument) {
Object[] fixInfo = prepareMissingConceptFix(xtextDocument, rsrcId, issue);
xtextDocument.replace(((Integer)fixInfo[1]).intValue(), 1, "." + System.getProperty("line.separator") + (fixInfo[0] != null ? fixInfo[0] : "New_Prop") + " describes .\n");
}
}
});
}
开发者ID:crapo,项目名称:sadlos2,代码行数:14,代码来源:SadlQuickfixProvider.java
示例20: bindXtextDocument
import org.eclipse.xtext.ui.editor.model.XtextDocument; //导入依赖的package包/类
/** Custom XtextDocument. */
public Class<? extends XtextDocument> bindXtextDocument() {
return N4JSDocument.class;
}
开发者ID:eclipse,项目名称:n4js,代码行数:5,代码来源:N4JSUiModule.java
注:本文中的org.eclipse.xtext.ui.editor.model.XtextDocument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论