use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class CommonCodeStyleSettingsManager method writeExternal.
public void writeExternal(@NotNull Element element) throws WriteExternalException {
synchronized (this) {
if (myCommonSettingsMap == null) {
return;
}
final Map<String, Language> idToLang = new THashMap<>();
for (Language language : myCommonSettingsMap.keySet()) {
idToLang.put(language.getID(), language);
}
String[] languages = ArrayUtil.toStringArray(ContainerUtil.union(myUnknownSettingsMap.keySet(), idToLang.keySet()));
Arrays.sort(languages);
for (String id : languages) {
final Language language = idToLang.get(id);
if (language != null) {
final CommonCodeStyleSettings commonSettings = myCommonSettingsMap.get(language);
Element commonSettingsElement = new Element(COMMON_SETTINGS_TAG);
commonSettings.writeExternal(commonSettingsElement);
commonSettingsElement.setAttribute(LANGUAGE_ATTR, language.getID());
if (!commonSettingsElement.getChildren().isEmpty()) {
element.addContent(commonSettingsElement);
}
} else {
final Content unknown = myUnknownSettingsMap.get(id);
if (unknown != null) {
element.addContent(unknown.detach());
}
}
}
}
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class UpdateFoldRegionsOperation method run.
@Override
public void run() {
EditorFoldingInfo info = EditorFoldingInfo.get(myEditor);
FoldingModelEx foldingModel = (FoldingModelEx) myEditor.getFoldingModel();
Map<TextRange, Boolean> rangeToExpandStatusMap = new THashMap<>();
// FoldingUpdate caches instances of our object, so they must be immutable.
FoldingUpdate.FoldingMap elementsToFold = new FoldingUpdate.FoldingMap(myElementsToFoldMap);
removeInvalidRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap);
Map<FoldRegion, Boolean> shouldExpand = new THashMap<>();
Map<FoldingGroup, Boolean> groupExpand = new THashMap<>();
List<FoldRegion> newRegions = addNewRegions(info, foldingModel, elementsToFold, rangeToExpandStatusMap, shouldExpand, groupExpand);
applyExpandStatus(newRegions, shouldExpand, groupExpand);
foldingModel.clearDocumentRangesModificationStatus();
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class GenericsHighlightUtil method checkUnrelatedConcrete.
static HighlightInfo checkUnrelatedConcrete(@NotNull PsiClass psiClass, @NotNull PsiIdentifier classIdentifier) {
final PsiClass superClass = psiClass.getSuperClass();
if (superClass != null && superClass.hasTypeParameters()) {
final Collection<HierarchicalMethodSignature> visibleSignatures = superClass.getVisibleSignatures();
final Map<MethodSignature, PsiMethod> overrideEquivalent = new THashMap<>(MethodSignatureUtil.METHOD_PARAMETERS_ERASURE_EQUALITY);
for (HierarchicalMethodSignature hms : visibleSignatures) {
final PsiMethod method = hms.getMethod();
if (method.isConstructor())
continue;
if (method.hasModifierProperty(PsiModifier.ABSTRACT) || method.hasModifierProperty(PsiModifier.DEFAULT))
continue;
if (psiClass.findMethodsBySignature(method, false).length > 0)
continue;
final PsiClass containingClass = method.getContainingClass();
if (containingClass == null)
continue;
final PsiSubstitutor containingClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(containingClass, psiClass, PsiSubstitutor.EMPTY);
final PsiSubstitutor finalSubstitutor = PsiSuperMethodUtil.obtainFinalSubstitutor(containingClass, containingClassSubstitutor, hms.getSubstitutor(), false);
final MethodSignatureBackedByPsiMethod signature = MethodSignatureBackedByPsiMethod.create(method, finalSubstitutor, false);
final PsiMethod foundMethod = overrideEquivalent.get(signature);
PsiClass foundMethodContainingClass;
if (foundMethod != null && !foundMethod.hasModifierProperty(PsiModifier.ABSTRACT) && !foundMethod.hasModifierProperty(PsiModifier.DEFAULT) && (foundMethodContainingClass = foundMethod.getContainingClass()) != null) {
final String description = "Methods " + JavaHighlightUtil.formatMethod(foundMethod) + " from " + HighlightUtil.formatClass(foundMethodContainingClass) + " and " + JavaHighlightUtil.formatMethod(method) + " from " + HighlightUtil.formatClass(containingClass) + " are inherited with the same signature";
final HighlightInfo info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(classIdentifier).descriptionAndTooltip(description).create();
//todo override fix
return info;
}
overrideEquivalent.put(signature, method);
}
}
return null;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class JavaBuilder method buildOutputDirectoriesMap.
private static Map<File, Set<File>> buildOutputDirectoriesMap(CompileContext context, ModuleChunk chunk) {
final Map<File, Set<File>> map = new THashMap<>(FileUtil.FILE_HASHING_STRATEGY);
for (ModuleBuildTarget target : chunk.getTargets()) {
final File outputDir = target.getOutputDir();
if (outputDir == null) {
continue;
}
final Set<File> roots = new THashSet<>(FileUtil.FILE_HASHING_STRATEGY);
for (JavaSourceRootDescriptor descriptor : context.getProjectDescriptor().getBuildRootIndex().getTargetRoots(target, context)) {
roots.add(descriptor.root);
}
map.put(outputDir, roots);
}
return map;
}
use of gnu.trove.THashMap in project intellij-community by JetBrains.
the class CompilerEncodingConfiguration method computeModuleCharsetMap.
private Map<JpsModule, Set<String>> computeModuleCharsetMap() {
final Map<JpsModule, Set<String>> map = new THashMap<>();
final Iterable<JavaBuilderExtension> builderExtensions = JpsServiceManager.getInstance().getExtensions(JavaBuilderExtension.class);
for (Map.Entry<String, String> entry : myUrlToCharset.entrySet()) {
final String fileUrl = entry.getKey();
final String charset = entry.getValue();
File file = JpsPathUtil.urlToFile(fileUrl);
if (charset == null || (!file.isDirectory() && !shouldHonorEncodingForCompilation(builderExtensions, file))) {
continue;
}
final JavaSourceRootDescriptor rootDescriptor = myRootsIndex.findJavaRootDescriptor(null, file);
if (rootDescriptor == null) {
continue;
}
final JpsModule module = rootDescriptor.target.getModule();
Set<String> set = map.get(module);
if (set == null) {
set = new LinkedHashSet<>();
map.put(module, set);
// need to search parents only once because
// file parent's charset, if explicitly defined, has higher priority than the charset assigned to individual files
// we deliberately check parents until the source roots
final File sourceRoot = rootDescriptor.root;
File current = FileUtilRt.getParentFile(file);
String parentCharset = null;
while (current != null) {
final String currentCharset = lookupCharsetMap(current);
if (currentCharset != null) {
parentCharset = currentCharset;
}
if (FileUtil.filesEqual(current, sourceRoot)) {
break;
}
current = FileUtilRt.getParentFile(current);
}
if (parentCharset != null) {
set.add(parentCharset);
}
}
set.add(charset);
}
for (JpsModule module : myJpsModel.getProject().getModules()) {
for (JpsModuleSourceRoot srcRoot : module.getSourceRoots()) {
final String encoding = getEncoding(srcRoot.getFile());
if (encoding != null) {
Set<String> charsets = map.get(module);
if (charsets == null) {
charsets = new LinkedHashSet<>();
map.put(module, charsets);
}
charsets.add(encoding);
}
}
}
return map;
}
Aggregations