Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
26,600 | String () { return PropertiesBundle.message("unused.property.suppress.for.file"); } | getFamilyName |
26,601 | void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { final PsiElement element = descriptor.getStartElement(); final PsiFile file = element.getContainingFile(); @NonNls final Document doc = PsiDocumentManager.getInstance(project).getDocument(file); LOG.assertTrue(doc != null, file); doc.insertString(0, "# suppress inspection \"" + shortName + "\" for whole file\n"); } | applyFix |
26,602 | boolean (@NotNull Project project, @NotNull PsiElement context) { return context.isValid() && context.getContainingFile() instanceof PropertiesFile; } | isAvailable |
26,603 | boolean () { return false; } | isSuppressAll |
26,604 | PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { if (!(holder.getFile() instanceof PropertiesFileImpl)) { return PsiElementVisitor.EMPTY_VISITOR; } final PropertiesCodeStyleSettings codeStyleSettings = PropertiesCodeStyleSettings.getInstance(holder.getProject()); final char codeStyleKeyValueDelimiter = codeStyleSettings.getDelimiter(); return new PsiElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof PropertyImpl) { final char delimiter = ((PropertyImpl)element).getKeyValueDelimiter(); if (delimiter != codeStyleKeyValueDelimiter) { holder.registerProblem(element, PropertiesBundle.message("wrong.property.key.value.delimiter.inspection.display.name"), new ReplaceKeyValueDelimiterQuickFix(element)); } } } }; } | buildVisitor |
26,605 | void (@NotNull PsiElement element) { if (element instanceof PropertyImpl) { final char delimiter = ((PropertyImpl)element).getKeyValueDelimiter(); if (delimiter != codeStyleKeyValueDelimiter) { holder.registerProblem(element, PropertiesBundle.message("wrong.property.key.value.delimiter.inspection.display.name"), new ReplaceKeyValueDelimiterQuickFix(element)); } } } | visitElement |
26,606 | String () { return getFamilyName(); } | getText |
26,607 | void (@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement element, @NotNull PsiElement endElement) { ((PropertyImpl) element).replaceKeyValueDelimiterWithDefault(); } | invoke |
26,608 | String () { return PropertiesBundle.message("replace.key.value.delimiter.quick.fix.family.name"); } | getFamilyName |
26,609 | String () { return "TrailingSpacesInProperty"; } | getShortName |
26,610 | OptPane () { return pane( checkbox("myIgnoreVisibleSpaces", PropertiesBundle.message("trailing.spaces.in.property.inspection.ignore.visible.spaces"))); } | getOptionsPane |
26,611 | ProblemDescriptor[] (@NotNull PsiFile file, @NotNull final InspectionManager manager, final boolean isOnTheFly) { if (!(file instanceof PropertiesFile)) return null; final List<IProperty> properties = ((PropertiesFile)file).getProperties(); final List<ProblemDescriptor> descriptors = new SmartList<>(); for (IProperty property : properties) { ProgressManager.checkCanceled(); final PropertyImpl propertyImpl = (PropertyImpl)property; for (ASTNode node : ContainerUtil.ar(propertyImpl.getKeyNode(), propertyImpl.getValueNode())) { if (node != null) { PsiElement key = node.getPsi(); TextRange textRange = getTrailingSpaces(key, myIgnoreVisibleSpaces); if (textRange != null) { descriptors.add(manager.createProblemDescriptor(key, textRange, PropertiesBundle .message("inspection.trailing.spaces.in.property.trailing.spaces.description"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, true, new RemoveTrailingSpacesFix(myIgnoreVisibleSpaces))); } } } } return descriptors.toArray(ProblemDescriptor.EMPTY_ARRAY); } | checkFile |
26,612 | TextRange (PsiElement element, boolean ignoreVisibleTrailingSpaces) { String key = element.getText(); if (ignoreVisibleTrailingSpaces) { for (int i = key.length() - 1; i > -1; i--) { if (key.charAt(i) != ' ' && key.charAt(i) != '\t') { return i == key.length() - 1 ? null : new TextRange(i + 1, key.length()); } } return element.getTextRange(); } else { return PropertyImpl.trailingSpaces(key); } } | getTrailingSpaces |
26,613 | String () { return PropertiesBundle.message("remove.trailing.spaces.fix.family.name"); } | getFamilyName |
26,614 | void (@NotNull Project project, @NotNull PsiElement element, @NotNull ModPsiUpdater updater) { PsiElement parent = element.getParent(); if (!(parent instanceof PropertyImpl)) return; TextRange textRange = getTrailingSpaces(element, myIgnoreVisibleSpaces); if (textRange != null) { Document document = element.getContainingFile().getViewProvider().getDocument(); TextRange docRange = textRange.shiftRight(element.getTextRange().getStartOffset()); document.deleteString(docRange.getStartOffset(), docRange.getEndOffset()); } } | applyFix |
26,615 | PsiElementVisitor (@NotNull ProblemsHolder holder, boolean isOnTheFly) { final Charset charset = EncodingProjectManager.getInstance(holder.getProject()).getDefaultCharsetForPropertiesFiles(null); if (charset != StandardCharsets.UTF_8) return PsiElementVisitor.EMPTY_VISITOR; return new PsiElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (!(element instanceof PropertyValueImpl)) return; boolean found = getThreeDots(((PropertyValueImpl)element).getChars()); if (found) { int length = element.getTextLength(); holder.registerProblem(element, TextRange.create(length - 3, length), PropertiesBundle.message("inspection.use.ellipsis.in.property.description"), ReplaceThreeDotsWithEllipsisFix.getInstance()); } } }; } | buildVisitor |
26,616 | void (@NotNull PsiElement element) { if (!(element instanceof PropertyValueImpl)) return; boolean found = getThreeDots(((PropertyValueImpl)element).getChars()); if (found) { int length = element.getTextLength(); holder.registerProblem(element, TextRange.create(length - 3, length), PropertiesBundle.message("inspection.use.ellipsis.in.property.description"), ReplaceThreeDotsWithEllipsisFix.getInstance()); } } | visitElement |
26,617 | boolean (@NotNull CharSequence element) { int textLength = element.length(); if (textLength <= 4) return false; // Ends with three dots… if (element.charAt(textLength - 3) != '.') return false; if (element.charAt(textLength - 2) != '.') return false; if (element.charAt(textLength - 1) != '.') return false; // But doesn't end with four dots and more if (element.charAt(textLength - 4) == '.') return false; return true; } | getThreeDots |
26,618 | ReplaceThreeDotsWithEllipsisFix () { if (instance == null) { synchronized (ReplaceThreeDotsWithEllipsisFix.class) { if (instance == null) { instance = new ReplaceThreeDotsWithEllipsisFix(); } } } return instance; } | getInstance |
26,619 | String () { return PropertiesBundle.message("use.ellipsis.fix.family.name"); } | getFamilyName |
26,620 | void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { PsiElement element = descriptor.getPsiElement(); if (!(element instanceof PropertyValueImpl)) return; boolean found = getThreeDots(((PropertyValueImpl)element).getChars()); if (found) { int length = element.getTextLength(); StringBuilder newText = new StringBuilder(((PropertyValueImpl)element).getChars()); newText.replace(length - 3, length, "…"); ((PropertyValueImpl)element).replaceWithText(newText.toString()); } } | applyFix |
26,621 | PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new PsiElementVisitor() { @Override public void visitFile(@NotNull PsiFile file) { var propertiesFile = findPropertiesFile(file); if (propertiesFile == null) return; var resourceBundle = propertiesFile.getResourceBundle(); final String resourceBundleBaseName = resourceBundle.getBaseName(); if (!isResourceBundleAlphaSortedExceptOneFile(resourceBundle, propertiesFile)) { holder.registerProblem(file, PropertiesBundle.message("inspection.alpha.unsorted.properties.file.description1", resourceBundleBaseName), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new PropertiesSorterQuickFix(false)); return; } if (!propertiesFile.isAlphaSorted()) { PropertiesSorterQuickFix fix = new PropertiesSorterQuickFix(true); holder.registerProblem(file, PropertiesBundle.message("inspection.alpha.unsorted.properties.file.description"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fix); } } }; } | buildVisitor |
26,622 | void (@NotNull PsiFile file) { var propertiesFile = findPropertiesFile(file); if (propertiesFile == null) return; var resourceBundle = propertiesFile.getResourceBundle(); final String resourceBundleBaseName = resourceBundle.getBaseName(); if (!isResourceBundleAlphaSortedExceptOneFile(resourceBundle, propertiesFile)) { holder.registerProblem(file, PropertiesBundle.message("inspection.alpha.unsorted.properties.file.description1", resourceBundleBaseName), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, new PropertiesSorterQuickFix(false)); return; } if (!propertiesFile.isAlphaSorted()) { PropertiesSorterQuickFix fix = new PropertiesSorterQuickFix(true); holder.registerProblem(file, PropertiesBundle.message("inspection.alpha.unsorted.properties.file.description"), ProblemHighlightType.GENERIC_ERROR_OR_WARNING, fix); } } | visitFile |
26,623 | boolean (@NotNull final ResourceBundle resourceBundle, @NotNull final PropertiesFile exceptedFile) { for (PropertiesFile file : resourceBundle.getPropertiesFiles()) { if (!(file instanceof PropertiesFileImpl)) { return true; } if (!file.equals(exceptedFile) && !file.isAlphaSorted()) { return false; } } return true; } | isResourceBundleAlphaSortedExceptOneFile |
26,624 | String () { return PropertiesBundle.message("properties.sorter.quick.fix.family.name"); } | getFamilyName |
26,625 | void (@NotNull Project project, @NotNull ProblemDescriptor descriptor) { Collection<PropertiesFile> filesToSort = getFilesToSort(descriptor.getPsiElement().getContainingFile()); final boolean force = filesToSort.size() == 1; for (PropertiesFile file : filesToSort) { if (!force && file.isAlphaSorted()) { continue; } sortPropertiesFile(file); } } | applyFix |
26,626 | Collection<PropertiesFile> (@NotNull PsiFile file) { PropertiesFile propertiesFile = findPropertiesFile(file); if (propertiesFile == null) return Collections.emptyList(); if (myOnlyCurrentFile) { return Collections.singleton(propertiesFile); } return propertiesFile.getResourceBundle().getPropertiesFiles(); } | getFilesToSort |
26,627 | void (final PropertiesFile file) { final List<IProperty> properties = new ArrayList<>(file.getProperties()); properties.sort(Comparator.comparing(IProperty::getKey, String.CASE_INSENSITIVE_ORDER)); final PropertiesList propertiesList = PsiTreeUtil.findChildOfType(file.getContainingFile(), PropertiesList.class); if (propertiesList == null) return; final char delimiter = PropertiesCodeStyleSettings.getInstance(file.getProject()).getDelimiter(); final StringBuilder rawText = new StringBuilder(propertiesList.getDocCommentText()); for (int i = 0; i < properties.size(); i++) { IProperty property = properties.get(i); final String value = property.getValue(); final String commentAboveProperty = property.getDocCommentText(); if (commentAboveProperty != null) { rawText.append(commentAboveProperty); } final String key = property.getKey(); final String propertyText; if (key != null) { propertyText = PropertiesElementFactory.getPropertyText(key, value != null ? value : "", delimiter, null, PropertyKeyValueFormat.FILE); rawText.append(propertyText); if (i != properties.size() - 1) { rawText.append("\n"); } } } final PropertiesFile fakeFile = PropertiesElementFactory.createPropertiesFile(file.getProject(), rawText.toString()); final PropertiesList fakePropertiesList = PsiTreeUtil.findChildOfType(fakeFile.getContainingFile(), PropertiesList.class); LOG.assertTrue(fakePropertiesList != null); propertiesList.replace(fakePropertiesList); } | sortPropertiesFile |
26,628 | String () { return "AlphaUnsortedPropertiesFile"; } | getShortName |
26,629 | void (@NotNull PsiFile file, @NotNull InspectionManager manager, @NotNull ProblemsHolder problemsHolder, @NotNull GlobalInspectionContext globalContext, @NotNull ProblemDescriptionsProcessor problemDescriptionsProcessor) { checkFile(file, manager, (GlobalInspectionContextBase)globalContext, globalContext.getRefManager(), problemDescriptionsProcessor); } | checkFile |
26,630 | void (@NotNull StringBuilder anchor, PsiElement element, final boolean isValue) { if (element != null) { final PsiElement parent = element.getParent(); PsiElement elementToLink = isValue ? parent.getFirstChild() : parent.getLastChild(); if (elementToLink != null) { HTMLComposer.appendAfterHeaderIndention(anchor); HTMLComposer.appendAfterHeaderIndention(anchor); String link = ""; final PsiFile file = element.getContainingFile(); if (file != null) { final VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { link = virtualFile.getUrl() + "#" + elementToLink.getTextRange().getStartOffset(); } } HtmlChunk.link(link, elementToLink.getText().replaceAll("\\$", "\\\\\\$")).appendTo(anchor); compoundLineLink(anchor, element); anchor.append("<br>"); } } else { HtmlChunk.tag("font") .style("font-family:verdana; font-weight:bold; color:#FF0000") .addText(PropertiesBundle.message("inspection.export.results.invalidated.item")).appendTo(anchor); } } | surroundWithHref |
26,631 | void (@NotNull StringBuilder lineAnchor, PsiElement psiElement) { final PsiFile file = psiElement.getContainingFile(); if (file != null) { final VirtualFile vFile = file.getVirtualFile(); if (vFile != null) { Document doc = FileDocumentManager.getInstance().getDocument(vFile); final int lineNumber = doc.getLineNumber(psiElement.getTextOffset()) + 1; lineAnchor.append(" ").append(AnalysisBundle.message("inspection.export.results.at.line")).append(" "); int offset = doc.getLineStartOffset(lineNumber - 1); offset = CharArrayUtil.shiftForward(doc.getCharsSequence(), offset, " \t"); HtmlChunk.link(vFile.getUrl() + "#" + offset, String.valueOf(lineNumber)).appendTo(lineAnchor); } } } | compoundLineLink |
26,632 | void (final PsiFile file, final InspectionManager manager, GlobalInspectionContextBase context, final RefManager refManager, final ProblemDescriptionsProcessor processor) { if (!(file instanceof PropertiesFile propertiesFile)) return; if (!context.isToCheckFile(file, this) || SuppressionUtil.inspectionResultSuppressed(file, this)) return; final PsiSearchHelper searchHelper = PsiSearchHelper.getInstance(file.getProject()); final List<IProperty> properties = propertiesFile.getProperties(); Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module == null) return; final GlobalSearchScope scope = GlobalSearchScope.getScopeRestrictedByFileTypes(CURRENT_FILE ? GlobalSearchScope.fileScope(file) : MODULE_WITH_DEPENDENCIES ? GlobalSearchScope.moduleWithDependenciesScope(module) : GlobalSearchScope.projectScope(file.getProject()), PropertiesFileType.INSTANCE); final Map<String, Set<PsiFile>> processedValueToFiles = Collections.synchronizedMap(new HashMap<>()); final Map<String, Set<PsiFile>> processedKeyToFiles = Collections.synchronizedMap(new HashMap<>()); final ProgressIndicator original = ProgressManager.getInstance().getProgressIndicator(); final ProgressIndicator progress = ProgressWrapper.wrap(original); ProgressManager.getInstance().runProcess(() -> { if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(properties, progress, property -> { if (original != null) { if (original.isCanceled()) return false; original.setText2(PropertiesBundle.message("searching.for.property.key.progress.text", property.getUnescapedKey())); } processTextUsages(processedValueToFiles, property.getValue(), processedKeyToFiles, searchHelper, scope); processTextUsages(processedKeyToFiles, property.getUnescapedKey(), processedValueToFiles, searchHelper, scope); return true; })) throw new ProcessCanceledException(); List<ProblemDescriptor> problemDescriptors = new ArrayList<>(); Map<String, Set<String>> keyToDifferentValues = new HashMap<>(); if (CHECK_DUPLICATE_KEYS || CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES) { prepareDuplicateKeysByFile(processedKeyToFiles, manager, keyToDifferentValues, problemDescriptors, file, original); } if (CHECK_DUPLICATE_VALUES) prepareDuplicateValuesByFile(processedValueToFiles, manager, problemDescriptors, file, original); if (CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES) { processDuplicateKeysWithDifferentValues(keyToDifferentValues, processedKeyToFiles, problemDescriptors, manager, file, original); } if (!problemDescriptors.isEmpty()) { processor.addProblemElement(refManager.getReference(file), problemDescriptors.toArray(ProblemDescriptor.EMPTY_ARRAY)); } }, progress); } | checkFile |
26,633 | void (final Map<String, Set<PsiFile>> processedTextToFiles, final String text, final Map<String, Set<PsiFile>> processedFoundTextToFiles, final PsiSearchHelper searchHelper, final GlobalSearchScope scope) { if (!processedTextToFiles.containsKey(text)) { if (processedFoundTextToFiles.containsKey(text)) { final Set<PsiFile> filesWithValue = processedFoundTextToFiles.get(text); processedTextToFiles.put(text, filesWithValue); } else { final Set<PsiFile> resultFiles = new HashSet<>(); findFilesWithText(text, searchHelper, scope, resultFiles); if (resultFiles.isEmpty()) return; processedTextToFiles.put(text, resultFiles); } } } | processTextUsages |
26,634 | void (final Map<String, Set<PsiFile>> valueToFiles, final InspectionManager manager, final List<? super ProblemDescriptor> problemDescriptors, final PsiFile psiFile, final ProgressIndicator progress) { for (final String value : valueToFiles.keySet()) { if (progress != null){ progress.setText2(PropertiesBundle.message("duplicate.property.value.progress.indicator.text", value)); progress.checkCanceled(); } if (value.length() == 0) continue; StringSearcher searcher = new StringSearcher(value, true, true); @Nls StringBuilder message = new StringBuilder(); final int[] duplicatesCount = {0}; Property[] propertyInCurrentFile = new Property[1]; Set<PsiFile> psiFilesWithDuplicates = valueToFiles.get(value); for (final PsiFile file : psiFilesWithDuplicates) { CharSequence text = file.getViewProvider().getContents(); LowLevelSearchUtil.processTexts(text, 0, text.length(), searcher, offset -> { PsiElement element = file.findElementAt(offset); if (element != null && element.getParent() instanceof Property property) { if (Objects.equals(property.getValue(), value) && element.getStartOffsetInParent() != 0) { if (duplicatesCount[0] == 0){ message.append(PropertiesBundle.message("duplicate.property.value.problem.descriptor", property.getValue())); } surroundWithHref(message, element, true); duplicatesCount[0]++; if (propertyInCurrentFile[0] == null && psiFile == file) { propertyInCurrentFile[0] = property; } } } return true; }); } if (duplicatesCount[0] > 1) { PsiElement elementToHighlight = ObjectUtils.notNull(propertyInCurrentFile[0], psiFile); problemDescriptors.add(manager.createProblemDescriptor(elementToHighlight, message.toString(), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } } | prepareDuplicateValuesByFile |
26,635 | void (final Map<String, Set<PsiFile>> keyToFiles, final InspectionManager manager, final Map<String, Set<String>> keyToValues, final List<? super ProblemDescriptor> problemDescriptors, final PsiFile psiFile, final ProgressIndicator progress) { for (String key : keyToFiles.keySet()) { if (progress!= null){ progress.setText2(PropertiesBundle.message("duplicate.property.key.progress.indicator.text", key)); ProgressIndicatorUtils.checkCancelledEvenWithPCEDisabled(progress); } @Nls StringBuilder message = new StringBuilder(); int duplicatesCount = 0; PsiElement propertyInCurrentFile = null; Set<PsiFile> psiFilesWithDuplicates = keyToFiles.get(key); for (PsiFile file : psiFilesWithDuplicates) { if (!(file instanceof PropertiesFile propertiesFile)) continue; final List<IProperty> propertiesByKey = propertiesFile.findPropertiesByKey(key); for (IProperty property : propertiesByKey) { if (duplicatesCount == 0){ message.append(PropertiesBundle.message("duplicate.property.key.problem.descriptor", key)); } surroundWithHref(message, property.getPsiElement().getFirstChild(), false); duplicatesCount ++; //prepare for filter same keys different values Set<String> values = keyToValues.get(key); if (values == null){ values = new HashSet<>(); keyToValues.put(key, values); } values.add(property.getValue()); if (propertyInCurrentFile == null && file == psiFile) { propertyInCurrentFile = property.getPsiElement(); } } } if (duplicatesCount > 1 && CHECK_DUPLICATE_KEYS) { problemDescriptors.add(manager.createProblemDescriptor(ObjectUtils.notNull(propertyInCurrentFile, psiFile), message.toString(), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } } | prepareDuplicateKeysByFile |
26,636 | void (final Map<String, Set<String>> keyToDifferentValues, final Map<String, Set<PsiFile>> keyToFiles, final List<? super ProblemDescriptor> problemDescriptors, final InspectionManager manager, final PsiFile psiFile, final ProgressIndicator progress) { for (String key : keyToDifferentValues.keySet()) { if (progress != null) { progress.setText2(PropertiesBundle.message("duplicate.property.diff.key.progress.indicator.text", key)); ProgressIndicatorUtils.checkCancelledEvenWithPCEDisabled(progress); } final Set<String> values = keyToDifferentValues.get(key); if (values == null || values.size() < 2){ keyToFiles.remove(key); } else { @Nls StringBuilder message = new StringBuilder(); final Set<PsiFile> psiFiles = keyToFiles.get(key); boolean firstUsage = true; for (PsiFile file : psiFiles) { if (!(file instanceof PropertiesFile propertiesFile)) continue; final List<IProperty> propertiesByKey = propertiesFile.findPropertiesByKey(key); for (IProperty property : propertiesByKey) { if (firstUsage){ message.append(PropertiesBundle.message("duplicate.property.diff.key.problem.descriptor", key)); firstUsage = false; } surroundWithHref(message, property.getPsiElement().getFirstChild(), false); } } problemDescriptors.add(manager.createProblemDescriptor(psiFile, message.toString(), false, null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING)); } } } | processDuplicateKeysWithDifferentValues |
26,637 | void (String stringToFind, PsiSearchHelper searchHelper, GlobalSearchScope scope, final Set<? super PsiFile> resultFiles) { final List<String> words = StringUtil.getWordsIn(stringToFind); if (words.isEmpty()) return; words.sort((o1, o2) -> o2.length() - o1.length()); for (String word : words) { final Set<PsiFile> files = new HashSet<>(); searchHelper.processAllFilesWithWord(word, scope, Processors.cancelableCollectProcessor(files), true); if (resultFiles.isEmpty()) { resultFiles.addAll(files); } else { resultFiles.retainAll(files); } if (resultFiles.isEmpty()) return; } } | findFilesWithText |
26,638 | String () { return InspectionsBundle.message("group.names.properties.files"); } | getGroupDisplayName |
26,639 | String () { return "DuplicatePropertyInspection"; } | getShortName |
26,640 | boolean () { return false; } | isEnabledByDefault |
26,641 | OptPane () { @SuppressWarnings("InjectedReferences") OptDropdown scope = dropdown("SCOPE", PropertiesBundle.message("label.analysis.scope"), option("file", PropertiesBundle.message("duplicate.property.file.scope.option")), option("module", PropertiesBundle.message("duplicate.property.module.scope.option")), option("project", PropertiesBundle.message("duplicate.property.project.scope.option"))); return pane( scope, checkbox("CHECK_DUPLICATE_VALUES", PropertiesBundle.message("duplicate.property.value.option")), checkbox("CHECK_DUPLICATE_KEYS_WITH_DIFFERENT_VALUES", PropertiesBundle.message("duplicate.property.diff.key.option")), checkbox("CHECK_DUPLICATE_KEYS", PropertiesBundle.message("duplicate.property.key.option")) ); } | getOptionsPane |
26,642 | OptionController () { return super.getOptionController().onValue( "SCOPE", () -> CURRENT_FILE ? "file" : MODULE_WITH_DEPENDENCIES ? "module" : "project", value -> { CURRENT_FILE = "file".equals(value); MODULE_WITH_DEPENDENCIES = "module".equals(value); }); } | getOptionController |
26,643 | boolean (@NotNull Property property) { final String propertiesFileName = property.getPropertiesFile().getName(); for (String keyword : LOGGER_PROPERTIES_KEYWORDS) { if (propertiesFileName.startsWith(keyword)) { return true; } } return false; } | isUsed |
26,644 | String () { return SHORT_NAME; } | getShortName |
26,645 | OptPane () { return OptPane.pane( OptPane.string("fileNameMask", PropertiesBundle.message("label.analyze.only.property.files.whose.name.matches"), 30, new RegexValidator()) ); } | getOptionsPane |
26,646 | OptionController () { return super.getOptionController().onValueSet("fileNameMask", value -> { if ("".equals(value)) fileNameMask = ".*"; }); } | getOptionController |
26,647 | GlobalSearchScope (@Nullable String key, @NotNull Project project, @NotNull Module ownModule) { if (key == null) return null; Set<Module> modules = new LinkedHashSet<>(); for (IProperty property : PropertiesImplUtil.findPropertiesByKey(project, key)) { Module module = ModuleUtilCore.findModuleForPsiElement(property.getPsiElement()); if (module == null) { return GlobalSearchScope.allScope(project); } if (module != ownModule) { modules.add(module); } } if (modules.isEmpty()) return null; return GlobalSearchScope.union(modules.stream().map(Module::getModuleWithDependentsScope).toArray(GlobalSearchScope[]::new)); } | getWidestUseScope |
26,648 | PsiElementVisitor (@NotNull final ProblemsHolder holder, final boolean isOnTheFly, @NotNull final LocalInspectionToolSession session) { final PsiFile file = session.getFile(); if (!fileNameMask.isEmpty()) { try { Pattern p = Pattern.compile(fileNameMask); if (!p.matcher(file.getName()).matches()) { return PsiElementVisitor.EMPTY_VISITOR; } } catch (PatternSyntaxException ignored) { } } final Module module = ModuleUtilCore.findModuleForPsiElement(file); if (module == null) return PsiElementVisitor.EMPTY_VISITOR; if (InjectedLanguageManager.getInstance(module.getProject()).isInjectedFragment(holder.getFile()) || holder.getFile().getUserData(FileContextUtil.INJECTED_IN_ELEMENT) != null) { // Properties inside injected fragments cannot be normally referenced return PsiElementVisitor.EMPTY_VISITOR; } VirtualFile virtualFile = holder.getFile().getVirtualFile(); if (virtualFile == null || !ProjectFileIndex.getInstance(module.getProject()).isInSource(virtualFile)) { return PsiElementVisitor.EMPTY_VISITOR; } final UnusedPropertiesSearchHelper helper = new UnusedPropertiesSearchHelper(module); final Set<PsiElement> propertiesBeingCommitted = getBeingCommittedProperties(file); return new PsiElementVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (!(element instanceof Property property)) return; if (propertiesBeingCommitted != null && !propertiesBeingCommitted.contains(property)) return; if (isPropertyUsed(property, helper, isOnTheFly)) return; final ASTNode propertyNode = property.getNode(); assert propertyNode != null; ASTNode[] nodes = propertyNode.getChildren(null); PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi(); LocalQuickFix fix = PropertiesQuickFixFactory.getInstance().createRemovePropertyLocalFix(property); holder.registerProblem(key, isOnTheFly ? PropertiesBundle.message("unused.property.problem.descriptor.name") : PropertiesBundle .message("unused.property.problem.descriptor.name.offline", property.getUnescapedKey()), fix); } }; } | buildVisitor |
26,649 | void (@NotNull PsiElement element) { if (!(element instanceof Property property)) return; if (propertiesBeingCommitted != null && !propertiesBeingCommitted.contains(property)) return; if (isPropertyUsed(property, helper, isOnTheFly)) return; final ASTNode propertyNode = property.getNode(); assert propertyNode != null; ASTNode[] nodes = propertyNode.getChildren(null); PsiElement key = nodes.length == 0 ? property : nodes[0].getPsi(); LocalQuickFix fix = PropertiesQuickFixFactory.getInstance().createRemovePropertyLocalFix(property); holder.registerProblem(key, isOnTheFly ? PropertiesBundle.message("unused.property.problem.descriptor.name") : PropertiesBundle .message("unused.property.problem.descriptor.name.offline", property.getUnescapedKey()), fix); } | visitElement |
26,650 | Set<PsiElement> (@NotNull PsiFile file) { final Map<Class<? extends PsiElement>, Set<PsiElement>> data = file.getUserData(InspectionProfileWrapper.PSI_ELEMENTS_BEING_COMMITTED); if (data == null) return null; return data.get(Property.class); } | getBeingCommittedProperties |
26,651 | boolean (@NotNull Property property) { for (ImplicitPropertyUsageProvider provider : EP_NAME.getIterable()) { if (provider.isUsed(property)) { return true; } } return false; } | isImplicitlyUsed |
26,652 | boolean (@NotNull Property property, @NotNull UnusedPropertiesSearchHelper helper, boolean isOnTheFly) { final ProgressIndicator original = ProgressManager.getInstance().getProgressIndicator(); if (original != null) { if (original.isCanceled()) return true; original.setText(PropertiesBundle.message("searching.for.property.key.progress.text", property.getUnescapedKey())); } if (isImplicitlyUsed(property)) { return true; } String name = property.getName(); if (name == null) return true; PsiSearchHelper searchHelper = helper.getSearchHelper(); if (mayHaveUsages(property, name, searchHelper, helper.getOwnUseScope(), isOnTheFly, original)) return true; final GlobalSearchScope widerScope = isOnTheFly ? getWidestUseScope(property.getKey(), property.getProject(), helper.getModule()) : GlobalSearchScope.projectScope(property.getProject()); if (widerScope != null && mayHaveUsages(property, name, searchHelper, widerScope, isOnTheFly, original)) return true; return false; } | isPropertyUsed |
26,653 | boolean (@NotNull PsiElement property, @NotNull String name, @NotNull PsiSearchHelper psiSearchHelper, @NotNull GlobalSearchScope searchScope, boolean onTheFly, @Nullable ProgressIndicator indicator) { GlobalSearchScope exceptPropertyFiles = createExceptPropertyFilesScope(searchScope); GlobalSearchScope newScope = searchScope.intersectWith(exceptPropertyFiles); if (onTheFly) { PsiSearchHelper.SearchCostResult cheapEnough = psiSearchHelper.isCheapEnoughToSearch(name, newScope, null, indicator); if (cheapEnough == PsiSearchHelper.SearchCostResult.ZERO_OCCURRENCES) return false; if (cheapEnough == PsiSearchHelper.SearchCostResult.TOO_MANY_OCCURRENCES) return true; } return ReferencesSearch.search(property, newScope, false).findFirst() != null; } | mayHaveUsages |
26,654 | GlobalSearchScope (@NotNull GlobalSearchScope origin) { return new DelegatingGlobalSearchScope(origin) { @Override public boolean contains(@NotNull VirtualFile file) { return super.contains(file) && !FileTypeRegistry.getInstance().isFileOfType(file, PropertiesFileType.INSTANCE); } }; } | createExceptPropertyFilesScope |
26,655 | boolean (@NotNull VirtualFile file) { return super.contains(file) && !FileTypeRegistry.getInstance().isFileOfType(file, PropertiesFileType.INSTANCE); } | contains |
26,656 | Module () { return myModule; } | getModule |
26,657 | boolean (PsiReferenceService.@NotNull Hints hints) { return false; } | shouldAskParentForReferences |
26,658 | PsiReference () { PsiReference[] references = getReferences(); return references.length == 0 ? null : references[0]; } | getReference |
26,659 | String () { return "PropertyValueImpl: " + getText(); } | toString |
26,660 | String () { return "Property{ key = " + getKey() + ", value = " + getValue() + "}"; } | toString |
26,661 | String () { return getUnescapedKey(); } | getName |
26,662 | String () { final PropertyStub stub = getStub(); if (stub != null) { return stub.getKey(); } final ASTNode node = getKeyNode(); if (node == null) { return null; } return node.getText(); } | getKey |
26,663 | ASTNode () { return getNode().findChildByType(PropertiesTokenTypes.KEY_CHARACTERS); } | getKeyNode |
26,664 | ASTNode () { return getNode().findChildByType(PropertiesTokenTypes.VALUE_CHARACTERS); } | getValueNode |
26,665 | String () { final ASTNode node = getValueNode(); if (node == null) { return ""; } return node.getText(); } | getValue |
26,666 | String () { return unescape(getValue()); } | getUnescapedValue |
26,667 | String (String s) { if (s == null) return null; StringBuilder sb = new StringBuilder(); parseCharacters(s, sb, null); return sb.toString(); } | unescape |
26,668 | boolean (String s, StringBuilder outChars, int @Nullable [] sourceOffsets) { assert sourceOffsets == null || sourceOffsets.length == s.length() + 1; int off = 0; int len = s.length(); boolean result = true; final int outOffset = outChars.length(); while (off < len) { char aChar = s.charAt(off++); if (sourceOffsets != null) { sourceOffsets[outChars.length() - outOffset] = off - 1; sourceOffsets[outChars.length() + 1 - outOffset] = off; } if (aChar == '\\') { aChar = s.charAt(off++); if (aChar == 'u') { // Read the xxxx int value = 0; boolean error = false; for (int i = 0; i < 4 && off < s.length(); i++) { aChar = s.charAt(off++); switch (aChar) { case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' -> value = (value << 4) + aChar - '0'; case 'a', 'b', 'c', 'd', 'e', 'f' -> value = (value << 4) + 10 + aChar - 'a'; case 'A', 'B', 'C', 'D', 'E', 'F' -> value = (value << 4) + 10 + aChar - 'A'; default -> { outChars.append("\\u"); int start = off - i - 1; int end = Math.min(start + 4, s.length()); outChars.append(s, start, end); i = 4; error = true; off = end; } } } if (!error) { outChars.append((char)value); } else { result = false; } } else if (aChar == '\n') { // escaped linebreak: skip whitespace in the beginning of next line while (off < len && (s.charAt(off) == ' ' || s.charAt(off) == '\t')) { off++; } } else if (aChar == 't') { outChars.append('\t'); } else if (aChar == 'r') { outChars.append('\r'); } else if (aChar == 'n') { outChars.append('\n'); } else if (aChar == 'f') { outChars.append('\f'); } else { outChars.append(aChar); } } else { outChars.append(aChar); } if (sourceOffsets != null) { sourceOffsets[outChars.length() - outOffset] = off; } } return result; } | parseCharacters |
26,669 | TextRange (String s) { if (s == null) { return null; } int off = 0; int len = s.length(); int startSpaces = -1; while (off < len) { char aChar = s.charAt(off++); if (aChar == '\\') { if (startSpaces == -1) startSpaces = off-1; aChar = s.charAt(off++); if (aChar == 'u') { // Read the xxxx int value = 0; boolean error = false; for (int i = 0; i < 4; i++) { aChar = off < s.length() ? s.charAt(off++) : 0; switch (aChar) { case '0', '1', '2', '3', '4', '5', '6', '7', '8', '9' -> value = (value << 4) + aChar - '0'; case 'a', 'b', 'c', 'd', 'e', 'f' -> value = (value << 4) + 10 + aChar - 'a'; case 'A', 'B', 'C', 'D', 'E', 'F' -> value = (value << 4) + 10 + aChar - 'A'; default -> { int start = off - i - 1; int end = Math.min(start + 4, s.length()); i = 4; error = true; off = end; startSpaces = -1; } } } if (!error) { if (Character.isWhitespace(value)) { if (startSpaces == -1) { startSpaces = off-1; } } else { startSpaces = -1; } } } else if (aChar == '\n') { // escaped linebreak: skip whitespace in the beginning of next line while (off < len && (s.charAt(off) == ' ' || s.charAt(off) == '\t')) { off++; } } else if (aChar == 't' || aChar == 'r') { if (startSpaces == -1) startSpaces = off; } else { if (aChar == 'n' || aChar == 'f') { if (startSpaces == -1) startSpaces = off; } else { if (Character.isWhitespace(aChar)) { if (startSpaces == -1) { startSpaces = off-1; } } else { startSpaces = -1; } } } } else { if (Character.isWhitespace(aChar)) { if (startSpaces == -1) { startSpaces = off-1; } } else { startSpaces = -1; } } } return startSpaces == -1 ? null : new TextRange(startSpaces, len); } | trailingSpaces |
26,670 | String () { return unescape(getKey()); } | getUnescapedKey |
26,671 | Icon (@IconFlags int flags) { return PlatformIcons.PROPERTY_ICON; } | getElementIcon |
26,672 | PropertiesFile () { PsiFile containingFile = super.getContainingFile(); if (!(containingFile instanceof PropertiesFile)) { LOG.error("Unexpected file type of: " + containingFile.getName()); } return (PropertiesFile)containingFile; } | getPropertiesFile |
26,673 | PsiElement (@NotNull final Property property) { PsiElement prev = property; for (PsiElement node = property.getPrevSibling(); node != null; node = node.getPrevSibling()) { if (node instanceof Property) break; if (node instanceof PsiWhiteSpace) { if (PROPERTIES_SEPARATOR.matcher(node.getText()).find()) break; } prev = node; } return prev; } | getEdgeOfProperty |
26,674 | String () { final PsiElement edge = getEdgeOfProperty(this); StringBuilder text = new StringBuilder(); for(PsiElement doc = edge; doc != this; doc = doc.getNextSibling()) { if (doc instanceof PsiComment) { text.append(doc.getText()); text.append("\n"); } } if (text.length() == 0) return null; return text.toString(); } | getDocCommentText |
26,675 | PsiElement () { return this; } | getPsiElement |
26,676 | SearchScope () { // property ref can occur in any file return GlobalSearchScope.allScope(getProject()); } | getUseScope |
26,677 | ItemPresentation () { return new ItemPresentation() { @Override public String getPresentableText() { return getName(); } @Override public String getLocationString() { return getPropertiesFile().getName(); } @Override public Icon getIcon(final boolean open) { return null; } }; } | getPresentation |
26,678 | String () { return getName(); } | getPresentableText |
26,679 | String () { return getPropertiesFile().getName(); } | getLocationString |
26,680 | Icon (final boolean open) { return null; } | getIcon |
26,681 | boolean () { return true; } | isValidHost |
26,682 | PsiLanguageInjectionHost (@NotNull String text) { return new PropertyManipulator().handleContentChange(this, text); } | updateText |
26,683 | char () { final PsiElement delimiter = findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR); if (delimiter == null) { return ' '; } final String text = delimiter.getText(); LOG.assertTrue(text.length() == 1); return text.charAt(0); } | getKeyValueDelimiter |
26,684 | void () { PropertyImpl property = (PropertyImpl)PropertiesElementFactory.createProperty(getProject(), "yyy", "xxx", null); final ASTNode newDelimiter = property.getNode().findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR); final ASTNode propertyNode = getNode(); final ASTNode oldDelimiter = propertyNode.findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR); if (areDelimitersEqual(newDelimiter, oldDelimiter)) { return; } if (newDelimiter == null) { propertyNode.replaceChild(oldDelimiter, ASTFactory.whitespace(" ")); } else { if (oldDelimiter == null) { propertyNode.addChild(newDelimiter, getValueNode()); final ASTNode insertedDelimiter = propertyNode.findChildByType(PropertiesTokenTypes.KEY_VALUE_SEPARATOR); LOG.assertTrue(insertedDelimiter != null); ASTNode currentPrev = insertedDelimiter.getTreePrev(); final List<ASTNode> toDelete = new ArrayList<>(); while (currentPrev != null && currentPrev.getElementType() == PropertiesTokenTypes.WHITE_SPACE) { toDelete.add(currentPrev); currentPrev = currentPrev.getTreePrev(); } for (ASTNode node : toDelete) { propertyNode.removeChild(node); } } else { propertyNode.replaceChild(oldDelimiter, newDelimiter); } } } | replaceKeyValueDelimiterWithDefault |
26,685 | boolean (@Nullable ASTNode node1, @Nullable ASTNode node2) { if (node1 == null && node2 == null) return true; if (node1 == null || node2 == null) return false; final String text1 = node1.getText(); final String text2 = node2.getText(); return text1.equals(text2); } | areDelimitersEqual |
26,686 | boolean (@NotNull TextRange rangeInsideHost, @NotNull StringBuilder outChars) { String subText = rangeInsideHost.substring(myHost.getText()); outSourceOffsets = new int[subText.length() + 1]; int prefixLen = outChars.length(); boolean b = PropertyImpl.parseCharacters(subText, outChars, outSourceOffsets); if (b) { for (int i = prefixLen, len = outChars.length(); i < len; i++) { char outChar = outChars.charAt(i); char inChar = subText.charAt(outSourceOffsets[i - prefixLen]); if (outChar != inChar && inChar != '\\') { LOG.error("input: " + subText + ";\noutput: " + outChars + "\nat: " + i + "; prefix-length: " + prefixLen); } } } return b; } | decode |
26,687 | int (int offsetInDecoded, @NotNull TextRange rangeInsideHost) { int result = offsetInDecoded < outSourceOffsets.length ? outSourceOffsets[offsetInDecoded] : -1; if (result == -1) return -1; return Math.min(result, rangeInsideHost.getLength()) + rangeInsideHost.getStartOffset(); } | getOffsetInHost |
26,688 | boolean () { return !myHost.getText().contains("\\"); } | isOneLine |
26,689 | Language () { return PropertiesLanguage.INSTANCE; } | getLanguage |
26,690 | PsiReference () { PsiReference[] references = getReferences(); return references.length == 0 ? null : references[0]; } | getReference |
26,691 | String () { return "Property key: " + getText(); } | toString |
26,692 | String () { return "PropertiesList"; } | toString |
26,693 | String () { final Property firstProp = PsiTreeUtil.getChildOfType(this, Property.class); // If there are no properties in the property file, // then the whole content of the file is considered to be a doc comment if (firstProp == null) return getText(); final PsiElement upperEdge = PropertyImpl.getEdgeOfProperty(firstProp); final List<PsiElement> comments = PsiTreeUtil.getChildrenOfTypeAsList(this, PsiElement.class); return comments.stream() .takeWhile(Predicate.not(upperEdge::equals)) .map(PsiElement::getText) .collect(Collectors.joining()); } | getDocCommentText |
26,694 | String () { return myKey; } | getKey |
26,695 | CompositeElement (@NotNull final IElementType type) { if (type instanceof IFileElementType) { return new FileElement(type, null); } return new CompositeElement(type); } | createComposite |
26,696 | LeafElement (@NotNull final IElementType type, @NotNull CharSequence text) { if (type == PropertiesTokenTypes.KEY_CHARACTERS) { return new PropertyKeyImpl(type, text); } if (type == PropertiesTokenTypes.VALUE_CHARACTERS) { return new PropertyValueImpl(type, text); } if (type == PropertiesTokenTypes.END_OF_LINE_COMMENT) { return new PsiCommentImpl(type, text); } return new LeafPsiElement(type, text); } | createLeaf |
26,697 | FileType () { return PropertiesFileType.INSTANCE; } | getFileType |
26,698 | String () { return "Properties file:" + getName(); } | toString |
26,699 | List<IProperty> () { PropertiesList propertiesList; final StubElement<?> stub = getGreenStub(); if (stub != null) { PropertiesListStub propertiesListStub = stub.findChildStubByType(PropertiesElementTypes.PROPERTIES_LIST); propertiesList = propertiesListStub == null ? null : propertiesListStub.getPsi(); } else { propertiesList = PsiTreeUtil.findChildOfType(this, PropertiesList.class); } //noinspection RedundantUnmodifiable return Collections.unmodifiableList(PsiTreeUtil.getStubChildrenOfTypeAsList(propertiesList, Property.class)); } | getProperties |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.