Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
26,400
ResourceBundleWithCachedFiles (@NotNull final String baseName, @Nullable final String extension, @NotNull final PsiDirectory baseDirectory) { final ResourceBundleManager bundleBaseNameManager = ResourceBundleManager.getInstance(baseDirectory.getProject()); final List<PropertiesFile> bundleFiles = Stream .of(baseDirectory.isValid() ? baseDirectory.getFiles() : PsiFile.EMPTY_ARRAY) .filter(f -> isPropertiesFile(f) && Comparing.strEqual(f.getVirtualFile().getExtension(), extension) && Objects.equals(bundleBaseNameManager.getBaseName(f), baseName)) .map(PropertiesImplUtil::getPropertiesFile) .collect(Collectors.toList()); if (bundleFiles.isEmpty()) return null; return new ResourceBundleWithCachedFiles(new ResourceBundleImpl(bundleFiles.get(0)), bundleFiles); }
getResourceBundle
26,401
boolean (@Nullable PsiFile file) { return getPropertiesFile(file) != null; }
isPropertiesFile
26,402
PropertiesFile (@NotNull VirtualFile file, @NotNull Project project) { return getPropertiesFile(PsiManager.getInstance(project).findFile(file)); }
getPropertiesFile
26,403
PropertiesFile (@Nullable PsiFile file) { if (!canBePropertyFile(file)) return null; return file instanceof PropertiesFile ? (PropertiesFile)file : XmlPropertiesFileImpl.getPropertiesFile(file); }
getPropertiesFile
26,404
boolean (PsiFile file) { return file instanceof PropertiesFile || file instanceof XmlFile && file.getFileType() == XmlFileType.INSTANCE; }
canBePropertyFile
26,405
PropertiesFile (@Nullable PsiElement element) { if (!(element instanceof PsiFile)) return null; return getPropertiesFile((PsiFile)element); }
getPropertiesFile
26,406
List<IProperty> (@NotNull final Project project, @NotNull final String key) { GlobalSearchScope scope = GlobalSearchScope.allScope(project); List<IProperty> properties = new ArrayList<>(PropertyKeyIndex.getInstance().getProperties(key, project, scope)); final Set<VirtualFile> files = new HashSet<>(); FileBasedIndex.getInstance().processValues(XmlPropertiesIndex.NAME, new XmlPropertiesIndex.Key(key), null, (file, value) -> { if (files.add(file)) { PsiFile psiFile = PsiManager.getInstance(project).findFile(file); if (psiFile != null) { PropertiesFile propertiesFile = XmlPropertiesFileImpl.getPropertiesFile(psiFile); if (propertiesFile != null) { properties.addAll(propertiesFile.findPropertiesByKey(key)); } } } return true; }, scope); return properties; }
findPropertiesByKey
26,407
ResourceBundle (final @NotNull String url, final @NotNull Project project) { final int idx = url.lastIndexOf('/'); if (idx == -1) return null; final String baseDirectoryName = url.substring(0, idx); final String baseName = url.substring(idx + 1); final VirtualFile baseDirectoryVirtualFile = VirtualFileManager.getInstance().findFileByUrl(baseDirectoryName); if (baseDirectoryVirtualFile == null) { return null; } final PsiDirectory baseDirectory = PsiManager.getInstance(project).findDirectory(baseDirectoryVirtualFile); if (baseDirectory == null) { return null; } final ResourceBundleManager bundleBaseNameManager = ResourceBundleManager.getInstance(project); for (PsiFile file : baseDirectory.getFiles()) { final PropertiesFile propertiesFile = getPropertiesFile(file); if (propertiesFile == null) continue; final String currBaseName = bundleBaseNameManager.getBaseName(file); if (currBaseName.equals(baseName)) { return getResourceBundle(propertiesFile); } } return null; }
createByUrl
26,408
boolean (final @NotNull Collection<? extends IProperty> properties) { String previousKey = null; for (IProperty property : properties) { final String key = property.getKey(); if (key == null) { return false; } if (previousKey != null && String.CASE_INSENSITIVE_ORDER.compare(previousKey, key) > 0) { return false; } previousKey = key; } return true; }
isAlphaSorted
26,409
IProperty (@Nullable PsiElement element) { if (element instanceof IProperty) { return (IProperty)element; } if (element instanceof PomTargetPsiElement) { final PomTarget target = ((PomTargetPsiElement)element).getTarget(); if (target instanceof XmlProperty) { return (IProperty)target; } } return null; }
getProperty
26,410
ResourceBundle () { return myBundle; }
getBundle
26,411
List<PropertiesFile> () { return myFiles; }
getFiles
26,412
String () { return PropertiesBundle.message("remove.property.intention.text"); }
getFamilyName
26,413
void (@NotNull ActionContext context, @NotNull Property property, @NotNull ModPsiUpdater updater) { property.delete(); }
invoke
26,414
CustomResourceBundle (final CustomResourceBundleState state, final Project project) { List<PropertiesFile> files = ContainerUtil.mapNotNull(state.getFiles(VirtualFileManager.getInstance()), virtualFile -> PropertiesImplUtil.getPropertiesFile(virtualFile, project)); return files.size() < 2 ? null : new CustomResourceBundle(files, state.getBaseName()); }
fromState
26,415
List<PropertiesFile> () { return myFiles; }
getPropertiesFiles
26,416
PropertiesFile () { //noinspection ConstantConditions return ContainerUtil.getFirstItem(myFiles); }
getDefaultPropertiesFile
26,417
String () { return myBaseName; }
getBaseName
26,418
VirtualFile () { VirtualFile baseDir = null; for (PropertiesFile file : myFiles) { final VirtualFile currentBaseDir = file.getContainingFile().getVirtualFile().getParent(); if (baseDir == null) { baseDir = currentBaseDir; } else if (!baseDir.equals(currentBaseDir)) { return null; } } return baseDir; }
getBaseDirectory
26,419
boolean () { for (PropertiesFile file : myFiles) { if (!file.getContainingFile().isValid()) { return false; } } return true; }
isValid
26,420
boolean (final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final CustomResourceBundle resourceBundle = (CustomResourceBundle)o; return resourceBundle.getPropertiesFiles().equals(getPropertiesFiles()) && resourceBundle.getBaseName().equals(getBaseName()); }
equals
26,421
int () { return myFiles.hashCode() * 31 + myBaseName.hashCode(); }
hashCode
26,422
void (@NotNull PsiElement element, @NotNull AnnotationHolder holder) { if (!(element instanceof Property property)) return; PropertiesFile propertiesFile = property.getPropertiesFile(); final String key = property.getUnescapedKey(); if (key == null) return; Collection<IProperty> others = propertiesFile.findPropertiesByKey(key); ASTNode keyNode = ((PropertyImpl)property).getKeyNode(); if (keyNode == null) return; if (others.size() != 1 && EP_NAME.findFirstSafe(suppressor -> suppressor.suppressAnnotationFor(property)) == null) { holder.newAnnotation(HighlightSeverity.ERROR,PropertiesBundle.message("duplicate.property.key.error.message")).range(keyNode) .withFix(PropertiesQuickFixFactory.getInstance().createRemovePropertyFix(property)).create(); } highlightTokens(keyNode, holder, new PropertiesHighlighter()); ASTNode valueNode = ((PropertyImpl)property).getValueNode(); if (valueNode != null) { highlightTokens(valueNode, holder, new PropertiesValueHighlighter()); } }
annotate
26,423
void (final ASTNode node, final AnnotationHolder holder, PropertiesHighlighter highlighter) { Lexer lexer = highlighter.getHighlightingLexer(); final String s = node.getText(); lexer.start(s); while (lexer.getTokenType() != null) { IElementType elementType = lexer.getTokenType(); TextAttributesKey[] keys = highlighter.getTokenHighlights(elementType); for (TextAttributesKey key : keys) { final String displayName = PropertiesComponent.getDisplayName(key); final HighlightSeverity severity = PropertiesComponent.getSeverity(key); if (severity != null && displayName != null) { int start = lexer.getTokenStart() + node.getTextRange().getStartOffset(); int end = lexer.getTokenEnd() + node.getTextRange().getStartOffset(); TextRange textRange = new TextRange(start, end); TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key); AnnotationBuilder builder = holder.newAnnotation(severity, displayName).range(textRange).enforcedTextAttributes(attributes); int startOffset = textRange.getStartOffset(); if (key == PropertiesComponent.PROPERTIES_INVALID_STRING_ESCAPE.getTextAttributesKey()) { builder = builder.withFix(new ModCommandAction() { @Override @NotNull public String getFamilyName() { return PropertiesBundle.message("unescape"); } @Override public @Nullable Presentation getPresentation(@NotNull ActionContext context) { if (!BaseIntentionAction.canModify(context.file())) return null; String text = context.file().getText(); return text.length() > startOffset && text.charAt(startOffset) == '\\' ? Presentation.of(getFamilyName()) : null; } @Override public @NotNull ModCommand perform(@NotNull ActionContext context) { return ModCommand.psiUpdate(context, updater -> { updater.getWritable(context.file()).getViewProvider().getDocument().deleteString(startOffset, startOffset + 1); }); } }); } builder.create(); } } lexer.advance(); } }
highlightTokens
26,424
String () { return PropertiesBundle.message("unescape"); }
getFamilyName
26,425
ModCommand (@NotNull ActionContext context) { return ModCommand.psiUpdate(context, updater -> { updater.getWritable(context.file()).getViewProvider().getDocument().deleteString(startOffset, startOffset + 1); }); }
perform
26,426
List<PropertiesFile> () { return PropertiesImplUtil.getResourceBundleFiles(getDefaultPropertiesFile()); }
getPropertiesFiles
26,427
PropertiesFile () { return Objects.requireNonNull(PropertiesImplUtil.getPropertiesFile(myDefaultPropertiesFile.getElement())); }
getDefaultPropertiesFile
26,428
String () { return ResourceBundleManager.getInstance(getProject()).getBaseName(Objects.requireNonNull(myDefaultPropertiesFile.getElement())); }
getBaseName
26,429
VirtualFile () { return getDefaultPropertiesFile().getVirtualFile().getParent(); }
getBaseDirectory
26,430
boolean () { return myValid && PropertiesImplUtil.getPropertiesFile(myDefaultPropertiesFile.getElement()) != null; }
isValid
26,431
void () { myValid = false; }
invalidate
26,432
boolean (final Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; final ResourceBundleImpl resourceBundle = (ResourceBundleImpl)o; if (!myDefaultPropertiesFile.equals(resourceBundle.myDefaultPropertiesFile)) return false; return true; }
equals
26,433
int () { return myDefaultPropertiesFile.hashCode(); }
hashCode
26,434
String () { return getBaseDirectory() + "/" + getBaseName(); }
getUrl
26,435
String () { return "ResourceBundleImpl:" + getBaseName(); }
toString
26,436
void (@NotNull PsiReferenceRegistrar registrar) { registrar.registerReferenceProvider(psiElement(PropertyValueImpl.class), new PsiReferenceProvider() { @Override public boolean acceptsTarget(@NotNull PsiElement target) { return false; // web references do not point to any real PsiElement } @Override public PsiReference @NotNull [] getReferencesByElement(@NotNull PsiElement element, @NotNull ProcessingContext context) { if (!(element instanceof PropertyValueImpl propertyValue)) return PsiReference.EMPTY_ARRAY; if (!element.textContains(':')) return PsiReference.EMPTY_ARRAY; String textValue = propertyValue.getText(); if (GlobalPathReferenceProvider.isWebReferenceUrl(textValue)) { return new PsiReference[]{new WebReference(element, textValue)}; } return PsiReference.EMPTY_ARRAY; } }, PsiReferenceRegistrar.LOWER_PRIORITY); }
registerReferenceProviders
26,437
boolean (@NotNull PsiElement target) { return false; // web references do not point to any real PsiElement }
acceptsTarget
26,438
void (@NotNull final PsiTreeChangeEvent event) { final PsiElement child = event.getChild(); if (!(child instanceof PsiFile)) { if (child instanceof PsiDirectory) { if (event.getOldParent() instanceof PsiDirectory && event.getNewParent() instanceof PsiDirectory) { final String fromDirUrl = ((PsiDirectory)event.getOldParent()).getVirtualFile().getUrl() + "/"; final NotNullLazyValue<String> toDirUrl = NotNullLazyValue.lazy(() -> { return ((PsiDirectory)event.getNewParent()).getVirtualFile().getUrl() + "/"; }); for (String dissociatedFileUrl : new SmartList<>(myState.getDissociatedFiles())) { if (dissociatedFileUrl.startsWith(fromDirUrl)) { myState.getDissociatedFiles().remove(dissociatedFileUrl); myState.getDissociatedFiles().add(toDirUrl.getValue() + dissociatedFileUrl.substring(fromDirUrl.length())); } } for (CustomResourceBundleState customResourceBundleState : myState.getCustomResourceBundles()) { for (String fileUrl : new SmartList<>(customResourceBundleState.getFileUrls())) { if (fileUrl.startsWith(fromDirUrl)) { customResourceBundleState.getFileUrls().remove(fileUrl); customResourceBundleState.getFileUrls().add(toDirUrl.getValue() + fileUrl.substring(fromDirUrl.length())); } } } } } return; } final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile((PsiFile)child); if (propertiesFile == null) { return; } final String oldParentUrl = getUrl(event.getOldParent()); if (oldParentUrl == null) { return; } final String newParentUrl = getUrl(event.getNewParent()); if (newParentUrl == null) { return; } final NotNullLazyValue<Pair<String, String>> oldAndNewUrls = NotNullLazyValue.lazy(() -> { final String newUrl = propertiesFile.getVirtualFile().getUrl(); return new Pair<>(oldParentUrl + newUrl.substring(newParentUrl.length()), newUrl); }); if (!myState.getDissociatedFiles().isEmpty()) { if (myState.getDissociatedFiles().remove(oldAndNewUrls.getValue().getFirst())) { myState.getDissociatedFiles().add(oldAndNewUrls.getValue().getSecond()); } } for (CustomResourceBundleState customResourceBundleState : myState.getCustomResourceBundles()) { if (customResourceBundleState.getFileUrls().remove(oldAndNewUrls.getValue().getFirst())) { customResourceBundleState.getFileUrls().add(oldAndNewUrls.getValue().getSecond()); break; } } }
childMoved
26,439
String (PsiElement element) { return !(element instanceof PsiDirectory) ? null : ((PsiDirectory)element).getVirtualFile().getUrl(); }
getUrl
26,440
void (@NotNull PsiTreeChangeEvent event) { final PsiElement child = event.getChild(); if (!(child instanceof PsiFile psiFile)) { if (child instanceof PsiDirectory) { final String deletedDirUrl = ((PsiDirectory)child).getVirtualFile().getUrl() + "/"; for (String dissociatedFileUrl : new SmartList<>(myState.getDissociatedFiles())) { if (dissociatedFileUrl.startsWith(deletedDirUrl)) { myState.getDissociatedFiles().remove(dissociatedFileUrl); } } for (CustomResourceBundleState customResourceBundleState : new SmartList<>(myState.getCustomResourceBundles())) { for (String fileUrl : new ArrayList<>(customResourceBundleState.getFileUrls())) { if (fileUrl.startsWith(deletedDirUrl)) { customResourceBundleState.getFileUrls().remove(fileUrl); } } if (customResourceBundleState.getFileUrls().size() < 2) { myState.getCustomResourceBundles().remove(customResourceBundleState); } } } return; } if (!PropertiesImplUtil.canBePropertyFile(psiFile)) return; final VirtualFile virtualFile = psiFile.getVirtualFile(); final NotNullLazyValue<String> url = NotNullLazyValue.lazy(() -> virtualFile.getUrl()); if (!myState.getDissociatedFiles().isEmpty()) { myState.getDissociatedFiles().remove(url.getValue()); } for (CustomResourceBundleState customResourceBundleState : new SmartList<>(myState.getCustomResourceBundles())) { final Set<String> urls = customResourceBundleState.getFileUrls(); if (urls.remove(url.getValue())) { if (urls.size() < 2) { myState.getCustomResourceBundles().remove(customResourceBundleState); } break; } } }
beforeChildRemoval
26,441
void () { }
dispose
26,442
ResourceBundleManager (final Project project) { return project.getService(ResourceBundleManager.class); }
getInstance
26,443
String (final @NotNull PropertiesFile propertiesFile) { return ReadAction.compute(() -> { final PsiDirectory directory = propertiesFile.getParent(); final String packageQualifiedName = PropertiesUtil.getPackageQualifiedName(directory); if (packageQualifiedName == null) { return null; } final StringBuilder qName = new StringBuilder(packageQualifiedName); if (qName.length() > 0) { qName.append("."); } qName.append(getBaseName(propertiesFile.getContainingFile())); return qName.toString(); }); }
getFullName
26,444
String (@NotNull final PsiFile file) { final VirtualFile vFile = file.getVirtualFile(); final CustomResourceBundleState customResourceBundle = getCustomResourceBundleState(vFile); if (customResourceBundle != null) { return customResourceBundle.getBaseName(); } if (isDefaultDissociated(vFile)) { return vFile.getNameWithoutExtension(); } return PropertiesUtil.getDefaultBaseName(file); }
getBaseName
26,445
void (final @NotNull ResourceBundle resourceBundle) { closeResourceBundleEditors(resourceBundle); if (resourceBundle instanceof CustomResourceBundle) { final CustomResourceBundleState state = getCustomResourceBundleState(resourceBundle.getDefaultPropertiesFile().getVirtualFile()); LOG.assertTrue(state != null); myState.getCustomResourceBundles().remove(state); } else { if (EmptyResourceBundle.getInstance() != resourceBundle) { ((ResourceBundleImpl) resourceBundle).invalidate(); } for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { final VirtualFile file = propertiesFile.getContainingFile().getVirtualFile(); myState.getDissociatedFiles().add(file.getUrl()); } } }
dissociateResourceBundle
26,446
void (final @NotNull List<? extends PropertiesFile> propertiesFiles, final String baseName) { if (propertiesFiles.isEmpty()) { throw new IllegalStateException(); } myState.getCustomResourceBundles() .add(new CustomResourceBundleState().addAll(ContainerUtil.map(propertiesFiles, file -> file.getVirtualFile().getUrl())).setBaseName(baseName)); }
combineToResourceBundle
26,447
ResourceBundle (final @NotNull List<? extends PropertiesFile> propertiesFiles, final String baseName) { combineToResourceBundle(propertiesFiles, baseName); return propertiesFiles.get(0).getResourceBundle(); }
combineToResourceBundleAndGet
26,448
CustomResourceBundle (final @NotNull PropertiesFile file) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) { return null; } final CustomResourceBundleState state = getCustomResourceBundleState(virtualFile); return state == null ? null : CustomResourceBundle.fromState(state, file.getProject()); }
getCustomResourceBundle
26,449
boolean (final @NotNull VirtualFile virtualFile) { if (myState.getDissociatedFiles().isEmpty() && myState.getCustomResourceBundles().isEmpty()) { return false; } final String url = virtualFile.getUrl(); return myState.getDissociatedFiles().contains(url) || getCustomResourceBundleState(virtualFile) != null; }
isDefaultDissociated
26,450
CustomResourceBundleState (final @NotNull VirtualFile virtualFile) { if (myState.getCustomResourceBundles().isEmpty()) { return null; } final String url = virtualFile.getUrl(); for (CustomResourceBundleState customResourceBundleState : myState.getCustomResourceBundles()) { if (customResourceBundleState.getFileUrls().contains(url)) { return customResourceBundleState; } } return null; }
getCustomResourceBundleState
26,451
ResourceBundleManagerState () { return myState.isEmpty() ? null : myState; }
getState
26,452
void (@NotNull ResourceBundleManagerState state) { myState = state.removeNonExistentFiles(); }
loadState
26,453
void (@NotNull ResourceBundle resourceBundle) { final FileEditorManager fileEditorManager = FileEditorManager.getInstance(resourceBundle.getProject()); fileEditorManager.closeFile(new ResourceBundleAsVirtualFile(resourceBundle)); for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { fileEditorManager.closeFile(propertiesFile.getVirtualFile()); } }
closeResourceBundleEditors
26,454
String () { return HASH_COMMENT_PREFIX; }
getLineCommentPrefix
26,455
String () { return null; }
getBlockCommentPrefix
26,456
String () { return null; }
getBlockCommentSuffix
26,457
String () { return null; }
getCommentedBlockCommentPrefix
26,458
String () { return null; }
getCommentedBlockCommentSuffix
26,459
CommenterDataHolder (int startLine, int endLine, @NotNull Document document, @NotNull PsiFile file) { return null; }
createLineCommentingState
26,460
CommenterDataHolder (int selectionStart, int selectionEnd, @NotNull Document document, @NotNull PsiFile file) { return null; }
createBlockCommentingState
26,461
void (int line, int offset, @NotNull Document document, @NotNull CommenterDataHolder data) { document.insertString(offset, HASH_COMMENT_PREFIX); }
commentLine
26,462
void (int line, int offset, @NotNull Document document, @NotNull CommenterDataHolder data) { document.deleteString(offset, offset + HASH_COMMENT_PREFIX.length()); }
uncommentLine
26,463
boolean (int line, int offset, @NotNull Document document, @NotNull CommenterDataHolder data) { return CharArrayUtil.regionMatches(document.getCharsSequence(), offset, HASH_COMMENT_PREFIX) || CharArrayUtil.regionMatches(document.getCharsSequence(), offset, EXCLAMATION_COMMENT_PREFIX); }
isLineCommented
26,464
String (int line, @NotNull Document document, @NotNull CommenterDataHolder data) { return HASH_COMMENT_PREFIX; }
getCommentPrefix
26,465
TextRange (int selectionStart, int selectionEnd, @NotNull Document document, @NotNull CommenterDataHolder data) { throw new UnsupportedOperationException(); }
getBlockCommentRange
26,466
String (int selectionStart, @NotNull Document document, @NotNull CommenterDataHolder data) { return getBlockCommentPrefix(); }
getBlockCommentPrefix
26,467
String (int selectionEnd, @NotNull Document document, @NotNull CommenterDataHolder data) { return getBlockCommentSuffix(); }
getBlockCommentSuffix
26,468
void (int startOffset, int endOffset, Document document, CommenterDataHolder data) { throw new UnsupportedOperationException(); }
uncommentBlockComment
26,469
TextRange (int startOffset, int endOffset, Document document, CommenterDataHolder data) { throw new UnsupportedOperationException(); }
insertBlockComment
26,470
IElementType () { return PropertiesTokenTypes.END_OF_LINE_COMMENT; }
getLineCommentTokenType
26,471
IElementType () { return null; }
getBlockCommentTokenType
26,472
IElementType () { return null; }
getDocumentationCommentTokenType
26,473
String () { return null; }
getDocumentationCommentPrefix
26,474
String () { return null; }
getDocumentationCommentLinePrefix
26,475
String () { return null; }
getDocumentationCommentSuffix
26,476
boolean (PsiComment element) { return false; }
isDocumentationComment
26,477
String () { return PropertiesBundle.message("properties.files.inspection.group.display.name"); }
getGroupDisplayName
26,478
String () { return myBaseName; }
getBaseName
26,479
Set<String> () { return myFileUrls; }
getFileUrls
26,480
List<VirtualFile> (@NotNull final VirtualFileManager manager) { return ContainerUtil.mapNotNull(getFileUrls(), url -> manager.findFileByUrl(url)); }
getFiles
26,481
CustomResourceBundleState (final VirtualFileManager virtualFileManager) { final List<String> existentFiles = ContainerUtil.filter(myFileUrls, url -> virtualFileManager.findFileByUrl(url) != null); if (existentFiles.isEmpty()) { return null; } final CustomResourceBundleState customResourceBundleState = new CustomResourceBundleState(); customResourceBundleState.myFileUrls.addAll(existentFiles); customResourceBundleState.myBaseName = myBaseName; return customResourceBundleState; }
removeNonExistentFiles
26,482
CustomResourceBundleState (final Collection<String> urls) { myFileUrls.addAll(urls); return this; }
addAll
26,483
CustomResourceBundleState (String baseName) { myBaseName = baseName; return this; }
setBaseName
26,484
String (final PsiFile psiFile) { PsiDirectory directory = ReadAction.compute(() -> psiFile.getParent()); if (directory == null) return null; String packageQualifiedName = PropertiesUtil.getPackageQualifiedName(directory); if (packageQualifiedName == null) return null; StringBuilder qName = new StringBuilder(packageQualifiedName); if (qName.length() > 0) qName.append("."); qName.append(ResourceBundleManager.getInstance(psiFile.getProject()).getBaseName(psiFile)); return qName.toString(); }
evaluateBundleName
26,485
String (final PsiFile psiFile) { return ResourceBundleManager.getInstance(psiFile.getProject()).getBaseName(psiFile); }
evaluateBundleName
26,486
TextRange (@NotNull PropertyImpl element) { ASTNode valueNode = element.getValueNode(); if (valueNode == null) return TextRange.from(element.getTextLength(), 0); TextRange range = valueNode.getTextRange(); return TextRange.from(range.getStartOffset() - element.getTextRange().getStartOffset(), range.getLength()); }
getRangeInElement
26,487
PropertiesReferenceManager (@NotNull Project project) { return project.getService(PropertiesReferenceManager.class); }
getInstance
26,488
List<PropertiesFile> (@NotNull Module module, @NotNull String bundleName) { ConcurrentMap<String, List<PropertiesFile>> map = CachedValuesManager.getManager(module.getProject()).getCachedValue(module, () -> { ConcurrentMap<String, List<PropertiesFile>> factoryMap = ConcurrentFactoryMap.createMap( bundleName1 -> findPropertiesFiles(GlobalSearchScope.moduleWithDependenciesAndLibrariesScope(module), bundleName1, BundleNameEvaluator.DEFAULT)); return CachedValueProvider.Result.create(factoryMap, PsiModificationTracker.MODIFICATION_COUNT); }); return map.get(bundleName); }
findPropertiesFiles
26,489
List<PropertiesFile> (@NotNull GlobalSearchScope searchScope, @NotNull String bundleName, @NotNull BundleNameEvaluator bundleNameEvaluator) { final ArrayList<PropertiesFile> result = new ArrayList<>(); processPropertiesFiles(searchScope, (baseName, propertiesFile) -> { if (baseName.equals(bundleName)) { result.add(propertiesFile); } return true; }, bundleNameEvaluator); return result; }
findPropertiesFiles
26,490
PropertiesFile (@NotNull Module module, @NotNull String bundleName, @Nullable Locale locale) { List<PropertiesFile> propFiles = findPropertiesFiles(module, bundleName); if (locale != null) { for(PropertiesFile propFile: propFiles) { if (propFile.getLocale().equals(locale)) { return propFile; } } } // fallback to default locale for(PropertiesFile propFile: propFiles) { if (propFile.getLocale().getLanguage().length() == 0 || propFile.getLocale().equals(Locale.getDefault())) { return propFile; } } // fallback to any file if (!propFiles.isEmpty()) { return propFiles.get(0); } return null; }
findPropertiesFile
26,491
boolean (@NotNull final PropertiesFileProcessor processor) { return processPropertiesFiles(GlobalSearchScope.allScope(myPsiManager.getProject()), processor, BundleNameEvaluator.DEFAULT); }
processAllPropertiesFiles
26,492
boolean (@NotNull final GlobalSearchScope searchScope, @NotNull final PropertiesFileProcessor processor, @NotNull final BundleNameEvaluator evaluator) { for(VirtualFile file:FileTypeIndex.getFiles(PropertiesFileType.INSTANCE, searchScope)) { if (!processFile(file, evaluator, processor)) return false; } if (!myDumbService.isDumb()) { for(VirtualFile file:FileBasedIndex.getInstance().getContainingFiles(XmlPropertiesIndex.NAME, XmlPropertiesIndex.MARKER_KEY, searchScope)) { if (!processFile(file, evaluator, processor)) return false; } } return true; }
processPropertiesFiles
26,493
boolean (@NotNull VirtualFile file, @NotNull BundleNameEvaluator evaluator, @NotNull PropertiesFileProcessor processor) { final PsiFile psiFile = myPsiManager.findFile(file); PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(psiFile); if (propertiesFile != null) { final String qName = evaluator.evaluateBundleName(psiFile); if (qName != null) { if (!processor.process(qName, propertiesFile)) return false; } } return true; }
processFile
26,494
PropertiesQuickFixFactory () { return ApplicationManager.getApplication().getService(PropertiesQuickFixFactory.class); }
getInstance
26,495
List<PropertiesFile> () { if (myBundleName == null) { return null; } return retrievePropertyFilesByBundleName(myBundleName, myElement); }
getPropertiesFiles
26,496
List<PropertiesFile> (String bundleName, PsiElement element) { return I18nUtil.propertiesFilesByBundleName(bundleName, element); }
retrievePropertyFilesByBundleName
26,497
List<PropertiesFile> (@Nullable String resourceBundleName, @NotNull PsiElement context) { if (resourceBundleName == null) return Collections.emptyList(); PsiFile containingFile = context.getContainingFile(); PsiElement containingFileContext = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile); if (containingFileContext != null) containingFile = containingFileContext.getContainingFile(); VirtualFile virtualFile = containingFile.getVirtualFile(); if (virtualFile == null) { virtualFile = containingFile.getOriginalFile().getVirtualFile(); } if (virtualFile != null) { Project project = containingFile.getProject(); final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(virtualFile); if (module != null) { PropertiesReferenceManager refManager = PropertiesReferenceManager.getInstance(project); return refManager.findPropertiesFiles(module, resourceBundleName); } } return Collections.emptyList(); }
propertiesFilesByBundleName
26,498
List<String> (@NotNull Project project, @NotNull Set<? extends Module> contextModules) { List<String> relevantPaths = new ArrayList<>(); List<String> otherPaths = new ArrayList<>(); final ProjectFileIndex projectFileIndex = ProjectRootManager.getInstance(project).getFileIndex(); PropertiesFileProcessor processor = (baseName, propertiesFile) -> { if (propertiesFile instanceof XmlPropertiesFile) { return true; } VirtualFile virtualFile = propertiesFile.getVirtualFile(); if (projectFileIndex.isInContent(virtualFile)) { String path = FileUtil.toSystemDependentName(virtualFile.getPath()); Module module = ModuleUtilCore.findModuleForFile(virtualFile, project); boolean relevant = contextModules.contains(module); (relevant ? relevantPaths : otherPaths).add(path); } return true; }; if (contextModules.isEmpty()) { PropertiesReferenceManager.getInstance(project).processAllPropertiesFiles(processor); } else { GlobalSearchScope scope = GlobalSearchScope.union(ContainerUtil.map(contextModules, Module::getModuleWithDependenciesScope)); PropertiesReferenceManager.getInstance(project).processPropertiesFiles(scope, processor, BundleNameEvaluator.DEFAULT); } Collections.sort(relevantPaths); Collections.sort(otherPaths); relevantPaths.addAll(otherPaths); return relevantPaths; }
defaultSuggestPropertiesFiles
26,499
void (PropertyReferenceBase propertyReference, final PropertiesFile propertiesFile, final Set<Object> variants) { if (propertiesFile == null) return; VirtualFile virtualFile = propertiesFile.getVirtualFile(); if (virtualFile == null || !ProjectRootManager.getInstance(propertiesFile.getProject()).getFileIndex().isInContent(virtualFile)) return; List<? extends IProperty> properties = propertiesFile.getProperties(); for (IProperty property : properties) { propertyReference.addKey(property, variants); } }
addVariantsFromFile