use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class TestPackage method createSearchingForTestsTask.
@Override
public SearchForTestsTask createSearchingForTestsTask() {
final JUnitConfiguration.Data data = getConfiguration().getPersistentData();
return new SearchForTestsTask(getConfiguration().getProject(), myServerSocket) {
private final THashSet<PsiClass> myClasses = new THashSet<>();
@Override
protected void search() {
myClasses.clear();
final SourceScope sourceScope = getSourceScope();
final Module module = getConfiguration().getConfigurationModule().getModule();
if (sourceScope != null && !ReadAction.compute(() -> isJUnit5(module, sourceScope, myProject))) {
try {
final TestClassFilter classFilter = getClassFilter(data);
LOG.assertTrue(classFilter.getBase() != null);
ConfigurationUtil.findAllTestClasses(classFilter, module, myClasses);
} catch (CantRunException ignored) {
}
}
}
@Override
protected void onFound() {
try {
addClassesListToJavaParameters(myClasses, psiClass -> psiClass != null ? JavaExecutionUtil.getRuntimeQualifiedName(psiClass) : null, getPackageName(data), createTempFiles(), getJavaParameters());
} catch (ExecutionException ignored) {
}
}
};
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class DependencyResolvingBuilder method syncPaths.
private static void syncPaths(final Collection<File> required, @NotNull Collection<File> resolved) throws Exception {
final THashSet<File> libFiles = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
libFiles.addAll(required);
libFiles.removeAll(resolved);
if (!libFiles.isEmpty()) {
final Map<String, File> nameToArtifactMap = new THashMap<>(FileUtil.PATH_HASHING_STRATEGY);
for (File f : resolved) {
final File prev = nameToArtifactMap.put(f.getName(), f);
if (prev != null) {
throw new Exception("Ambiguous artifacts with the same name: " + prev.getPath() + " and " + f.getPath());
}
}
for (File file : libFiles) {
final File resolvedArtifact = nameToArtifactMap.get(file.getName());
if (resolvedArtifact != null) {
FileUtil.copy(resolvedArtifact, file);
}
}
}
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class FormsInstrumenter method build.
@Override
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
final JpsProject project = context.getProjectDescriptor().getProject();
final JpsUiDesignerConfiguration config = JpsUiDesignerExtensionService.getInstance().getOrCreateUiDesignerConfiguration(project);
if (!config.isInstrumentClasses()) {
return ExitCode.NOTHING_DONE;
}
final Map<File, Collection<File>> srcToForms = FORMS_TO_COMPILE.get(context);
FORMS_TO_COMPILE.set(context, null);
if (srcToForms == null || srcToForms.isEmpty()) {
return ExitCode.NOTHING_DONE;
}
final Set<File> formsToCompile = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
for (Collection<File> files : srcToForms.values()) {
formsToCompile.addAll(files);
}
if (JavaBuilderUtil.isCompileJavaIncrementally(context)) {
final ProjectBuilderLogger logger = context.getLoggingManager().getProjectBuilderLogger();
if (logger.isEnabled()) {
logger.logCompiledFiles(formsToCompile, getPresentableName(), "Compiling forms:");
}
}
try {
final Collection<File> platformCp = ProjectPaths.getPlatformCompilationClasspath(chunk, false);
final List<File> classpath = new ArrayList<>();
classpath.addAll(ProjectPaths.getCompilationClasspath(chunk, false));
// forms_rt.jar
classpath.add(getResourcePath(GridConstraints.class));
final Map<File, String> chunkSourcePath = ProjectPaths.getSourceRootsWithDependents(chunk);
// sourcepath for loading forms resources
classpath.addAll(chunkSourcePath.keySet());
final JpsSdk<JpsDummyElement> sdk = chunk.representativeTarget().getModule().getSdk(JpsJavaSdkType.INSTANCE);
final InstrumentationClassFinder finder = ClassProcessingBuilder.createInstrumentationClassFinder(sdk, platformCp, classpath, outputConsumer);
try {
final Map<File, Collection<File>> processed = instrumentForms(context, chunk, chunkSourcePath, finder, formsToCompile, outputConsumer);
final OneToManyPathsMapping sourceToFormMap = context.getProjectDescriptor().dataManager.getSourceToFormMap();
for (Map.Entry<File, Collection<File>> entry : processed.entrySet()) {
final File src = entry.getKey();
final Collection<File> forms = entry.getValue();
final Collection<String> formPaths = new ArrayList<>(forms.size());
for (File form : forms) {
formPaths.add(form.getPath());
}
sourceToFormMap.update(src.getPath(), formPaths);
srcToForms.remove(src);
}
// clean mapping
for (File srcFile : srcToForms.keySet()) {
sourceToFormMap.remove(srcFile.getPath());
}
} finally {
finder.releaseResources();
}
} finally {
context.processMessage(new ProgressMessage("Finished instrumenting forms [" + chunk.getPresentableShortName() + "]"));
}
return ExitCode.OK;
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class ProjectDictionaryState method retrieveProjectDictionaries.
private void retrieveProjectDictionaries() {
Set<EditableDictionary> dictionaries = new THashSet<>();
if (dictionaryStates != null) {
for (DictionaryState dictionaryState : dictionaryStates) {
dictionaryState.loadState(dictionaryState);
dictionaries.add(dictionaryState.getDictionary());
}
}
projectDictionary = new ProjectDictionary(dictionaries);
}
use of gnu.trove.THashSet in project intellij-community by JetBrains.
the class MavenProjectReader method doReadProjectModel.
private RawModelReadResult doReadProjectModel(VirtualFile file, boolean headerOnly) {
MavenModel result = null;
Collection<MavenProjectProblem> problems = MavenProjectProblem.createProblemsList();
Set<String> alwaysOnProfiles = new THashSet<>();
String fileExtension = file.getExtension();
if (!"pom".equalsIgnoreCase(fileExtension) && !"xml".equalsIgnoreCase(fileExtension)) {
File basedir = getBaseDir(file);
MavenEmbeddersManager manager = MavenProjectsManager.getInstance(myProject).getEmbeddersManager();
MavenEmbedderWrapper embedder = manager.getEmbedder(MavenEmbeddersManager.FOR_MODEL_READ, basedir.getPath(), basedir.getPath());
try {
result = embedder.readModel(VfsUtilCore.virtualToIoFile(file));
} catch (MavenProcessCanceledException ignore) {
} finally {
manager.release(embedder);
}
if (result == null) {
result = new MavenModel();
result.setPackaging(MavenConstants.TYPE_JAR);
return new RawModelReadResult(result, problems, alwaysOnProfiles);
} else {
return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
}
result = new MavenModel();
Element xmlProject = readXml(file, problems, MavenProjectProblem.ProblemType.SYNTAX);
if (xmlProject == null || !"project".equals(xmlProject.getName())) {
result.setPackaging(MavenConstants.TYPE_JAR);
return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
MavenParent parent;
if (MavenJDOMUtil.hasChildByPath(xmlProject, "parent")) {
parent = new MavenParent(new MavenId(MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.groupId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.artifactId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.version", UNKNOWN)), MavenJDOMUtil.findChildValueByPath(xmlProject, "parent.relativePath", "../pom.xml"));
result.setParent(parent);
} else {
parent = new MavenParent(new MavenId(UNKNOWN, UNKNOWN, UNKNOWN), "../pom.xml");
}
result.setMavenId(new MavenId(MavenJDOMUtil.findChildValueByPath(xmlProject, "groupId", parent.getMavenId().getGroupId()), MavenJDOMUtil.findChildValueByPath(xmlProject, "artifactId", UNKNOWN), MavenJDOMUtil.findChildValueByPath(xmlProject, "version", parent.getMavenId().getVersion())));
if (headerOnly)
return new RawModelReadResult(result, problems, alwaysOnProfiles);
result.setPackaging(MavenJDOMUtil.findChildValueByPath(xmlProject, "packaging", MavenConstants.TYPE_JAR));
result.setName(MavenJDOMUtil.findChildValueByPath(xmlProject, "name"));
readModelBody(result, result.getBuild(), xmlProject);
result.setProfiles(collectProfiles(file, xmlProject, problems, alwaysOnProfiles));
return new RawModelReadResult(result, problems, alwaysOnProfiles);
}
Aggregations