Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
299,500
|
boolean (@NotNull String tagName) { return HTML5_TAGS_SET.contains(tagName); }
|
isHtml5Tag
|
299,501
|
boolean (String attributeName) { return attributeName.startsWith(HTML5_DATA_ATTR_PREFIX); }
|
isCustomHtml5Attribute
|
299,502
|
boolean (XmlAttributeDescriptor descriptor) { // common html attributes are defined mostly in common.rnc, core-scripting.rnc, etc // while own tag attributes are defined in meta.rnc final PsiElement declaration = descriptor.getDeclaration(); final PsiFile file = declaration != null ? declaration.getContainingFile() : null; final String name = file != null ? file.getName() : null; return "meta.rnc".equals(name) || "web-forms.rnc".equals(name) || "embed.rnc".equals(name) || "tables.rnc".equals(name) || "media.rnc".equals(name); }
|
isOwnHtmlAttribute
|
299,503
|
boolean (@NotNull XmlTag context) { XmlElementDescriptor descriptor = context.getDescriptor(); XmlNSDescriptor nsDescriptor = descriptor != null ? descriptor.getNSDescriptor() : null; return isHtml5Schema(nsDescriptor); }
|
tagHasHtml5Schema
|
299,504
|
boolean (@Nullable XmlNSDescriptor nsDescriptor) { XmlFile descriptorFile = nsDescriptor != null ? nsDescriptor.getDescriptorFile() : null; String descriptorPath = descriptorFile != null ? descriptorFile.getVirtualFile().getPath() : null; return Objects.equals(Html5SchemaProvider.getHtml5SchemaLocation(), descriptorPath) || Objects.equals(Html5SchemaProvider.getXhtml5SchemaLocation(), descriptorPath); }
|
isHtml5Schema
|
299,505
|
String (@NotNull String line) { if (startsWithTag(line)) { int tagStart = line.indexOf("<"); if (tagStart >= 0) { tagStart++; for (int i = tagStart; i < line.length(); i ++) { char ch = line.charAt(i); if (!(Character.isAlphabetic(ch) || (i > tagStart && (Character.isDigit(ch) || ch == '-' )))) { return line.substring(tagStart, i); } } } } return null; }
|
getStartTag
|
299,506
|
boolean (@NotNull String line) { if (line.trim().startsWith("<")) { return HTML_TAG_PATTERN.matcher(line).matches(); } return false; }
|
startsWithTag
|
299,507
|
Charset (@NotNull CharSequence content) { // check for <meta http-equiv="charset=CharsetName" > or <meta charset="CharsetName"> and return Charset // because we will lightly parse and explicit charset isn't used very often do quick check for applicability int charPrefix = StringUtil.indexOf(content, CHARSET); do { if (charPrefix == -1) return null; int charsetPrefixEnd = charPrefix + CHARSET.length(); while (charsetPrefixEnd < content.length() && Character.isWhitespace(content.charAt(charsetPrefixEnd))) ++charsetPrefixEnd; if (charsetPrefixEnd < content.length() && content.charAt(charsetPrefixEnd) == '=') break; charPrefix = StringUtil.indexOf(content, CHARSET, charsetPrefixEnd); } while (true); if (content.length() > charPrefix + 200) { String name = tryFetchCharsetFromFileContent(content.subSequence(0, charPrefix + 200)); if (name != null) { return CharsetToolkit.forName(name); } } String name = tryFetchCharsetFromFileContent(content); return CharsetToolkit.forName(name); }
|
detectCharsetFromMetaTag
|
299,508
|
String (@NotNull CharSequence content) { final Ref<String> charsetNameRef = new Ref<>(); try { new HtmlBuilderDriver(content).build(new XmlBuilder() { final @NonNls Set<String> inTag = new HashSet<>(); boolean metHttpEquiv; boolean metHtml5Charset; @Override public void doctype(final @Nullable CharSequence publicId, final @Nullable CharSequence systemId, final int startOffset, final int endOffset) { } @Override public ProcessingOrder startTag(final CharSequence localName, final String namespace, final int startOffset, final int endOffset, final int headerEndOffset) { @NonNls String name = StringUtil.toLowerCase(localName.toString()); inTag.add(name); if (!inTag.contains("head") && !"html".equals(name)) terminate(); return ProcessingOrder.TAGS_AND_ATTRIBUTES; } private static void terminate() { throw TerminateException.INSTANCE; } @Override public void endTag(final CharSequence localName, final String namespace, final int startoffset, final int endoffset) { final @NonNls String name = StringUtil.toLowerCase(localName.toString()); if ("meta".equals(name) && (metHttpEquiv || metHtml5Charset) && contentAttributeValue != null) { String charsetName; if (metHttpEquiv) { int start = contentAttributeValue.indexOf(CHARSET_PREFIX); if (start == -1) return; start += CHARSET_PREFIX.length(); int end = contentAttributeValue.indexOf(';', start); if (end == -1) end = contentAttributeValue.length(); charsetName = contentAttributeValue.substring(start, end); } else /*if (metHttml5Charset) */ { charsetName = StringUtil.unquoteString(contentAttributeValue); } charsetNameRef.set(charsetName); terminate(); } if ("head".equals(name)) { terminate(); } inTag.remove(name); metHttpEquiv = false; metHtml5Charset = false; contentAttributeValue = null; } private String contentAttributeValue; @Override public void attribute(final CharSequence localName, final CharSequence v, final int startoffset, final int endoffset) { final @NonNls String name = StringUtil.toLowerCase(localName.toString()); if (inTag.contains("meta")) { @NonNls String value = StringUtil.toLowerCase(v.toString()); if (name.equals("http-equiv")) { metHttpEquiv |= value.equals("content-type"); } else if (name.equals(CHARSET)) { metHtml5Charset = true; contentAttributeValue = value; } if (name.equals("content")) { contentAttributeValue = value; } } } @Override public void textElement(final CharSequence display, final CharSequence physical, final int startoffset, final int endoffset) { } @Override public void entityRef(final CharSequence ref, final int startOffset, final int endOffset) { } @Override public void error(@NotNull String message, int startOffset, int endOffset) { } }); } catch (TerminateException ignored) { //ignore } catch (Exception ignored) { // some weird things can happen, like unbalanaced tree } return charsetNameRef.get(); }
|
tryFetchCharsetFromFileContent
|
299,509
|
void (final @Nullable CharSequence publicId, final @Nullable CharSequence systemId, final int startOffset, final int endOffset) { }
|
doctype
|
299,510
|
ProcessingOrder (final CharSequence localName, final String namespace, final int startOffset, final int endOffset, final int headerEndOffset) { @NonNls String name = StringUtil.toLowerCase(localName.toString()); inTag.add(name); if (!inTag.contains("head") && !"html".equals(name)) terminate(); return ProcessingOrder.TAGS_AND_ATTRIBUTES; }
|
startTag
|
299,511
|
void () { throw TerminateException.INSTANCE; }
|
terminate
|
299,512
|
void (final CharSequence localName, final String namespace, final int startoffset, final int endoffset) { final @NonNls String name = StringUtil.toLowerCase(localName.toString()); if ("meta".equals(name) && (metHttpEquiv || metHtml5Charset) && contentAttributeValue != null) { String charsetName; if (metHttpEquiv) { int start = contentAttributeValue.indexOf(CHARSET_PREFIX); if (start == -1) return; start += CHARSET_PREFIX.length(); int end = contentAttributeValue.indexOf(';', start); if (end == -1) end = contentAttributeValue.length(); charsetName = contentAttributeValue.substring(start, end); } else /*if (metHttml5Charset) */ { charsetName = StringUtil.unquoteString(contentAttributeValue); } charsetNameRef.set(charsetName); terminate(); } if ("head".equals(name)) { terminate(); } inTag.remove(name); metHttpEquiv = false; metHtml5Charset = false; contentAttributeValue = null; }
|
endTag
|
299,513
|
void (final CharSequence localName, final CharSequence v, final int startoffset, final int endoffset) { final @NonNls String name = StringUtil.toLowerCase(localName.toString()); if (inTag.contains("meta")) { @NonNls String value = StringUtil.toLowerCase(v.toString()); if (name.equals("http-equiv")) { metHttpEquiv |= value.equals("content-type"); } else if (name.equals(CHARSET)) { metHtml5Charset = true; contentAttributeValue = value; } if (name.equals("content")) { contentAttributeValue = value; } } }
|
attribute
|
299,514
|
void (final CharSequence display, final CharSequence physical, final int startoffset, final int endoffset) { }
|
textElement
|
299,515
|
void (final CharSequence ref, final int startOffset, final int endOffset) { }
|
entityRef
|
299,516
|
void (@NotNull String message, int startOffset, int endOffset) { }
|
error
|
299,517
|
boolean (@NonNls String tagName) { return "br".equalsIgnoreCase(tagName); }
|
isTagWithoutAttributes
|
299,518
|
boolean (@NotNull PsiFile file) { return isHtmlFile(file) || file.getViewProvider() instanceof TemplateLanguageFileViewProvider; }
|
hasHtml
|
299,519
|
boolean (@NotNull PsiFile file) { return XmlTypedHandlersAdditionalSupport.supportsTypedHandlers(file); }
|
supportsXmlTypedHandlers
|
299,520
|
boolean (@NotNull String url) { return url.startsWith("http://") || url.startsWith("https://") || url.startsWith("//") || //Protocol-relative URL url.startsWith("ftp://"); }
|
hasHtmlPrefix
|
299,521
|
boolean (@NotNull PsiElement element) { Language language = element.getLanguage(); return language.isKindOf(HTMLLanguage.INSTANCE) || language.isKindOf(XHTMLLanguage.INSTANCE); }
|
isHtmlFile
|
299,522
|
boolean (@NotNull VirtualFile file) { FileType fileType = file.getFileType(); return fileType == HtmlFileType.INSTANCE || fileType == XHtmlFileType.INSTANCE; }
|
isHtmlFile
|
299,523
|
boolean (PsiElement element) { if (element == null) { return false; } final PsiFile containingFile = element.getContainingFile(); if (containingFile != null) { if (containingFile instanceof HtmlCompatibleFile) { return true; } final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class, false); if (tag instanceof HtmlTag) { return true; } final XmlDocument document = PsiTreeUtil.getParentOfType(element, XmlDocument.class, false); if (document instanceof HtmlDocumentImpl) { return true; } final FileViewProvider provider = containingFile.getViewProvider(); Language language; if (provider instanceof TemplateLanguageFileViewProvider) { language = ((TemplateLanguageFileViewProvider)provider).getTemplateDataLanguage(); } else { language = provider.getBaseLanguage(); } return language == XHTMLLanguage.INSTANCE; } return false; }
|
isHtmlTagContainingFile
|
299,524
|
boolean (@Nullable XmlTag tag) { return tag != null && tag.getLocalName().equalsIgnoreCase(SCRIPT_TAG_NAME); }
|
isScriptTag
|
299,525
|
String (PsiElement context) { return myTagName; }
|
getName
|
299,526
|
String () { return myTagName; }
|
getDefaultName
|
299,527
|
boolean (final String namespace, final XmlTag context) { return true; }
|
allowElementsFromNamespace
|
299,528
|
Iterable<String> (@Nullable String classAttributeValue) { // comma is useduse as separator because class name cannot contain comma but it can be part of JSF classes attributes return classAttributeValue != null ? StringUtil.tokenize(classAttributeValue, " \t,") : Collections.emptyList(); }
|
splitClassNames
|
299,529
|
boolean (@NotNull PsiElement element) { PsiElement child = element.getFirstChild(); while (child != null) { if (child instanceof CompositeElement) { return containsOuterLanguageElements(child); } if (child instanceof OuterLanguageElement) { return true; } child = child.getNextSibling(); } return false; }
|
containsOuterLanguageElements
|
299,530
|
List<XmlAttributeValue> (final @NotNull XmlFile file) { final List<XmlAttributeValue> result = new ArrayList<>(); file.acceptChildren(new XmlRecursiveElementWalkingVisitor() { @Override public void visitXmlTag(@NotNull XmlTag tag) { XmlAttribute attribute = null; if ("link".equalsIgnoreCase(tag.getName())) { attribute = tag.getAttribute("href"); } else if ("script".equalsIgnoreCase(tag.getName()) || "img".equalsIgnoreCase(tag.getName())) { attribute = tag.getAttribute("src"); } if (attribute != null) result.add(attribute.getValueElement()); super.visitXmlTag(tag); } @Override public void visitElement(@NotNull PsiElement element) { if (element.getLanguage() instanceof XMLLanguage) { super.visitElement(element); } } }); return result.isEmpty() ? Collections.emptyList() : result; }
|
getIncludedPathsElements
|
299,531
|
void (@NotNull XmlTag tag) { XmlAttribute attribute = null; if ("link".equalsIgnoreCase(tag.getName())) { attribute = tag.getAttribute("href"); } else if ("script".equalsIgnoreCase(tag.getName()) || "img".equalsIgnoreCase(tag.getName())) { attribute = tag.getAttribute("src"); } if (attribute != null) result.add(attribute.getValueElement()); super.visitXmlTag(tag); }
|
visitXmlTag
|
299,532
|
void (@NotNull PsiElement element) { if (element.getLanguage() instanceof XMLLanguage) { super.visitElement(element); } }
|
visitElement
|
299,533
|
XmlTag () { return (XmlTag)getParent(); }
|
getParentTag
|
299,534
|
XmlTagChild () { return null; }
|
getNextSiblingInTag
|
299,535
|
XmlTagChild () { return null; }
|
getPrevSiblingInTag
|
299,536
|
String () { return getOriginal().getText(); }
|
getText
|
299,537
|
String () { return getOriginal().getValue(); }
|
getValue
|
299,538
|
int (int offset) { return getOriginal().physicalToDisplay(offset); }
|
physicalToDisplay
|
299,539
|
int (int offset) { return getOriginal().displayToPhysical(offset); }
|
displayToPhysical
|
299,540
|
boolean (@NotNull XmlFile file) { return file.getFileType() == HtmlFileType.INSTANCE || file.getFileType() == XHtmlFileType.INSTANCE; }
|
overrideNamespaceFromDocType
|
299,541
|
boolean (Class<? extends PsiElement> elementClass) { return ReflectionUtil.isAssignable(XmlElement.class, elementClass); }
|
canResolveTo
|
299,542
|
String () { String name = getElement() instanceof XmlTag ? "tag" : "attribute"; return myDescriptor.isFixed() ? XmlPsiBundle.message("xml.inspections.should.have.fixed.value", StringUtil.capitalize(name), myDescriptor.getDefaultValue()) : XmlPsiBundle.message("xml.inspections.wrong.value", name); }
|
getUnresolvedMessagePattern
|
299,543
|
List<XmlEnumeratedValueReference> () { if (myDescriptor.isList()) return super.getReferences(); return Collections.singletonList(createReference(null, 0)); }
|
getReferences
|
299,544
|
boolean () { T t = myRef.get(); if (t != null) { return t.isValid(); } return myOriginal.retrieve() != null; }
|
isValid
|
299,545
|
boolean (Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; IncludedXmlElement element = (IncludedXmlElement)o; if (!myParent.equals(element.myParent)) return false; if (!myOriginal.equals(element.myOriginal)) return false; return true; }
|
equals
|
299,546
|
int () { int result = myOriginal.hashCode(); result = 31 * result + myParent.hashCode(); return result; }
|
hashCode
|
299,547
|
T () { T element = myRef.get(); if (element != null) { return element; } element = (T)myOriginal.retrieve(); if (element == null) { throw new PsiInvalidElementAccessException(this); } myRef = new SoftReference<>(element); return element; }
|
getOriginal
|
299,548
|
T () { return getOriginal(); }
|
getNavigationElement
|
299,549
|
PsiFile () { return myParent.getContainingFile(); }
|
getContainingFile
|
299,550
|
PsiElement () { return myParent; }
|
getParent
|
299,551
|
String () { return getClass().getSimpleName(); }
|
toString
|
299,552
|
boolean (final PsiElementProcessor processor, PsiElement place) { final IncludedXmlElement<T> self = this; return getOriginal().processElements(new PsiElementProcessor() { @SuppressWarnings("unchecked") @Override public boolean execute(@NotNull PsiElement element) { if (element instanceof XmlTag) { XmlTag theirParent = ((XmlTag)element).getParentTag(); PsiElement parent = getOriginal().equals(theirParent) ? (XmlTag)self : theirParent; return processor.execute(new IncludedXmlTag((XmlTag)element, parent)); } if (element instanceof XmlAttribute) { XmlTag theirParent = ((XmlAttribute)element).getParent(); XmlTag parent = getOriginal().equals(theirParent) ? (XmlTag)self : theirParent; return processor.execute(new IncludedXmlAttribute((XmlAttribute)element, parent)); } if (element instanceof XmlText) { XmlTag theirParent = ((XmlText)element).getParentTag(); XmlTag parent = getOriginal().equals(theirParent) ? (XmlTag)self : theirParent; return processor.execute(new IncludedXmlText((XmlText)element, parent)); } return processor.execute(element); } }, place); }
|
processElements
|
299,553
|
boolean (@NotNull PsiElement element) { if (element instanceof XmlTag) { XmlTag theirParent = ((XmlTag)element).getParentTag(); PsiElement parent = getOriginal().equals(theirParent) ? (XmlTag)self : theirParent; return processor.execute(new IncludedXmlTag((XmlTag)element, parent)); } if (element instanceof XmlAttribute) { XmlTag theirParent = ((XmlAttribute)element).getParent(); XmlTag parent = getOriginal().equals(theirParent) ? (XmlTag)self : theirParent; return processor.execute(new IncludedXmlAttribute((XmlAttribute)element, parent)); } if (element instanceof XmlText) { XmlTag theirParent = ((XmlText)element).getParentTag(); XmlTag parent = getOriginal().equals(theirParent) ? (XmlTag)self : theirParent; return processor.execute(new IncludedXmlText((XmlText)element, parent)); } return processor.execute(element); }
|
execute
|
299,554
|
boolean (XmlElement element, PsiElementProcessor<? super PsiElement> processor, boolean deepFlag) { return processXmlElements(element, processor, deepFlag, false); }
|
processXmlElements
|
299,555
|
boolean (XmlElement element, PsiElementProcessor<? super PsiElement> processor, boolean deepFlag, boolean wideFlag) { if (element == null) return true; PsiFile baseFile = element.isValid() ? element.getContainingFile() : null; return processXmlElements(element, processor, deepFlag, wideFlag, baseFile); }
|
processXmlElements
|
299,556
|
boolean (final XmlElement element, final PsiElementProcessor<? super PsiElement> processor, final boolean deepFlag, final boolean wideFlag, final PsiFile baseFile) { return processXmlElements(element, processor, deepFlag, wideFlag, baseFile, true); }
|
processXmlElements
|
299,557
|
boolean (final XmlElement element, final PsiElementProcessor<? super PsiElement> processor, final boolean deepFlag, final boolean wideFlag, final PsiFile baseFile, boolean processIncludes) { return AstLoadingFilter.forceAllowTreeLoading(baseFile, () -> new XmlElementProcessor(baseFile, processor).processXmlElements(element, deepFlag, wideFlag, processIncludes) ); }
|
processXmlElements
|
299,558
|
boolean (final XmlElement element, final PsiElementProcessor<? super PsiElement> processor, final boolean deepFlag) { final XmlPsiUtil.XmlElementProcessor p = new XmlPsiUtil.XmlElementProcessor(element.getContainingFile(), processor); for (PsiElement child = element.getFirstChild(); child != null; child = child.getNextSibling()) { if (!p.processElement(child, deepFlag, false, true)) return false; } return true; }
|
processXmlElementChildren
|
299,559
|
boolean (@NotNull PsiElement element) { if (element instanceof XmlElement && predicate.matches(element.getNode().getElementType())) { result.set((XmlElement)element); return false; } return true; }
|
execute
|
299,560
|
boolean (PsiElement element, boolean deepFlag, boolean wideFlag, boolean processIncludes) { if (deepFlag) if (!processor.execute(element)) return false; PsiElement startFrom = element.getFirstChild(); if (element instanceof XmlEntityRef ref) { if (!visitedEntities.add(ref.getText())) return true; PsiElement newElement = parseEntityRef(targetFile, ref); while (newElement != null) { if (!processElement(newElement, deepFlag, wideFlag, processIncludes)) return false; newElement = newElement.getNextSibling(); } return true; } else if (element instanceof XmlConditionalSection xmlConditionalSection) { if (!xmlConditionalSection.isIncluded(targetFile)) return true; startFrom = xmlConditionalSection.getBodyStart(); } else if (processIncludes && XmlIncludeHandler.isXInclude(element)) { if (IdempotenceChecker.isLoggingEnabled()) { IdempotenceChecker.logTrace("Processing xinclude " + element.getText()); } PsiElement[] tags = InclusionProvider.getIncludedTags((XmlTag)element); for (PsiElement psiElement : tags) { if (IdempotenceChecker.isLoggingEnabled()) { IdempotenceChecker.logTrace("Processing included tag " + psiElement); } if (!processElement(psiElement, deepFlag, wideFlag, true)) return false; } } for (PsiElement child = startFrom; child != null; child = child.getNextSibling()) { if (!processElement(child, deepFlag, wideFlag, processIncludes) && !wideFlag) return false; } return true; }
|
processXmlElements
|
299,561
|
boolean (PsiElement child, boolean deepFlag, boolean wideFlag, boolean processIncludes) { if (deepFlag) { if (!processXmlElements(child, true, wideFlag, processIncludes)) { return false; } } else { if (child instanceof XmlEntityRef) { if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; } else if (child instanceof XmlConditionalSection) { if (!processXmlElements(child, false, wideFlag, processIncludes)) return false; } else if (processIncludes && XmlIncludeHandler.isXInclude(child)) { if (!processXmlElements(child, false, wideFlag, true)) return false; } else if (!processor.execute(child)) return false; } if (targetFile != null && child instanceof XmlEntityDecl xmlEntityDecl) { XmlEntityCache.cacheParticularEntity(targetFile, xmlEntityDecl); } return true; }
|
processElement
|
299,562
|
PsiElement (PsiFile targetFile, XmlEntityRef ref) { XmlEntityDecl.EntityContextType type = getContextType(ref); { final XmlEntityDecl entityDecl = ref.resolve(targetFile); if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); } PsiElement e = ref; while (e != null) { if (e.getUserData(XmlElement.INCLUDING_ELEMENT) != null) { e = e.getUserData(XmlElement.INCLUDING_ELEMENT); final PsiFile f = e.getContainingFile(); if (f != null) { final XmlEntityDecl entityDecl = ref.resolve(targetFile); if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); } continue; } if (e instanceof PsiFile refFile) { final XmlEntityDecl entityDecl = ref.resolve(refFile); if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); break; } e = e.getParent(); } final PsiElement element = ref.getUserData(XmlElement.DEPENDING_ELEMENT); if (element instanceof XmlFile) { final XmlEntityDecl entityDecl = ref.resolve((PsiFile)element); if (entityDecl != null) return parseEntityDecl(entityDecl, targetFile, type, ref); } return null; }
|
parseEntityRef
|
299,563
|
PsiElement (final XmlEntityDecl entityDecl, final PsiFile targetFile, final XmlEntityDecl.EntityContextType type, final XmlEntityRef entityRef) { CachedValue<PsiElement> value = entityRef.getUserData(PARSED_DECL_KEY); if (value == null) { value = CachedValuesManager.getManager(entityDecl.getProject()).createCachedValue(() -> { final PsiElement res = entityDecl.parse(targetFile, type, entityRef); if (res == null) return new CachedValueProvider.Result<>(null, targetFile); if (!entityDecl.isInternalReference()) XmlEntityCache.copyEntityCaches(res.getContainingFile(), targetFile); return new CachedValueProvider.Result<>(res, res.getUserData(XmlElement.DEPENDING_ELEMENT), entityDecl, targetFile, entityRef); }, false); value = ((XmlEntityRefImpl)entityRef).putUserDataIfAbsent(PARSED_DECL_KEY, value); } return value.getValue(); }
|
parseEntityDecl
|
299,564
|
boolean (final @NotNull @NonNls String s) { return ourSystemColors.contains(s); }
|
isSystemColorName
|
299,565
|
boolean (final @NotNull @NonNls String s) { return ourStandardColors.contains(s); }
|
isStandardColor
|
299,566
|
Color (String text) { if (StringUtil.isEmptyOrSpaces(text)) { return null; } String hexValue = text.charAt(0) == '#' ? text : getHexCodeForColorName(StringUtil.toLowerCase(text)); if (hexValue != null) { return ColorUtil.fromHex(hexValue, null); } return null; }
|
getColor
|
299,567
|
void (final @NotNull MetaDataRegistrar registrar) { { registrar.registerMetaData( new AndFilter( new NamespaceFilter(XmlUtil.SCHEMA_URIS), new ClassFilter(XmlDocument.class) ), SchemaNSDescriptor.class ); registrar.registerMetaData( new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("schema")), SchemaNSDescriptor.class ); } { registrar.registerMetaData( new OrFilter( new AndFilter( new ContentFilter( new OrFilter( new ClassFilter(XmlElementDecl.class), new ClassFilter(XmlEntityDecl.class), new ClassFilter(XmlConditionalSection.class), new ClassFilter(XmlEntityRef.class) ) ), new ClassFilter(XmlDocument.class) ), new ClassFilter(XmlMarkupDecl.class) ), XmlNSDescriptorImpl.class ); } { registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("element")), XmlElementDescriptorImpl.class); } { registrar.registerMetaData( new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("attribute")), XmlAttributeDescriptorImpl.class ); } { registrar.registerMetaData( new ClassFilter(XmlElementDecl.class), com.intellij.xml.impl.dtd.XmlElementDescriptorImpl.class ); } { registrar.registerMetaData( new ClassFilter(XmlAttributeDecl.class), com.intellij.xml.impl.dtd.XmlAttributeDescriptorImpl.class ); } { registrar.registerMetaData( new AndFilter( new ClassFilter(XmlDocument.class), new TargetNamespaceFilter(XmlUtil.XHTML_URI), new NamespaceFilter(XmlUtil.SCHEMA_URIS)), RelaxedHtmlFromSchemaNSDescriptor.class ); } { registrar.registerMetaData(new AndFilter(XmlTagFilter.INSTANCE, new NamespaceFilter(XmlUtil.SCHEMA_URIS), new XmlTextFilter("complexType", "simpleType", "group", "attributeGroup")), NamedObjectDescriptor.class); } }
|
contributeMetaData
|
299,568
|
boolean (String attributeName) { return knownAttributes.contains(attributeName.toLowerCase(Locale.US)); }
|
isKnownAttributeDescriptor
|
299,569
|
boolean (Exception ex) { if (ex instanceof ProcessCanceledException) throw (ProcessCanceledException)ex; if (ex instanceof XmlResourceResolver.IgnoredResourceException) throw (XmlResourceResolver.IgnoredResourceException)ex; if (ex instanceof FileNotFoundException || ex instanceof MalformedURLException || ex instanceof NoRouteToHostException || ex instanceof SocketTimeoutException || ex instanceof UnknownHostException || ex instanceof ConnectException ) { // do not log problems caused by malformed and/or ignored external resources return true; } if (ex instanceof ArrayIndexOutOfBoundsException) { // thrown by xerces on malformed xml return true; } return false; }
|
filterValidationException
|
299,570
|
void () { myHandler.doParse(); }
|
startProcessing
|
299,571
|
boolean () { return false; }
|
isStopOnUndeclaredResource
|
299,572
|
boolean (final SAXParseException e) { String error = myHandler.buildMessageString(e); if (ourErrorsSet.contains(error)) return false; ourErrorsSet.add(error); return true; }
|
isUniqueProblem
|
299,573
|
void (ErrorReporter errorReporter) { myErrorReporter = errorReporter; }
|
setErrorReporter
|
299,574
|
VirtualFile (SAXParseException ex) { String publicId = ex.getPublicId(); String systemId = ex.getSystemId(); if (publicId == null) { if (systemId != null) { if (systemId.startsWith("file:/")) { VirtualFile file = VirtualFileManager.getInstance() .findFileByUrl(systemId.startsWith("file://") ? systemId : systemId.replace("file:/", "file://")); if (file != null) return file; } final String path = myXmlResourceResolver.getPathByPublicId(systemId); if (path != null) return UriUtil.findRelativeFile(path,null); final PsiFile file = myXmlResourceResolver.resolve(null, systemId); if (file != null) return file.getVirtualFile(); } return myFile.getVirtualFile(); } final String path = myXmlResourceResolver.getPathByPublicId(publicId); if (path != null) return UriUtil.findRelativeFile(path,null); return null; }
|
getProblemFile
|
299,575
|
String (SAXParseException ex) { String msg = "(" + ex.getLineNumber() + ":" + ex.getColumnNumber() + ") " + ex.getMessage(); final VirtualFile file = getProblemFile(ex); if ( file != null && !file.equals(myFile.getVirtualFile())) { msg = file.getName() + ":" + msg; } return msg; }
|
buildMessageString
|
299,576
|
boolean (XmlFile file) { return true; }
|
isAvailable
|
299,577
|
void (XmlFile file) { myProject = file.getProject(); myFile = file; myXmlResourceResolver = new XmlResourceResolver(myFile, myProject, myErrorReporter); myXmlResourceResolver.setStopOnUnDeclaredResource( myErrorReporter.isStopOnUndeclaredResource() ); try { try { myParser = createParser(); } catch (Exception e) { filterAppException(e); } if (myParser == null) return; myErrorReporter.startProcessing(); } catch (XmlResourceResolver.IgnoredResourceException ignore) { } catch (Exception exception) { filterAppException(exception); } }
|
doValidate
|
299,578
|
void (Exception exception) { if (!myErrorReporter.filterValidationException(exception)) { LOG.error(exception); } }
|
filterAppException
|
299,579
|
void () { try { InputSource inputSource = new InputSource(new StringReader(myFile.getText())); inputSource.setSystemId(myFile.getVirtualFile().getUrl().replace("file:", "file:/")); myParser.parse(inputSource, new DefaultHandler() { @Override public void warning(SAXParseException e) throws SAXException { if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.WARNING); } @Override public void error(SAXParseException e) throws SAXException { if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.ERROR); } @Override public void fatalError(SAXParseException e) throws SAXException { if (myErrorReporter.isUniqueProblem(e)) myErrorReporter.processError(e, ProblemType.FATAL); } @Override public InputSource resolveEntity(String publicId, String systemId) { final PsiFile psiFile = myXmlResourceResolver.resolve(null, systemId); if (psiFile == null) return null; return new InputSource(new StringReader(psiFile.getText())); } @Override public void startDocument() throws SAXException { super.startDocument(); myParser.setProperty( ENTITY_RESOLVER_PROPERTY_NAME, myXmlResourceResolver ); configureEntityManager(myFile, myParser); } }); final String[] resourcePaths = myXmlResourceResolver.getResourcePaths(); if (resourcePaths.length > 0) { // if caches are used final VirtualFile[] files = new VirtualFile[resourcePaths.length]; for (int i = 0; i < resourcePaths.length; ++i) { files[i] = UriUtil.findRelativeFile(resourcePaths[i], null); } myFile.putUserData(DEPENDENT_FILES_KEY, files); myFile.putUserData(GRAMMAR_POOL_TIME_STAMP_KEY, calculateTimeStamp(files, myProject)); } myFile.putUserData(KNOWN_NAMESPACES_KEY, getNamespaces(myFile)); } catch (SAXException e) { LOG.debug(e); } catch (Exception exception) { filterAppException(exception); } catch (StackOverflowError error) { // http://issues.apache.org/jira/browse/XERCESJ-589 } }
|
doParse
|
299,580
|
InputSource (String publicId, String systemId) { final PsiFile psiFile = myXmlResourceResolver.resolve(null, systemId); if (psiFile == null) return null; return new InputSource(new StringReader(psiFile.getText())); }
|
resolveEntity
|
299,581
|
XMLGrammarPool (XmlFile file, boolean forceChecking) { final XMLGrammarPool previousGrammarPool = getGrammarPool(file); XMLGrammarPool grammarPool = null; // check if the pool is valid if (!forceChecking && !isValidationDependentFilesOutOfDate(file)) { grammarPool = previousGrammarPool; } if (grammarPool == null) { invalidateEntityManager(file); grammarPool = new XMLGrammarPoolImpl(); file.putUserData(GRAMMAR_POOL_KEY, grammarPool); } return grammarPool; }
|
getGrammarPool
|
299,582
|
boolean (XmlFile myFile) { final VirtualFile[] files = myFile.getUserData(DEPENDENT_FILES_KEY); final Long grammarPoolTimeStamp = myFile.getUserData(GRAMMAR_POOL_TIME_STAMP_KEY); String[] ns = myFile.getUserData(KNOWN_NAMESPACES_KEY); if (!Arrays.equals(ns, getNamespaces(myFile))) { return true; } if (grammarPoolTimeStamp != null && files != null) { long dependentFilesTimestamp = calculateTimeStamp(files,myFile.getProject()); if (dependentFilesTimestamp == grammarPoolTimeStamp.longValue()) { return false; } } return true; }
|
isValidationDependentFilesOutOfDate
|
299,583
|
void (XmlFile file) { file.putUserData(ENTITIES_KEY, null); }
|
invalidateEntityManager
|
299,584
|
String[] (XmlFile file) { XmlTag rootTag = file.getRootTag(); if (rootTag == null) return ArrayUtilRt.EMPTY_STRING_ARRAY; return ContainerUtil.mapNotNull(rootTag.getAttributes(), attribute -> attribute.getValue(), ArrayUtilRt.EMPTY_STRING_ARRAY); }
|
getNamespaces
|
299,585
|
long (final VirtualFile[] files, Project myProject) { long timestamp = 0; for(VirtualFile file:files) { if (file == null || !file.isValid()) break; final PsiFile psifile = PsiManager.getInstance(myProject).findFile(file); if (psifile != null && psifile.isValid()) { timestamp += psifile.getViewProvider().getModificationStamp(); } else { break; } } return timestamp; }
|
calculateTimeStamp
|
299,586
|
boolean () { XmlDocument document = myFile.getDocument(); if (document == null) return false; XmlProlog prolog = document.getProlog(); if (prolog == null) return false; XmlDoctype doctype = prolog.getDoctype(); if (doctype == null) return false; return true; }
|
hasDtdDeclaration
|
299,587
|
boolean () { XmlDocument document = myFile.getDocument(); if (document == null) return false; return (document.getProlog()!=null && document.getProlog().getDoctype()!=null); }
|
needsDtdChecking
|
299,588
|
boolean () { XmlDocument document = myFile.getDocument(); if (document == null) return false; XmlTag rootTag = document.getRootTag(); if (rootTag == null) return false; XmlAttribute[] attributes = rootTag.getAttributes(); for (XmlAttribute attribute : attributes) { if (attribute.isNamespaceDeclaration()) return true; } return false; }
|
needsSchemaChecking
|
299,589
|
String (final InputStream is) { return computeNamespace(new InputStreamReader(is, StandardCharsets.UTF_8)).getNamespace(); }
|
computeNamespace
|
299,590
|
XsdNamespaceBuilder (@NotNull Reader reader) { try (reader) { XsdNamespaceBuilder xsdBuilder = new XsdNamespaceBuilder(); NanoXmlBuilder builder = xsdBuilder.new NanoBuilder(); NanoXmlUtil.parse(reader, builder); HashSet<String> tags = new HashSet<>(xsdBuilder.getTags()); tags.removeAll(xsdBuilder.myReferencedTags); xsdBuilder.getRootTags().addAll(tags); return xsdBuilder; } catch (IOException e) { // can never happen throw new RuntimeException(e); } }
|
computeNamespace
|
299,591
|
void (String name, String nsPrefix, String nsURI) { myCurrentDepth--; myCurrentTag = null; }
|
endElement
|
299,592
|
int (@NotNull XsdNamespaceBuilder o) { return Comparing.compare(myNamespace, o.myNamespace); }
|
compareTo
|
299,593
|
boolean (@NotNull String tagName) { return myTags.contains(tagName); }
|
hasTag
|
299,594
|
int (@Nullable String tagName, @Nullable String version) { int rate = 0; if (tagName != null && myTags.contains(tagName)) { rate |= 0x02; } if (version != null && version.equals(myVersion)) { rate |= 0x01; } return rate; }
|
getRating
|
299,595
|
String () { return myNamespace; }
|
getNamespace
|
299,596
|
String () { return myVersion; }
|
getVersion
|
299,597
|
List<String> () { return myTags; }
|
getTags
|
299,598
|
List<String> () { return myRootTags; }
|
getRootTags
|
299,599
|
List<String> () { return myAttributes; }
|
getAttributes
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.