Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
27,200
PsiDirectory (ResourceBundle resourceBundle) { PsiDirectory containingDirectory = null; for (PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { if (containingDirectory == null) { containingDirectory = propertiesFile.getContainingFile().getContainingDirectory(); } else if (!containingDirectory.isEquivalentTo(propertiesFile.getContainingFile().getContainingDirectory())) { return null; } } LOG.assertTrue(containingDirectory != null); return containingDirectory; }
getResourceBundlePlacementDirectory
27,201
String () { return PropertiesBundle.message("create.resource.bundle.dialog.error"); }
getErrorTitle
27,202
String (@NotNull PsiDirectory directory, @NotNull String newName) { return PropertiesBundle.message("create.resource.bundle.dialog.action.name", newName); }
getActionName
27,203
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
27,204
void (@NotNull AnActionEvent e) { ResourceBundle resourceBundle = getResourceBundle(e); e.getPresentation().setEnabledAndVisible(resourceBundle != null && CreateResourceBundleDialogComponent.getResourceBundlePlacementDirectory(resourceBundle) != null); }
update
27,205
void (@NotNull AnActionEvent e) { final ResourceBundle resourceBundle = getResourceBundle(e); if (resourceBundle == null) return; Project project = e.getProject(); if (project == null) return; new CreateResourceBundleDialogComponent.Dialog(project, null, resourceBundle).show(); }
actionPerformed
27,206
ResourceBundle (@NotNull AnActionEvent e) { final Navigatable[] data = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY); if (data == null || data.length != 1) return null; if (!(data[0] instanceof ResourceBundleAwareNode)) return null; return ((ResourceBundleAwareNode)data[0]).getResourceBundle(); }
getResourceBundle
27,207
FormattingModel (@NotNull FormattingContext formattingContext) { final ASTNode root = TreeUtil.getFileElement((TreeElement)SourceTreeToPsiMap.psiElementToTree(formattingContext.getPsiElement())); PsiFile containingFile = formattingContext.getContainingFile(); final FormattingDocumentModelImpl documentModel = FormattingDocumentModelImpl.createOn(containingFile); return new PsiBasedFormattingModel(containingFile, new PropertiesRootBlock(root, formattingContext.getCodeStyleSettings()), documentModel); }
createModel
27,208
PsiBasedStripTrailingSpacesFilter (@NotNull Document document) { return new PsiBasedStripTrailingSpacesFilter(document) { @Override protected void process(@NotNull PsiFile psiFile) { new PsiRecursiveElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof PropertyImpl) { final ASTNode valueNode = ((PropertyImpl)element).getValueNode(); if (valueNode != null) { disableRange(valueNode.getTextRange(), true); } } super.visitElement(element); } }.visitElement(psiFile); } }; }
createFilter
27,209
void (@NotNull PsiFile psiFile) { new PsiRecursiveElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof PropertyImpl) { final ASTNode valueNode = ((PropertyImpl)element).getValueNode(); if (valueNode != null) { disableRange(valueNode.getTextRange(), true); } } super.visitElement(element); } }.visitElement(psiFile); }
process
27,210
void (@NotNull PsiElement element) { if (element instanceof PropertyImpl) { final ASTNode valueNode = ((PropertyImpl)element).getValueNode(); if (valueNode != null) { disableRange(valueNode.getTextRange(), true); } } super.visitElement(element); }
visitElement
27,211
boolean (@NotNull Language language) { return language.is(PropertiesLanguage.INSTANCE); }
isApplicableTo
27,212
List<Block> () { return Collections.emptyList(); }
buildChildren
27,213
Spacing (@Nullable Block child1, @NotNull Block child2) { return null; }
getSpacing
27,214
boolean () { return true; }
isLeaf
27,215
Indent () { return Indent.getAbsoluteNoneIndent(); }
getIndent
27,216
List<Block> () { final List<Block> result = new ArrayList<>(); ASTNode child = myNode.getFirstChildNode(); while (child != null) { if (!(child instanceof PsiWhiteSpace)) { if (child.getElementType() == PropertiesElementTypes.PROPERTIES_LIST) { ASTNode propertyNode = child.getFirstChildNode(); while (propertyNode != null) { if (propertyNode.getElementType() == PropertiesElementTypes.PROPERTY) { collectPropertyBlock(propertyNode, result); } else if (PropertiesTokenTypes.END_OF_LINE_COMMENT.equals(propertyNode.getElementType()) || PropertiesTokenTypes.BAD_CHARACTER.equals(propertyNode.getElementType())) { result.add(new PropertyBlock(propertyNode, null)); } propertyNode = propertyNode.getTreeNext(); } } else if (PropertiesTokenTypes.BAD_CHARACTER.equals(child.getElementType())) { result.add(new PropertyBlock(child, null)); } } if (PropertiesTokenTypes.END_OF_LINE_COMMENT.equals(child.getElementType())) { result.add(new PropertyBlock(child, null)); } child = child.getTreeNext(); } return result; }
buildChildren
27,217
void (ASTNode propertyNode, List<? super Block> collector) { final ASTNode[] nonWhiteSpaces = propertyNode.getChildren(TokenSet.create(PropertiesTokenTypes.KEY_CHARACTERS, PropertiesTokenTypes.KEY_VALUE_SEPARATOR, PropertiesTokenTypes.VALUE_CHARACTERS)); final Alignment alignment = mySettings.getCommonSettings(PropertiesLanguage.INSTANCE).ALIGN_GROUP_FIELD_DECLARATIONS ? mySeparatorAlignment : null; boolean hasKVSeparator = false; for (ASTNode node : nonWhiteSpaces) { if (node instanceof PropertyKeyImpl) { collector.add(new PropertyBlock(node, null)); } else if (PropertiesTokenTypes.KEY_VALUE_SEPARATOR.equals(node.getElementType())) { collector.add(new PropertyBlock(node, alignment)); hasKVSeparator = true; } else if (node instanceof PropertyValueImpl) { if (hasKVSeparator) { collector.add(new PropertyBlock(node, null)); } else { collector.add(new PropertyBlock(node, alignment)); } } } }
collectPropertyBlock
27,218
Spacing (@Nullable Block child1, @NotNull Block child2) { if (child1 == null) { return null; } return mySettings.getCustomSettings(PropertiesCodeStyleSettings.class).SPACES_AROUND_KEY_VALUE_DELIMITER && (isSeparator(child1) || isSeparator(child2)) || isKeyValue(child1, child2) ? Spacing.createSpacing(1, 1, 0, true, 0) : Spacing.createSpacing(0, 0, 0, true, mySettings.getCustomSettings(PropertiesCodeStyleSettings.class).KEEP_BLANK_LINES ? 999 : 0); }
getSpacing
27,219
boolean (Block maybeKey, Block maybeValue) { if (!(maybeKey instanceof PropertyBlock) || !PropertiesTokenTypes.KEY_CHARACTERS.equals(((PropertyBlock)maybeKey).getNode().getElementType())) { return false; } return maybeValue instanceof PropertyBlock && PropertiesTokenTypes.VALUE_CHARACTERS.equals(((PropertyBlock)maybeValue).getNode().getElementType()); }
isKeyValue
27,220
boolean (Block block) { return block instanceof PropertyBlock && PropertiesTokenTypes.KEY_VALUE_SEPARATOR.equals(((PropertyBlock)block).getNode().getElementType()); }
isSeparator
27,221
boolean () { return false; }
isLeaf
27,222
StructureViewBuilder (@NotNull final PsiFile psiFile) { PropertiesFileImpl file = (PropertiesFileImpl)psiFile; String separator = PropertiesSeparatorManager.getInstance(file.getProject()).getSeparator(file.getResourceBundle()); return new StructureViewBuilder() { @Override @NotNull public StructureView createStructureView(FileEditor fileEditor, @NotNull Project project) { return new PropertiesFileStructureViewComponent(project, file, fileEditor, separator); } }; }
getStructureViewBuilder
27,223
StructureView (FileEditor fileEditor, @NotNull Project project) { return new PropertiesFileStructureViewComponent(project, file, fileEditor, separator); }
createStructureView
27,224
boolean (@NotNull TemplateActionContext templateActionContext) { final PsiFile file = templateActionContext.getFile(); return file instanceof PropertiesFile && !(file.findElementAt(templateActionContext.getStartOffset()) instanceof PsiWhiteSpace); }
isInContext
27,225
Tokenizer (PsiElement element) { if (element instanceof PropertyValueImpl) { return myPropertyValueTokenizer; } if (element instanceof PropertyKeyImpl) { return myPropertyTokenizer; } if (element instanceof Property) { return EMPTY_TOKENIZER; } return super.getTokenizer(element); }
getTokenizer
27,226
String () { return PropertiesBundle.message("copy.property.value.to.clipboard.intention.family.name"); }
getFamilyName
27,227
ModCommand (@NotNull ActionContext context) { final Property property = CopyPropertyValueToClipboardIntention.getProperty(context); if (property == null) return ModCommand.nop(); final String value = property.getUnescapedValue(); if (value == null) return ModCommand.nop(); return ModCommand.copyToClipboard(value); }
perform
27,228
String () { return PropertiesBundle.message("copy.property.key.to.clipboard.intention.family.name"); }
getFamilyName
27,229
ModCommand (@NotNull ActionContext context) { final Property property = CopyPropertyValueToClipboardIntention.getProperty(context); if (property == null) return ModCommand.nop(); final String key = property.getUnescapedKey(); if (key == null) return ModCommand.nop(); return ModCommand.copyToClipboard(key); }
perform
27,230
PsiElement (@NotNull PsiElement element) { return null; }
adjustElementToCopy
27,231
String (@NotNull PsiElement element) { return element instanceof Property ? ((Property)element).getKey() : null; }
getQualifiedName
27,232
PsiElement (@NotNull String fqn, @NotNull Project project) { return null; }
qualifiedNameToElement
27,233
boolean (final Object element, final VirtualFile vFile) { if (element instanceof ResourceBundle bundle) { final List<PropertiesFile> propertiesFiles = bundle.getPropertiesFiles(); for (PropertiesFile file : propertiesFiles) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile == null) continue; if (vFile.getPath().equals(virtualFile.getPath())) { return true; } } } return false; }
elementContainsFile
27,234
int (final Object element, final boolean isSortByType) { return -1; }
getElementWeight
27,235
String (final Object element) { return null; }
getElementLocation
27,236
boolean (final Object element) { if (element instanceof ResourceBundle resourceBundle) { List<PropertiesFile> propertiesFiles = resourceBundle.getPropertiesFiles(); if (propertiesFiles.size() == 1) { //todo result.add(new PsiFileNode(myProject, propertiesFiles.iterator().next(), this)); return true; } } return false; }
isInvalidElement
27,237
String () { return "resource_bundle"; }
getFavoriteTypeId
27,238
String (final Object element) { if (element instanceof ResourceBundleImpl) { return ((ResourceBundleImpl)element).getUrl(); } else if (element instanceof PsiFile[] files) { ResourceBundle bundle = null; for (PsiFile file : files) { PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(file); if (propertiesFile == null) return null; ResourceBundle currentBundle = propertiesFile.getResourceBundle(); if (bundle == null) { bundle = currentBundle; } else if (!PsiManager.getInstance(bundle.getProject()).areElementsEquivalent(bundle.getDefaultPropertiesFile().getContainingFile(), currentBundle.getDefaultPropertiesFile().getContainingFile())) { return null; } } return getElementUrl(bundle); } return null; }
getElementUrl
27,239
String (final Object element) { return null; }
getElementModuleName
27,240
Object[] (final Project project, final String url, final String moduleName) { return new Object[]{PropertiesImplUtil.createByUrl(url, project)}; }
createPathFromUrl
27,241
CodeStyleConfigurable (@NotNull CodeStyleSettings baseSettings, @NotNull CodeStyleSettings modelSettings) { return new CodeStyleAbstractConfigurable(baseSettings, modelSettings, PropertiesBundle.message("properties.files.code.style.node.title")) { @Override public String getHelpTopic() { return "reference.settingsdialog.codestyle.properties"; } @Override protected @NotNull CodeStyleAbstractPanel createPanel(@NotNull CodeStyleSettings settings) { return new PropertiesCodeStyleSettingsPanel(settings); } }; }
createConfigurable
27,242
String () { return "reference.settingsdialog.codestyle.properties"; }
getHelpTopic
27,243
CodeStyleAbstractPanel (@NotNull CodeStyleSettings settings) { return new PropertiesCodeStyleSettingsPanel(settings); }
createPanel
27,244
CustomCodeStyleSettings (@NotNull CodeStyleSettings settings) { return new PropertiesCodeStyleSettings(settings); }
createCustomSettings
27,245
Language () { return PropertiesLanguage.INSTANCE; }
getLanguage
27,246
void (@NotNull CodeStyleSettingsCustomizable consumer, @NotNull SettingsType settingsType) { consumer.showStandardOptions("ALIGN_GROUP_FIELD_DECLARATIONS"); consumer.showCustomOption(PropertiesCodeStyleSettings.class, "SPACES_AROUND_KEY_VALUE_DELIMITER", PropertiesBundle.message("insert.space.around.key.value.delimiter.code.style.settings.name"), null); consumer.showCustomOption(PropertiesCodeStyleSettings.class, "KEY_VALUE_DELIMITER_CODE", PropertiesBundle.message("key.value.delimiter.code.style.settings.name"), null, new String[]{"=", ":", PropertiesBundle.message("whitespace.symbol.delimeter.combobox.presentation")}, new int[]{0, 1, 2}); consumer.showCustomOption(PropertiesCodeStyleSettings.class, "KEEP_BLANK_LINES", PropertiesBundle.message("keep.blank.lines.code.style.setting.name"), null); }
customizeSettings
27,247
String (@NotNull SettingsType settingsType) { return """ key1=value some_key=some_value #commentaries last.key=some text here"""; }
getCodeSample
27,248
CodeStyleFieldAccessor (@NotNull Object codeStyleObject, @NotNull Field field) { if (codeStyleObject instanceof PropertiesCodeStyleSettings) { if ("KEY_VALUE_DELIMITER_CODE".equals(field.getName())) { return new MagicIntegerConstAccessor( codeStyleObject, field, new int[] {0, 1, 2}, new String[] {"equals", "colon", "space"} ); } } return super.getAccessor(codeStyleObject, field); }
getAccessor
27,249
void () { addOption("ALIGN_GROUP_FIELD_DECLARATIONS", PropertiesBundle.message("align.properties.in.column.code.style.option")); }
initTables
27,250
Language () { return PropertiesLanguage.INSTANCE; }
getDefaultLanguage
27,251
boolean (PsiElement element) { return element instanceof IProperty; }
handlesElement
27,252
NonCodeUsageSearchInfo (@NotNull PsiElement element, PsiElement @NotNull [] allElementsToDelete, @NotNull List<? super UsageInfo> result) { SafeDeleteProcessor.findGenericElementUsages(element, result, allElementsToDelete); return new NonCodeUsageSearchInfo(SafeDeleteProcessor.getDefaultInsideDeletedCondition(allElementsToDelete), element); }
findUsages
27,253
Collection<PsiElement> (@NotNull PsiElement element, @NotNull Collection<? extends PsiElement> allElementsToDelete, boolean askUser) { final IProperty property = (IProperty)element; final String key = property.getKey(); if (key == null) { return null; } final PropertiesFile file = property.getPropertiesFile(); if (file == null) { return null; } final List<PsiElement> result = new ArrayList<>(); for (PropertiesFile propertiesFile : file.getResourceBundle().getPropertiesFiles()) { for (IProperty p : propertiesFile.findPropertiesByKey(key)) { final PsiElement propertyElement = p.getPsiElement(); if (!allElementsToDelete.contains(propertyElement)) { result.add(propertyElement); } } } return result; }
getAdditionalElementsToDelete
27,254
Collection<String> (@NotNull PsiElement element, PsiElement @NotNull [] allElementsToDelete) { return null; }
findConflicts
27,255
boolean (PsiElement element) { return RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_COMMENTS; }
isToSearchInComments
27,256
void (PsiElement element, boolean enabled) { RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_COMMENTS = enabled; }
setToSearchInComments
27,257
boolean (PsiElement element) { return RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_NON_JAVA; }
isToSearchForTextOccurrences
27,258
void (PsiElement element, boolean enabled) { RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_NON_JAVA = enabled; }
setToSearchForTextOccurrences
27,259
boolean (final PsiElement element) { return element instanceof PropertiesFile; }
handlesElement
27,260
NonCodeUsageSearchInfo (@NotNull final PsiElement element, final PsiElement @NotNull [] allElementsToDelete, final @NotNull List<? super UsageInfo> result) { PropertiesFile file = (PropertiesFile) element; List<PsiElement> elements = new ArrayList<>(); elements.add(file.getContainingFile()); for (IProperty property : file.getProperties()) { elements.add(property.getPsiElement()); } for(PsiElement psiElement: elements) { SafeDeleteProcessor.findGenericElementUsages(psiElement, result, allElementsToDelete, GlobalSearchScope.projectScope(element.getProject())); } return new NonCodeUsageSearchInfo(SafeDeleteProcessor.getDefaultInsideDeletedCondition(allElementsToDelete), elements); }
findUsages
27,261
Collection<PsiElement> (@NotNull final PsiElement element, final @NotNull Collection<? extends PsiElement> allElementsToDelete) { return Collections.singletonList(element); }
getElementsToSearch
27,262
Collection<PsiElement> (@NotNull final PsiElement element, final @NotNull Collection<? extends PsiElement> allElementsToDelete, final boolean askUser) { return null; }
getAdditionalElementsToDelete
27,263
Collection<String> (@NotNull final PsiElement element, final PsiElement @NotNull [] allElementsToDelete) { return null; }
findConflicts
27,264
UsageInfo[] (final @NotNull Project project, final UsageInfo @NotNull [] usages) { return usages; }
preprocessUsages
27,265
boolean (PsiElement element) { return RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_COMMENTS; }
isToSearchInComments
27,266
boolean (PsiElement element) { return RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_NON_JAVA; }
isToSearchForTextOccurrences
27,267
void (PsiElement element, boolean enabled) { RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_COMMENTS = enabled; }
setToSearchInComments
27,268
void (PsiElement element, boolean enabled) { RefactoringSettings.getInstance().SAFE_DELETE_SEARCH_IN_NON_JAVA = enabled; }
setToSearchForTextOccurrences
27,269
boolean (@NotNull PsiElement element) { return true; }
isSafeDeleteAvailable
27,270
boolean (@NotNull PsiElement element, @Nullable PsiElement context) { return true; }
isMemberInplaceRenameAvailable
27,271
boolean (@NotNull final PsiElement element) { return element instanceof IProperty || (element instanceof PomTargetPsiElement && ((PomTargetPsiElement)element).getTarget() instanceof XmlProperty); }
canProcessElement
27,272
void (@NotNull final PsiElement element, @NotNull final String newName, @NotNull final Map<PsiElement, String> allRenames) { ResourceBundle resourceBundle = Objects.requireNonNull(PropertiesImplUtil.getProperty(element)).getPropertiesFile().getResourceBundle(); final Map<PsiElement, String> allRenamesCopy = new LinkedHashMap<>(allRenames); allRenames.clear(); allRenamesCopy.forEach((key, value) -> { final IProperty property = PropertiesImplUtil.getProperty(key); if (property != null) { final List<IProperty> properties = PropertiesUtil.findAllProperties(resourceBundle, property.getUnescapedKey()); for (final IProperty toRename : properties) { allRenames.put(toRename.getPsiElement(), value); } } }); }
prepareRenaming
27,273
void (@NotNull PsiElement element, @NotNull final String newName, @NotNull Map<? extends PsiElement, String> allRenames, @NotNull List<UsageInfo> result) { allRenames.forEach((key, value) -> { final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(key.getContainingFile()); if (propertiesFile == null) return; final IProperty property = propertiesFile.findPropertyByKey(value); if (property == null) return; result.add(new UnresolvableCollisionUsageInfo(property.getPsiElement(), key) { @Override public String getDescription() { return PropertiesBundle.message("rename.hides.existing.property.conflict", value); } }); }); }
findCollisions
27,274
String () { return PropertiesBundle.message("rename.hides.existing.property.conflict", value); }
getDescription
27,275
boolean (@NotNull PsiElement element) { return PropertiesRefactoringSettings.getInstance().RENAME_SEARCH_IN_COMMENTS; }
isToSearchInComments
27,276
void (@NotNull PsiElement element, boolean enabled) { PropertiesRefactoringSettings.getInstance().RENAME_SEARCH_IN_COMMENTS = enabled; }
setToSearchInComments
27,277
void (PsiElement @NotNull [] elements, @NotNull GlobalCompilingVisitor globalVisitor) { if (elements.length > 1) throw new MalformedPatternException(); final CompiledPattern pattern = globalVisitor.getContext().getPattern(); for (PsiElement element : elements) { if (element instanceof PsiComment comment) { final String commentText = comment.getText(); if (globalVisitor.hasFragments(commentText)) { final MatchingHandler handler = globalVisitor.processPatternStringWithFragments(commentText, GlobalCompilingVisitor.OccurenceKind.COMMENT); if (handler != null) { comment.putUserData(CompiledPattern.HANDLER_KEY, handler); } } else { globalVisitor.handle(comment); } pattern.getHandler(element).setFilter(e -> e instanceof PsiComment); } else if (element instanceof Property property) { pattern.getHandler(element).setFilter(e -> e instanceof Property); final PsiElement firstChild = property.getFirstChild(); if (firstChild instanceof PropertyKeyImpl) { globalVisitor.handle(firstChild); pattern.getHandler(firstChild).setFilter(e -> e instanceof PropertyKeyImpl); } final PsiElement lastChild = property.getLastChild(); if (lastChild instanceof PropertyValueImpl) { final String valueText = lastChild.getText(); final MatchingHandler handler = globalVisitor.processPatternStringWithFragments(valueText, GlobalCompilingVisitor.OccurenceKind.TEXT); if (handler != null) { lastChild.putUserData(CompiledPattern.HANDLER_KEY, handler); } pattern.getHandler(firstChild).setFilter(e -> e instanceof PropertyValueImpl); } } pattern.setHandler(element, new TopLevelMatchingHandler(pattern.getHandler(element))); } }
compile
27,278
PsiElementVisitor (@NotNull GlobalMatchingVisitor globalVisitor) { return new PsiElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof Property) { Property other = globalVisitor.getElement(Property.class); final PsiElement key = element.getFirstChild(); if (globalVisitor.setResult(globalVisitor.match(key, other.getFirstChild()))) { final PsiElement value = element.getLastChild(); if (value instanceof PropertyValueImpl) { final PsiElement otherValue = other.getLastChild(); globalVisitor.setResult(globalVisitor.matchOptionally(value, otherValue instanceof PropertyValueImpl ? otherValue : null)); } } } else if (element instanceof PropertyKeyImpl) { final PropertyKeyImpl other = globalVisitor.getElement(PropertyKeyImpl.class); final MatchContext context = globalVisitor.getMatchContext(); final MatchingHandler handler = context.getPattern().getHandler(element); if (handler instanceof SubstitutionHandler) { globalVisitor.setResult(((SubstitutionHandler)handler).handle(other, context)); } else { globalVisitor.setResult(globalVisitor.matchText(element, other)); } } else if (element instanceof PropertyValueImpl) { final PropertyValueImpl other = globalVisitor.getElement(PropertyValueImpl.class); final MatchContext context = globalVisitor.getMatchContext(); final MatchingHandler handler = element.getUserData(CompiledPattern.HANDLER_KEY); if (handler instanceof LiteralWithSubstitutionHandler) { globalVisitor.setResult(handler.match(element, other, context)); } else if (handler instanceof SubstitutionHandler) { globalVisitor.setResult(((SubstitutionHandler)handler).handle(other, context)); } else { globalVisitor.setResult(globalVisitor.matchText(element, other)); } } } @Override public void visitComment(@NotNull PsiComment comment) { final PsiElement other = globalVisitor.getElement(); final MatchingHandler handler = comment.getUserData(CompiledPattern.HANDLER_KEY); globalVisitor.setResult(handler instanceof LiteralWithSubstitutionHandler ? handler.match(comment, other, globalVisitor.getMatchContext()) : globalVisitor.matchText(comment, other)); } }; }
createMatchingVisitor
27,279
void (@NotNull PsiElement element) { if (element instanceof Property) { Property other = globalVisitor.getElement(Property.class); final PsiElement key = element.getFirstChild(); if (globalVisitor.setResult(globalVisitor.match(key, other.getFirstChild()))) { final PsiElement value = element.getLastChild(); if (value instanceof PropertyValueImpl) { final PsiElement otherValue = other.getLastChild(); globalVisitor.setResult(globalVisitor.matchOptionally(value, otherValue instanceof PropertyValueImpl ? otherValue : null)); } } } else if (element instanceof PropertyKeyImpl) { final PropertyKeyImpl other = globalVisitor.getElement(PropertyKeyImpl.class); final MatchContext context = globalVisitor.getMatchContext(); final MatchingHandler handler = context.getPattern().getHandler(element); if (handler instanceof SubstitutionHandler) { globalVisitor.setResult(((SubstitutionHandler)handler).handle(other, context)); } else { globalVisitor.setResult(globalVisitor.matchText(element, other)); } } else if (element instanceof PropertyValueImpl) { final PropertyValueImpl other = globalVisitor.getElement(PropertyValueImpl.class); final MatchContext context = globalVisitor.getMatchContext(); final MatchingHandler handler = element.getUserData(CompiledPattern.HANDLER_KEY); if (handler instanceof LiteralWithSubstitutionHandler) { globalVisitor.setResult(handler.match(element, other, context)); } else if (handler instanceof SubstitutionHandler) { globalVisitor.setResult(((SubstitutionHandler)handler).handle(other, context)); } else { globalVisitor.setResult(globalVisitor.matchText(element, other)); } } }
visitElement
27,280
void (@NotNull PsiComment comment) { final PsiElement other = globalVisitor.getElement(); final MatchingHandler handler = comment.getUserData(CompiledPattern.HANDLER_KEY); globalVisitor.setResult(handler instanceof LiteralWithSubstitutionHandler ? handler.match(comment, other, globalVisitor.getMatchContext()) : globalVisitor.matchText(comment, other)); }
visitComment
27,281
CompiledPattern () { return new CompiledPattern() { { setStrategy(PropertiesMatchingStrategy.INSTANCE); } @Override public String @NotNull [] getTypedVarPrefixes() { return new String[] {TYPED_VAR_PREFIX}; } @Override public boolean isTypedVar(@NotNull String str) { return str.startsWith(TYPED_VAR_PREFIX); } }; }
createCompiledPattern
27,282
boolean (@NotNull String str) { return str.startsWith(TYPED_VAR_PREFIX); }
isTypedVar
27,283
boolean (@NotNull Language language) { return language == PropertiesLanguage.INSTANCE; }
isMyLanguage
27,284
StructuralReplaceHandler (@NotNull Project project, @NotNull ReplaceOptions replaceOptions) { return new DocumentBasedReplaceHandler(project); }
getReplaceHandler
27,285
boolean (PsiElement start) { return start.getLanguage() == PropertiesLanguage.INSTANCE; }
continueMatching
27,286
boolean (PsiElement element, PsiElement elementToMatchWith) { return false; }
shouldSkip
27,287
void (final @NotNull AnActionEvent e) { final List<PropertiesFile> initialPropertiesFiles = getPropertiesFiles(e); final List<PropertiesFile> propertiesFiles = initialPropertiesFiles == null ? new ArrayList<>() : new ArrayList<>(initialPropertiesFiles); final List<ResourceBundle> resourceBundles = getResourceBundles(e); if (resourceBundles != null) { for (ResourceBundle bundle : resourceBundles) { propertiesFiles.addAll(bundle.getPropertiesFiles()); } } final String newBaseName = Messages.showInputDialog(propertiesFiles.get(0).getProject(), PropertiesBundle.message("combine.properties.files.prompt.text"), PropertiesBundle.message("combine.properties.files.title"), Messages.getQuestionIcon(), PropertiesUtil.getDefaultBaseName(propertiesFiles), new MyInputValidator(propertiesFiles)); if (newBaseName != null) { final Project project = propertiesFiles.get(0).getProject(); final Set<ResourceBundle> uniqueBundlesToDissociate = new HashSet<>(); for (PropertiesFile file : propertiesFiles) { final ResourceBundle resourceBundle = file.getResourceBundle(); if (resourceBundle.getPropertiesFiles().size() != 1) { uniqueBundlesToDissociate.add(resourceBundle); } } final ResourceBundleManager resourceBundleManager = ResourceBundleManager.getInstance(project); for (ResourceBundle resourceBundle : uniqueBundlesToDissociate) { resourceBundleManager.dissociateResourceBundle(resourceBundle); } final ResourceBundle resourceBundle = resourceBundleManager.combineToResourceBundleAndGet(propertiesFiles, newBaseName); FileEditorManager.getInstance(project).openFile(new ResourceBundleAsVirtualFile(resourceBundle), true); ProjectView.getInstance(project).refresh(); } }
actionPerformed
27,288
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
27,289
void (final @NotNull AnActionEvent e) { final Collection<PropertiesFile> propertiesFiles = getPropertiesFiles(e); final List<ResourceBundle> resourceBundles = getResourceBundles(e); int elementCount = 0; if (propertiesFiles != null) { elementCount += propertiesFiles.size(); } if (resourceBundles != null) { elementCount += resourceBundles.size(); } e.getPresentation().setEnabledAndVisible(elementCount > 1); }
update
27,290
boolean () { return true; }
isDumbAware
27,291
boolean (final String newBaseName) { return !newBaseName.isEmpty() && checkBaseName(newBaseName) == null; }
checkInput
27,292
String () { return myFailedFile; }
getFailedFile
27,293
ActionUpdateThread () { return ActionUpdateThread.BGT; }
getActionUpdateThread
27,294
void (@NotNull final AnActionEvent e) { final Project project = e.getProject(); if (project == null) { return; } final Collection<ResourceBundle> resourceBundles = extractResourceBundles(e); assert resourceBundles.size() > 0; dissociate(resourceBundles, project); }
actionPerformed
27,295
void (@NotNull final AnActionEvent e) { final Collection<ResourceBundle> resourceBundles = extractResourceBundles(e); if (!resourceBundles.isEmpty()) { final String actionText = resourceBundles.size() == 1 ? PropertiesBundle.message("action.DissociateResourceBundleSingle.text", ContainerUtil.getFirstItem(resourceBundles).getBaseName()) : PropertiesBundle.message("action.DissociateResourceBundleMultiple.text", resourceBundles.size()); e.getPresentation().setText(actionText, false); e.getPresentation().setVisible(true); } else { e.getPresentation().setVisible(false); } }
update
27,296
void (final Collection<? extends ResourceBundle> resourceBundles, final Project project) { final Set<PsiFileSystemItem> toUpdateInProjectView = new HashSet<>(); for (ResourceBundle resourceBundle : resourceBundles) { for (final PropertiesFile propertiesFile : resourceBundle.getPropertiesFiles()) { PsiDirectory containingDirectory = propertiesFile.getContainingFile().getContainingDirectory(); if (containingDirectory != null) { toUpdateInProjectView.add(containingDirectory); } } ResourceBundleManager.getInstance(project).dissociateResourceBundle(resourceBundle); } AbstractProjectViewPane currentProjectViewPane = ProjectView.getInstance(project).getCurrentProjectViewPane(); if (currentProjectViewPane != null) { for (PsiFileSystemItem item : toUpdateInProjectView) { currentProjectViewPane.updateFrom(item, false, true); } } }
dissociate
27,297
Collection<ResourceBundle> (final AnActionEvent event) { final Set<ResourceBundle> targetResourceBundles = new HashSet<>(); final ResourceBundle[] chosenResourceBundles = event.getData(ResourceBundle.ARRAY_DATA_KEY); if (chosenResourceBundles != null) { for (ResourceBundle resourceBundle : chosenResourceBundles) { if (resourceBundle.getPropertiesFiles().size() > 1) { targetResourceBundles.add(resourceBundle); } } } final PsiElement[] psiElements = event.getData(LangDataKeys.PSI_ELEMENT_ARRAY); if (psiElements != null) { for (PsiElement element : psiElements) { final PropertiesFile propertiesFile = PropertiesImplUtil.getPropertiesFile(element); if (propertiesFile != null) { final ResourceBundle bundle = propertiesFile.getResourceBundle(); if (bundle.getPropertiesFiles().size() > 1) { targetResourceBundles.add(bundle); } } } } return targetResourceBundles; }
extractResourceBundles
27,298
String () { return "Properties"; }
getName
27,299
String () { return PropertiesBundle.message("filetype.properties.description"); }
getDescription