use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class FileChooserFactoryImpl method getMacroMap.
public static Map<String, String> getMacroMap() {
final PathMacros macros = PathMacros.getInstance();
final Set<String> allNames = macros.getAllMacroNames();
final Map<String, String> map = new THashMap<>(allNames.size());
for (String eachMacroName : allNames) {
map.put("$" + eachMacroName + "$", macros.getValue(eachMacroName));
}
return map;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class ExternalizablePropertyContainer method readExternal.
public void readExternal(@NotNull Element element) {
Map<String, AbstractProperty> propertyByName = new THashMap<>();
for (AbstractProperty abstractProperty : myExternalizers.keySet()) {
propertyByName.put(abstractProperty.getName(), abstractProperty);
}
for (Element child : element.getChildren()) {
AbstractProperty property = propertyByName.get(child.getName());
if (property == null) {
continue;
}
Externalizer externalizer = myExternalizers.get(property);
if (externalizer == null) {
continue;
}
try {
myValues.put(property, externalizer.readValue(child));
} catch (Exception e) {
LOG.info(e);
}
}
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class FormsBindingManager method build.
@Override
public ExitCode build(CompileContext context, ModuleChunk chunk, DirtyFilesHolder<JavaSourceRootDescriptor, ModuleBuildTarget> dirtyFilesHolder, OutputConsumer outputConsumer) throws ProjectBuildException, IOException {
ExitCode exitCode = ExitCode.NOTHING_DONE;
final JpsProject project = context.getProjectDescriptor().getProject();
final JpsUiDesignerConfiguration config = JpsUiDesignerExtensionService.getInstance().getOrCreateUiDesignerConfiguration(project);
if (!config.isInstrumentClasses() && !config.isCopyFormsRuntimeToOutput()) {
return exitCode;
}
final Map<File, ModuleBuildTarget> filesToCompile = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
final Map<File, ModuleBuildTarget> formsToCompile = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
final Map<File, Collection<File>> srcToForms = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
if (!JavaBuilderUtil.isForcedRecompilationAllJavaModules(context) && config.isInstrumentClasses() && FORCE_FORMS_REBUILD_FLAG.get(context, Boolean.FALSE)) {
// force compilation of all forms, but only once per chunk
if (!FORMS_REBUILD_FORCED.get(context, Boolean.FALSE)) {
FORMS_REBUILD_FORCED.set(context, Boolean.TRUE);
FSOperations.markDirty(context, CompilationRound.CURRENT, chunk, FORM_SOURCES_FILTER);
}
}
dirtyFilesHolder.processDirtyFiles(new FileProcessor<JavaSourceRootDescriptor, ModuleBuildTarget>() {
public boolean apply(ModuleBuildTarget target, File file, JavaSourceRootDescriptor descriptor) throws IOException {
if (JAVA_SOURCES_FILTER.accept(file)) {
filesToCompile.put(file, target);
} else if (FORM_SOURCES_FILTER.accept(file)) {
formsToCompile.put(file, target);
}
return true;
}
});
if (config.isInstrumentClasses()) {
final JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(project);
final JpsCompilerExcludes excludes = configuration.getCompilerExcludes();
// force compilation of bound source file if the form is dirty
for (final Map.Entry<File, ModuleBuildTarget> entry : formsToCompile.entrySet()) {
final File form = entry.getKey();
final ModuleBuildTarget target = entry.getValue();
final Collection<File> sources = findBoundSourceCandidates(context, target, form);
for (File boundSource : sources) {
if (!excludes.isExcluded(boundSource)) {
addBinding(boundSource, form, srcToForms);
FSOperations.markDirty(context, CompilationRound.CURRENT, boundSource);
filesToCompile.put(boundSource, target);
exitCode = ExitCode.OK;
}
}
}
// form should be considered dirty if the class it is bound to is dirty
final OneToManyPathsMapping sourceToFormMap = context.getProjectDescriptor().dataManager.getSourceToFormMap();
for (Map.Entry<File, ModuleBuildTarget> entry : filesToCompile.entrySet()) {
final File srcFile = entry.getKey();
final ModuleBuildTarget target = entry.getValue();
final Collection<String> boundForms = sourceToFormMap.getState(srcFile.getPath());
if (boundForms != null) {
for (String formPath : boundForms) {
final File formFile = new File(formPath);
if (!excludes.isExcluded(formFile) && formFile.exists()) {
addBinding(srcFile, formFile, srcToForms);
FSOperations.markDirty(context, CompilationRound.CURRENT, formFile);
formsToCompile.put(formFile, target);
exitCode = ExitCode.OK;
}
}
}
}
}
FORMS_TO_COMPILE.set(context, srcToForms.isEmpty() ? null : srcToForms);
if (config.isCopyFormsRuntimeToOutput() && containsValidForm(formsToCompile.keySet())) {
for (ModuleBuildTarget target : chunk.getTargets()) {
if (!target.isTests()) {
final File outputDir = target.getOutputDir();
if (outputDir != null) {
final String outputRoot = FileUtil.toSystemIndependentName(outputDir.getPath());
final List<File> generatedFiles = CopyResourcesUtil.copyFormsRuntime(outputRoot, false);
if (!generatedFiles.isEmpty()) {
exitCode = ExitCode.OK;
// now inform others about files just copied
for (File file : generatedFiles) {
outputConsumer.registerOutputFile(target, file, Collections.<String>emptyList());
}
}
}
}
}
}
return exitCode;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class MavenProjectNamer method generateNameMap.
//private static Logger LOG = Logger.getInstance(MavenProjectNamer.class);
public static Map<MavenProject, String> generateNameMap(Collection<MavenProject> mavenProjects) {
MultiMap<String, MavenProject> artifactIdMap = new MultiMap<>();
for (MavenProject project : mavenProjects) {
artifactIdMap.putValue(project.getMavenId().getArtifactId(), project);
}
Map<MavenProject, String> res = new THashMap<>();
for (Map.Entry<String, Collection<MavenProject>> entry : artifactIdMap.entrySet()) {
List<MavenProject> projectList = (List<MavenProject>) entry.getValue();
String artifactId = entry.getKey();
if (projectList.size() == 1) {
res.put(projectList.get(0), artifactId);
} else if (allGroupsAreDifferent(projectList)) {
for (MavenProject mavenProject : projectList) {
res.put(mavenProject, mavenProject.getMavenId().getGroupId() + ':' + mavenProject.getMavenId().getArtifactId());
}
} else if (allGroupsEqual(mavenProjects)) {
for (MavenProject mavenProject : projectList) {
res.put(mavenProject, mavenProject.getMavenId().getArtifactId() + ':' + mavenProject.getMavenId().getVersion());
}
} else {
for (MavenProject mavenProject : projectList) {
MavenId mavenId = mavenProject.getMavenId();
res.put(mavenProject, mavenId.getGroupId() + ':' + mavenId.getArtifactId() + ':' + mavenId.getVersion());
}
}
}
return res;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class SceneBuilderImpl method loadBuiltinComponents.
@NotNull
private static Map<String, BuiltinComponent> loadBuiltinComponents(Predicate<String> psiClassExists) {
final Map<String, BuiltinComponent> components = new THashMap<>();
for (LibraryItem item : BuiltinLibrary.getLibrary().getItems()) {
final Ref<String> refQualifiedName = new Ref<>();
final List<String> imports = new ArrayList<>();
final Map<String, String> attributes = new THashMap<>();
final Ref<Boolean> rootTagProcessed = new Ref<>(false);
NanoXmlUtil.parse(new StringReader(item.getFxmlText()), new NanoXmlUtil.IXMLBuilderAdapter() {
@Override
public void newProcessingInstruction(String target, Reader reader) throws Exception {
if ("import".equals(target)) {
final String imported = StreamUtil.readTextFrom(reader);
imports.add(imported);
}
}
@Override
public void addAttribute(String key, String nsPrefix, String nsURI, String value, String type) throws Exception {
if (rootTagProcessed.get())
return;
if (key != null && value != null && StringUtil.isEmpty(nsPrefix)) {
attributes.put(key, value);
}
}
@Override
public void elementAttributesProcessed(String name, String nsPrefix, String nsURI) throws Exception {
rootTagProcessed.set(true);
}
@Override
public void startElement(String name, String nsPrefix, String nsURI, String systemID, int lineNr) throws Exception {
if (rootTagProcessed.get())
return;
for (String imported : imports) {
if (imported.equals(name) || imported.endsWith("." + name)) {
refQualifiedName.set(imported);
break;
}
if (imported.endsWith(".*")) {
String className = imported.substring(0, imported.length() - 1) + name;
if (psiClassExists.test(className)) {
refQualifiedName.set(className);
break;
}
}
}
}
});
final String qualifiedName = refQualifiedName.get();
if (!StringUtil.isEmpty(qualifiedName)) {
final BuiltinComponent previous = components.get(qualifiedName);
if (previous == null || previous.getAttributes().size() < attributes.size()) {
components.put(qualifiedName, new BuiltinComponent(attributes));
}
}
}
return components;
}
Aggregations