當前位置: 首頁>>代碼示例>>Java>>正文


Java XtextResource.getContents方法代碼示例

本文整理匯總了Java中org.eclipse.xtext.resource.XtextResource.getContents方法的典型用法代碼示例。如果您正苦於以下問題:Java XtextResource.getContents方法的具體用法?Java XtextResource.getContents怎麽用?Java XtextResource.getContents使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.xtext.resource.XtextResource的用法示例。


在下文中一共展示了XtextResource.getContents方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modelChanged

import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Override
public void modelChanged(XtextResource resource) {
	if (resource == null || !getDirtyResource().isInitialized())
		return;
	resource.getContents(); // trigger init
	super.modelChanged(resource);
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:8,代碼來源:N4JSDirtyStateEditorSupport.java

示例2: getImportSection

import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Override
public XImportSection getImportSection(XtextResource resource) {
	EList<EObject> contents = resource.getContents();
	if (!contents.isEmpty())
	{
		for (Iterator<EObject> i = contents.get(0).eAllContents(); i.hasNext();) {
			EObject next = i.next();
			if (next instanceof XImportSection)
				return (XImportSection) next;
		}
	}
	return null;
}
 
開發者ID:eclipse,項目名稱:xtext-extras,代碼行數:14,代碼來源:DefaultImportsConfiguration.java

示例3: _format

import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
/**
 * For {@link XtextResource resources}, assume we want to format the first EObject from the contents list only.
 * Because that's where the parser puts the semantic model.
 */
protected void _format(XtextResource resource, IFormattableDocument document) {
	List<EObject> contents = resource.getContents();
	if (!contents.isEmpty()) {
		EObject model = contents.get(0);
		document.format(model);
	}
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:12,代碼來源:AbstractFormatter2.java

示例4: testExplicitRuleCallsAreTracked

import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
@Test
public void testExplicitRuleCallsAreTracked() throws Exception {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("grammar test.Lang with org.eclipse.xtext.common.Terminals");
  _builder.newLine();
  _builder.append("generate test \'http://test\'");
  _builder.newLine();
  _builder.append("Rule: name=super::ID name=ID;");
  _builder.newLine();
  _builder.append("terminal ID: super;");
  _builder.newLine();
  _builder.append("terminal _super: \'s\';");
  _builder.newLine();
  final String grammarAsString = _builder.toString();
  final XtextResource resource = this.getResourceFromString(grammarAsString);
  EObject _get = resource.getContents().get(0);
  Grammar grammar = ((Grammar) _get);
  final AbstractRule firstRule = IterableExtensions.<AbstractRule>head(grammar.getRules());
  final RuleCall firstRuleCall = IteratorExtensions.<RuleCall>head(Iterators.<RuleCall>filter(firstRule.eAllContents(), RuleCall.class));
  Assert.assertTrue(firstRuleCall.isExplicitlyCalled());
  final RuleCall secondRuleCall = IteratorExtensions.<RuleCall>last(Iterators.<RuleCall>filter(firstRule.eAllContents(), RuleCall.class));
  Assert.assertFalse(secondRuleCall.isExplicitlyCalled());
  final RuleCall thirdRuleCall = IteratorExtensions.<RuleCall>head(Iterators.<RuleCall>filter(grammar.getRules().get(1).eAllContents(), RuleCall.class));
  Assert.assertTrue(thirdRuleCall.isExplicitlyCalled());
  resource.update(grammarAsString.indexOf("_super"), 1, " ");
  Assert.assertEquals(resource, firstRuleCall.eResource());
  Assert.assertEquals(resource, secondRuleCall.eResource());
  Assert.assertEquals(resource, thirdRuleCall.eResource());
  resource.getContents();
  Assert.assertFalse(thirdRuleCall.isExplicitlyCalled());
  Assert.assertEquals(IterableExtensions.<AbstractRule>last(grammar.getRules()), thirdRuleCall.getRule());
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:33,代碼來源:XtextLinkerTest.java

示例5: create

import org.eclipse.xtext.resource.XtextResource; //導入方法依賴的package包/類
public ContentAssistContext[] create(String document, ITextRegion selection, int offset, XtextResource resource) {
	this.document = document;
	this.selection = selection;
	this.resource = resource;
	//This is called to make sure late initialization is done.
	if (resource instanceof DerivedStateAwareResource) {
		resource.getContents();
	}
	this.parseResult = resource.getParseResult();
	if (parseResult == null)
		throw new NullPointerException("parseResult is null");
	return doCreateContexts(offset);
}
 
開發者ID:eclipse,項目名稱:xtext-core,代碼行數:14,代碼來源:ContentAssistContextFactory.java


注:本文中的org.eclipse.xtext.resource.XtextResource.getContents方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。