Java Code Examples for consulo.roots.types.BinariesOrderRootType#getInstance()

The following examples show how to use consulo.roots.types.BinariesOrderRootType#getInstance() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ModuleRootManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static OrderRootsEnumerator getEnumeratorForType(OrderRootType type, Module module) {
  OrderEnumerator base = OrderEnumerator.orderEntries(module);
  if (type == BinariesOrderRootType.getInstance()) {
    return base.exportedOnly().withoutModuleSourceEntries().recursively().classes();
  }
  if (type == SourcesOrderRootType.getInstance()) {
    return base.exportedOnly().recursively().sources();
  }
  return base.roots(type);
}
 
Example 2
Source File: LibraryDataService.java    From consulo with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("MethodMayBeStatic")
public void registerPaths(@Nonnull final Map<OrderRootType, Collection<File>> libraryFiles, @Nonnull Library.ModifiableModel model, @Nonnull String libraryName) {
  for (Map.Entry<OrderRootType, Collection<File>> entry : libraryFiles.entrySet()) {
    for (File file : entry.getValue()) {
      VirtualFile virtualFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(file);
      if (virtualFile == null) {
        if (ExternalSystemConstants.VERBOSE_PROCESSING && entry.getKey() == BinariesOrderRootType.getInstance()) {
          LOG.warn(String.format("Can't find %s of the library '%s' at path '%s'", entry.getKey(), libraryName, file.getAbsolutePath()));
        }
        String url = VfsUtil.getUrlForLibraryRoot(file);
        model.addRoot(url, entry.getKey());
        continue;
      }
      if (virtualFile.isDirectory()) {
        model.addRoot(virtualFile, entry.getKey());
      }
      else {
        VirtualFile archiveRoot = ArchiveVfsUtil.getArchiveRootForLocalFile(virtualFile);
        if (archiveRoot == null) {
          LOG.warn(String.format("Can't parse contents of the jar file at path '%s' for the library '%s''", file.getAbsolutePath(), libraryName));
          continue;
        }
        model.addRoot(archiveRoot, entry.getKey());
      }
    }
  }
}
 
Example 3
Source File: Unity3dPackageOrderEntry.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public String[] getUrls(@Nonnull OrderRootType rootType)
{
	List<String> urls = new SmartList<>();

	if(rootType == BinariesOrderRootType.getInstance() || rootType == SourcesOrderRootType.getInstance())
	{
		// moved to project files
		String projectPackageCache = getProjectPackageCache();
		if(new File(projectPackageCache, myNameWithVersion).exists())
		{
			urls.add(StandardFileSystems.FILE_PROTOCOL_PREFIX + FileUtil.toSystemIndependentName(projectPackageCache + "/" + myNameWithVersion));
		}

		if(urls.isEmpty())
		{
			Unity3dPackageWatcher watcher = Unity3dPackageWatcher.getInstance();
			for(String path : watcher.getPackageDirPaths())
			{
				if(new File(path, myNameWithVersion).exists())
				{
					urls.add(StandardFileSystems.FILE_PROTOCOL_PREFIX + FileUtil.toSystemIndependentName(path + "/" + myNameWithVersion));
				}
			}
		}
	}

	if(urls.isEmpty())
	{
		Sdk sdk = getSdk();
		if(sdk != null)
		{
			String builtInPath = sdk.getHomePath() + "/" + getBuiltInPackagesRelativePath();
			String packageName = getPackageName();
			if(new File(builtInPath, packageName).exists())
			{
				urls.add(StandardFileSystems.FILE_PROTOCOL_PREFIX + FileUtil.toSystemIndependentName(builtInPath + "/" + packageName));
			}
		}
	}

	return ArrayUtil.toStringArray(urls);
}
 
Example 4
Source File: Unity3dPackageOrderEntry.java    From consulo-unity3d with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
@RequiredReadAction
public VirtualFile[] getFiles(@Nonnull OrderRootType rootType)
{
	List<VirtualFile> files = new ArrayList<>();

	if(rootType == BinariesOrderRootType.getInstance() || rootType == SourcesOrderRootType.getInstance())
	{
		LocalFileSystem localFileSystem = LocalFileSystem.getInstance();

		// moved to project files
		String projectPackageCache = getProjectPackageCache();
		VirtualFile localFile = localFileSystem.findFileByIoFile(new File(projectPackageCache, myNameWithVersion));
		addDotNetModulesInsideLibrary(files, localFile);

		if(files.isEmpty())
		{
			Unity3dPackageWatcher watcher = Unity3dPackageWatcher.getInstance();
			for(String path : watcher.getPackageDirPaths())
			{
				VirtualFile file = localFileSystem.findFileByIoFile(new File(path, myNameWithVersion));
				addDotNetModulesInsideLibrary(files, file);
			}
		}
	}

	if(files.isEmpty())
	{
		Sdk sdk = getSdk();
		if(sdk != null)
		{
			VirtualFile homeDirectory = sdk.getHomeDirectory();
			if(homeDirectory != null)
			{
				VirtualFile builtInDirectory = homeDirectory.findFileByRelativePath(getBuiltInPackagesRelativePath());
				if(builtInDirectory != null)
				{
					VirtualFile packageDirectory = builtInDirectory.findChild(getPackageName());
					ContainerUtil.addIfNotNull(files, packageDirectory);
				}
			}
		}
	}
	return VfsUtilCore.toVirtualFileArray(files);
}
 
Example 5
Source File: OrderEnumeratorBase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public OrderRootsEnumerator classes() {
  return new OrderRootsEnumeratorImpl(this, BinariesOrderRootType.getInstance());
}
 
Example 6
Source File: LibraryType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public static OrderRootType[] getDefaultExternalRootTypes() {
  return new OrderRootType[]{BinariesOrderRootType.getInstance()};
}
 
Example 7
Source File: BinariesOrderRootTypeUIFactory.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@Override
public SdkPathEditor createPathEditor(Sdk sdk) {
  return new SdkPathEditor(ProjectBundle.message("library.binaries.node"), BinariesOrderRootType.getInstance(),
                           new FileChooserDescriptor(true, true, true, false, true, true), sdk);
}
 
Example 8
Source File: SandBundleType.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isRootTypeApplicable(OrderRootType type) {
  return type == BinariesOrderRootType.getInstance();
}