use of gnu.trove.THashSet in project intellij-elixir by KronicDeth.
the class Exports method from.
/*
* Static Methods
*/
@Nullable
public static Exports from(@NotNull Chunk chunk) {
Exports exports = null;
if (chunk.typeID.equals(EXPT.toString()) && chunk.data.length >= 4) {
Collection<Export> exportCollection = new THashSet<Export>();
int offset = 0;
Pair<Long, Integer> exportCountByteCount = unsignedInt(chunk.data, 0);
long exportCount = exportCountByteCount.first;
offset += exportCountByteCount.second;
for (long i = 0; i < exportCount; i++) {
Pair<Long, Integer> atomIndexByteCount = unsignedInt(chunk.data, offset);
long atomIndex = atomIndexByteCount.first;
offset += atomIndexByteCount.second;
Pair<Long, Integer> arityByteCount = unsignedInt(chunk.data, offset);
long arity = arityByteCount.first;
offset += arityByteCount.second;
// label is currently unused, but it must be consumed to read the next export at the correct offset
Pair<Long, Integer> labelByteCount = unsignedInt(chunk.data, offset);
offset += labelByteCount.second;
exportCollection.add(new Export(atomIndex, arity));
}
exports = new Exports(exportCollection);
}
return exports;
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class MavenModuleImporter method configDependencies.
private void configDependencies() {
THashSet<String> dependencyTypesFromSettings = new THashSet<>();
AccessToken accessToken = ReadAction.start();
try {
if (myModule.getProject().isDisposed())
return;
dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myModule.getProject()).getImportingSettings().getDependencyTypesAsSet());
} finally {
accessToken.finish();
}
for (MavenArtifact artifact : myMavenProject.getDependencies()) {
String dependencyType = artifact.getType();
if (!dependencyTypesFromSettings.contains(dependencyType) && !myMavenProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
continue;
}
DependencyScope scope = selectScope(artifact.getScope());
MavenProject depProject = myMavenTree.findProject(artifact.getMavenId());
if (depProject != null) {
if (depProject == myMavenProject)
continue;
String moduleName = myMavenProjectToModuleName.get(depProject);
if (moduleName == null || myMavenTree.isIgnored(depProject)) {
MavenArtifact projectsArtifactInRepository = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
myRootModelAdapter.addLibraryDependency(projectsArtifactInRepository, scope, myModifiableModelsProvider, myMavenProject);
} else {
boolean isTestJar = MavenConstants.TYPE_TEST_JAR.equals(dependencyType) || "tests".equals(artifact.getClassifier());
myRootModelAdapter.addModuleDependency(moduleName, scope, isTestJar);
Element buildHelperCfg = depProject.getPluginGoalConfiguration("org.codehaus.mojo", "build-helper-maven-plugin", "attach-artifact");
if (buildHelperCfg != null) {
addAttachArtifactDependency(buildHelperCfg, scope, depProject, artifact);
}
if (IMPORTED_CLASSIFIERS.contains(artifact.getClassifier()) && !isTestJar && !"system".equals(artifact.getScope()) && !"false".equals(System.getProperty("idea.maven.classifier.dep"))) {
MavenArtifact a = new MavenArtifact(artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getBaseVersion(), dependencyType, artifact.getClassifier(), artifact.getScope(), artifact.isOptional(), artifact.getExtension(), null, myMavenProject.getLocalRepository(), false, false);
myRootModelAdapter.addLibraryDependency(a, scope, myModifiableModelsProvider, myMavenProject);
}
}
} else if ("system".equals(artifact.getScope())) {
myRootModelAdapter.addSystemDependency(artifact, scope);
} else {
myRootModelAdapter.addLibraryDependency(artifact, scope, myModifiableModelsProvider, myMavenProject);
}
}
configSurefirePlugin();
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class MavenProjectImporter method scheduleRefreshResolvedArtifacts.
private void scheduleRefreshResolvedArtifacts(List<MavenProjectsProcessorTask> postTasks) {
// We have to refresh all the resolved artifacts manually in order to
// update all the VirtualFilePointers. It is not enough to call
// VirtualFileManager.refresh() since the newly created files will be only
// picked by FS when FileWatcher finishes its work. And in the case of import
// it doesn't finish in time.
// I couldn't manage to write a test for this since behaviour of VirtualFileManager
// and FileWatcher differs from real-life execution.
List<MavenArtifact> artifacts = new ArrayList<>();
for (MavenProject each : myProjectsToImportWithChanges.keySet()) {
artifacts.addAll(each.getDependencies());
}
final Set<File> files = new THashSet<>();
for (MavenArtifact each : artifacts) {
if (each.isResolved())
files.add(each.getFile());
}
if (ApplicationManager.getApplication().isUnitTestMode()) {
doRefreshFiles(files);
} else {
postTasks.add(new MavenProjectsProcessorTask() {
public void perform(Project project, MavenEmbeddersManager embeddersManager, MavenConsole console, MavenProgressIndicator indicator) throws MavenProcessCanceledException {
indicator.setText("Refreshing files...");
doRefreshFiles(files);
}
});
}
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class XmlHighlightingTest method doSchemaTestWithManyFilesFromSeparateDir.
private void doSchemaTestWithManyFilesFromSeparateDir(final String[][] urls, @Nullable Processor<List<VirtualFile>> additionalTestingProcessor) throws Exception {
try {
List<VirtualFile> files = new ArrayList<>(6);
files.add(getVirtualFile(BASE_PATH + getTestName(false) + ".xml"));
final Set<VirtualFile> usedFiles = new THashSet<>();
final String base = BASE_PATH + getTestName(false) + "Schemas/";
for (String[] pair : urls) {
final String url = pair[0];
final String filename = pair.length > 1 ? pair[1] : url.substring(url.lastIndexOf('/') + 1) + (url.endsWith(".xsd") ? "" : ".xsd");
final VirtualFile virtualFile = getVirtualFile(base + filename);
usedFiles.add(virtualFile);
if (url != null)
ExternalResourceManagerExImpl.registerResourceTemporarily(url, virtualFile.getPath(), getTestRootDisposable());
files.add(virtualFile);
}
for (VirtualFile file : LocalFileSystem.getInstance().findFileByPath(getTestDataPath() + base.substring(0, base.length() - 1)).getChildren()) {
if (!usedFiles.contains(file)) {
files.add(file);
}
}
doTest(VfsUtilCore.toVirtualFileArray(files), true, false);
if (additionalTestingProcessor != null)
additionalTestingProcessor.process(files);
} finally {
unregisterResources(urls);
}
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class SearchScope method iterateContent.
public void iterateContent(@NotNull final Project project, final Processor<VirtualFile> processor) {
switch(getScopeType()) {
case PROJECT:
//noinspection unchecked
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
break;
case MODULE:
final Module module = ModuleManager.getInstance(project).findModuleByName(getModuleName());
assert module != null;
ModuleRootManager.getInstance(module).getFileIndex().iterateContent(new MyFileIterator(processor, Conditions.<VirtualFile>alwaysTrue()));
break;
case DIRECTORY:
final String dirName = getPath();
assert dirName != null;
final VirtualFile virtualFile = findFile(dirName);
if (virtualFile != null) {
iterateRecursively(virtualFile, processor, isRecursive());
}
break;
case CUSTOM:
assert myCustomScope != null;
final ContentIterator iterator;
if (myCustomScope instanceof GlobalSearchScope) {
final GlobalSearchScope searchScope = (GlobalSearchScope) myCustomScope;
iterator = new MyFileIterator(processor, virtualFile13 -> searchScope.contains(virtualFile13));
if (searchScope.isSearchInLibraries()) {
final OrderEnumerator enumerator = OrderEnumerator.orderEntries(project).withoutModuleSourceEntries().withoutDepModules();
final Collection<VirtualFile> libraryFiles = new THashSet<>();
Collections.addAll(libraryFiles, enumerator.getClassesRoots());
Collections.addAll(libraryFiles, enumerator.getSourceRoots());
final Processor<VirtualFile> adapter = virtualFile1 -> iterator.processFile(virtualFile1);
for (final VirtualFile file : libraryFiles) {
iterateRecursively(file, adapter, true);
}
}
} else {
final PsiManager manager = PsiManager.getInstance(project);
iterator = new MyFileIterator(processor, virtualFile12 -> {
final PsiFile element = manager.findFile(virtualFile12);
return element != null && PsiSearchScopeUtil.isInScope(myCustomScope, element);
});
}
ProjectRootManager.getInstance(project).getFileIndex().iterateContent(iterator);
}
}
Aggregations