Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
305,300
boolean (final @NotNull IElementType lbraceType, final @Nullable IElementType contextType) { return true; }
isPairedBracesAllowedBeforeType
305,301
boolean (final @NotNull FileType fileType, final int braceGroupId) { if (braceGroupId == XML_TAG_TOKEN_GROUP) { // Other xml languages may have nonbalanced tag names return isStrictTagMatchingForFileType(fileType); } return false; }
isStrictTagMatching
305,302
boolean (final FileType fileType) { return fileType == XmlFileType.INSTANCE || fileType == XHtmlFileType.INSTANCE; }
isStrictTagMatchingForFileType
305,303
boolean (final @NotNull FileType fileType, final int braceGroupId) { return braceGroupId == XML_TAG_TOKEN_GROUP && fileType == XmlFileType.INSTANCE; }
areTagsCaseSensitive
305,304
boolean (HighlighterIterator iterator) { IElementType tokenType = iterator.getTokenType(); int balance = 0; int count = 0; while(balance >= 0){ iterator.retreat(); count++; if (iterator.atEnd()) break; tokenType = iterator.getTokenType(); if (tokenType == XmlTokenType.XML_TAG_END || tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END){ balance++; } else if (tokenType == XmlTokenType.XML_END_TAG_START || tokenType == XmlTokenType.XML_START_TAG_START){ balance--; } } while(count-- > 0) iterator.advance(); return tokenType == XmlTokenType.XML_END_TAG_START; }
findEndTagStart
305,305
String (@NotNull CharSequence fileText, @NotNull HighlighterIterator iterator) { final IElementType tokenType = iterator.getTokenType(); String name = null; if (tokenType == XmlTokenType.XML_START_TAG_START) { iterator.advance(); IElementType tokenType1 = iterator.atEnd() ? null : iterator.getTokenType(); boolean wasWhiteSpace = false; if (isWhitespace(tokenType1)) { wasWhiteSpace = true; iterator.advance(); tokenType1 = iterator.atEnd() ? null : iterator.getTokenType(); } if (tokenType1 == XmlTokenType.XML_TAG_NAME || tokenType1 == XmlTokenType.XML_NAME ) { name = fileText.subSequence(iterator.getStart(), iterator.getEnd()).toString(); } if (wasWhiteSpace) iterator.retreat(); iterator.retreat(); } else if (tokenType == XmlTokenType.XML_TAG_END || tokenType == XmlTokenType.XML_EMPTY_ELEMENT_END) { int balance = 0; int count = 0; IElementType tokenType1 = iterator.getTokenType(); while (balance >=0) { iterator.retreat(); count++; if (iterator.atEnd()) break; tokenType1 = iterator.getTokenType(); if (tokenType1 == XmlTokenType.XML_TAG_END || tokenType1 == XmlTokenType.XML_EMPTY_ELEMENT_END) { balance++; } else if (tokenType1 == XmlTokenType.XML_TAG_NAME) { balance--; } } if (tokenType1 == XmlTokenType.XML_TAG_NAME) { name = fileText.subSequence(iterator.getStart(), iterator.getEnd()).toString(); } while (count-- > 0) iterator.advance(); } return name; }
getTagName
305,306
boolean (final IElementType tokenType1) { return tokenType1 == TokenType.WHITE_SPACE; }
isWhitespace
305,307
IElementType (final @NotNull IElementType type) { PairedBraceMatcher matcher = getPairedBraceMatcher(type); if (matcher != null) { BracePair[] pairs = matcher.getPairs(); for (BracePair pair : pairs) { if (pair.getLeftBraceType() == type ) return pair.getRightBraceType(); if (pair.getRightBraceType() == type ) return pair.getLeftBraceType(); } } return null; }
getOppositeBraceTokenType
305,308
int (final @NotNull PsiFile file, int openingBraceOffset) { return openingBraceOffset; }
getCodeConstructStart
305,309
boolean (final @NotNull PsiElement queryParameters, final @NotNull Processor<? super PsiElement> consumer) { if (queryParameters instanceof XmlTag xml) { if (ReadAction.compute(() -> isTypeElement(xml))) { final Collection<SchemaTypeInfo> infos = ReadAction.compute(() -> gatherInheritors(xml)); if (infos != null && ! infos.isEmpty()) { final XmlFile file = XmlUtil.getContainingFile(xml); final Project project = file.getProject(); final Module module = ModuleUtilCore.findModuleForPsiElement(queryParameters); //if (module == null) return false; final VirtualFile vf = file.getVirtualFile(); String thisNs = ReadAction.compute(() -> XmlNamespaceIndex.getNamespace(vf, project)); thisNs = thisNs == null ? getDefaultNs(file) : thisNs; // so thisNs can be null if (thisNs == null) return false; final ArrayList<SchemaTypeInfo> infosLst = new ArrayList<>(infos); Collections.sort(infosLst); final Map<String, Set<XmlFile>> nsMap = new HashMap<>(); for (final SchemaTypeInfo info : infosLst) { Set<XmlFile> targetFiles = nsMap.get(info.getNamespaceUri()); if (targetFiles == null) { targetFiles = new HashSet<>(); if (Objects.equals(info.getNamespaceUri(), thisNs)) { targetFiles.add(file); } final Collection<XmlFile> files = ReadAction.compute(() -> XmlUtil.findNSFilesByURI(info.getNamespaceUri(), project, module)); if (files != null) { targetFiles.addAll(files); } nsMap.put(info.getNamespaceUri(), targetFiles); } if (! targetFiles.isEmpty()) { for (final XmlFile targetFile : targetFiles) { ApplicationManager.getApplication().runReadAction(() -> { final String prefixByURI = XmlUtil.findNamespacePrefixByURI(targetFile, info.getNamespaceUri()); if (prefixByURI == null) return; final PsiElementProcessor processor = new PsiElementProcessor() { @Override public boolean execute(@NotNull PsiElement element) { if (element instanceof XmlTag) { if (isCertainTypeElement((XmlTag)element, info.getTagName(), prefixByURI) || isElementWithEmbeddedType((XmlTag)element, info.getTagName(), prefixByURI)) { consumer.process(element); return false; } } return true; } }; XmlUtil.processXmlElements(targetFile, processor, true); }); } } } } } } return true; }
execute
305,310
boolean (@NotNull PsiElement element) { if (element instanceof XmlTag) { if (isCertainTypeElement((XmlTag)element, info.getTagName(), prefixByURI) || isElementWithEmbeddedType((XmlTag)element, info.getTagName(), prefixByURI)) { consumer.process(element); return false; } } return true; }
execute
305,311
boolean (XmlTag xml) { final String localName = xml.getLocalName(); if (! (XmlUtil.XML_SCHEMA_URI.equals(xml.getNamespace()) && "element".equals(localName))) { return false; } final XmlTag[] tags = xml.getSubTags(); for (XmlTag tag : tags) { if (isTypeElement(tag)) { return true; } } return false; }
isElementWithSomeEmbeddedType
305,312
boolean (XmlTag xml, final String typeName, final String typeNsPrefix) { final String localName = xml.getLocalName(); if (! (XmlUtil.XML_SCHEMA_URI.equals(xml.getNamespace()) && "element".equals(localName))) { return false; } final XmlAttribute nameAttr = getNameAttr(xml); if (nameAttr == null || nameAttr.getValue() == null) return false; final String localTypeName = XmlUtil.findLocalNameByQualifiedName(nameAttr.getValue()); final String prefix = XmlUtil.findPrefixByQualifiedName(nameAttr.getValue()); if (! typeName.equals(localTypeName) || ! typeNsPrefix.equals(prefix)) { return false; } final XmlTag[] tags = xml.getSubTags(); for (XmlTag tag : tags) { if (isTypeElement(tag)) { return true; } } return false; }
isElementWithEmbeddedType
305,313
boolean (XmlTag xml, final String typeName, final String nsPrefix) { if (! isTypeElement(xml)) return false; final XmlAttribute name = getNameAttr(xml); if (name == null) return false; final String value = name.getValue(); if (value == null) return false; final String localName = XmlUtil.findLocalNameByQualifiedName(value); return typeName.equals(localName) && nsPrefix.equals(XmlUtil.findPrefixByQualifiedName(value)); }
isCertainTypeElement
305,314
boolean (XmlTag xml) { final String localName = xml.getLocalName(); return XmlUtil.XML_SCHEMA_URI.equals(xml.getNamespace()) && ("complexType".equals(localName) || "simpleType".equals(localName)); }
isTypeElement
305,315
Collection<SchemaTypeInfo> (XmlTag xml) { XmlAttribute name = getNameAttr(xml); if (name == null || StringUtil.isEmptyOrSpaces(name.getValue())) return null; String localName = name.getValue(); final boolean hasPrefix = localName.contains(":"); localName = hasPrefix ? localName.substring(localName.indexOf(':') + 1) : localName; final String nsPrefix = hasPrefix ? name.getValue().substring(0, name.getValue().indexOf(':')) : null; final XmlFile file = XmlUtil.getContainingFile(xml); if (file == null) return null; final Project project = file.getProject(); final Set<SchemaTypeInfo> result = new HashSet<>(); final ArrayDeque<SchemaTypeInfo> queue = new ArrayDeque<>(); String nsUri; if (! hasPrefix) { nsUri = getDefaultNs(file); } else { nsUri = XmlUtil.findNamespaceByPrefix(nsPrefix, file.getRootTag()); } if (nsUri == null) return null; queue.add(new SchemaTypeInfo(localName, true, nsUri)); final BiFunction<String, String, List<Set<SchemaTypeInfo>>> worker = SchemaTypeInheritanceIndex.getWorker(project, file.getContainingFile().getVirtualFile()); while (! queue.isEmpty()) { final SchemaTypeInfo info = queue.removeFirst(); final List<Set<SchemaTypeInfo>> childrenOfType = worker.apply(info.getNamespaceUri(), info.getTagName()); for (Set<SchemaTypeInfo> infos : childrenOfType) { for (SchemaTypeInfo typeInfo : infos) { if (typeInfo.isIsTypeName()) { queue.add(typeInfo); } result.add(typeInfo); } } } return result; }
gatherInheritors
305,316
XmlAttribute (XmlTag xml) { XmlAttribute name = xml.getAttribute("name", XmlUtil.XML_SCHEMA_URI); name = name == null ? xml.getAttribute("name") : name; return name; }
getNameAttr
305,317
String (final XmlFile file) { return ReadAction.compute(() -> { String nsUri; final XmlTag tag = file.getDocument().getRootTag(); XmlAttribute xmlns = tag.getAttribute("xmlns", XmlUtil.XML_SCHEMA_URI); xmlns = xmlns == null ? tag.getAttribute("xmlns") : xmlns; nsUri = xmlns == null ? null : xmlns.getValue(); return nsUri; }); }
getDefaultNs
305,318
PsiElementListCellRenderer (@NotNull PsiElement element, @NotNull GotoTargetHandler.GotoData gotoData) { if (element instanceof XmlTag) { if (SchemaDefinitionsSearch.isTypeElement((XmlTag)element)) { return new MyRenderer(""); } else if (SchemaDefinitionsSearch.isElementWithSomeEmbeddedType((XmlTag)element)) { return new MyRenderer("xsd:element: "); } } return null; }
getRenderer
305,319
String (XmlTag element) { final XmlAttribute attr = SchemaDefinitionsSearch.getNameAttr(element); return myPrefix + (attr == null || attr.getValue() == null ? element.getName() : attr.getValue()); }
getElementText
305,320
String (XmlTag element, String name) { final PsiFile file = element.getContainingFile(); return "(" + file.getName() + ")"; }
getContainerText