use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class MavenArtifactDownloader method collectArtifactsToDownload.
private Map<MavenId, DownloadData> collectArtifactsToDownload(List<MavenExtraArtifactType> types) {
Map<MavenId, DownloadData> result = new THashMap<>();
THashSet<String> dependencyTypesFromSettings = new THashSet<>();
AccessToken accessToken = ReadAction.start();
try {
if (myProject.isDisposed())
return result;
dependencyTypesFromSettings.addAll(MavenProjectsManager.getInstance(myProject).getImportingSettings().getDependencyTypesAsSet());
} finally {
accessToken.finish();
}
for (MavenProject eachProject : myMavenProjects) {
List<MavenRemoteRepository> repositories = eachProject.getRemoteRepositories();
for (MavenArtifact eachDependency : eachProject.getDependencies()) {
if (myArtifacts != null && !myArtifacts.contains(eachDependency))
continue;
if (MavenConstants.SCOPE_SYSTEM.equalsIgnoreCase(eachDependency.getScope()))
continue;
if (myProjectsTree.findProject(eachDependency.getMavenId()) != null)
continue;
String dependencyType = eachDependency.getType();
if (!dependencyTypesFromSettings.contains(dependencyType) && !eachProject.getDependencyTypesFromImporters(SupportedRequestType.FOR_IMPORT).contains(dependencyType)) {
continue;
}
MavenId id = eachDependency.getMavenId();
DownloadData data = result.get(id);
if (data == null) {
data = new DownloadData();
result.put(id, data);
}
data.repositories.addAll(repositories);
for (MavenExtraArtifactType eachType : types) {
Pair<String, String> classifierAndExtension = eachProject.getClassifierAndExtension(eachDependency, eachType);
String classifier = eachDependency.getFullClassifier(classifierAndExtension.first);
String extension = classifierAndExtension.second;
data.classifiersWithExtensions.add(new DownloadElement(classifier, extension, eachType));
}
}
}
return result;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class MavenPluginConfigurationDomExtender method collectParameters.
private static Collection<ParameterData> collectParameters(MavenDomPluginModel pluginModel, MavenDomConfiguration config) {
List<String> selectedGoals = null;
MavenDomPluginExecution executionElement = config.getParentOfType(MavenDomPluginExecution.class, false);
if (executionElement != null) {
selectedGoals = new ArrayList<>();
String id = executionElement.getId().getStringValue();
String defaultPrefix = "default-";
if (id != null && id.startsWith(defaultPrefix)) {
String goal = id.substring(defaultPrefix.length());
if (!StringUtil.isEmptyOrSpaces(goal))
selectedGoals.add(goal);
}
for (GenericDomValue<String> goal : executionElement.getGoals().getGoals()) {
selectedGoals.add(goal.getStringValue());
}
}
Map<String, ParameterData> namesWithParameters = new THashMap<>();
for (MavenDomMojo eachMojo : pluginModel.getMojos().getMojos()) {
String goal = eachMojo.getGoal().getStringValue();
if (goal == null)
continue;
if (selectedGoals == null || selectedGoals.contains(goal)) {
for (MavenDomParameter eachParameter : eachMojo.getParameters().getParameters()) {
if (eachParameter.getEditable().getValue() == Boolean.FALSE)
continue;
String name = eachParameter.getName().getStringValue();
if (name == null)
continue;
ParameterData data = new ParameterData(eachParameter);
fillParameterData(name, data, eachMojo);
ParameterData oldParameter = namesWithParameters.get(name);
if (oldParameter == null || hasMorePriority(data, oldParameter, executionElement != null)) {
namesWithParameters.put(name, data);
}
}
}
}
return namesWithParameters.values();
}
use of gnu.trove.THashMap 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.THashMap in project intellij-community by JetBrains.
the class MicrodataUtil method findScopesWithItemRef.
private static Map<String, XmlTag> findScopesWithItemRef(@Nullable final PsiFile file) {
if (!(file instanceof XmlFile))
return Collections.emptyMap();
return CachedValuesManager.getCachedValue(file, new CachedValueProvider<Map<String, XmlTag>>() {
@Nullable
@Override
public Result<Map<String, XmlTag>> compute() {
final Map<String, XmlTag> result = new THashMap<>();
file.accept(new XmlRecursiveElementVisitor() {
@Override
public void visitXmlTag(final XmlTag tag) {
super.visitXmlTag(tag);
XmlAttribute refAttr = tag.getAttribute(ITEM_REF);
if (refAttr != null && tag.getAttribute(ITEM_SCOPE) != null) {
getReferencesForAttributeValue(refAttr.getValueElement(), (t, v) -> {
result.put(t, tag);
return null;
});
}
}
});
return Result.create(result, file);
}
});
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class FormsInstrumenter method instrumentForms.
private Map<File, Collection<File>> instrumentForms(CompileContext context, ModuleChunk chunk, final Map<File, String> chunkSourcePath, final InstrumentationClassFinder finder, Collection<File> forms, OutputConsumer outConsumer) throws ProjectBuildException {
final Map<File, Collection<File>> instrumented = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
final Map<String, File> class2form = new HashMap<>();
final MyNestedFormLoader nestedFormsLoader = new MyNestedFormLoader(chunkSourcePath, ProjectPaths.getOutputPathsWithDependents(chunk), finder);
for (File formFile : forms) {
final LwRootContainer rootContainer;
try {
rootContainer = Utils.getRootContainer(formFile.toURI().toURL(), new CompiledClassPropertiesProvider(finder.getLoader()));
} catch (AlienFormFileException e) {
// ignore non-IDEA forms
continue;
} catch (UnexpectedFormElementException e) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, e.getMessage(), formFile.getPath()));
LOG.info(e);
continue;
} catch (UIDesignerException e) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, e.getMessage(), formFile.getPath()));
LOG.info(e);
continue;
} catch (Exception e) {
throw new ProjectBuildException("Cannot process form file " + formFile.getAbsolutePath(), e);
}
final String classToBind = rootContainer.getClassToBind();
if (classToBind == null) {
continue;
}
final CompiledClass compiled = findClassFile(outConsumer, classToBind);
if (compiled == null) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.WARNING, "Class to bind does not exist: " + classToBind, formFile.getAbsolutePath()));
continue;
}
final File alreadyProcessedForm = class2form.get(classToBind);
if (alreadyProcessedForm != null) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.WARNING, formFile.getAbsolutePath() + ": The form is bound to the class " + classToBind + ".\nAnother form " + alreadyProcessedForm.getAbsolutePath() + " is also bound to this class", formFile.getAbsolutePath()));
continue;
}
class2form.put(classToBind, formFile);
for (File file : compiled.getSourceFiles()) {
addBinding(file, formFile, instrumented);
}
try {
context.processMessage(new ProgressMessage("Instrumenting forms... [" + chunk.getPresentableShortName() + "]"));
final BinaryContent originalContent = compiled.getContent();
final ClassReader classReader = new FailSafeClassReader(originalContent.getBuffer(), originalContent.getOffset(), originalContent.getLength());
final int version = ClassProcessingBuilder.getClassFileVersion(classReader);
final InstrumenterClassWriter classWriter = new InstrumenterClassWriter(classReader, ClassProcessingBuilder.getAsmClassWriterFlags(version), finder);
final AsmCodeGenerator codeGenerator = new AsmCodeGenerator(rootContainer, finder, nestedFormsLoader, false, classWriter);
final byte[] patchedBytes = codeGenerator.patchClass(classReader);
if (patchedBytes != null) {
compiled.setContent(new BinaryContent(patchedBytes));
}
final FormErrorInfo[] warnings = codeGenerator.getWarnings();
for (final FormErrorInfo warning : warnings) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.WARNING, warning.getErrorMessage(), formFile.getAbsolutePath()));
}
final FormErrorInfo[] errors = codeGenerator.getErrors();
if (errors.length > 0) {
StringBuilder message = new StringBuilder();
for (final FormErrorInfo error : errors) {
if (message.length() > 0) {
message.append("\n");
}
message.append(formFile.getAbsolutePath()).append(": ").append(error.getErrorMessage());
}
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, message.toString()));
}
} catch (Exception e) {
context.processMessage(new CompilerMessage(getPresentableName(), BuildMessage.Kind.ERROR, "Forms instrumentation failed" + e.getMessage(), formFile.getAbsolutePath()));
}
}
return instrumented;
}
Aggregations