• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java IStorage2UriMapper类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getFileFromStorageMapper

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * Gets an {@link IFile} from the {@link IStorage2UriMapper} corresponding to given {@link URI}. If none
 * could be found, <code>null</code> is returned.
 * 
 * @param storage2UriMapper
 *          the storage to URI mapper
 * @param fileUri
 *          the URI
 * @return the file from the storage to URI mapper or <code>null</code> if no match found
 */
private IFile getFileFromStorageMapper(final IStorage2UriMapper storage2UriMapper, final URI fileUri) {
  if (storage2UriMapper == null) {
    return null; // Should not occur
  }

  for (Pair<IStorage, IProject> storage : storage2UriMapper.getStorages(fileUri)) {
    if (storage.getFirst() instanceof IFile) {
      return (IFile) storage.getFirst();
    }
  }
  if (LOGGER.isDebugEnabled()) {
    LOGGER.debug(MessageFormat.format("Could not find storage for URI {0}", fileUri.toString())); //$NON-NLS-1$
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:26,代码来源:CheckMarkerUpdateJob.java


示例2: findFileStorage

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * Returns the file {@link IFile} based on its {@link URI}.
 *
 * @param uri
 *          the URI of the resource for which an IFile is to be returned
 * @param mapper
 *          class returning e.g. set of storages {@link IStorage} matching given URI; injected by concrete BuilderParticipant
 * @return the file associated with given URI
 */
public static IFile findFileStorage(final URI uri, final IStorage2UriMapper mapper) {
  Iterable<Pair<IStorage, IProject>> storages = mapper.getStorages(uri);
  try {
    Pair<IStorage, IProject> fileStorage = Iterables.find(storages, new Predicate<Pair<IStorage, IProject>>() {
      @Override
      public boolean apply(final Pair<IStorage, IProject> input) {
        IStorage storage = input.getFirst();
        if (storage instanceof IFile) {
          return true;
        }
        return false;
      }
    });

    return (IFile) fileStorage.getFirst();
  } catch (NoSuchElementException e) {
    LOGGER.debug("Cannot find file storage for " + uri); //$NON-NLS-1$
    return null;
  }
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:30,代码来源:RuntimeProjectUtil.java


示例3: BuildInstruction

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * Create a build instruction for the given project.
 */
public BuildInstruction(IProject project,
		Map<String, OutputConfiguration> outputConfigurations,
		IDerivedResourceMarkers derivedResourceMarkers,
		EclipseResourceFileSystemAccess2 access,
		Map<OutputConfiguration, Iterable<IMarker>> generatorMarkers,
		IStorage2UriMapper storage2UriMapper, ICompositeGenerator compositeGenerator,
		Injector injector) {
	super(project, outputConfigurations, derivedResourceMarkers);
	this.access = access;
	this.generatorMarkers = generatorMarkers;
	this.storage2UriMapper = storage2UriMapper;
	this.compositeGenerator = compositeGenerator;
	this.injector = injector;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:18,代码来源:BuildInstruction.java


示例4: configure

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
@Override
protected void configure() {
	bind(IResourceClusteringPolicy.class).to(N4JSVerboseClusteringPolicy.class);
	bind(XtextBuilder.class).to(N4JSBuildTypeTrackingBuilder.class);
	bind(ClusteringBuilderState.class).to(N4JSGenerateImmediatelyBuilderState.class);
	bind(IStorage2UriMapper.class).to(N4JSStorage2UriMapper.class);
	bind(PersistedStateProvider.class).to(ContributingResourceDescriptionPersister.class);
	bind(IBuildLogger.class).annotatedWith(BuilderState.class).to(BuilderStateLogger.class);
	bind(DirtyStateManager.class).to(PrevStateAwareDirtyStateManager.class);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:11,代码来源:N4JSClusteringBuilderConfiguration.java


示例5: getResourceSet

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * Gets the resource set. Note that not all sources must be part of the same resource set.
 * 
 * @param storage2UriMapper
 *          the storage2 uri mapper
 * @param uri
 *          the uri
 * @return the resource set
 */
private ResourceSet getResourceSet(final IStorage2UriMapper storage2UriMapper, final URI uri) {
  Iterable<Pair<IStorage, IProject>> storages = storage2UriMapper.getStorages(uri);
  if (!Iterables.isEmpty(storages)) {
    IProject project = Iterables.get(storages, 0).getSecond();
    XtextResourceSetProvider resourceSetProvider = this.serviceProviderRegistry.getResourceServiceProvider(uri).get(XtextResourceSetProvider.class);
    return resourceSetProvider.get(project);
  }
  return null;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:19,代码来源:CheckMarkerUpdateJob.java


示例6: configure

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
@Override
	protected void configure() {
		bind(ToBeBuiltComputer.class).to(SadlToBeBuiltComputer.class);
		bind(ProjectClasspathChangeListener.class).asEagerSingleton();
		bind(IStorage2UriMapper.class).to(IStorage2UriMapperJdtExtensions.class);
		bind(IStorage2UriMapperJdtExtensions.class).to(Storage2UriMapperJavaImpl.class);
		bind(IResourceSetProvider.class).to(XtextResourceSetProvider.class);
//		bind(TypeResourceUnloader.class).asEagerSingleton();
		bind(JavaChangeQueueFiller.class).asEagerSingleton();
		bind(StorageAwareTrace.class).to(JarEntryAwareTrace.class);
		bind(DefaultTraceURIConverter.class).to(DefaultUITraceURIConverter.class);
	}
 
开发者ID:crapo,项目名称:sadlos2,代码行数:13,代码来源:SadlSharedModule.java


示例7: run

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
protected IStatus run(final IProgressMonitor monitor) {

  // Let's start (number of task = number of resource * 2 (loading + validating))
  monitor.beginTask("", 2 * this.uris.size()); //$NON-NLS-1$

  for (final URI uri : this.uris) {
    // Last chance to cancel before next validation
    if (monitor.isCanceled()) {
      return Status.CANCEL_STATUS;
    }

    final IResourceServiceProvider serviceProvider = serviceProviderRegistry.getResourceServiceProvider(uri);
    if (serviceProvider == null) {
      // This may happen for non-Xtext resources in ice entities
      if (LOGGER.isDebugEnabled()) {
        LOGGER.debug(MessageFormat.format("Could not validate {0}: no resource service provider found", uri.toString())); //$NON-NLS-1$
      }
      continue; // Skip to next URI
    }

    final IResourceValidator resourceValidator = serviceProvider.getResourceValidator();
    final IStorage2UriMapper uriMapper = serviceProvider.get(IStorage2UriMapper.class);
    final MarkerCreator markerCreator = serviceProvider.get(MarkerCreator.class);

    // Get the file; only local files will be re-validated, derived files are ignored
    final IFile iFile = getFileFromStorageMapper(uriMapper, uri);
    if (iFile == null) {
      continue; // no storage mapping found for this URI
    }

    if (resourceValidator == null) {
      LOGGER.error(MessageFormat.format("Could not validate {0}: no resource validator found", iFile.getName())); //$NON-NLS-1$
    } else if (iFile != null) {
      monitor.subTask("loading " + iFile.getName()); //$NON-NLS-1$

      // Don't try to evaluate resource set before it has been checked that the storage provider contains a mapping
      // for current uri
      final ResourceSet resourceSet = getResourceSet(uriMapper, uri);

      // Load the corresponding resource
      boolean loaded = false;
      Resource eResource = null;
      try {
        eResource = resourceSet.getResource(uri, false);
        if ((eResource == null) || (eResource != null && !eResource.isLoaded())) {
          // if the resource does not exist in the resource set, or is not loaded yet
          // load it.
          eResource = resourceSet.getResource(uri, true);
          loaded = true;
        }
        monitor.worked(1);
        // CHECKSTYLE:OFF
      } catch (final RuntimeException e) {
        // CHECKSTYLE:ON
        LOGGER.error(MessageFormat.format("{0} could not be validated.", iFile.getName()), e); //$NON-NLS-1$
      } finally {
        if (eResource != null) {
          validate(resourceValidator, markerCreator, iFile, eResource, monitor);
          LOGGER.debug("Validated " + uri); //$NON-NLS-1$
          if (loaded) { // NOPMD
            // unload any resource that was previously loaded as part of this loop.
            eResource.unload();
          }
        }
      }
    }
  }

  monitor.done();

  return Status.OK_STATUS;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:75,代码来源:CheckMarkerUpdateJob.java


示例8: setMapper

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
public void setMapper(IStorage2UriMapper mapper) {
	this.mapper = mapper;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:4,代码来源:AbstractStorage2UriMapperClient.java


示例9: getMapper

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
public IStorage2UriMapper getMapper() {
	return mapper;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:4,代码来源:AbstractStorage2UriMapperClient.java


示例10: getStorage2UriMapper

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * @since 2.4
 */
protected IStorage2UriMapper getStorage2UriMapper() {
	return storage2UriMapper;
}
 
开发者ID:cplutte,项目名称:bts,代码行数:7,代码来源:XtextDocumentProvider.java


示例11: ValidMarkerUpdateJob

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * Instantiates a new valid marker update job.
 *
 * @param name
 *          the name
 * @param fileExtensions
 *          the file extensions
 * @param resourceSet
 *          the resource set
 * @param markerCreator
 *          the marker creator
 * @param resourceDescriptions
 *          the resource descriptions
 * @param resourceServiceProvider
 *          the resource service provider
 * @param performExpensiveValidation
 *          true if expensive validation should be performed, false otherwise
 */
public ValidMarkerUpdateJob(final String name, final String fileExtensions, final ResourceSet resourceSet, final MarkerCreator markerCreator, final IResourceDescriptions resourceDescriptions, final IResourceServiceProvider resourceServiceProvider, final boolean performExpensiveValidation, final IStorage2UriMapper storage2UriMapper) {
  super(name + " " + fileExtensions); //$NON-NLS-1$

  this.fileExtensions = fileExtensions;
  this.resourceSet = resourceSet;
  this.markerCreator = markerCreator;
  this.resourceDescriptions = resourceDescriptions;
  this.resourceServiceProvider = resourceServiceProvider;
  this.performExpensiveValidation = performExpensiveValidation;
  this.checkMode = performExpensiveValidation ? CheckMode.ALL : CheckMode.NORMAL_AND_FAST;
  this.storage2UriMapper = storage2UriMapper;
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:31,代码来源:ValidMarkerUpdateJob.java


示例12: getProject

import org.eclipse.xtext.ui.resource.IStorage2UriMapper; //导入依赖的package包/类
/**
 * Returns the project containing the file indicated by a URI.
 *
 * @param uri
 *          URI containing path from which the project name is extracted
 * @param mapper
 *          class returning e.g. set of storages {@link IStorage} matching given URI; injected by concrete BuilderParticipant
 * @return project {@link IProject} associated with given URI
 */
public static IProject getProject(final URI uri, final IStorage2UriMapper mapper) {
  final IFile file = findFileStorage(uri, mapper);
  return file == null ? null : file.getProject();
}
 
开发者ID:dsldevkit,项目名称:dsl-devkit,代码行数:14,代码来源:RuntimeProjectUtil.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java Transaction类代码示例发布时间:2022-05-23
下一篇:
Java Item类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap