Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
299,600
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; XsdNamespaceBuilder builder = (XsdNamespaceBuilder)o; if (!Objects.equals(myNamespace, builder.myNamespace)) return false; if (!Objects.equals(myVersion, builder.myVersion)) return false; if (!Objects.equals(myTags, builder.myTags)) return false; return true; }
equals
299,601
int () { int result = myNamespace != null ? myNamespace.hashCode() : 0; result = 31 * result + (myVersion != null ? myVersion.hashCode() : 0); result = 31 * result + (myTags != null ? myTags.hashCode() : 0); return result; }
hashCode
299,602
GlobalSearchScope (@NotNull Project project) { GlobalSearchScope projectScope = GlobalSearchScope.allScope(project); return new GlobalSearchScope(project) { @Override public int compare(@NotNull VirtualFile file1, @NotNull VirtualFile file2) { return projectScope.compare(file1, file2); } @Override public boolean isSearchInModuleContent(@NotNull Module aModule) { return true; } @Override public boolean contains(@NotNull VirtualFile file) { final VirtualFile parent = file.getParent(); return parent != null && (parent.getName().equals("standardSchemas") || projectScope.contains(file)); } @Override public boolean isSearchInLibraries() { return true; } }; }
createFilter
299,603
int (@NotNull VirtualFile file1, @NotNull VirtualFile file2) { return projectScope.compare(file1, file2); }
compare
299,604
boolean (@NotNull Module aModule) { return true; }
isSearchInModuleContent
299,605
boolean (@NotNull VirtualFile file) { final VirtualFile parent = file.getParent(); return parent != null && (parent.getName().equals("standardSchemas") || projectScope.contains(file)); }
contains
299,606
boolean () { return true; }
isSearchInLibraries
299,607
KeyDescriptor<String> () { return EnumeratorStringDescriptor.INSTANCE; }
getKeyDescriptor
299,608
boolean (final @NotNull VirtualFile file) { if (!"xsd".equals(file.getExtension())) { return false; } if (file.isInLocalFileSystem()) { return true; } VirtualFile parent = file.getParent(); return parent != null && parent.getName().equals("standardSchemas"); }
acceptInput
299,609
boolean () { return true; }
dependsOnFileContent
299,610
int () { return 1; }
getVersion
299,611
boolean (final @NotNull VirtualFile file) { return "xsd".equals(file.getExtension()); }
acceptInput
299,612
DataExternalizer<XsdNamespaceBuilder> () { return new DataExternalizer<>() { @Override public void save(@NotNull DataOutput out, XsdNamespaceBuilder value) throws IOException { IOUtil.writeUTF(out, value.getNamespace() != null ? value.getNamespace() : NULL_STRING); IOUtil.writeUTF(out, value.getVersion() != null ? value.getVersion() : NULL_STRING); IOUtil.writeStringList(out, value.getTags()); IOUtil.writeStringList(out, value.getRootTags()); } @Override public XsdNamespaceBuilder read(@NotNull DataInput in) throws IOException { String namespace = IOUtil.readUTF(in); if (NULL_STRING.equals(namespace)) namespace = null; String version = IOUtil.readUTF(in); if (NULL_STRING.equals(version)) version = null; return new XsdNamespaceBuilder(namespace, version, IOUtil.readStringList(in), IOUtil.readStringList(in)); } }; }
getValueExternalizer
299,613
int () { return 8; }
getVersion
299,614
int (IndexedRelevantResource<String, XsdNamespaceBuilder> o1, IndexedRelevantResource<String, XsdNamespaceBuilder> o2) { return weight(o1) - weight(o2); }
compare
299,615
ResourceRelevance (VirtualFile resource, @Nullable Module module, ProjectFileIndex fileIndex, @Nullable GlobalSearchScope additionalScope) { boolean inTest = fileIndex.isInTestSourceContent(resource); if (module != null) { GlobalSearchScope scope = module.getModuleRuntimeScope(inTest); Module resourceModule = fileIndex.getModuleForFile(resource); if (resourceModule != null && (resourceModule == module || scope.isSearchInModuleContent(resourceModule)) || scope.contains(resource) || (additionalScope != null && additionalScope.contains(resource))) { return inTest || fileIndex.isInSource(resource) ? SOURCE : LIBRARY; } } else if (inTest || fileIndex.isInSource(resource)) { return SOURCE; } else if (fileIndex.isInLibraryClasses(resource)) { return LIBRARY; } ExternalResourceManagerEx resourceManager = (ExternalResourceManagerEx)ExternalResourceManager.getInstance(); return resourceManager.isUserResource(resource) ? MAPPED : STANDARD; }
getRelevance
299,616
void (NameSpaceHelper nameSpaceHelper) { myNameSpaceHelper = nameSpaceHelper; }
setNameSpaceHelper
299,617
void (String value, final String typeName) { /*final int separatorIdx = value.indexOf(':'); final String ns = separatorIdx <= 0 ? "" : new String(value.substring(0, separatorIdx)); final String element = separatorIdx <= 0 ? value : new String(value.substring(separatorIdx + 1)); String nsUri = myNameSpaceHelper.getNamespaces().get(ns); nsUri = (nsUri == null ? ns : nsURI);*/ final boolean isAnonymous = SIGN.equals(typeName); if (isAnonymous && myCurrentElementName != null) { myMap.putValue(createSchemaTypeInfo(value, true), createSchemaTypeInfo(myCurrentElementName, false)); } else { myMap.putValue(createSchemaTypeInfo(value, true), createSchemaTypeInfo(typeName, true)); //myMap.putValue(new SchemaTypeInfo(element, true, nsURI), new SchemaTypeInfo(typeName, true, typeNamespace)); } }
putTypeDataToMap
299,618
SchemaTypeInfo (final String value, final boolean isType) { final int separatorIdx = value.indexOf(':'); final String ns = separatorIdx <= 0 ? "" : value.substring(0, separatorIdx); final String element = separatorIdx <= 0 ? value : value.substring(separatorIdx + 1); String nsUri = myNameSpaceHelper.getNamespaces().get(ns); nsUri = nsUri == null ? ns : nsUri; return new SchemaTypeInfo(element, isType, nsUri); }
createSchemaTypeInfo
299,619
void (String key, String value, String systemId, int lineNr) { super.attributeAdded(key, value, systemId, lineNr); if (myInSchema) { if (key.startsWith(XMLNS)) { if (key.length() == XMLNS.length()) { myNamespaces.put("", value); } else if (key.startsWith(XMLNS_)) { final String prefix = key.substring(XMLNS_.length()); myNamespaces.put(prefix, value); } } } }
attributeAdded
299,620
void (String name, String systemId, int lineNr) { super.elementStarted(name, systemId, lineNr); myInSchema = "schema".equals(name) || name.endsWith(":schema"); }
elementStarted
299,621
List<Set<SchemaTypeInfo>> (final Project project, final String ns, final String name) { GlobalSearchScope filter = createFilter(project); return FileBasedIndex.getInstance().getValues(NAME, NsPlusTag.INSTANCE.encode(Pair.create(ns, name)), filter); }
getDirectChildrenOfType
299,622
List<Set<SchemaTypeInfo>> (String ns, String name) { List<Set<SchemaTypeInfo>> type = getDirectChildrenOfType(myProject, ns, name); if (myShouldParseCurrent) { if (myMap == null) { try { myMap = XsdComplexTypeInfoBuilder.parse(CharArrayUtil.readerFromCharSequence(VfsUtilCore.loadText(myCurrentFile))); type.add(new HashSet<>(myMap.get(new SchemaTypeInfo(name, true, ns)))); } catch (IOException e) { LOG.info(e); } } } return type; }
apply
299,623
int () { return 2; }
getVersion
299,624
DataExternalizer<Set<SchemaTypeInfo>> () { return new DataExternalizer<>() { @Override public void save(@NotNull DataOutput out, Set<SchemaTypeInfo> value) throws IOException { DataInputOutputUtil.writeINT(out, value.size()); for (SchemaTypeInfo key : value) { IOUtil.writeUTF(out, key.getNamespaceUri()); IOUtil.writeUTF(out, key.getTagName()); out.writeBoolean(key.isIsTypeName()); } } @Override public Set<SchemaTypeInfo> read(@NotNull DataInput in) throws IOException { final Set<SchemaTypeInfo> set = new HashSet<>(); final int size = DataInputOutputUtil.readINT(in); for (int i = 0; i < size; i++) { final String nsUri = IOUtil.readUTF(in); final String tagName = IOUtil.readUTF(in); final boolean isType = in.readBoolean(); set.add(new SchemaTypeInfo(tagName, isType, nsUri)); } return set; } }; }
getValueExternalizer
299,625
String (Pair<String, String> pair) { return pair.getFirst() + ourSeparator + pair.getSecond(); }
encode
299,626
String () { return myTagName; }
getTagName
299,627
String () { return myNamespaceUri; }
getNamespaceUri
299,628
boolean () { return myIsTypeName; }
isIsTypeName
299,629
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SchemaTypeInfo info = (SchemaTypeInfo)o; if (myIsTypeName != info.myIsTypeName) return false; if (myNamespaceUri != null ? !myNamespaceUri.equals(info.myNamespaceUri) : info.myNamespaceUri != null) return false; if (!myTagName.equals(info.myTagName)) return false; return true; }
equals
299,630
int () { int result = myTagName.hashCode(); result = 31 * result + (myNamespaceUri != null ? myNamespaceUri.hashCode() : 0); result = 31 * result + (myIsTypeName ? 1 : 0); return result; }
hashCode
299,631
int (SchemaTypeInfo o) { return myTagName.compareTo(o.getTagName()); }
compareTo
299,632
Collection<VirtualFile> (@NotNull String tagName, @NotNull Project project) { return FileBasedIndex.getInstance().getContainingFiles(NAME, tagName, createFilter(project)); }
getFilesByTagName
299,633
Collection<String> (@NotNull Project project) { return FileBasedIndex.getInstance().getAllKeys(NAME, project); }
getAllTagNames
299,634
DataExternalizer<Void> () { return VoidDataExternalizer.INSTANCE; }
getValueExternalizer
299,635
void (@NotNull Reader reader, @NotNull Consumer<String> consumer) { try (reader) { NanoXmlUtil.parse(reader, new NanoXmlBuilder() { private boolean elementStarted; @Override public void startElement(@NonNls String name, @NonNls String nsPrefix, @NonNls String nsURI, String systemID, int lineNr) { elementStarted = nsPrefix != null && nsURI.equals(XmlUtil.XML_SCHEMA_URI) && name.equals("element"); } @Override public void addAttribute(@NonNls String key, String nsPrefix, String nsURI, String value, String type) { if (elementStarted && key.equals("name")) { consumer.accept(value); elementStarted = false; } } }); } catch (IOException ignore) { } }
computeTagNames
299,636
void (@NonNls String name, @NonNls String nsPrefix, @NonNls String nsURI, String systemID, int lineNr) { elementStarted = nsPrefix != null && nsURI.equals(XmlUtil.XML_SCHEMA_URI) && name.equals("element"); }
startElement
299,637
void (@NonNls String key, String nsPrefix, String nsURI, String value, String type) { if (elementStarted && key.equals("name")) { consumer.accept(value); elementStarted = false; } }
addAttribute
299,638
VirtualFile () { return myFile; }
getFile
299,639
V () { return myValue; }
getValue
299,640
ResourceRelevance () { return myRelevance; }
getRelevance
299,641
int (IndexedRelevantResource<K, V> o) { int i = myRelevance.compareTo(o.getRelevance()); return i == 0 ? myValue.compareTo(o.getValue()) : i; }
compareTo
299,642
K () { return myKey; }
getKey
299,643
String () { return "IndexedRelevantResource{" + "myRelevance=" + myRelevance + ", myKey=" + myKey + ", myValue=" + myValue + ", myFile=" + myFile + '}'; }
toString
299,644
String[] () { return StringUtil.filterEmptyStrings(getEnumeratedValues()); }
getValuesForCompletion
299,645
PsiElement (XmlElement attributeValue, String value) { String defaultValue = getDefaultValue(); if (Objects.equals(defaultValue, value)) { return getDefaultValueDeclaration(); } return isFixed() ? null : getEnumeratedValueDeclaration(attributeValue, value); }
getValueDeclaration
299,646
boolean () { return false; }
isList
299,647
PsiReference[] (T element, @NotNull String text) { return new XmlEnumeratedReferenceSet(element, this).getPsiReferences(); }
getValueReferences
299,648
NamedReferenceProviders () { return ApplicationManager.getApplication().getService(NamedReferenceProviders.class); }
getInstance
299,649
ByHostClass (@NotNull XmlNamedReferenceHost element) { return myByHostClass.computeIfAbsent(element.getClass(), NamedReferenceProviders::byHostClassInner); }
byHostClass
299,650
ByHostClass (@NotNull Class<?> hostClass) { List<XmlNamedReferenceProviderBean> result = new SmartList<>(); for (XmlNamedReferenceProviderBean bean : EP_NAME.getExtensionList()) { if (bean.getHostElementClass().isAssignableFrom(hostClass)) { result.add(bean); } } return new ByHostClass(result); }
byHostClassInner
299,651
Collection<PsiSymbolReferenceProvider> (@NotNull Class<?> targetClass) { List<PsiSymbolReferenceProvider> result = new SmartList<>(); for (XmlNamedReferenceProviderBean bean : EP_NAME.getExtensionList()) { if (targetClass.isAssignableFrom(bean.getResolveTargetClass())) { result.add(bean.getInstance()); } } return result; }
byTargetClassInner
299,652
String (PsiElement context) { return getName(); }
getName
299,653
boolean (XmlElement context) { return isEnumerated(); }
isEnumerated
299,654
String () { return getName(); }
toString
299,655
PsiElement (XmlElement xmlElement, String value) { String[] values = getEnumeratedValues(); if (values == null || values.length == 0) return getFirstItem(getDeclarations()); return ArrayUtilRt.find(values, value) != -1 ? getFirstItem(getDeclarations()) : null; }
getEnumeratedValueDeclaration
299,656
PsiElement () { return getFirstItem(getDeclarations()); }
getDefaultValueDeclaration
299,657
boolean (XmlFile file) { return file.getUserData(AUTO_GENERATED) != null; }
isAutoGeneratedSchema
299,658
boolean (final @NotNull XmlDocument document, XmlNSDescriptor defaultNSDescriptorInner) { if (defaultNSDescriptorInner == null) { return false; } XmlFile descriptorFile = defaultNSDescriptorInner.getDescriptorFile(); if (descriptorFile == null) { return false; } @NonNls String otherName = XmlUtil.getContainingFile(document).getName() + ".dtd"; return descriptorFile.getName().equals(otherName); }
isGeneratedFromDtd
299,659
String (@Nullable PsiFile file) { if (file == null) { return "NULL"; } final VirtualFile vFile = file.getVirtualFile(); return vFile != null ? vFile.getPath() : "NULL_VFILE"; }
getFilePathForLogging
299,660
record (PsiElement element, @InspectionMessage String message, Validator.ValidationHost.ErrorType type) { }
ValidationInfo
299,661
void (final XmlElement element, Validator.ValidationHost host) { final PsiFile file = element.getContainingFile(); if (file == null || file.getVirtualFile() == null) return; if (myFile == file && myModificationStamp == file.getModificationStamp() && !ValidateXmlActionHandler.isValidationDependentFilesOutOfDate((XmlFile)file) && dereference(myInfos)!=null // we have validated before ) { addAllInfos(host,myInfos.get()); return; } if (myHandler==null) myHandler = new ValidateXmlActionHandler(false); final Project project = element.getProject(); final Document document = PsiDocumentManager.getInstance(project).getDocument(file); if (document==null) return; final List<ValidationInfo> results = new LinkedList<>(); myHost = new Validator.ValidationHost() { @Override public void addMessage(final PsiElement context, final String message, final @NotNull ErrorType type) { final ValidationInfo o = new ValidationInfo(context, message, type); results.add(o); } }; myHandler.setErrorReporter(new ErrorReporter(myHandler) { int unsupportedSchemeAt = -1; @Override public boolean isStopOnUndeclaredResource() { return true; } @Override public void processError(final SAXParseException e, final ValidateXmlActionHandler.ProblemType warning) { try { ApplicationManager.getApplication().runReadAction(() -> { if (e.getPublicId() != null) { return; } final VirtualFile errorFile = myHandler.getProblemFile(e); if (!Comparing.equal(errorFile, file.getVirtualFile()) && errorFile != null) { return; // error in attached schema } if (document.getLineCount() < e.getLineNumber() || e.getLineNumber() <= 0) { return; } Validator.ValidationHost.ErrorType problemType = getProblemType(warning); int offset = Math.max(0, document.getLineStartOffset(e.getLineNumber() - 1) + e.getColumnNumber() - 2); if (offset >= document.getTextLength()) return; PsiElement currentElement = PsiDocumentManager.getInstance(project).getPsiFile(document).findElementAt(offset); PsiElement originalElement = currentElement; final String elementText = currentElement.getText(); if (elementText.equals("</")) { currentElement = currentElement.getNextSibling(); } else if (elementText.equals(">") || elementText.equals("/>") || elementText.equals("=")) { currentElement = currentElement.getPrevSibling(); } // Cannot find the declaration of element String localizedMessage = e.getLocalizedMessage(); // Ideally would be to switch one messageIds int endIndex = localizedMessage.indexOf(':'); if (endIndex < localizedMessage.length() - 1 && localizedMessage.charAt(endIndex + 1) == '/') { endIndex = -1; // ignore : in http:// } String messageId = endIndex != -1 ? localizedMessage.substring(0, endIndex ):""; localizedMessage = localizedMessage.substring(endIndex + 1).trim(); if ("cvc-elt.1.a".equals(messageId)) { XmlTag tag = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class); if (tag != null && tag.getNamespace().isEmpty()) { // "Cannot find the declaration of element" is not helpful without schema return; } } else if ("SchemeUnsupported".equals(messageId)) { unsupportedSchemeAt = offset; return; } else if (unsupportedSchemeAt == offset && ("An 'include' failed, and no 'fallback' element was found.".equals(localizedMessage) || (e.getLocalizedMessage().startsWith("Include operation failed, reverting to fallback.")))) { return; } if (localizedMessage.startsWith(CANNOT_FIND_DECLARATION_ERROR_PREFIX) || localizedMessage.startsWith(ELEMENT_ERROR_PREFIX) || localizedMessage.startsWith(ROOT_ELEMENT_ERROR_PREFIX) || localizedMessage.startsWith(CONTENT_OF_ELEMENT_TYPE_ERROR_PREFIX) ) { addProblemToTagName(currentElement, originalElement, localizedMessage, warning); //return; } else if (localizedMessage.startsWith(VALUE_ERROR_PREFIX)) { addProblemToTagName(currentElement, originalElement, localizedMessage, warning); } else { if (messageId.startsWith(ATTRIBUTE_MESSAGE_PREFIX)) { @NonNls String prefix = "of attribute "; final int i = localizedMessage.indexOf(prefix); if (i != -1) { int messagePrefixLength = prefix.length() + i; final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); currentElement = parent.getAttribute(attrName,null); if (currentElement != null) { currentElement = ((XmlAttribute)currentElement).getValueElement(); } } if (currentElement!=null) { assertValidElement(currentElement, originalElement,localizedMessage); myHost.addMessage(currentElement,localizedMessage, problemType); } else { addProblemToTagName(originalElement, originalElement, localizedMessage, warning); } } else if (localizedMessage.startsWith(ATTRIBUTE_ERROR_PREFIX)) { final int messagePrefixLength = ATTRIBUTE_ERROR_PREFIX.length(); if ( localizedMessage.charAt(messagePrefixLength) == '"' || localizedMessage.charAt(messagePrefixLength) == '\'' ) { // extract the attribute name from message and get it from tag! final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); currentElement = parent.getAttribute(attrName,null); if (currentElement!=null) { currentElement = SourceTreeToPsiMap.treeElementToPsi( XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild( SourceTreeToPsiMap.psiElementToTree(currentElement) ) ); } } else { currentElement = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class, false); } if (currentElement!=null) { assertValidElement(currentElement, originalElement,localizedMessage); myHost.addMessage(currentElement,localizedMessage, problemType); } else { addProblemToTagName(originalElement, originalElement, localizedMessage, warning); } } else if (localizedMessage.startsWith(STRING_ERROR_PREFIX)) { if (currentElement != null) { myHost.addMessage(currentElement,localizedMessage, Validator.ValidationHost.ErrorType.WARNING); } } else { currentElement = getNodeForMessage(currentElement != null ? currentElement:originalElement); assertValidElement(currentElement, originalElement,localizedMessage); if (currentElement!=null) { myHost.addMessage(currentElement,localizedMessage, problemType); } } } }); } catch (Exception ex) { if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex; if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex; LOG.error(ex); } } }); myHandler.doValidate((XmlFile)file); myFile = file; myModificationStamp = myFile.getModificationStamp(); myInfos = new WeakReference<>(results); addAllInfos(host,results); }
runJaxpValidation
299,662
void (final PsiElement context, final String message, final @NotNull ErrorType type) { final ValidationInfo o = new ValidationInfo(context, message, type); results.add(o); }
addMessage
299,663
boolean () { return true; }
isStopOnUndeclaredResource
299,664
void (final SAXParseException e, final ValidateXmlActionHandler.ProblemType warning) { try { ApplicationManager.getApplication().runReadAction(() -> { if (e.getPublicId() != null) { return; } final VirtualFile errorFile = myHandler.getProblemFile(e); if (!Comparing.equal(errorFile, file.getVirtualFile()) && errorFile != null) { return; // error in attached schema } if (document.getLineCount() < e.getLineNumber() || e.getLineNumber() <= 0) { return; } Validator.ValidationHost.ErrorType problemType = getProblemType(warning); int offset = Math.max(0, document.getLineStartOffset(e.getLineNumber() - 1) + e.getColumnNumber() - 2); if (offset >= document.getTextLength()) return; PsiElement currentElement = PsiDocumentManager.getInstance(project).getPsiFile(document).findElementAt(offset); PsiElement originalElement = currentElement; final String elementText = currentElement.getText(); if (elementText.equals("</")) { currentElement = currentElement.getNextSibling(); } else if (elementText.equals(">") || elementText.equals("/>") || elementText.equals("=")) { currentElement = currentElement.getPrevSibling(); } // Cannot find the declaration of element String localizedMessage = e.getLocalizedMessage(); // Ideally would be to switch one messageIds int endIndex = localizedMessage.indexOf(':'); if (endIndex < localizedMessage.length() - 1 && localizedMessage.charAt(endIndex + 1) == '/') { endIndex = -1; // ignore : in http:// } String messageId = endIndex != -1 ? localizedMessage.substring(0, endIndex ):""; localizedMessage = localizedMessage.substring(endIndex + 1).trim(); if ("cvc-elt.1.a".equals(messageId)) { XmlTag tag = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class); if (tag != null && tag.getNamespace().isEmpty()) { // "Cannot find the declaration of element" is not helpful without schema return; } } else if ("SchemeUnsupported".equals(messageId)) { unsupportedSchemeAt = offset; return; } else if (unsupportedSchemeAt == offset && ("An 'include' failed, and no 'fallback' element was found.".equals(localizedMessage) || (e.getLocalizedMessage().startsWith("Include operation failed, reverting to fallback.")))) { return; } if (localizedMessage.startsWith(CANNOT_FIND_DECLARATION_ERROR_PREFIX) || localizedMessage.startsWith(ELEMENT_ERROR_PREFIX) || localizedMessage.startsWith(ROOT_ELEMENT_ERROR_PREFIX) || localizedMessage.startsWith(CONTENT_OF_ELEMENT_TYPE_ERROR_PREFIX) ) { addProblemToTagName(currentElement, originalElement, localizedMessage, warning); //return; } else if (localizedMessage.startsWith(VALUE_ERROR_PREFIX)) { addProblemToTagName(currentElement, originalElement, localizedMessage, warning); } else { if (messageId.startsWith(ATTRIBUTE_MESSAGE_PREFIX)) { @NonNls String prefix = "of attribute "; final int i = localizedMessage.indexOf(prefix); if (i != -1) { int messagePrefixLength = prefix.length() + i; final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); currentElement = parent.getAttribute(attrName,null); if (currentElement != null) { currentElement = ((XmlAttribute)currentElement).getValueElement(); } } if (currentElement!=null) { assertValidElement(currentElement, originalElement,localizedMessage); myHost.addMessage(currentElement,localizedMessage, problemType); } else { addProblemToTagName(originalElement, originalElement, localizedMessage, warning); } } else if (localizedMessage.startsWith(ATTRIBUTE_ERROR_PREFIX)) { final int messagePrefixLength = ATTRIBUTE_ERROR_PREFIX.length(); if ( localizedMessage.charAt(messagePrefixLength) == '"' || localizedMessage.charAt(messagePrefixLength) == '\'' ) { // extract the attribute name from message and get it from tag! final int nextQuoteIndex = localizedMessage.indexOf(localizedMessage.charAt(messagePrefixLength), messagePrefixLength + 1); String attrName = nextQuoteIndex == -1 ? null : localizedMessage.substring(messagePrefixLength + 1, nextQuoteIndex); XmlTag parent = PsiTreeUtil.getParentOfType(originalElement,XmlTag.class); currentElement = parent.getAttribute(attrName,null); if (currentElement!=null) { currentElement = SourceTreeToPsiMap.treeElementToPsi( XmlChildRole.ATTRIBUTE_NAME_FINDER.findChild( SourceTreeToPsiMap.psiElementToTree(currentElement) ) ); } } else { currentElement = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class, false); } if (currentElement!=null) { assertValidElement(currentElement, originalElement,localizedMessage); myHost.addMessage(currentElement,localizedMessage, problemType); } else { addProblemToTagName(originalElement, originalElement, localizedMessage, warning); } } else if (localizedMessage.startsWith(STRING_ERROR_PREFIX)) { if (currentElement != null) { myHost.addMessage(currentElement,localizedMessage, Validator.ValidationHost.ErrorType.WARNING); } } else { currentElement = getNodeForMessage(currentElement != null ? currentElement:originalElement); assertValidElement(currentElement, originalElement,localizedMessage); if (currentElement!=null) { myHost.addMessage(currentElement,localizedMessage, problemType); } } } }); } catch (Exception ex) { if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex; if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex; LOG.error(ex); } }
processError
299,665
PsiElement (final PsiElement currentElement) { PsiElement parentOfType = PsiTreeUtil.getNonStrictParentOfType( currentElement, XmlTag.class, XmlProcessingInstruction.class, XmlElementDecl.class, XmlMarkupDecl.class, XmlEntityRef.class, XmlDoctype.class ); if (parentOfType == null) { if (currentElement instanceof XmlToken) { parentOfType = currentElement.getParent(); } else { parentOfType = currentElement; } } return parentOfType; }
getNodeForMessage
299,666
void (Validator.ValidationHost host, List<? extends ValidationInfo> highlightInfos) { for (ValidationInfo info : highlightInfos) { host.addMessage(info.element, info.message, info.type); } }
addAllInfos
299,667
void (PsiElement currentElement, final PsiElement originalElement, final @InspectionMessage String localizedMessage, final ValidateXmlActionHandler.ProblemType problemType) { currentElement = PsiTreeUtil.getParentOfType(currentElement,XmlTag.class,false); if (currentElement==null) { currentElement = PsiTreeUtil.getParentOfType(originalElement,XmlElementDecl.class,false); } if (currentElement == null) { currentElement = originalElement; } assertValidElement(currentElement, originalElement,localizedMessage); if (currentElement!=null) { myHost.addMessage(currentElement,localizedMessage, getProblemType(problemType)); } }
addProblemToTagName
299,668
void (PsiElement currentElement, PsiElement originalElement, String message) { if (currentElement==null) { XmlTag tag = PsiTreeUtil.getParentOfType(originalElement, XmlTag.class); LOG.error("The validator message:" + message + " is bound to null node,\n" + "initial element:" + originalElement.getText() + ",\n" + "parent:" + originalElement.getParent() + ",\n" + "tag:" + (tag != null ? tag.getText() : "null") + ",\n" + "offset in tag: " + (originalElement.getTextOffset() - (tag == null ? 0 : tag.getTextOffset()))); } }
assertValidElement
299,669
int () { return getMinOccursImpl(myRef) * getMinOccursImpl(myTag); }
getMinOccurs
299,670
int (XmlTag tag) { if (tag == null) return 1; String value = tag.getAttributeValue("minOccurs"); try { return value == null ? 1 : Integer.parseInt(value); } catch (NumberFormatException e) { return 1; } }
getMinOccursImpl
299,671
int () { return getMaxOccursImpl(myRef) * getMaxOccursImpl(myTag); }
getMaxOccurs
299,672
int (XmlTag tag) { if (tag == null) return 1; String value = tag.getAttributeValue("maxOccurs"); if (value == null) return 1; if ("unbounded".equals(value)) return Integer.MAX_VALUE; try { return Integer.parseInt(value); } catch (NumberFormatException e) { return 1; } }
getMaxOccursImpl
299,673
XmlElementsGroup () { return myParent; }
getParentGroup
299,674
PsiElement () { return null; }
getDeclaration
299,675
String (PsiElement context) { return null; }
getName
299,676
String () { return null; }
getName
299,677
void (PsiElement element) { throw new UnsupportedOperationException(); }
init
299,678
boolean (String[] tagNames, PsiElementProcessor<? super XmlTag> processor) { for (XmlNSDescriptorImpl descriptor : myDescriptors) { if (!descriptor.processTagsInNamespace(tagNames, processor)) return false; } return true; }
processTagsInNamespace
299,679
Type () { return Type.LEAF; }
getGroupType
299,680
List<XmlElementsGroup> () { return Collections.emptyList(); }
getSubGroups
299,681
XmlElementDescriptor () { return myDescriptor; }
getLeafDescriptor
299,682
XmlTag () { return myDescriptorTag; }
getDeclaration
299,683
String (PsiElement context) { String value = myDescriptorTag.getAttributeValue("name"); if(context instanceof XmlElement){ final String namespace = getNamespaceByContext(context); final XmlTag tag = PsiTreeUtil.getParentOfType(context, XmlTag.class, false); if(tag != null){ final String namespacePrefix = tag.getPrefixByNamespace(namespace); if (namespacePrefix != null && namespacePrefix.length() > 0) { final XmlTag rootTag = ((XmlFile)myDescriptorTag.getContainingFile()).getRootTag(); if (!isQualifiedForm() && tag.getNamespaceByPrefix("").isEmpty() && myDescriptorTag.getParentTag() != rootTag) { value = XmlUtil.findLocalNameByQualifiedName(value); } else { value = namespacePrefix + ":" + XmlUtil.findLocalNameByQualifiedName(value); } } } } return value; }
getName
299,684
String () { return XmlUtil.findLocalNameByQualifiedName(getName(null)); }
getName
299,685
String (PsiElement context) { //while(context != null){ // if(context instanceof XmlTag){ // final XmlTag contextTag = ((XmlTag)context); // final XmlNSDescriptorImpl schemaDescriptor = XmlUtil.findXmlNSDescriptorByType(contextTag); // if (schemaDescriptor != null) { // return schemaDescriptor.getDefaultNamespace(); // } // } // context = context.getContext(); //} return getNamespace(); }
getNamespaceByContext
299,686
String () { String name = getName(); if (name == null) return XmlUtil.EMPTY_URI; if (getNSDescriptor() == null || myDescriptorTag == null) return XmlUtil.EMPTY_URI; final String namespacePrefix = XmlUtil.findPrefixByQualifiedName(name); return namespacePrefix.isEmpty() ? getDefaultNamespace() : myDescriptorTag.getNamespaceByPrefix(namespacePrefix); }
getNamespace
299,687
void (PsiElement element) { if (myDescriptorTag!=element && myDescriptorTag!=null) { NSDescriptor = null; } myDescriptorTag = (XmlTag) element; }
init
299,688
XmlNSDescriptor (XmlElement context) { XmlNSDescriptor nsDescriptor = getNSDescriptor(); if (context instanceof XmlTag tag && nsDescriptor instanceof XmlNSDescriptorImpl) { final String defaultNamespace = ((XmlNSDescriptorImpl)nsDescriptor).getDefaultNamespace(); if (XmlUtil.XML_SCHEMA_URI.equals(defaultNamespace)) return nsDescriptor; // do not check for overriden for efficiency final String tagNs = tag.getNamespace(); if (tagNs.equals(defaultNamespace)) { XmlNSDescriptor previousDescriptor = nsDescriptor; nsDescriptor = tag.getNSDescriptor(tagNs, true); if (nsDescriptor == null) nsDescriptor = previousDescriptor; } } return nsDescriptor; }
getNSDescriptor
299,689
XmlNSDescriptor () { XmlNSDescriptor nsDescriptor = NSDescriptor; if (nsDescriptor == null || !NSDescriptor.getDeclaration().isValid()) { final XmlFile file = XmlUtil.getContainingFile(getDeclaration()); if(file == null) return null; final XmlDocument document = file.getDocument(); if(document == null) return null; NSDescriptor = nsDescriptor = (XmlNSDescriptor)document.getMetaData(); } return nsDescriptor; }
getNSDescriptor
299,690
XmlElementsGroup () { TypeDescriptor type = getType(); return type instanceof ComplexTypeDescriptor ? ((ComplexTypeDescriptor)type).getTopGroup() : null; }
getTopGroup
299,691
XmlElementDescriptor[] (XmlTag context) { if (context != null) { final XmlElementDescriptor parentDescriptorByType = XmlUtil.findXmlDescriptorByType(context); if (parentDescriptorByType != null && !parentDescriptorByType.equals(this)) { return parentDescriptorByType.getElementsDescriptors(context); } } XmlElementDescriptor[] elementsDescriptors = getElementsDescriptorsImpl(context); final TypeDescriptor type = getType(context); if (type instanceof ComplexTypeDescriptor descriptor) { PsiFile containingFile = context != null ? context.getContainingFile():null; if (context != null && !containingFile.isPhysical()) { containingFile = containingFile.getOriginalFile(); //context = context.getParentTag(); } String contextNs; if (context != null && descriptor.canContainTag(context.getLocalName(), contextNs = context.getNamespace(), context) && (!contextNs.equals(getNamespace()) || descriptor.hasAnyInContentModel()) && containingFile instanceof XmlFile) { // JSXmlLiteralExpressionImpl, being an xml element itself, may be contained in non-XML file final XmlNSDescriptor nsDescriptor = getNSDescriptor(); if (nsDescriptor != null) { elementsDescriptors = ArrayUtil.mergeArrays( elementsDescriptors, nsDescriptor.getRootElementsDescriptors(((XmlFile)containingFile).getDocument()) ); } } } return elementsDescriptors; }
getElementsDescriptors
299,692
XmlElementDescriptor[] (XmlElement context) { TypeDescriptor type = getType(context); if (type instanceof ComplexTypeDescriptor typeDescriptor) { XmlElementDescriptor[] elements = typeDescriptor.getElements(context); if (context instanceof XmlTag && elements.length > 0) { String[] namespaces = ((XmlTag)context).knownNamespaces(); if (namespaces.length > 1) { List<XmlElementDescriptor> result = new ArrayList<>(Arrays.asList(elements)); for (String namespace : namespaces) { if (namespace.equals(typeDescriptor.getNsDescriptor().getDefaultNamespace())) { continue; } XmlNSDescriptor descriptor = ((XmlTag)context).getNSDescriptor(namespace, false); if (descriptor instanceof XmlNSDescriptorImpl && ((XmlNSDescriptorImpl)descriptor).hasSubstitutions()) { for (XmlElementDescriptor element : elements) { String name = XmlUtil.getLocalName(element.getName(context)).toString(); String s = ((XmlNSDescriptorImpl)element.getNSDescriptor()).getDefaultNamespace(); XmlElementDescriptor[] substitutes = ((XmlNSDescriptorImpl)descriptor).getSubstitutes(name, s); result.addAll(Arrays.asList(substitutes)); } } } return result.toArray(XmlElementDescriptor.EMPTY_ARRAY); } } return elements; } return EMPTY_ARRAY; }
getElementsDescriptorsImpl
299,693
XmlAttributeDescriptor[] (final XmlTag context) { TypeDescriptor type = getType(context); if (type instanceof ComplexTypeDescriptor typeDescriptor) { XmlAttributeDescriptor[] attributeDescriptors = typeDescriptor.getAttributes(context); if (context != null) { final String contextNs = context.getNamespace(); boolean seenXmlNs = false; for(String ns:context.knownNamespaces()) { if (!contextNs.equals(ns) && ns.length() > 0) { seenXmlNs |= XmlUtil.XML_NAMESPACE_URI.equals(ns); attributeDescriptors = updateAttributeDescriptorsFromAny(context, typeDescriptor, attributeDescriptors, ns); } } if (!seenXmlNs) { attributeDescriptors = updateAttributeDescriptorsFromAny(context, typeDescriptor, attributeDescriptors, XmlUtil.XML_NAMESPACE_URI); } } return attributeDescriptors; } return XmlAttributeDescriptor.EMPTY; }
getAttributesDescriptors
299,694
XmlAttributeDescriptor[] (final XmlTag context, final ComplexTypeDescriptor typeDescriptor, XmlAttributeDescriptor[] attributeDescriptors, final String ns) { if (typeDescriptor.canContainAttribute(ns, null) != ComplexTypeDescriptor.CanContainAttributeType.CanNotContain) { // anyAttribute found final XmlNSDescriptor descriptor = context.getNSDescriptor(ns, true); if (descriptor instanceof XmlNSDescriptorImpl) { XmlAttributeDescriptor[] rootDescriptors = ((XmlNSDescriptorImpl)descriptor).getRootAttributeDescriptors(context); attributeDescriptors = ArrayUtil.mergeArrays(attributeDescriptors, rootDescriptors); } } return attributeDescriptors; }
updateAttributeDescriptorsFromAny
299,695
XmlAttributeDescriptor (String attributeName, final XmlTag context) { return getAttributeDescriptorImpl(attributeName,context); }
getAttributeDescriptor
299,696
String () { XmlNSDescriptor nsDescriptor = getNSDescriptor(); return nsDescriptor instanceof XmlNSDescriptorImpl ? ((XmlNSDescriptorImpl)nsDescriptor).getDefaultNamespace() : ""; }
getDefaultNamespace
299,697
XmlAttributeDescriptor (XmlAttribute attribute) { return getAttributeDescriptorImpl(attribute.getName(),attribute.getParent()); }
getAttributeDescriptor
299,698
int () { TypeDescriptor type = getType(); if (type instanceof ComplexTypeDescriptor) { return ((ComplexTypeDescriptor)type).getContentType(); } return CONTENT_TYPE_MIXED; }
getContentType
299,699
XmlElementDescriptor (XmlTag element, XmlTag contextTag) { final XmlElement context = (XmlElement)element.getParent(); XmlElementDescriptor elementDescriptor = getElementDescriptor( element.getLocalName(), element.getNamespace(), context, element.getName() ); if(elementDescriptor == null || element.getAttributeValue("xsi:type") != null){ final XmlElementDescriptor xmlDescriptorByType = XmlUtil.findXmlDescriptorByType(element); if (xmlDescriptorByType != null) elementDescriptor = xmlDescriptorByType; else if (context instanceof XmlTag && ((XmlTag)context).getAttributeValue("xsi:type") != null && askParentDescriptorViaXsi()) { final XmlElementDescriptor parentXmlDescriptorByType = XmlUtil.findXmlDescriptorByType(((XmlTag)context)); if (parentXmlDescriptorByType != null) { elementDescriptor = parentXmlDescriptorByType.getElementDescriptor(element, contextTag); } } } return elementDescriptor; }
getElementDescriptor