Search in sources :

Example 6 with THashSet

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) {
            }
        }
    };
}
Also used : SourceScope(com.intellij.execution.testframework.SourceScope) SearchForTestsTask(com.intellij.execution.testframework.SearchForTestsTask) Module(com.intellij.openapi.module.Module) THashSet(gnu.trove.THashSet)

Example 7 with THashSet

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);
            }
        }
    }
}
Also used : THashMap(gnu.trove.THashMap) File(java.io.File) THashSet(gnu.trove.THashSet) IOException(java.io.IOException) UnknownHostException(java.net.UnknownHostException)

Example 8 with THashSet

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;
}
Also used : ProgressMessage(org.jetbrains.jps.incremental.messages.ProgressMessage) OneToManyPathsMapping(org.jetbrains.jps.incremental.storage.OneToManyPathsMapping) InstrumentationClassFinder(com.intellij.compiler.instrumentation.InstrumentationClassFinder) THashSet(gnu.trove.THashSet) ProjectBuilderLogger(org.jetbrains.jps.builders.logging.ProjectBuilderLogger) JpsUiDesignerConfiguration(org.jetbrains.jps.uiDesigner.model.JpsUiDesignerConfiguration) GridConstraints(com.intellij.uiDesigner.core.GridConstraints) JpsProject(org.jetbrains.jps.model.JpsProject) JpsDummyElement(org.jetbrains.jps.model.JpsDummyElement) THashMap(gnu.trove.THashMap)

Example 9 with THashSet

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);
}
Also used : ProjectDictionary(com.intellij.spellchecker.dictionary.ProjectDictionary) EditableDictionary(com.intellij.spellchecker.dictionary.EditableDictionary) THashSet(gnu.trove.THashSet)

Example 10 with THashSet

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);
}
Also used : MavenProcessCanceledException(org.jetbrains.idea.maven.utils.MavenProcessCanceledException) Element(org.jdom.Element) MavenEmbedderWrapper(org.jetbrains.idea.maven.server.MavenEmbedderWrapper) THashSet(gnu.trove.THashSet) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Aggregations

THashSet (gnu.trove.THashSet)239 NotNull (org.jetbrains.annotations.NotNull)65 VirtualFile (com.intellij.openapi.vfs.VirtualFile)62 Project (com.intellij.openapi.project.Project)35 File (java.io.File)35 THashMap (gnu.trove.THashMap)31 Nullable (org.jetbrains.annotations.Nullable)31 Module (com.intellij.openapi.module.Module)29 IOException (java.io.IOException)24 PsiElement (com.intellij.psi.PsiElement)21 PsiFile (com.intellij.psi.PsiFile)18 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)16 java.util (java.util)16 Element (org.jdom.Element)14 Pair (com.intellij.openapi.util.Pair)13 Logger (com.intellij.openapi.diagnostic.Logger)12 ContainerUtil (com.intellij.util.containers.ContainerUtil)12 Document (com.intellij.openapi.editor.Document)11 Library (com.intellij.openapi.roots.libraries.Library)11 StringUtil (com.intellij.openapi.util.text.StringUtil)10