Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
20,500 | void (@NotNull InsertionContext context, MavenRepositoryArtifactInfo completionItem, XmlFile contextFile, MavenDomShortArtifactCoordinates domCoordinates) { domCoordinates.getGroupId().setStringValue(completionItem.getGroupId()); domCoordinates.getArtifactId().setStringValue(completionItem.getArtifactId()); if (domCoordinates instanceof MavenDomDependency) { String scope = MavenScopeTable.getUsualScope(completionItem); if (scope != null) { ((MavenDomDependency)domCoordinates).getScope().setStringValue(scope); } } DomFileElement<MavenDomProjectModel> domModel = DomManager.getDomManager(context.getProject()).getFileElement(contextFile, MavenDomProjectModel.class); if (!MavenDependencyCompletionUtil.isInsideManagedDependency(domCoordinates)) { MavenDomDependency declarationOfDependency = MavenDependencyCompletionUtil.findManagedDependency(domModel.getRootElement(), context.getProject(), completionItem.getGroupId(), completionItem.getArtifactId()); if (declarationOfDependency != null) { if (domCoordinates instanceof MavenDomDependency) { if (declarationOfDependency.getType().getRawText() != null) { ((MavenDomDependency)domCoordinates).getType().setStringValue(declarationOfDependency.getType().getRawText()); } if (declarationOfDependency.getClassifier().getRawText() != null) { ((MavenDomDependency)domCoordinates).getClassifier().setStringValue(declarationOfDependency.getClassifier().getRawText()); } } return; } } if (domCoordinates instanceof MavenDomArtifactCoordinates) { insertVersion(context, completionItem, (MavenDomArtifactCoordinates)domCoordinates); } } | setDependency |
20,501 | void (@NotNull InsertionContext context, MavenRepositoryArtifactInfo completionItem, MavenDomArtifactCoordinates domCoordinates) { if (completionItem.getItems().length == 1 && completionItem.getVersion() != null) { domCoordinates.getVersion().setStringValue(completionItem.getVersion()); } else { domCoordinates.getVersion().setStringValue(""); int versionPosition = domCoordinates.getVersion().getXmlTag().getValue().getTextRange().getStartOffset(); context.getEditor().getCaretModel().moveToOffset(versionPosition); MavenDependencyCompletionUtil.invokeCompletion(context, CompletionType.BASIC); } } | insertVersion |
20,502 | String (MavenDomParent mavenDomParent) { String groupId = mavenDomParent.getGroupId().getStringValue(); String artifactId = mavenDomParent.getGroupId().getStringValue(); String version = mavenDomParent.getVersion().getStringValue(); String relativePath = mavenDomParent.getRelativePath().getStringValue(); return "Parent (" + groupId + ':' + artifactId + ':' + version + (StringUtil.isEmpty(relativePath) ? "" : ", relativePath=\"" + relativePath) +"\")"; } | getName |
20,503 | String (MavenDomGoals mavenDomGoals) { StringBuilder res = new StringBuilder("Goals"); boolean hasGoals = false; for (MavenDomGoal mavenDomGoal : mavenDomGoals.getGoals()) { String goal = mavenDomGoal.getStringValue(); if (!StringUtil.isEmptyOrSpaces(goal)) { if (hasGoals) { res.append(", "); } else { res.append(" ("); hasGoals = true; } res.append(goal); } } if (hasGoals) { res.append(")"); } return res.toString(); } | getName |
20,504 | String (MavenDomPluginExecution mavenDomPluginExecution) { String id = mavenDomPluginExecution.getId().getStringValue(); if (id == null) return "Execution"; return "Execution (id=" + id + ')'; } | getName |
20,505 | String (MavenDomPlugin plugin) { String artifactId = plugin.getArtifactId().getStringValue(); String version = plugin.getVersion().getStringValue(); return version == null ? artifactId : artifactId + ':' + version; } | getName |
20,506 | String (MavenDomRepository mavenDomRepository) { return "Repository (id=" + mavenDomRepository.getId().getStringValue() + ", url=" + mavenDomRepository.getUrl().getStringValue() + ')'; } | getName |
20,507 | String (MavenDomArtifactCoordinates coordinates) { return StringUtil.notNullize(coordinates.getGroupId().getStringValue(), UNKNOWN) + ':' + StringUtil.notNullize(coordinates.getArtifactId().getStringValue(), UNKNOWN) + ':' + StringUtil.notNullize(coordinates.getVersion().getStringValue(), UNKNOWN); } | getName |
20,508 | String (MavenDomExclusion mavenDomExclusion) { String groupId = mavenDomExclusion.getGroupId().getStringValue(); String artifactId = mavenDomExclusion.getArtifactId().getStringValue(); return groupId + ':' + artifactId; } | getName |
20,509 | String (MavenDomProfile mavenDomProfile) { return mavenDomProfile.getId().getStringValue(); } | getName |
20,510 | boolean (@NotNull DataContext context) { return findTarget(context) != null; } | isAvailableOnDataContext |
20,511 | void (@NotNull Project project, Editor editor, PsiFile file, @NotNull DataContext dataContext) { invoke(project, PsiElement.EMPTY_ARRAY, dataContext); } | invoke |
20,512 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { PsiElement element = elements.length == 1 ? elements[0] : null; if (element == null) element = findTarget(dataContext); RenameDialog.showRenameDialog(dataContext, new RenameDialog(project, element, null, CommonDataKeys.EDITOR.getData(dataContext))); } | invoke |
20,513 | PsiElement (DataContext context) { return MavenTargetUtil.getRefactorTarget(CommonDataKeys.EDITOR.getData(context), CommonDataKeys.PSI_FILE.getData(context)); } | findTarget |
20,514 | boolean (PsiElement target) { if (target instanceof MavenPsiElementWrapper) return true; PsiFile file = target.getContainingFile(); return MavenDomUtil.isProjectFile(file) || MavenDomUtil.isProfilesFile(file); } | value |
20,515 | void () { myNameField.removeDataChangedListener(myNameChangedListener); super.dispose(); } | dispose |
20,516 | void () { super.init(); updateOkStatus(); } | init |
20,517 | String () { return myNameField.getEnteredName().trim(); } | getEnteredName |
20,518 | MavenDomProjectModel () { MavenDomProjectModel selectedItem = (MavenDomProjectModel)ComboBoxUtil.getSelectedValue((DefaultComboBoxModel)myMavenProjectsComboBox.getModel()); return selectedItem == null ? myMavenDomProjectModel : selectedItem; } | getSelectedProject |
20,519 | String[] () { return getSuggestions(1); } | getSuggestions |
20,520 | String[] (int level) { Collection<String> result = new HashSet<>(); String value = mySelectedString.trim(); boolean addUnqualifiedForm = true; XmlTag parent = PsiTreeUtil.getParentOfType(myContext, XmlTag.class, false); DomElement domParent = DomUtil.getDomElement(parent); if (domParent != null) { DomElement domSuperParent = domParent.getParent(); DomFileElement<DomElement> domFile = DomUtil.getFileElement(domParent); if (domSuperParent != null && domFile != null && domFile.getRootElement() == domSuperParent) { value = domSuperParent.getXmlElementName(); addUnqualifiedForm = false; } else { MavenDomShortArtifactCoordinates coordinates = DomUtil.getParentOfType(domParent, MavenDomShortArtifactCoordinates.class, false); if (coordinates != null && !(coordinates instanceof MavenDomProjectModel) && domParent != coordinates.getArtifactId()) { String artifactId = coordinates.getArtifactId().getStringValue(); if (!StringUtil.isEmptyOrSpaces(artifactId)) { value = artifactId; addUnqualifiedForm = false; } } } } while (true) { String newValue = value.replaceAll(" ", " "); if (newValue.equals(value)) break; value = newValue; } value = value.replaceAll(" ", "."); List<String> parts = StringUtil.split(value, "."); String shortValue = parts.get(parts.size() - 1); if (addUnqualifiedForm) { result.add(value); result.add(shortValue); } String suffix = ""; while (parent != null && level != 0) { suffix = parent.getName() + suffix; result.add(suffix); result.add(value + "." + suffix); result.add(shortValue + "." + suffix); suffix = "." + suffix; parent = parent.getParentTag(); level--; } result = new ArrayList<>(result); ((List)result).sort(CodeStyleSettingsManager.getSettings(myProject).getCustomSettings(JavaCodeStyleSettings.class).PREFER_LONGER_NAMES ? StringLenComparator.getDescendingInstance() : StringLenComparator.getInstance()); return ArrayUtilRt.toStringArray(result); } | getSuggestions |
20,521 | String (@NotNull String s, @NotNull String delimiter) { return joinWords(StringUtil.split(s, delimiter)); } | joinWords |
20,522 | String (@NotNull List<String> stringList) { StringBuilder sb = new StringBuilder(); for (int i = 0; i < stringList.size(); i++) { String word = stringList.get(i); if (!StringUtil.isEmptyOrSpaces(word)) { sb.append(i == 0 ? StringUtil.decapitalize(word.trim()) : StringUtil.capitalize(word.trim())); } } return sb.toString(); } | joinWords |
20,523 | JComponent () { myFieldNamePanel.setLayout(new BorderLayout()); myNameField = new NameSuggestionsField(myProject); myNameChangedListener = () -> updateOkStatus(); myNameField.addDataChangedListener(myNameChangedListener); myNameField.setSuggestions(getSuggestions()); myFieldNamePanel.add(myNameField, BorderLayout.CENTER); List<MavenDomProjectModel> projects = getProjects(); ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), projects, model -> Pair.create(MavenDomUtil.getProjectName(model), model)); myMavenProjectsComboBox.setSelectedItem(myMavenDomProjectModel); return myMainPanel; } | createCenterPanel |
20,524 | List<MavenDomProjectModel> () { List<MavenDomProjectModel> projects = new ArrayList<>(); projects.add(myMavenDomProjectModel); projects.addAll(MavenDomProjectProcessorUtils.collectParentProjects(myMavenDomProjectModel)); return projects; } | getProjects |
20,525 | void () { String text = getEnteredName(); setOKActionEnabled(!StringUtil.isEmptyOrSpaces(text) && !isContainWrongSymbols(text) && !isPropertyExist(text)); } | updateOkStatus |
20,526 | boolean (@NotNull String text) { return text.length() == 0 || Character.isDigit(text.charAt(0)) || StringUtil.containsAnyChar(text, "\t ;*'\"\\/,()^&<>={}[]"); } | isContainWrongSymbols |
20,527 | boolean (@NotNull String text) { MavenDomProjectModel project = getSelectedProject(); if (isPropertyExist(text, project)) return true; for (MavenDomProjectModel child : MavenDomProjectProcessorUtils.getChildrenProjects(project)) { if (isPropertyExist(text, child)) return true; } for (MavenDomProjectModel parent : MavenDomProjectProcessorUtils.collectParentProjects(project)) { if (isPropertyExist(text, parent)) return true; } return false; } | isPropertyExist |
20,528 | boolean (String propertyName, MavenDomProjectModel project) { MavenDomProperties props = project.getProperties(); XmlTag propsTag = props.getXmlTag(); if (propsTag != null) { for (XmlTag each : propsTag.getSubTags()) { if (propertyName.equals(each.getName())) return true; } } return false; } | isPropertyExist |
20,529 | JComponent () { return myNameField.getFocusableComponent(); } | getPreferredFocusedComponent |
20,530 | boolean () { return true; } | isAvailableInEditorOnly |
20,531 | boolean (PsiElement @NotNull [] elements) { return false; } | isEnabledOnElements |
20,532 | RefactoringActionHandler (@NotNull DataContext dataContext) { return new MyRefactoringActionHandler(); } | getHandler |
20,533 | boolean (PsiFile file) { VirtualFile virtualFile = file.getVirtualFile(); return MavenDomUtil.isMavenFile(file) && virtualFile != null && virtualFile.getFileSystem() != JarFileSystem.getInstance(); } | isAvailableForFile |
20,534 | boolean (@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) { if (!super.isAvailableOnElementInEditorAndFile(element, editor, file, context)) return false; return getSelectedElementAndTextRange(editor, file) != null; } | isAvailableOnElementInEditorAndFile |
20,535 | void (@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) { MavenActionsUsagesCollector.trigger(project, MavenActionsUsagesCollector.INTRODUCE_PROPERTY); PsiDocumentManager.getInstance(project).commitAllDocuments(); Pair<XmlElement, TextRange> elementAndRange = getSelectedElementAndTextRange(editor, file); if (elementAndRange == null) return; XmlElement selectedElement = elementAndRange.first; final TextRange range = elementAndRange.second; String stringValue = selectedElement.getText(); if (stringValue == null) return; final MavenDomProjectModel model = MavenDomUtil.getMavenDomModel(file, MavenDomProjectModel.class); final String selectedString = editor.getDocument().getText(range); List<TextRange> ranges = getPropertiesTextRanges(stringValue); int offsetInElement = range.getStartOffset() - selectedElement.getTextOffset(); if (model == null || StringUtil.isEmptyOrSpaces(selectedString) || isIntersectWithRanges(ranges, offsetInElement, offsetInElement + selectedString.length())) { return; } editor.getSelectionModel().setSelection(range.getStartOffset(), range.getEndOffset()); IntroducePropertyDialog dialog = new IntroducePropertyDialog(project, selectedElement, model, selectedString); dialog.show(); if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) return; final String propertyName = dialog.getEnteredName(); final MavenDomProjectModel selectedProject = dialog.getSelectedProject(); if (ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(getFiles(file, selectedProject)).hasReadonlyFiles()) { return; } final String replaceWith = PREFIX + propertyName + SUFFIX; WriteCommandAction.runWriteCommandAction(project, () -> { editor.getDocument().replaceString(range.getStartOffset(), range.getEndOffset(), replaceWith); PsiDocumentManager.getInstance(project).commitAllDocuments(); createMavenProperty(selectedProject, propertyName, selectedString); PsiDocumentManager.getInstance(project).commitAllDocuments(); }); showFindUsages(project, propertyName, selectedString, replaceWith, selectedProject); } | invoke |
20,536 | List<VirtualFile> (PsiFile file, MavenDomProjectModel model) { Set<VirtualFile> virtualFiles = new HashSet<>(); VirtualFile virtualFile = file.getVirtualFile(); if (virtualFile != null) { virtualFiles.add(virtualFile); } XmlElement xmlElement = model.getXmlElement(); if (xmlElement != null) { VirtualFile vf = xmlElement.getContainingFile().getVirtualFile(); if (vf != null) virtualFiles.add(vf); } return new ArrayList<>(virtualFiles); } | getFiles |
20,537 | void (@NotNull MavenDomProjectModel model, @NotNull String enteredName, @NotNull String selectedString) { MavenDomProperties mavenDomProperties = model.getProperties(); XmlTag xmlTag = mavenDomProperties.ensureTagExists(); XmlTag propertyTag = xmlTag.createChildTag(enteredName, xmlTag.getNamespace(), selectedString, false); xmlTag.add(propertyTag); } | createMavenProperty |
20,538 | void (@NotNull Project project, @NotNull String propertyName, @NotNull String selectedString, @NotNull String replaceWith, @NotNull MavenDomProjectModel model) { UsageViewManager manager = UsageViewManager.getInstance(project); if (manager == null) return; assureFindToolWindowRegistered(project); FindManager findManager = FindManager.getInstance(project); FindModel findModel = createFindModel(findManager, selectedString, replaceWith); final UsageViewPresentation presentation = FindInProjectUtil.setupViewPresentation(true, findModel); final FindUsagesProcessPresentation processPresentation = FindInProjectUtil.setupProcessPresentation(true, presentation); findManager.getFindInProjectModel().copyFrom(findModel); final FindModel findModelCopy = findModel.clone(); ReplaceInProjectManager.getInstance(project) .searchAndShowUsages(manager, new MyUsageSearcherFactory(model, propertyName, selectedString), findModelCopy, presentation, processPresentation ); } | showFindUsages |
20,539 | void (@NotNull Project project) { UsageViewContentManager uvm = UsageViewContentManager.getInstance(project); } | assureFindToolWindowRegistered |
20,540 | FindModel (FindManager findManager, String selectedString, String replaceWith) { FindModel findModel = findManager.getFindInProjectModel().clone(); findModel.setStringToFind(selectedString); findModel.setStringToReplace(replaceWith); findModel.setReplaceState(true); findModel.setPromptOnReplace(true); findModel.setCaseSensitive(true); findModel.setRegularExpressions(false); return findModel; } | createFindModel |
20,541 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { } | invoke |
20,542 | UsageSearcher () { return new UsageSearcher() { final Set<UsageInfo> usages = new HashSet<>(); @Override public void generate(@NotNull final Processor<? super Usage> processor) { ApplicationManager.getApplication().runReadAction(() -> { collectUsages(myModel); for (MavenDomProjectModel model : MavenDomProjectProcessorUtils.getChildrenProjects(myModel)) { collectUsages(model); } for (UsageInfo usage : usages) { processor.process(UsageInfo2UsageAdapter.CONVERTER.fun(usage)); } }); } private void collectUsages(@NotNull MavenDomProjectModel model) { if (model.isValid()) { final XmlElement root = model.getXmlElement(); if (root != null) { root.acceptChildren(new XmlElementVisitor() { @Override public void visitXmlText(@NotNull XmlText text) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(text, XmlTag.class); if (xmlTag != null && !xmlTag.getName().equals(myPropertyName)) { usages.addAll(getUsages(text)); } } @Override public void visitXmlAttributeValue(@NotNull XmlAttributeValue value) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(value, XmlTag.class); if (xmlTag != null && !xmlTag.equals(root)) { usages.addAll(getUsages(value)); } } @Override public void visitXmlElement(@NotNull XmlElement element) { element.acceptChildren(this); } }); } } } @NotNull private Set<UsageInfo> getUsages(@NotNull XmlElement xmlElement) { String s = xmlElement.getText(); if (StringUtil.isEmptyOrSpaces(s)) return Collections.emptySet(); int start = s.indexOf(mySelectedString); if (start == -1) return Collections.emptySet(); Set<UsageInfo> usages = new HashSet<>(); List<TextRange> ranges = getPropertiesTextRanges(s); TextRange elementTextRange = xmlElement.getTextRange(); PsiFile containingFile = xmlElement.getContainingFile(); do { int end = start + mySelectedString.length(); boolean isInsideProperty = isIntersectWithRanges(ranges, start, end); if (!isInsideProperty) { usages .add(new UsageInfo(containingFile, elementTextRange.getStartOffset() + start, elementTextRange.getStartOffset() + end)); } start = s.indexOf(mySelectedString, end); } while (start != -1); return usages; } }; } | create |
20,543 | void (@NotNull final Processor<? super Usage> processor) { ApplicationManager.getApplication().runReadAction(() -> { collectUsages(myModel); for (MavenDomProjectModel model : MavenDomProjectProcessorUtils.getChildrenProjects(myModel)) { collectUsages(model); } for (UsageInfo usage : usages) { processor.process(UsageInfo2UsageAdapter.CONVERTER.fun(usage)); } }); } | generate |
20,544 | void (@NotNull MavenDomProjectModel model) { if (model.isValid()) { final XmlElement root = model.getXmlElement(); if (root != null) { root.acceptChildren(new XmlElementVisitor() { @Override public void visitXmlText(@NotNull XmlText text) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(text, XmlTag.class); if (xmlTag != null && !xmlTag.getName().equals(myPropertyName)) { usages.addAll(getUsages(text)); } } @Override public void visitXmlAttributeValue(@NotNull XmlAttributeValue value) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(value, XmlTag.class); if (xmlTag != null && !xmlTag.equals(root)) { usages.addAll(getUsages(value)); } } @Override public void visitXmlElement(@NotNull XmlElement element) { element.acceptChildren(this); } }); } } } | collectUsages |
20,545 | void (@NotNull XmlText text) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(text, XmlTag.class); if (xmlTag != null && !xmlTag.getName().equals(myPropertyName)) { usages.addAll(getUsages(text)); } } | visitXmlText |
20,546 | void (@NotNull XmlAttributeValue value) { XmlTag xmlTag = PsiTreeUtil.getParentOfType(value, XmlTag.class); if (xmlTag != null && !xmlTag.equals(root)) { usages.addAll(getUsages(value)); } } | visitXmlAttributeValue |
20,547 | void (@NotNull XmlElement element) { element.acceptChildren(this); } | visitXmlElement |
20,548 | Set<UsageInfo> (@NotNull XmlElement xmlElement) { String s = xmlElement.getText(); if (StringUtil.isEmptyOrSpaces(s)) return Collections.emptySet(); int start = s.indexOf(mySelectedString); if (start == -1) return Collections.emptySet(); Set<UsageInfo> usages = new HashSet<>(); List<TextRange> ranges = getPropertiesTextRanges(s); TextRange elementTextRange = xmlElement.getTextRange(); PsiFile containingFile = xmlElement.getContainingFile(); do { int end = start + mySelectedString.length(); boolean isInsideProperty = isIntersectWithRanges(ranges, start, end); if (!isInsideProperty) { usages .add(new UsageInfo(containingFile, elementTextRange.getStartOffset() + start, elementTextRange.getStartOffset() + end)); } start = s.indexOf(mySelectedString, end); } while (start != -1); return usages; } | getUsages |
20,549 | List<TextRange> (String s) { List<TextRange> ranges = new ArrayList<>(); int startOffset = s.indexOf(PREFIX); while (startOffset >= 0) { int endOffset = s.indexOf(SUFFIX, startOffset); if (endOffset > startOffset) { if (s.substring(startOffset + PREFIX.length(), endOffset).contains(PREFIX)) { startOffset = s.indexOf(PREFIX, startOffset + 1); } else { ranges.add(new TextRange(startOffset, endOffset)); startOffset = s.indexOf(PREFIX, endOffset); } } else { break; } } return ranges; } | getPropertiesTextRanges |
20,550 | boolean (@NotNull Collection<TextRange> ranges, int start, int end) { for (TextRange range : ranges) { if (start <= range.getStartOffset() && end >= range.getEndOffset()) { continue; // range is inside [start, end] } if (end <= range.getStartOffset()) { continue; // range is on right } if (start >= range.getEndOffset()) { continue; // range is on right } return true; } return false; } | isIntersectWithRanges |
20,551 | boolean () { return true; } | isAvailableInEditorOnly |
20,552 | boolean (PsiElement @NotNull [] elements) { return false; } | isEnabledOnElements |
20,553 | RefactoringActionHandler (@NotNull DataContext dataContext) { return new MyRefactoringActionHandler(); } | getHandler |
20,554 | boolean (PsiFile file) { return MavenDomUtil.isMavenFile(file); } | isAvailableForFile |
20,555 | boolean (@NotNull PsiElement element, @NotNull Editor editor, @NotNull PsiFile file, @NotNull DataContext context) { if (!super.isAvailableOnElementInEditorAndFile(element, editor, file, context)) return false; return findDependencyAndParent(file, editor) != null; } | isAvailableOnElementInEditorAndFile |
20,556 | Set<MavenDomProjectModel> (@NotNull PsiFile file) { final MavenDomProjectModel model = MavenDomUtil.getMavenDomModel(file, MavenDomProjectModel.class); if (model == null) return Collections.emptySet(); return MavenDomProjectProcessorUtils.collectParentProjects(model); } | getParentProjects |
20,557 | boolean (@NotNull MavenDomDependency dependency) { return MavenDomProjectProcessorUtils.searchManagingDependency(dependency) != null; } | isManagedDependency |
20,558 | void (@NotNull final Project project, final Editor editor, PsiFile file, DataContext dataContext) { MavenActionsUsagesCollector.trigger(project, MavenActionsUsagesCollector.EXTRACT_MANAGED_DEPENDENCIES); Pair<MavenDomDependency, Set<MavenDomProjectModel>> depAndParents = findDependencyAndParent(file, editor); if (depAndParents == null) return; final MavenDomDependency dependency = depAndParents.first; Set<MavenDomProjectModel> parent = depAndParents.second; Function<MavenDomProjectModel, Set<MavenDomDependency>> funOccurrences = getOccurencesFunction(dependency); final ProcessData processData = getProcessData(project, parent, funOccurrences, dependency.getExclusions().getXmlElement() != null); if (processData == null) return; final MavenDomProjectModel model = processData.getModel(); final Set<MavenDomDependency> usages = processData.getUsages(); final boolean extractExclusions = processData.isExtractExclusions(); assert model != null; assert usages != null; WriteCommandAction.writeCommandAction(project, getFiles(file, model, usages)).run(() -> { MavenDomDependency addedDependency = model.getDependencyManagement().getDependencies().addDependency(); addedDependency.getGroupId().setStringValue(dependency.getGroupId().getStringValue()); addedDependency.getArtifactId().setStringValue(dependency.getArtifactId().getStringValue()); addedDependency.getVersion().setStringValue(dependency.getVersion().getStringValue()); String typeValue = dependency.getType().getStringValue(); dependency.getVersion().undefine(); if (typeValue != null) { addedDependency.getType().setStringValue(typeValue); } String classifier = dependency.getClassifier().getStringValue(); if (classifier != null) { addedDependency.getClassifier().setStringValue(classifier); } String systemPath = dependency.getSystemPath().getStringValue(); if (systemPath != null) { addedDependency.getSystemPath().setStringValue(systemPath); dependency.getSystemPath().undefine(); } if (extractExclusions) { MavenDomExclusions addedExclusions = addedDependency.getExclusions(); for (MavenDomExclusion exclusion : dependency.getExclusions().getExclusions()) { MavenDomExclusion domExclusion = addedExclusions.addExclusion(); domExclusion.getGroupId().setStringValue(exclusion.getGroupId().getStringValue()); domExclusion.getArtifactId().setStringValue(exclusion.getArtifactId().getStringValue()); } dependency.getExclusions().undefine(); } for (MavenDomDependency usage : usages) { usage.getVersion().undefine(); } }); } | invoke |
20,559 | PsiFile[] (@NotNull PsiFile file, @NotNull MavenDomProjectModel model, @NotNull Set<? extends MavenDomDependency> usages) { Set<PsiFile> files = new HashSet<>(); files.add(file); XmlElement xmlElement = model.getXmlElement(); if (xmlElement != null) files.add(xmlElement.getContainingFile()); for (MavenDomDependency usage : usages) { XmlElement element = usage.getXmlElement(); if (element != null) { files.add(element.getContainingFile()); } } return PsiUtilCore.toPsiFileArray(files); } | getFiles |
20,560 | ProcessData (@NotNull Project project, @NotNull Set<MavenDomProjectModel> models, @NotNull Function<MavenDomProjectModel, Set<MavenDomDependency>> funOccurrences, boolean hasExclusions) { if (models.size() == 0) return null; if (models.size() == 1 && !hasExclusions) { MavenDomProjectModel model = models.iterator().next(); if (funOccurrences.fun(model).size() == 0) { return new ProcessData(model, Collections.emptySet(), false); } } SelectMavenProjectDialog dialog = new SelectMavenProjectDialog(project, models, funOccurrences, hasExclusions); dialog.show(); if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) { MavenDomProjectModel model = dialog.getSelectedProject(); return new ProcessData(model, dialog.isReplaceAllOccurrences() ? funOccurrences.fun(model) : Collections.emptySet(), dialog.isExtractExclusions()); } return null; } | getProcessData |
20,561 | void (@NotNull Project project, PsiElement @NotNull [] elements, DataContext dataContext) { } | invoke |
20,562 | MavenDomProjectModel () { return myModel; } | getModel |
20,563 | Set<MavenDomDependency> () { return myUsages; } | getUsages |
20,564 | boolean () { return myExtractExclusions; } | isExtractExclusions |
20,565 | void () { super.init(); updateOkStatus(); } | init |
20,566 | void () { super.dispose(); if (myReplaceAllCheckBox != null) { myReplaceAllCheckBox.removeItemListener(myReplaceAllListener); } } | dispose |
20,567 | MavenDomProjectModel () { return (MavenDomProjectModel)ComboBoxUtil.getSelectedValue((DefaultComboBoxModel)myMavenProjectsComboBox.getModel()); } | getSelectedProject |
20,568 | boolean () { return myReplaceAllCheckBox.isSelected(); } | isReplaceAllOccurrences |
20,569 | boolean () { return myExtractExclusions.isSelected(); } | isExtractExclusions |
20,570 | JComponent () { ComboBoxUtil.setModel(myMavenProjectsComboBox, new DefaultComboBoxModel(), myMavenDomProjectModels, model -> Pair.create(MavenDomUtil.getProjectName(model), model)); myReplaceAllListener = new ItemListener() { @Override public void itemStateChanged(ItemEvent e) { updateControls(); } }; myMavenProjectsComboBox.addItemListener(myReplaceAllListener); myMavenProjectsComboBox.setSelectedItem(0); myReplaceAllCheckBox.setVisible(myHasUsagesInProjects); myExtractExclusions.setVisible(myHasExclusions); updateControls(); return myMainPanel; } | createCenterPanel |
20,571 | void (ItemEvent e) { updateControls(); } | itemStateChanged |
20,572 | void () { MavenDomProjectModel project = getSelectedProject(); int count = myOccurrencesCountFunction.fun(project).size(); myReplaceAllCheckBox.setText(RefactoringBundle.message("replace.all.occurences", count)); myReplaceAllCheckBox.setEnabled(count != 0); } | updateControls |
20,573 | void () { setOKActionEnabled(getSelectedProject() != null); } | updateOkStatus |
20,574 | JComponent () { return myMavenProjectsComboBox; } | getPreferredFocusedComponent |
20,575 | Collection<String> (@NotNull ConvertContext context) { return VALUES; } | getValues |
20,576 | Converter (@NotNull GenericDomValue domElement) { Project project = domElement.getManager().getProject(); JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(project); PsiClass psiClass = psiFacade.findClass(myType, GlobalSearchScope.allScope(project)); if (psiClass != null) { GenericDomValueConvertersRegistry convertersRegistry = MavenDomConvertersRegistry.getInstance().getConvertersRegistry(); return convertersRegistry.getConverter(domElement, psiFacade.getElementFactory().createType(psiClass)); } return null; } | getConverter |
20,577 | String (@Nullable @NonNls String s, ConvertContext context) { if (s == null) return null; MavenId id = MavenArtifactCoordinatesHelper.getId(context); Project contextProject = context.getProject(); MavenIndicesManager manager = MavenIndicesManager.getInstance(contextProject); ConverterStrategy strategy = selectStrategy(context); boolean isValid = strategy.isValid(id, manager, context); if (!isValid) { MavenIndex localIndex = manager.getIndex().getLocalIndex(); if (localIndex == null) return null; Path artifactPath = MavenUtil.getArtifactPath(Path.of(localIndex.getRepositoryPathOrUrl()), id, "pom", null); if (artifactPath != null && artifactPath.toFile().exists()) { MavenIndicesManager.getInstance(contextProject).scheduleArtifactIndexing(id, artifactPath.toFile()); return s; } return null; } return s; } | fromString |
20,578 | String (@Nullable String s, ConvertContext context) { return s; } | toString |
20,579 | Collection<String> (ConvertContext context) { DependencySearchService searchService = DependencySearchService.getInstance(context.getProject()); MavenId id = MavenArtifactCoordinatesHelper.getId(context); MavenDomShortArtifactCoordinates coordinates = MavenArtifactCoordinatesHelper.getCoordinates(context); return selectStrategy(context).getVariants(id, searchService, coordinates); } | getVariants |
20,580 | PsiElement (String o, ConvertContext context) { MavenId id = MavenArtifactCoordinatesHelper.getId(context); PsiFile result = selectStrategy(context).resolve(id, context); return result != null ? result : super.resolve(o, context); } | resolve |
20,581 | String (@Nullable String s, ConvertContext context) { return selectStrategy(context).getErrorMessage(s, context); } | getErrorMessage |
20,582 | boolean (@NotNull DomElement element) { DomElement dependencyOrPluginElement = element.getParent(); if (dependencyOrPluginElement instanceof MavenDomDependency) { DomElement dependencies = dependencyOrPluginElement.getParent(); if (dependencies instanceof MavenDomDependencies) { if (dependencies.getParent() instanceof MavenDomDependencyManagement) { return true; } } } else if (dependencyOrPluginElement instanceof MavenDomPlugin) { DomElement pluginsElement = dependencyOrPluginElement.getParent(); if (pluginsElement instanceof MavenDomPlugins) { if (pluginsElement.getParent() instanceof MavenDomPluginManagement) { return true; } } } return false; } | isSoft |
20,583 | VirtualFile (ConvertContext context) { PsiFile psiFile = context.getFile().getOriginalFile(); return psiFile.getVirtualFile(); } | getMavenProjectFile |
20,584 | ConverterStrategy (ConvertContext context) { DomElement parent = context.getInvocationElement().getParent(); if (parent instanceof MavenDomProjectModel) { return new ProjectStrategy(); } if (parent instanceof MavenDomParent) { return new ParentStrategy((MavenDomParent)parent); } if (parent instanceof MavenDomDependency) { return new DependencyStrategy((MavenDomDependency)parent); } if (parent instanceof MavenDomExclusion) { return new ExclusionStrategy(); } if (parent instanceof MavenDomPlugin) { return new PluginOrExtensionStrategy(true); } if (parent instanceof MavenDomExtension) { return new PluginOrExtensionStrategy(false); } return new ConverterStrategy(); } | selectStrategy |
20,585 | String () { return MavenDomBundle.message("inspection.group"); } | getFamilyName |
20,586 | String () { return MavenDomBundle.message("fix.update.indices"); } | getText |
20,587 | boolean () { return false; } | startInWriteAction |
20,588 | boolean (@NotNull Project project, Editor editor, PsiFile file) { return MavenUtil.isPomFile(project, file.getVirtualFile()) && ContainerUtil.exists(MavenIndicesManager.getInstance(project).getIndex() .getGAVIndices(), i -> i.getRepository() != null && !"central".equals(i.getRepository().getName())); } | isAvailable |
20,589 | String (@Nullable String s, ConvertContext context) { return MavenDomBundle.message("artifact.0.not.found", MavenArtifactCoordinatesHelper.getId(context)); } | getErrorMessage |
20,590 | boolean (MavenId id, MavenIndicesManager manager, ConvertContext context) { return doIsValid(id, manager, context) || resolveBySpecifiedPath() != null; } | isValid |
20,591 | Set<String> (MavenId id, DependencySearchService searchService, MavenDomShortArtifactCoordinates coordinates) { return doGetVariants(id, searchService); } | getVariants |
20,592 | PsiFile (MavenId id, ConvertContext context) { PsiManager psiManager = context.getPsiManager(); MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(psiManager.getProject()); PsiFile result = resolveBySpecifiedPath(); if (result != null) return result; result = resolveInProjects(id, projectsManager, context); if (result != null) return result; return resolveInLocalRepository(id, projectsManager, psiManager); } | resolve |
20,593 | PsiFile () { return null; } | resolveBySpecifiedPath |
20,594 | PsiFile (MavenId id, MavenProjectsManager projectsManager, ConvertContext context) { MavenProject project = resolveMavenProject(id, projectsManager, context); return project == null ? null : context.getPsiManager().findFile(project.getFile()); } | resolveInProjects |
20,595 | MavenProject (MavenId id, MavenProjectsManager projectsManager, ConvertContext context) { if (MavenConsumerPomUtil.isAutomaticVersionFeatureEnabled(context)) { return projectsManager.findSingleProjectInReactor(id); } else { return projectsManager.findProject(id); } } | resolveMavenProject |
20,596 | PsiFile (MavenId id, MavenProjectsManager projectsManager, PsiManager psiManager) { File file = MavenUtil.getRepositoryFile(psiManager.getProject(), id, "pom", null); if (null == file) return null; VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(file); if (virtualFile == null) return null; return psiManager.findFile(virtualFile); } | resolveInLocalRepository |
20,597 | PsiFile (MavenId id, ConvertContext context) { return null; } | resolve |
20,598 | boolean (MavenId id, MavenIndicesManager manager, ConvertContext context) { return true; } | isValid |
20,599 | String (@Nullable String s, ConvertContext context) { return MavenDomBundle.message("project.0.not.found", MavenArtifactCoordinatesHelper.getId(context)); } | getErrorMessage |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.