Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
24,000 | boolean () { return myApplyToSubTags; } | isApplyToSubTags |
24,001 | void (final boolean applyToSubTagTexts) { myApplyToSubTags = applyToSubTagTexts; } | setApplyToSubTags |
24,002 | boolean (PsiElement element) { if (element instanceof XmlAttributeValue) { PsiElement parent = element.getParent(); return parent instanceof XmlAttribute && acceptsPsiElement(parent); } else return element instanceof XmlTag && acceptsPsiElement(element); } | acceptForReference |
24,003 | JPanel () { return myRoot; } | getComponent |
24,004 | void () { myNameTextField.setText(myOrigInjection.getDisplayName()); myLocalName.setText(myOrigInjection.getAttributeName()); myNamespace.getEditor().setItem(myOrigInjection.getAttributeNamespace()); myUseGeneratedName = Objects.equals(myOrigInjection.getDisplayName(), myOrigInjection.getGeneratedName()); } | resetImpl |
24,005 | void (XmlAttributeInjection other) { other.setAttributeName(myLocalName.getText()); other.setAttributeNamespace(getNamespace()); String name = myNameTextField.getText(); boolean useGenerated = myUseGeneratedName && Objects.equals(myOrigInjection.getDisplayName(), name); String newName = useGenerated || StringUtil.isEmptyOrSpaces(name) ? other.getGeneratedName() : name; other.setDisplayName(newName); } | apply |
24,006 | String () { final String s = (String)myNamespace.getEditor().getItem(); return s != null ? s : ""; } | getNamespace |
24,007 | void () { myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); myTagPanel = new TagPanel(myProject, myOrigInjection); myAdvancedPanel = new AdvancedXmlPanel(myProject, myOrigInjection); myLocalName = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getAttributeName()); myNamespace = new ComboBox(200); } | createUIComponents |
24,008 | ComboBoxModel (Project project) { final List<String> data = project.getUserData(URI_MODEL); if (data != null) { return new DefaultComboBoxModel(data.toArray()); } final List<String> urls = new ArrayList<>(Arrays.asList(ExternalResourceManager.getInstance().getResourceUrls(null, true))); Collections.sort(urls); final JspSupportProxy jspSupport = JspSupportProxy.getInstance(); if (jspSupport != null) { final List<String> tlds = new ArrayList<>(); final Module[] modules = ModuleManager.getInstance(project).getModules(); for (final Module module : modules) { final String[] tldUris = ReadAction.compute(() -> jspSupport.getPossibleTldUris(module)); for (String uri : tldUris) { if (!tlds.contains(uri)) { tlds.add(uri); } } } Collections.sort(tlds); // TLD URIs are intentionally kept above the other URIs to make it easier to find them urls.addAll(0, tlds); } project.putUserData(URI_MODEL, urls); return new DefaultComboBoxModel(urls.toArray()); } | createNamespaceUriModel |
24,009 | JPanel () { return myRoot; } | getComponent |
24,010 | void () { myLocalName.setText(myOrigInjection.getTagName()); myNamespace.getEditor().setItem(myOrigInjection.getTagNamespace()); myWithSubtags.setSelected(myOrigInjection.isApplyToSubTags()); } | resetImpl |
24,011 | void (AbstractTagInjection other) { other.setTagName(myLocalName.getText()); other.setTagNamespace(getNamespace()); other.setApplyToSubTags(myWithSubtags.isSelected()); } | apply |
24,012 | String () { final String s = (String)myNamespace.getEditor().getItem(); return s != null ? s : ""; } | getNamespace |
24,013 | void () { myLocalName = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getTagName()); myNamespace = new ComboBox(200); } | createUIComponents |
24,014 | void (XmlTagInjection other) { String name = myNameTextField.getText(); boolean useGenerated = myUseGeneratedName && Objects.equals(myOrigInjection.getDisplayName(), name); String newName = useGenerated || StringUtil.isEmptyOrSpaces(name) ? other.getGeneratedName() : name; other.setDisplayName(newName); } | apply |
24,015 | void () { myNameTextField.setText(myOrigInjection.getDisplayName()); myUseGeneratedName = Objects.equals(myOrigInjection.getDisplayName(), myOrigInjection.getGeneratedName()); } | resetImpl |
24,016 | JPanel () { return myRoot; } | getComponent |
24,017 | void () { myLanguagePanel = new LanguagePanel(myProject, myOrigInjection); myPanel = new TagPanel(myProject, myOrigInjection); myAdvancedPanel = new AdvancedXmlPanel(myProject, myOrigInjection); } | createUIComponents |
24,018 | void (AbstractTagInjection other) { other.setValuePattern(myValuePattern.getText()); other.setSingleFile(mySingleFileCheckBox.isSelected()); other.setXPathCondition(myXPathCondition.getText()); } | apply |
24,019 | void () { myValuePattern.setText(myOrigInjection.getValuePattern()); mySingleFileCheckBox.setSelected(myOrigInjection.isSingleFile()); myXPathCondition.setText(myOrigInjection.getXPathCondition()); } | resetImpl |
24,020 | JPanel () { return myRoot; } | getComponent |
24,021 | void () { myValuePattern = new LanguageTextField(RegExpLanguage.INSTANCE, myProject, myOrigInjection.getValuePattern(), new LanguageTextField.SimpleDocumentCreator() { @Override public void customizePsiFile(PsiFile psiFile) { psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE); } }); // don't even bother to look up the language when xpath-evaluation isn't possible final XPathSupportProxy proxy = XPathSupportProxy.getInstance(); myXPathCondition = new LanguageTextField(proxy != null ? InjectedLanguage.findLanguageById("XPath") : null, myProject, myOrigInjection.getXPathCondition(), new LanguageTextField.SimpleDocumentCreator() { @Override public void customizePsiFile(PsiFile psiFile) { // important to get proper validation & completion for Jaxen's built-in and PSI functions // like lower-case(), file-type(), file-ext(), file-name(), etc. if (proxy != null) { proxy.attachContext(psiFile); } } }); } | createUIComponents |
24,022 | void (PsiFile psiFile) { psiFile.putCopyableUserData(ValueRegExpAnnotator.KEY, Boolean.TRUE); } | customizePsiFile |
24,023 | void (PsiFile psiFile) { // important to get proper validation & completion for Jaxen's built-in and PSI functions // like lower-case(), file-type(), file-ext(), file-name(), etc. if (proxy != null) { proxy.attachContext(psiFile); } } | customizePsiFile |
24,024 | void (@NotNull final MultiHostRegistrar registrar, @NotNull PsiElement host) { final XmlElement xmlElement = (XmlElement) host; if (!isInIndex(xmlElement)) return; final TreeSet<TextRange> ranges = new TreeSet<>(InjectorUtils.RANGE_COMPARATOR); final PsiFile containingFile = xmlElement.getContainingFile(); final Ref<Boolean> unparsableRef = Ref.create(); getInjectedLanguage(xmlElement, unparsableRef, (language, list) -> { for (InjectionInfo trinity : list) { if (ranges.contains(trinity.range().shiftRight(trinity.host().getTextRange().getStartOffset()))) return true; } for (InjectionInfo trinity : list) { if (trinity.host().getContainingFile() != containingFile) continue; final TextRange textRange = trinity.range(); ranges.add(textRange.shiftRight(trinity.host().getTextRange().getStartOffset())); } InjectorUtils.registerInjection(language, containingFile, list, registrar); InjectorUtils.registerSupport(InjectorUtils.findNotNullInjectionSupport(XmlLanguageInjectionSupport.XML_SUPPORT_ID), true, list.get(0).host(), language); if (Boolean.TRUE.equals(unparsableRef.get())) { InjectorUtils.putInjectedFileUserData(host, language, InjectedLanguageUtil.FRANKENSTEIN_INJECTION, Boolean.TRUE); } return true; }); } | getLanguagesToInject |
24,025 | void (@NotNull PsiElement element) { if (element instanceof XmlText) { if (!(element instanceof PsiLanguageInjectionHost) || element.getTextLength() == 0) return; if (!injection.shouldBeIgnored(element)) { List<TextRange> list = injection.getInjectedArea(element); InjectedLanguage l = InjectedLanguage.create(injection.getInjectedLanguageId(), injection.getPrefix(), injection.getSuffix(), false); for (TextRange textRange : list) { result.add(new InjectionInfo((PsiLanguageInjectionHost)element, l, textRange)); } } } else if (element instanceof XmlTag) { if (!separateFiles) unparsableRef.set(Boolean.TRUE); if (injection instanceof AbstractTagInjection && ((AbstractTagInjection)injection).isApplyToSubTags()) { element.acceptChildren(this); } } } | visitElement |
24,026 | Configuration () { return Configuration.getProjectInstance(myProject); } | getConfiguration |
24,027 | boolean (XmlElement xmlElement) { final XmlIndex index = getXmlAnnotatedElementsValue(); if (xmlElement instanceof XmlAttributeValue) xmlElement = (XmlElement)xmlElement.getParent(); final XmlTag tag; if (xmlElement instanceof XmlAttribute attribute) { if (areThereInjectionsWithText(attribute.getLocalName(), index)) return true; if (areThereInjectionsWithText(attribute.getValue(), index)) return true; //if (areThereInjectionsWithText(attribute.getNamespace(), index)) return false; tag = attribute.getParent(); if (tag == null) return false; } else if (xmlElement instanceof XmlTag) { tag = (XmlTag)xmlElement; } else { return false; } if (areThereInjectionsWithText(tag.getLocalName(), index)) return true; //if (areThereInjectionsWithText(tag.getNamespace(), index)) return false; return false; } | isInIndex |
24,028 | boolean (final String text, XmlIndex index) { if (text == null) return false; if (index.strings.contains(text)) return true; Pattern pattern = index.pattern; return pattern != null && pattern.matcher(text).matches(); } | areThereInjectionsWithText |
24,029 | XmlIndex () { Configuration configuration = getConfiguration(); XmlIndex index = myXmlIndex; if (index == null || configuration.getModificationCount() != index.modCount) { final Map<ElementPattern<?>, BaseInjection> map = new HashMap<>(); for (BaseInjection injection : configuration.getInjections(XmlLanguageInjectionSupport.XML_SUPPORT_ID)) { for (InjectionPlace place : injection.getInjectionPlaces()) { if (!place.isEnabled() || place.getElementPattern() == null) continue; map.put(place.getElementPattern(), injection); } } final Collection<String> stringSet = PatternValuesIndex.buildStringIndex(map.keySet()); index = new XmlIndex(configuration.getModificationCount(), buildPattern(stringSet), stringSet); myXmlIndex = index; } return index; } | getXmlAnnotatedElementsValue |
24,030 | Pattern (Collection<String> stringSet) { final StringBuilder sb = new StringBuilder(); for (String s : stringSet) { if (!InjectorUtils.isRegexp(s)) continue; if (sb.length() > 0) sb.append('|'); sb.append("(?:").append(s).append(")"); } return sb.length() == 0 ? null : Pattern.compile(sb.toString()); } | buildPattern |
24,031 | boolean (final PsiLanguageInjectionHost host) { if (host instanceof XmlAttributeValue) { final PsiElement p = host.getParent(); if (p instanceof XmlAttribute) { final String s = ((XmlAttribute)p).getName(); return !("xmlns".equals(s) || s.startsWith("xmlns:")); } } else if (host instanceof XmlText) { final XmlTag tag = ((XmlText)host).getParentTag(); return tag != null/* && tag.getValue().getTextElements().length == 1 && tag.getSubTags().length == 0*/; } return false; } | isMine |
24,032 | String () { return XML_SUPPORT_ID; } | getId |
24,033 | boolean (PsiLanguageInjectionHost host) { return host instanceof XmlElement; } | isApplicableTo |
24,034 | BaseInjection (@NotNull PsiElement host, @Nullable Ref<? super PsiElement> commentRef) { if (host instanceof XmlAttributeValue) return null; return InjectorUtils.findCommentInjection(host instanceof XmlText ? host.getParent() : host, getId(), commentRef); } | findCommentInjection |
24,035 | boolean (Language language, final PsiLanguageInjectionHost psiElement) { if (!isMine(psiElement)) return false; String id = language.getID(); if (psiElement instanceof XmlAttributeValue) { return doInjectInAttributeValue((XmlAttributeValue)psiElement, id); } else if (psiElement instanceof XmlText) { return doInjectInXmlText((XmlText)psiElement, id); } return false; } | addInjectionInPlace |
24,036 | boolean (final PsiLanguageInjectionHost host) { return removeInjection(host); } | removeInjectionInPlace |
24,037 | boolean (PsiElement host) { final Project project = host.getProject(); final Configuration configuration = Configuration.getProjectInstance(project); final ArrayList<BaseInjection> injections = collectInjections(host, configuration); if (injections.isEmpty()) return false; final ArrayList<BaseInjection> newInjections = new ArrayList<>(); for (BaseInjection injection : injections) { final BaseInjection newInjection = injection.copy(); newInjection.setPlaceEnabled(null, false); if (InjectorUtils.canBeRemoved(newInjection)) continue; newInjections.add(newInjection); } configuration.replaceInjectionsWithUndo( project, host.getContainingFile(), newInjections, injections, Collections.emptyList()); return true; } | removeInjection |
24,038 | boolean (final PsiLanguageInjectionHost host) { if (!isMine(host)) return false; final Project project = host.getProject(); final Configuration configuration = Configuration.getProjectInstance(project); final ArrayList<BaseInjection> injections = collectInjections(host, configuration); if (injections.isEmpty()) return false; final BaseInjection originalInjection = injections.get(0); final BaseInjection xmlInjection = createFrom(originalInjection); final BaseInjection newInjection = xmlInjection == null? showDefaultInjectionUI(project, originalInjection.copy()) : showInjectionUI(project, xmlInjection); if (newInjection != null) { configuration.replaceInjectionsWithUndo( project, host.getContainingFile(), Collections.singletonList(newInjection), Collections.singletonList(originalInjection), Collections.emptyList()); } return true; } | editInjectionInPlace |
24,039 | BaseInjection (final Project project, final BaseInjection xmlInjection) { final AbstractInjectionPanel panel; String helpId; if (xmlInjection instanceof XmlTagInjection) { panel = new XmlTagPanel((XmlTagInjection)xmlInjection, project); helpId = "reference.settings.injection.language.injection.settings.xml.tag"; } else if (xmlInjection instanceof XmlAttributeInjection) { panel = new XmlAttributePanel((XmlAttributeInjection)xmlInjection, project); helpId = "reference.settings.injection.language.injection.settings.xml.attribute"; } else { throw new AssertionError(); } panel.reset(); return showEditInjectionDialog(project, panel, null, helpId) ? xmlInjection.copy() : null; } | showInjectionUI |
24,040 | BaseInjection (final BaseInjection injection) { if (injection.getInjectionPlaces().length == 0 || injection.getInjectionPlaces().length > 1) return null; AbstractTagInjection result; final InjectionPlace place = injection.getInjectionPlaces()[0]; final ElementPattern<? extends PsiElement> rootPattern = place.getElementPattern(); final ElementPatternCondition<? extends PsiElement> rootCondition = rootPattern.getCondition(); final Class<? extends PsiElement> elementClass = rootCondition.getInitialCondition().getAcceptedClass(); if (XmlAttribute.class.equals(elementClass)) { result = new XmlAttributeInjection().copyFrom(injection); } else if (XmlTag.class.equals(elementClass)) { result = new XmlTagInjection().copyFrom(injection); } else return null; result.setInjectionPlaces(InjectionPlace.EMPTY_ARRAY); for (PatternCondition<?> condition : rootCondition.getConditions()) { final String value = extractValue(condition); if ("withLocalName".equals(condition.getDebugMethodName())) { if (value == null) return null; if (result instanceof XmlAttributeInjection) { ((XmlAttributeInjection)result).setAttributeName(value); } else { result.setTagName(value); } } else if ("withNamespace".equals(condition.getDebugMethodName())) { if (value == null) return null; if (result instanceof XmlAttributeInjection) { ((XmlAttributeInjection)result).setAttributeNamespace(value); } else { result.setTagNamespace(value); } } else if (result instanceof XmlAttributeInjection && condition instanceof PatternConditionPlus) { boolean strict = "withParent".equals(condition.getDebugMethodName()); if (!strict && !"inside".equals(condition.getDebugMethodName())) return null; result.setApplyToSubTags(!strict); ElementPattern<?> insidePattern = ((PatternConditionPlus<?, ?>)condition).getValuePattern(); if (!XmlTag.class.equals(insidePattern.getCondition().getInitialCondition().getAcceptedClass())) return null; for (PatternCondition<?> insideCondition : insidePattern.getCondition().getConditions()) { String tagValue = extractValue(insideCondition); if (tagValue == null) return null; if ("withLocalName".equals(insideCondition.getDebugMethodName())) { result.setTagName(tagValue); } else if ("withNamespace".equals(insideCondition.getDebugMethodName())) { result.setTagNamespace(tagValue); } } } else { return null; } } result.generatePlaces(); return result; } | createFrom |
24,041 | String (PatternCondition<?> condition) { if (!(condition instanceof PatternConditionPlus)) return null; final ElementPattern valuePattern = ((PatternConditionPlus<?, ?>)condition).getValuePattern(); final ElementPatternCondition<?> rootCondition = valuePattern.getCondition(); if (!String.class.equals(rootCondition.getInitialCondition().getAcceptedClass())) return null; if (rootCondition.getConditions().size() != 1) return null; final PatternCondition<?> valueCondition = rootCondition.getConditions().get(0); if (!(valueCondition instanceof ValuePatternCondition<?>)) return null; final Collection values = ((ValuePatternCondition)valueCondition).getValues(); if (values.size() == 1) { final Object value = values.iterator().next(); return value instanceof String? (String)value : null; } else if (!values.isEmpty()) { for (Object value : values) { if (!(value instanceof String)) return null; } //noinspection unchecked return StringUtil.join(values, "|"); } return null; } | extractValue |
24,042 | BaseInjection (Element element) { String place = StringUtil.notNullize(element.getChildText("place")); if (place.startsWith("xmlAttribute")) { return new XmlAttributeInjection(); } else if (place.startsWith("xmlTag")) { return new XmlTagInjection(); } else { return new BaseInjection(XML_SUPPORT_ID); } } | createInjection |
24,043 | boolean (final XmlText host, final String languageId) { final XmlTag tag = host.getParentTag(); if (tag != null) { final XmlTagInjection injection = new XmlTagInjection(); injection.setInjectedLanguageId(languageId); injection.setTagName(tag.getLocalName()); injection.setTagNamespace(tag.getNamespace()); injection.generatePlaces(); doEditInjection(host.getProject(), host.getContainingFile(), injection); return true; } return false; } | doInjectInXmlText |
24,044 | void (final Project project, PsiFile psiFile, final XmlTagInjection template) { final Configuration configuration = InjectorUtils.getEditableInstance(project); final AbstractTagInjection originalInjection = (AbstractTagInjection)configuration.findExistingInjection(template); final XmlTagInjection newInjection = originalInjection == null? template : new XmlTagInjection().copyFrom(originalInjection); configuration.replaceInjectionsWithUndo( project, psiFile, Collections.singletonList(newInjection), ContainerUtil.createMaybeSingletonList(originalInjection), Collections.emptyList()); } | doEditInjection |
24,045 | boolean (final XmlAttributeValue host, final String languageId) { final XmlAttribute attribute = PsiTreeUtil.getParentOfType(host, XmlAttribute.class, true); final XmlTag tag = attribute == null? null : attribute.getParent(); if (tag != null) { final XmlAttributeInjection injection = new XmlAttributeInjection(); injection.setInjectedLanguageId(languageId); injection.setAttributeName(attribute.getLocalName()); injection.setAttributeNamespace(attribute.getNamespace()); injection.setTagName(tag.getLocalName()); injection.setTagNamespace(tag.getNamespace()); injection.generatePlaces(); doEditInjection(host.getProject(), host.getContainingFile(), injection); return true; } return false; } | doInjectInAttributeValue |
24,046 | void (final Project project, PsiFile file, final XmlAttributeInjection template) { final Configuration configuration = InjectorUtils.getEditableInstance(project); final BaseInjection originalInjection = configuration.findExistingInjection(template); final BaseInjection newInjection = originalInjection == null ? template : originalInjection.copy(); configuration.replaceInjectionsWithUndo( project, file, Collections.singletonList(newInjection), ContainerUtil.createMaybeSingletonList(originalInjection), Collections.emptyList()); } | doEditInjection |
24,047 | ArrayList<BaseInjection> (final PsiElement host, final Configuration configuration) { final ArrayList<BaseInjection> result = new ArrayList<>(); final PsiElement element = host instanceof XmlText? ((XmlText)host).getParentTag() : host instanceof XmlAttributeValue? host.getParent(): host; for (BaseInjection injection : configuration.getInjections(XML_SUPPORT_ID)) { if (injection.acceptsPsiElement(element)) { result.add(injection); } } return result; } | collectInjections |
24,048 | AnAction[] (final Project project, final Consumer<? super BaseInjection> consumer) { return new AnAction[] { new AnAction(IntelliLangBundle.messagePointer("action.XmlLanguageInjectionSupport.Anonymous.xml.tag.injection"), Presentation.NULL_STRING, PlatformIcons.XML_TAG_ICON) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { final BaseInjection newInjection = showInjectionUI(project, new XmlTagInjection()); if (newInjection != null) consumer.consume(newInjection); } }, new AnAction(IntelliLangBundle.messagePointer("action.XmlLanguageInjectionSupport.Anonymous.xml.attribute.injection"), Presentation.NULL_STRING, PlatformIcons.ANNOTATION_TYPE_ICON) { @Override public void actionPerformed(@NotNull final AnActionEvent e) { final BaseInjection injection = showInjectionUI(project, new XmlAttributeInjection()); if (injection != null) consumer.consume(injection); } } }; } | createAddActions |
24,049 | void (@NotNull final AnActionEvent e) { final BaseInjection newInjection = showInjectionUI(project, new XmlTagInjection()); if (newInjection != null) consumer.consume(newInjection); } | actionPerformed |
24,050 | void (@NotNull final AnActionEvent e) { final BaseInjection injection = showInjectionUI(project, new XmlAttributeInjection()); if (injection != null) consumer.consume(injection); } | actionPerformed |
24,051 | AnAction (final Project project, final Factory<? extends BaseInjection> producer) { return new AnAction() { @Override public void actionPerformed(@NotNull final AnActionEvent e) { final BaseInjection originalInjection = producer.create(); final BaseInjection injection = createFrom(originalInjection); if (injection != null) { final BaseInjection newInjection = showInjectionUI(project, injection); if (newInjection != null) { originalInjection.copyFrom(newInjection); } } else { perform(project, producer); } } }; } | createEditAction |
24,052 | void (@NotNull final AnActionEvent e) { final BaseInjection originalInjection = producer.create(); final BaseInjection injection = createFrom(originalInjection); if (injection != null) { final BaseInjection newInjection = showInjectionUI(project, injection); if (newInjection != null) { originalInjection.copyFrom(newInjection); } } else { perform(project, producer); } } | actionPerformed |
24,053 | JComponent () { myPanel = new AdvancedSettingsPanel(); return myPanel.myRoot; } | createComponent |
24,054 | boolean () { return myPanel.isModified(); } | isModified |
24,055 | void () { myPanel.reset(); } | reset |
24,056 | void () { myPanel = null; } | disposeUIResources |
24,057 | String () { return IntelliLangBundle.message("configurable.AdvancedSettingsUI.display.name"); } | getDisplayName |
24,058 | String () { return "reference.settings.injection.advanced"; } | getHelpTopic |
24,059 | String () { return "IntelliLang.Advanced"; } | getId |
24,060 | void (ActionEvent e) { final TreeClassChooserFactory factory = TreeClassChooserFactory.getInstance(myProject); final GlobalSearchScope scope = GlobalSearchScope.allScope(myProject); final PsiClass aClass = JavaPsiFacade.getInstance(myProject).findClass(myField.getText(), scope); final TreeClassChooser chooser = factory.createNoInnerClassesScopeChooser(IntelliLangBundle.message("dialog.title.select.annotation.class"), scope, new ClassFilter() { @Override public boolean isAccepted(PsiClass aClass) { return aClass.isAnnotationType(); } }, aClass); chooser.showDialog(); final PsiClass psiClass = chooser.getSelected(); if (psiClass != null) { myField.setText(psiClass.getQualifiedName()); } } | actionPerformed |
24,061 | boolean (PsiClass aClass) { return aClass.isAnnotationType(); } | isAccepted |
24,062 | void (JPanel panel, ReferenceEditorWithBrowseButton field) { panel.add(field, BorderLayout.CENTER); final Component[] components = panel.getParent().getComponents(); final int index = Arrays.asList(components).indexOf(panel); if (index > 0) { final Component component = components[index - 1]; if (component instanceof JLabel) { ((JLabel)component).setLabelFor(field); } } } | addField |
24,063 | boolean () { if (getInstrumentation() != myConfiguration.getInstrumentation()) { return true; } if (!myAnnotationField.getText().equals(myConfiguration.getLanguageAnnotationClass())) { return true; } if (!myPatternField.getText().equals(myConfiguration.getPatternAnnotationClass())) { return true; } if (!mySubstField.getText().equals(myConfiguration.getSubstAnnotationClass())) { return true; } if (!myConfiguration.getDfaOption().equals(getDfaOption())) { return true; } if (myConfiguration.isIncludeUncomputablesAsLiterals() != myIncludeUncomputableOperandsAsCheckBox.isSelected()) { return true; } if (myConfiguration.isSourceModificationAllowed() != mySourceModificationAllowedCheckBox.isSelected()) { return true; } return false; } | isModified |
24,064 | void () { myAnnotationField.setText(myConfiguration.getLanguageAnnotationClass()); myPatternField.setText(myConfiguration.getPatternAnnotationClass()); mySubstField.setText(myConfiguration.getSubstAnnotationClass()); myNoInstrumentation.setSelected(myConfiguration.getInstrumentation() == Configuration.InstrumentationType.NONE); myAssertInstrumentation.setSelected(myConfiguration.getInstrumentation() == Configuration.InstrumentationType.ASSERT); myExceptionInstrumentation.setSelected(myConfiguration.getInstrumentation() == Configuration.InstrumentationType.EXCEPTION); setDfaOption(myConfiguration.getDfaOption()); myIncludeUncomputableOperandsAsCheckBox.setSelected(myConfiguration.isIncludeUncomputablesAsLiterals()); mySourceModificationAllowedCheckBox.setSelected(myConfiguration.isSourceModificationAllowed()); } | reset |
24,065 | void (@NotNull final Configuration.DfaOption dfaOption) { switch (dfaOption) { case OFF -> myDfaOff.setSelected(true); case RESOLVE -> myAnalyzeReferences.setSelected(true); case ASSIGNMENTS -> myLookForAssignments.setSelected(true); case DFA -> myUseDfa.setSelected(true); } } | setDfaOption |
24,066 | PsiElementVisitor (@NotNull final ProblemsHolder holder, boolean isOnTheFly) { return new JavaElementVisitor() { final String annotationName = getAnnotationName(holder.getProject()); @Override public void visitAnnotation(@NotNull PsiAnnotation annotation) { final String name = annotation.getQualifiedName(); if (annotationName.equals(name)) { checkAnnotation(annotation, holder); } else if (name != null) { final PsiClass psiClass = JavaPsiFacade.getInstance(annotation.getProject()).findClass(name, annotation.getResolveScope()); if (psiClass != null && AnnotationUtil.isAnnotated(psiClass, annotationName, CHECK_EXTERNAL)) { checkAnnotation(annotation, holder); } } } }; } | buildVisitor |
24,067 | void (@NotNull PsiAnnotation annotation) { final String name = annotation.getQualifiedName(); if (annotationName.equals(name)) { checkAnnotation(annotation, holder); } else if (name != null) { final PsiClass psiClass = JavaPsiFacade.getInstance(annotation.getProject()).findClass(name, annotation.getResolveScope()); if (psiClass != null && AnnotationUtil.isAnnotated(psiClass, annotationName, CHECK_EXTERNAL)) { checkAnnotation(annotation, holder); } } } | visitAnnotation |
24,068 | void (PsiAnnotation annotation, ProblemsHolder holder) { final PsiModifierListOwner owner = PsiTreeUtil.getParentOfType(annotation, PsiModifierListOwner.class); if (owner instanceof PsiVariable) { final PsiType type = ((PsiVariable)owner).getType(); if (isTypeApplicable(type)) { registerProblem(annotation, holder); } } else if (owner instanceof PsiMethod) { final PsiType type = ((PsiMethod)owner).getReturnType(); if (isTypeApplicable(type)) { registerProblem(annotation, holder); } } } | checkAnnotation |
24,069 | void (PsiAnnotation annotation, ProblemsHolder holder) { holder.registerProblem(annotation, getDescriptionTemplate(), new RemoveAnnotationQuickFix(annotation, null)); } | registerProblem |
24,070 | Object (@NotNull PsiExpression e, @NotNull Configuration.DfaOption dfaOption, boolean includeUncomputablesAsLiterals, @NotNull List<? super PsiExpression> uncomputables) { ConcurrentMap<PsiElement, Object> map = new ConcurrentHashMap<>(); return myHelper.computeExpression(e, false, new PsiConstantEvaluationHelper.AuxEvaluator() { @Override public @Nullable Object computeExpression(@NotNull PsiExpression o, @NotNull PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) { PsiType resolvedType = null; if (o instanceof PsiMethodCallExpression c) { PsiMethod m = (PsiMethod)c.getMethodExpression().resolve(); PsiType returnType = m != null ? m.getReturnType() : null; if (returnType != null && !PsiTypes.voidType().equals(returnType)) { // find substitution Object substituted = calcSubstituted(m); if (substituted != null) return substituted; } resolvedType = returnType; } else if (o instanceof PsiReferenceExpression) { PsiElement resolved = ((PsiReferenceExpression)o).resolve(); if (resolved instanceof PsiModifierListOwner) { // find substitution Object substituted = calcSubstituted((PsiModifierListOwner)resolved); if (substituted != null) return substituted; if (resolved instanceof PsiVariable psiVariable) { resolvedType = psiVariable.getType(); Collection<PsiExpression> values; if (dfaOption == Configuration.DfaOption.ASSIGNMENTS) { values = DfaPsiUtil.getVariableAssignmentsInFile(psiVariable, true, o); } else if (dfaOption == Configuration.DfaOption.DFA) { values = DfaUtil.getVariableValues(psiVariable, o); } else if (dfaOption == Configuration.DfaOption.RESOLVE) { PsiExpression initializer = psiVariable.getInitializer(); values = ContainerUtil.createMaybeSingletonList(initializer); } else { values = Collections.emptyList(); } // return the first computed value as far as we do not support multiple injection for (PsiExpression value : values) { Object computedValue = auxEvaluator.computeExpression(value, this); if (computedValue != null) { return computedValue; } } } } } uncomputables.add(o); if (includeUncomputablesAsLiterals) { if (resolvedType != null) { if (PsiTypes.doubleType().isAssignableFrom(resolvedType)) return 1; // magic number! } StringBuilder sb = new StringBuilder(); o.accept(new PsiRecursiveElementWalkingVisitor() { @Override public void visitElement(@NotNull PsiElement element) { if (element instanceof PsiExpressionList) return; if (element instanceof PsiIdentifier) { if (sb.length() > 0) sb.append("."); sb.append(element.getText()); } super.visitElement(element); } }); return sb.toString(); } return null; } @Override public @NotNull ConcurrentMap<PsiElement, Object> getCacheMap(boolean overflow) { return map; } }); } | computeExpression |
24,071 | void (@NotNull PsiElement element) { if (element instanceof PsiExpressionList) return; if (element instanceof PsiIdentifier) { if (sb.length() > 0) sb.append("."); sb.append(element.getText()); } super.visitElement(element); } | visitElement |
24,072 | PsiElement () { return myValue; } | getElement |
24,073 | TextRange () { return ElementManipulators.getValueTextRange(myValue); } | getRangeInElement |
24,074 | String () { return myValue.getText(); } | getCanonicalText |
24,075 | boolean (@NotNull PsiElement element) { return resolve() == element; } | isReferenceTo |
24,076 | String () { return (String)myValue.getValue(); } | getValue |
24,077 | PsiParameter (PsiElement element) { PsiElement p = element.getParent(); if (!(p instanceof PsiExpressionList list)) return null; PsiElement parent = list.getParent(); if (!(parent instanceof PsiCallExpression)) return null; PsiExpression[] arguments = list.getExpressions(); int i = ArrayUtil.indexOf(arguments, element); if (i != -1) { final PsiCallExpression call = (PsiCallExpression)parent; final PsiMethod method = call.resolveMethod(); if (method != null) { final PsiParameter[] parameters = method.getParameterList().getParameters(); if (parameters.length > i) { return parameters[i]; } else if (parameters.length > 0) { final PsiParameter lastParam = parameters[parameters.length - 1]; if (lastParam.getType() instanceof PsiEllipsisType) { return lastParam; } } } } return null; } | getParameterForArgument |
24,078 | boolean (final PsiElement place) { return place instanceof PsiLiteralExpression && PsiUtil.isJavaToken(place.getFirstChild(), ElementType.TEXT_LITERALS); } | isStringOrCharacterLiteral |
24,079 | boolean (@NotNull PsiType type) { if (type instanceof PsiClassType) { // optimization. doesn't require resolve final String shortName = ((PsiClassType)type).getClassName(); if (!Objects.equals(shortName, CommonClassNames.JAVA_LANG_STRING_SHORT)) return false; } return CommonClassNames.JAVA_LANG_STRING.equals(type.getCanonicalText(false)); } | isString |
24,080 | boolean (@NotNull PsiType type) { if (type instanceof PsiArrayType) { return isString(((PsiArrayType)type).getComponentType()); } else { return isString(type); } } | isStringOrStringArray |
24,081 | Document (final String s, final Project project) { if (ApplicationManager.getApplication().isUnitTestMode() || project.isDefault()) { return new DocumentImpl(s); } else { return JavaReferenceEditorUtil.createTypeDocument(s, project); } } | createDocument |
24,082 | boolean (final PsiModifierListOwner owner) { if (owner instanceof PsiMethod) { final PsiType returnType = ((PsiMethod)owner).getReturnType(); if (returnType == null || !isStringOrStringArray(returnType)) { return false; } } else if (owner instanceof PsiVariable) { final PsiType type = ((PsiVariable)owner).getType(); if (!isStringOrStringArray(type)) { return false; } } else { return false; } return true; } | isLanguageAnnotationTarget |
24,083 | List<Object> (@NotNull String prefix, String suffix, Ref<? super Boolean> unparsable, PsiElement[] operands) { ArrayList<Object> result = new ArrayList<>(); ContextComputationProcessor processor = new ContextComputationProcessor(operands[0].getProject()); addStringFragment(prefix, result); PsiElement topParent = Objects.requireNonNull(PsiTreeUtil.findCommonParent(operands)); processor.collectOperands(getTopLevelInjectionTarget(topParent), result, unparsable); addStringFragment(suffix, result); return result; } | collectOperands |
24,084 | void (String string, List<Object> result) { if (StringUtil.isEmpty(string)) return; int size = result.size(); Object last = size > 0? result.get(size -1) : null; if (last instanceof String) { result.set(size - 1, last + string); } else { result.add(string); } } | addStringFragment |
24,085 | void (PsiElement expression, List<Object> result, Ref<? super Boolean> unparsable) { if (expression instanceof PsiParenthesizedExpression) { collectOperands(((PsiParenthesizedExpression)expression).getExpression(), result, unparsable); } else if (expression instanceof PsiTypeCastExpression) { collectOperands(((PsiTypeCastExpression)expression).getOperand(), result, unparsable); } else if (expression instanceof PsiConditionalExpression) { unparsable.set(Boolean.TRUE); collectOperands(((PsiConditionalExpression)expression).getThenExpression(), result, unparsable); addStringFragment(" ", result); // do not glue branches together collectOperands(((PsiConditionalExpression)expression).getElseExpression(), result, unparsable); } else if (expression instanceof PsiPolyadicExpression binaryExpression && ((PsiPolyadicExpression)expression).getOperationTokenType() == JavaTokenType.PLUS) { for (PsiExpression operand : binaryExpression.getOperands()) { collectOperands(operand, result, unparsable); } } else if (expression instanceof PsiAssignmentExpression assignmentExpression && ((PsiAssignmentExpression)expression).getOperationTokenType() == JavaTokenType.PLUSEQ) { unparsable.set(Boolean.TRUE); collectOperands(assignmentExpression.getLExpression(), result, unparsable); collectOperands(assignmentExpression.getRExpression(), result, unparsable); } else if (PsiUtilEx.isStringOrCharacterLiteral(expression)) { result.add(expression); } else if (expression instanceof PsiExpression) { SmartList<PsiExpression> uncomputables = new SmartList<>(); Object o = myEvaluationHelper.computeExpression((PsiExpression)expression, uncomputables); // in many languages 'null' is a reserved word addStringFragment(o == null? "missingValue" : String.valueOf(o), result); if (uncomputables.size() > 0) { unparsable.set(Boolean.TRUE); } } else { unparsable.set(Boolean.TRUE); result.add(expression); } } | collectOperands |
24,086 | PsiElement (@NotNull PsiElement host) { PsiElement target = host; PsiElement parent = target.getParent(); for (; parent != null; target = parent, parent = target.getParent()) { if (parent instanceof PsiPolyadicExpression) continue; if (parent instanceof PsiParenthesizedExpression) continue; if (parent instanceof PsiConditionalExpression && ((PsiConditionalExpression)parent).getCondition() != target) continue; break; } return target; } | getTopLevelInjectionTarget |
24,087 | PsiModifierListOwner (@Nullable PsiElement element, LookupType type) { while (element != null) { if (type == LookupType.PREFER_DECLARATION || type == LookupType.DECLARATION_ONLY) { if (element instanceof PsiReferenceExpression) { final PsiElement e = ((PsiReferenceExpression)element).resolve(); if (e instanceof PsiModifierListOwner) { return (PsiModifierListOwner)e; } if (type == LookupType.DECLARATION_ONLY) { return null; } } } element = ContextComputationProcessor.getTopLevelInjectionTarget(element); final PsiElement parent = element.getParent(); if (element instanceof PsiAssignmentExpression && ((PsiAssignmentExpression)element).getOperationTokenType() == JavaTokenType.PLUSEQ) { element = ((PsiAssignmentExpression)element).getLExpression(); continue; } else if (parent instanceof PsiAssignmentExpression p) { if (p.getRExpression() == element) { element = p.getLExpression(); continue; } } else if (parent instanceof PsiReturnStatement) { final PsiMethod m = PsiTreeUtil.getParentOfType(parent, PsiMethod.class); if (m != null) { return m; } } else if (parent instanceof PsiModifierListOwner) { return (PsiModifierListOwner)parent; } else if (parent instanceof PsiArrayInitializerMemberValue value) { final PsiElement pair = value.getParent(); if (pair instanceof PsiNameValuePair) { return AnnotationUtil.getAnnotationMethod((PsiNameValuePair)pair); } } else if (parent instanceof PsiNameValuePair) { return AnnotationUtil.getAnnotationMethod((PsiNameValuePair)parent); } else { return PsiUtilEx.getParameterForArgument(element); } // If no annotation has been found through the usage context, check if the element // (i.e., the element the reference refers to) is annotated itself if (type != LookupType.DECLARATION_ONLY) { if (element instanceof PsiReferenceExpression) { final PsiElement e = ((PsiReferenceExpression)element).resolve(); if (e instanceof PsiModifierListOwner) { return (PsiModifierListOwner)e; } } } return null; } return null; } | getAnnotatedElementFor |
24,088 | void (@Nullable PsiElement element, AnnotatedElementVisitor visitor) { if (element == null) return; for (PsiElement cur = ContextComputationProcessor.getTopLevelInjectionTarget(element); cur != null; cur = cur.getParent()) { if (cur instanceof PsiMethodCallExpression) break; if (!visitAnnotatedElementInner(cur, visitor)) return; } } | visitAnnotatedElements |
24,089 | boolean (@NotNull PsiElement element, @NotNull AnnotatedElementVisitor visitor) { final PsiElement parent = element.getParent(); if (element instanceof PsiReferenceExpression) { if (parent instanceof PsiReferenceExpression) return false; // skip qualified references if (!visitor.visitReference((PsiReferenceExpression)element)) return false; } else if (element instanceof PsiNameValuePair && parent != null && parent.getParent() instanceof PsiAnnotation) { return visitor.visitAnnotationParameter((PsiNameValuePair)element, (PsiAnnotation)parent.getParent()); } if (parent instanceof PsiAssignmentExpression p) { if (p.getRExpression() == element || p.getOperationTokenType() == JavaTokenType.PLUSEQ) { final PsiExpression left = p.getLExpression(); if (left instanceof PsiReferenceExpression) { return visitor.visitReference((PsiReferenceExpression)left); } } } else if (parent instanceof PsiConditionalExpression && ((PsiConditionalExpression)parent).getCondition() == element) { return false; } else if (parent instanceof PsiFunctionalExpression) { PsiMethod m = LambdaUtil.getFunctionalInterfaceMethod(parent); return m == null || visitor.visitMethodReturnStatement(element, m); } else if (parent instanceof PsiReturnStatement) { PsiElement e = PsiTreeUtil.getParentOfType(parent, PsiMethod.class, PsiFunctionalExpression.class); PsiMethod m = e == null ? null : e instanceof PsiMethod ? (PsiMethod)e : LambdaUtil.getFunctionalInterfaceMethod(e); return m == null || visitor.visitMethodReturnStatement(parent, m); } else if (parent instanceof PsiVariable) { return visitor.visitVariable((PsiVariable)parent); } else if (parent instanceof PsiModifierListOwner) { return false; // PsiClass/PsiClassInitializer/PsiCodeBlock } else if (parent instanceof PsiArrayInitializerMemberValue || parent instanceof PsiNameValuePair) { return true; } else if (parent instanceof PsiExpressionList && parent.getParent() instanceof PsiCall) { return visitor.visitMethodParameter((PsiExpression)element, (PsiCall)parent.getParent()); } return true; } | visitAnnotatedElementInner |
24,090 | PsiAnnotation[] (PsiModifierListOwner owner, Pair<String, ? extends Set<String>> annotationName, boolean allowIndirect, boolean inHierarchy) { final PsiAnnotation directAnnotation = inHierarchy? AnnotationUtil.findAnnotationInHierarchy(owner, annotationName.second) : AnnotationUtil.findAnnotation(owner, annotationName.second); if (directAnnotation != null) { return new PsiAnnotation[]{directAnnotation}; } if (allowIndirect) { final PsiAnnotation[] annotations = getAnnotations(owner, inHierarchy); for (PsiAnnotation annotation : annotations) { PsiJavaCodeReferenceElement nameReference = annotation.getNameReferenceElement(); if (nameReference == null) continue; PsiElement resolved = nameReference.resolve(); if (resolved instanceof PsiClass) { final PsiAnnotation psiAnnotation = AnnotationUtil.findAnnotationInHierarchy((PsiModifierListOwner)resolved, annotationName.second); if (psiAnnotation != null) { return new PsiAnnotation[]{psiAnnotation, annotation}; } } } } return PsiAnnotation.EMPTY_ARRAY; } | getAnnotationsFromImpl |
24,091 | PsiAnnotation[] (@NotNull PsiModifierListOwner owner, @NotNull Pair<String, ? extends Set<String>> annotationName, boolean allowIndirect) { return getAnnotationFrom(owner, annotationName, allowIndirect, true); } | getAnnotationFrom |
24,092 | String (PsiAnnotation[] annotation, @NonNls String attr) { for (PsiAnnotation psiAnnotation : annotation) { final String value = calcAnnotationValue(psiAnnotation, attr); if (value != null) return value; } return null; } | calcAnnotationValue |
24,093 | String (@NotNull PsiAnnotation annotation, @NonNls String attr) { PsiElement value = annotation.findAttributeValue(attr); Object o = CONSTANT_EVALUATION_HELPER.computeConstantExpression(value); if (o instanceof String) { return (String)o; } return null; } | calcAnnotationValue |
24,094 | PsiAnnotation[] (@NotNull final PsiModifierListOwner listOwner, final boolean inHierarchy) { final PsiModifierList modifierList = listOwner.getModifierList(); if (!inHierarchy) { return modifierList == null ? PsiAnnotation.EMPTY_ARRAY : modifierList.getAnnotations(); } return CachedValuesManager.getCachedValue(listOwner, () -> CachedValueProvider.Result .create(getHierarchyAnnotations(listOwner), PsiModificationTracker.MODIFICATION_COUNT)); } | getAnnotations |
24,095 | PsiAnnotation[] (PsiModifierListOwner listOwner) { final Set<PsiAnnotation> all = new HashSet<>() { @Override public boolean add(PsiAnnotation o) { // don't overwrite "higher level" annotations return !contains(o) && super.add(o); } }; PsiModifierList modifierList = listOwner.getModifierList(); if (modifierList != null) { ContainerUtil.addAll(all, modifierList.getAnnotations()); } for (PsiModifierListOwner superOwner : AnnotationUtil.getSuperAnnotationOwners(listOwner)) { modifierList = superOwner.getModifierList(); if (modifierList != null) { ContainerUtil.addAll(all, modifierList.getAnnotations()); } } return all.isEmpty() ? PsiAnnotation.EMPTY_ARRAY : all.toArray(PsiAnnotation.EMPTY_ARRAY); } | getHierarchyAnnotations |
24,096 | boolean (PsiAnnotation o) { // don't overwrite "higher level" annotations return !contains(o) && super.add(o); } | add |
24,097 | boolean (final PsiLanguageInjectionHost psiElement) { return PsiUtilEx.isStringOrCharacterLiteral(psiElement); } | isMine |
24,098 | String () { return JAVA_SUPPORT_ID; } | getId |
24,099 | Configurable[] (final Project project, final Configuration configuration) { return new Configurable[]{new AdvancedSettingsUI(project, configuration)}; } | createSettings |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.