当前位置: 首页>>代码示例>>Java>>正文


Java XtextDocument类代码示例

本文整理汇总了Java中org.eclipse.xtext.ui.editor.model.XtextDocument的典型用法代码示例。如果您正苦于以下问题:Java XtextDocument类的具体用法?Java XtextDocument怎么用?Java XtextDocument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


XtextDocument类属于org.eclipse.xtext.ui.editor.model包,在下文中一共展示了XtextDocument类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的org.eclipse.xtext.ui.editor.model.XtextDocument类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。