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


Java IResourceDescription类代码示例

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


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

示例1: getIncomingReferences

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
/***/
public static Set<IReferenceDescription> getIncomingReferences(URI uri) {
	Set<IReferenceDescription> desc = Sets.newHashSet();
	Iterable<IResourceDescription> descriptions = getAllResourceDescriptions();
	for (IResourceDescription res : descriptions) {
		Iterable<IReferenceDescription> descriptions2 = res.getReferenceDescriptions();
		for (IReferenceDescription ref : descriptions2) {
			if (uri.hasFragment()) {
				if (ref.getTargetEObjectUri().equals(uri))
					desc.add(ref);
			} else {
				if (ref.getTargetEObjectUri().trimFragment().equals(uri.trimFragment()))
					desc.add(ref);
			}
		}
	}
	return desc;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:BuilderUtil.java

示例2: getContainedReferences

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
/***/
public static Set<IReferenceDescription> getContainedReferences(URI uri) {
	Set<IReferenceDescription> desc = Sets.newHashSet();
	Iterable<IResourceDescription> descriptions = getAllResourceDescriptions();
	for (IResourceDescription res : descriptions) {
		Iterable<IReferenceDescription> descriptions2 = res.getReferenceDescriptions();
		for (IReferenceDescription ref : descriptions2) {
			if (uri.hasFragment()) {
				if (ref.getSourceEObjectUri().equals(uri))
					desc.add(ref);
			} else {
				if (ref.getSourceEObjectUri().trimFragment().equals(uri.trimFragment()))
					desc.add(ref);
			}
		}
	}
	return desc;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:19,代码来源:BuilderUtil.java

示例3: indexResource

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
/**
 * Install the given resource's description into the given index. Raw JavaScript files will not be indexed. Note
 * that when this method is called for the given resource, it is not yet fully processed and therefore the
 * serialized type model is not added to the index.
 * <p>
 * This is due to the fact that we keep a common resource set for all projects that contains the resources of all
 * projects with unprocessed dependencies, unlike in the IDE case where we have one resource set per open document
 * and load the type models from the index.
 * </p>
 * <p>
 * Since the type models are available in the resource set as long as they may still be referenced, they need not be
 * serialized and stored into the index.
 * </p>
 *
 * @param resource
 *            the resource to be indexed
 * @param index
 *            the index to add the given resource to
 */
private void indexResource(Resource resource, ResourceDescriptionsData index) {
	if (!shouldIndexResource(resource))
		return;

	final URI uri = resource.getURI();
	IResourceServiceProvider serviceProvider = IResourceServiceProvider.Registry.INSTANCE
			.getResourceServiceProvider(uri);
	if (serviceProvider != null) {
		if (logger.isCreateDebugOutput()) {
			logger.debug("  Indexing resource " + uri);
		}

		IResourceDescription.Manager resourceDescriptionManager = serviceProvider.getResourceDescriptionManager();
		IResourceDescription resourceDescription = resourceDescriptionManager.getResourceDescription(resource);

		if (resourceDescription != null) {
			index.addDescription(uri, resourceDescription);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:40,代码来源:N4HeadlessCompiler.java

示例4: isSignificantChange

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
private boolean isSignificantChange(IResourceDescription.Delta delta) {
	if (delta.haveEObjectDescriptionsChanged()) {
		IResourceDescription newDescription = delta.getNew();
		IResourceDescription oldDescription = delta.getOld();
		if ((newDescription != null) != (oldDescription != null)) {
			return true;
		}
		if (newDescription == null || oldDescription == null) {
			throw new IllegalStateException();
		}
		List<IEObjectDescription> newDescriptions = Lists.newArrayList(newDescription.getExportedObjects());
		List<IEObjectDescription> oldDescriptions = Lists.newArrayList(oldDescription.getExportedObjects());
		if (newDescriptions.size() != oldDescriptions.size()) {
			return true;
		}
		URI resourceURI = delta.getUri();
		for (int i = 0; i < newDescriptions.size(); i++) {
			if (!equalDescriptions(newDescriptions.get(i), oldDescriptions.get(i), resourceURI)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:25,代码来源:N4JSDirtyStateEditorSupport.java

示例5: extractOldDescription

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
private IResourceDescription extractOldDescription(final IDirtyResource dirtyResource) {
	IDirtyResource myDirtyResource = reflectiveGetInnerResource(dirtyResource);
	if (myDirtyResource instanceof PrevStateAwareDocumentBasedDirtyResource) {
		return ((PrevStateAwareDocumentBasedDirtyResource) myDirtyResource).getPrevDescription();
	}
	return null;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:8,代码来源:PrevStateAwareDirtyStateManager.java

示例6: isAffected

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
/**
 * {@inheritDoc}
 *
 * This marks {@code n4js} as affected if the manifest of the project changes. In turn, they will be revalidated and
 * taken into consideration for the code generation step.
 */
@Override
public boolean isAffected(Collection<IResourceDescription.Delta> deltas, IResourceDescription candidate,
		IResourceDescriptions context) {
	boolean result = basicIsAffected(deltas, candidate);
	if (!result) {
		for (IResourceDescription.Delta delta : deltas) {
			URI uri = delta.getUri();
			if (IN4JSProject.N4MF_MANIFEST.equalsIgnoreCase(uri.lastSegment())) {
				URI prefixURI = uri.trimSegments(1).appendSegment("");
				if (candidate.getURI().replacePrefix(prefixURI, prefixURI) != null) {
					return true;
				}
			}
		}
	}
	return result;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:24,代码来源:N4JSResourceDescriptionManager.java

示例7: registerDescription

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected void registerDescription(final IResourceDescription description,
		final Map<QualifiedName, Object> target) {

	for (final IEObjectDescription object : description.getExportedObjects()) {
		final QualifiedName lowerCase = object.getName().toLowerCase();
		final Object existing = target.put(lowerCase, description);
		if (existing != null && existing != description) {
			Set<IResourceDescription> set = null;
			if (existing instanceof IResourceDescription) {
				// The linked hash set is the difference comparing to the super class.
				set = Sets.newLinkedHashSetWithExpectedSize(2);
				set.add((IResourceDescription) existing);
			} else {
				set = (Set<IResourceDescription>) existing;
			}
			set.add(description);
			target.put(lowerCase, set);
		}
	}
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:23,代码来源:OrderedResourceDescriptionsData.java

示例8: build

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@Override
public void build(IBuildContext context, IProgressMonitor monitor) throws CoreException {
	SubMonitor progress = SubMonitor.convert(monitor);
	if (!prefs.isCompilerEnabled()) {
		return;
	}
	final List<IResourceDescription.Delta> deltas = getRelevantDeltas(context);
	if (deltas.isEmpty()) {
		return;
	}
	if (progress.isCanceled()) {
		throw new OperationCanceledException();
	}
	progress.beginTask("Compiling solidity...", deltas.size());

	List<URI> uris = deltas.stream().map(delta -> delta.getUri()).collect(Collectors.toList());
	compiler.compile(uris, progress);
	context.getBuiltProject().refreshLocal(IProject.DEPTH_INFINITE, progress);
	progress.done();

}
 
开发者ID:Yakindu,项目名称:solidity-ide,代码行数:22,代码来源:SolidityBuilderParticipant.java

示例9: testStubGeneration_02

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@Test
public void testStubGeneration_02() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("public interface MyTest {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("public String helloWorld();");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<IResourceDescription> _function = (IResourceDescription it) -> {
    Assert.assertEquals("MyTest", IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getQualifiedName().toString());
    EObject _eObjectOrProxy = IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getEObjectOrProxy();
    Assert.assertTrue(((JvmGenericType) _eObjectOrProxy).isInterface());
    Assert.assertEquals(1, IterableExtensions.size(it.getExportedObjects()));
  };
  this.resultsIn(_builder, _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:ResourceDescriptionProviderTest.java

示例10: testStubGeneration_04

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@Test
public void testStubGeneration_04() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("public @interface MyTest {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("String value();");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<IResourceDescription> _function = (IResourceDescription it) -> {
    Assert.assertEquals("MyTest", IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getQualifiedName().toString());
    EObject _eObjectOrProxy = IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getEObjectOrProxy();
    Assert.assertTrue((_eObjectOrProxy instanceof JvmAnnotationType));
    Assert.assertEquals(1, IterableExtensions.size(it.getExportedObjects()));
  };
  this.resultsIn(_builder, _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:ResourceDescriptionProviderTest.java

示例11: testStubGeneration_05

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@Test
public void testStubGeneration_05() {
  StringConcatenation _builder = new StringConcatenation();
  _builder.append("package my.pack;");
  _builder.newLine();
  _builder.newLine();
  _builder.append("public abstract class MyTest {");
  _builder.newLine();
  _builder.append("\t");
  _builder.append("abstract String value();");
  _builder.newLine();
  _builder.append("}");
  _builder.newLine();
  final Procedure1<IResourceDescription> _function = (IResourceDescription it) -> {
    Assert.assertEquals("my.pack.MyTest", IterableExtensions.<IEObjectDescription>head(it.getExportedObjects()).getQualifiedName().toString());
    Assert.assertEquals(1, IterableExtensions.size(it.getExportedObjects()));
  };
  this.resultsIn(_builder, _function);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:20,代码来源:ResourceDescriptionProviderTest.java

示例12: getSymbols

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
public List<? extends SymbolInformation> getSymbols(final String query, final IReferenceFinder.IResourceAccess resourceAccess, final IResourceDescriptions indexData, final CancelIndicator cancelIndicator) {
  final LinkedList<SymbolInformation> result = CollectionLiterals.<SymbolInformation>newLinkedList();
  Iterable<IResourceDescription> _allResourceDescriptions = indexData.getAllResourceDescriptions();
  for (final IResourceDescription resourceDescription : _allResourceDescriptions) {
    {
      this.operationCanceledManager.checkCanceled(cancelIndicator);
      final IResourceServiceProvider resourceServiceProvider = this._registry.getResourceServiceProvider(resourceDescription.getURI());
      DocumentSymbolService _get = null;
      if (resourceServiceProvider!=null) {
        _get=resourceServiceProvider.<DocumentSymbolService>get(DocumentSymbolService.class);
      }
      final DocumentSymbolService documentSymbolService = _get;
      if ((documentSymbolService != null)) {
        List<? extends SymbolInformation> _symbols = documentSymbolService.getSymbols(resourceDescription, query, resourceAccess, cancelIndicator);
        Iterables.<SymbolInformation>addAll(result, _symbols);
      }
    }
  }
  return result;
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:21,代码来源:WorkspaceSymbolService.java

示例13: testNoReferenceDescriptionsForPackageFragments

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@Test
public void testNoReferenceDescriptionsForPackageFragments() {
  try {
    final XExpression expression = this.expression("java::lang::String::valueOf(\"\")");
    final Resource resource = expression.eResource();
    final IResourceDescription description = this.resourceDescriptionManager.getResourceDescription(resource);
    final Function1<IReferenceDescription, String> _function = (IReferenceDescription it) -> {
      return it.getTargetEObjectUri().toString();
    };
    final Set<String> referenceDescriptions = IterableExtensions.<String>toSet(IterableExtensions.<IReferenceDescription, String>map(description.getReferenceDescriptions(), _function));
    Assert.assertEquals(2, referenceDescriptions.size());
    final Set<String> expectation = Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("java:/Objects/java.lang.String#java.lang.String", "java:/Objects/java.lang.String#java.lang.String.valueOf(java.lang.Object)"));
    Assert.assertEquals(expectation, referenceDescriptions);
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:18,代码来源:XbaseResourceDescriptionStrategyTest.java

示例14: getJavaStubSource

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
public String getJavaStubSource(IEObjectDescription description, IResourceDescription resourceDescription) {
	if(isNestedType(description) || !isJvmDeclaredType(description)) {
		return null;
	}
	Multimap<QualifiedName, IEObjectDescription> owner2nested = LinkedHashMultimap.create();
	for(IEObjectDescription other: resourceDescription.getExportedObjects()) {
		if(isJvmDeclaredType(other) && isNestedType(other))
			owner2nested.put(getOwnerClassName(other.getQualifiedName()), other);
	}
	StringBuilder classSignatureBuilder = new StringBuilder();
	QualifiedName qualifiedName = description.getQualifiedName();
	if (qualifiedName.getSegments().size() > 1) {
		String string = qualifiedName.toString();
		classSignatureBuilder.append("package " + string.substring(0, string.lastIndexOf('.')) + ";");
	}
	appendType(description, owner2nested, classSignatureBuilder);
	return classSignatureBuilder.toString();
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:19,代码来源:EObjectDescriptionBasedStubGenerator.java

示例15: testContainerAddRemove

import org.eclipse.xtext.resource.IResourceDescription; //导入依赖的package包/类
@Test
public void testContainerAddRemove() throws Exception {
	ResourceSet resourceSet = new XtextResourceSet();
	Resource res = parse("local", resourceSet).eResource();
	parse("other", resourceSet);
	IResourceDescription resourceDescription = descriptionManager.getResourceDescription(res);
	IResourceDescriptions resourceDescriptions = descriptionsProvider.getResourceDescriptions(res);
	List<IContainer> containers = containerManager.getVisibleContainers(resourceDescription, resourceDescriptions);
	assertEquals(1, containers.size());
	IContainer container = containers.get(0);

	assertEquals("local, other", format(container.getExportedObjects()));

	Resource foo = parse("foo", resourceSet).eResource();
	assertEquals("foo, local, other", format(container.getExportedObjects()));

	resourceSet.getResources().remove(foo);
	assertEquals("local, other", format(container.getExportedObjects()));
}
 
开发者ID:eclipse,项目名称:xtext-core,代码行数:20,代码来源:AbstractLiveContainerTest.java


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