Unnamed: 0
int64 0
305k
| body
stringlengths 7
52.9k
| name
stringlengths 1
185
|
|---|---|---|
302,000
|
void () { doHighlightingTest("bad-ref-4.rng"); }
|
testBadRef4
|
302,001
|
void () { doTestQuickFix("create-definition-1", "rng"); }
|
testCreateDefinition1
|
302,002
|
void () { doHighlightingTest("parent-ref-1.rng"); }
|
testParentRef1
|
302,003
|
void () { myTestFixture.copyFileToProject("include.rng"); doHighlightingTest("parent-ref-2.rng"); }
|
testParentRef2
|
302,004
|
void () { doHighlightingTest("bad-parent-ref-1.rng"); }
|
testBadParentRef1
|
302,005
|
void () { myTestFixture.copyFileToProject("bad-parent-ref-1.rng"); doHighlightingTest("bad-parent-ref-2.rng"); }
|
testBadParentRef2
|
302,006
|
void () { doTestQuickFix("create-definition-2", "rng"); }
|
testCreateDefinition2
|
302,007
|
void () { doCustomHighlighting("missing-start-element.rng", false, true); }
|
testMissingStartElement
|
302,008
|
void () { myTestFixture.copyFileToProject("included-grammar.rng"); doCustomHighlighting("missing-start-element-and-include.rng", false, true); }
|
testMissingStartElementAndInclude
|
302,009
|
void () { doHighlightingTest("bad-ns-prefix.rng"); }
|
testBadNsPrefix
|
302,010
|
void () { doExternalToolHighlighting("bad-element.rng"); }
|
testBadElement
|
302,011
|
void () { myTestFixture.copyFileToProject("include.rng"); doHighlightingTest("good-include.rng"); }
|
testInclude
|
302,012
|
void () { myTestFixture.copyFileToProject("include.rng"); doHighlightingTest("good-include-ref-1.rng"); }
|
testIncludedRef1
|
302,013
|
void () { myTestFixture.copyFileToProject("include.rng"); final PsiReference ref = myTestFixture.getReferenceAtCaretPositionWithAssertion("resolve-include-ref-1.rng"); final PsiElement element = ref.resolve(); assertTrue(element instanceof XmlTag); assertNotSame(element.getContainingFile(), ref.getElement().getContainingFile()); assertEquals(0, ((XmlTag)element).getSubTags().length); }
|
testResolveIncludedRef1
|
302,014
|
void () { myTestFixture.copyFileToProject("include.rng"); final PsiReference ref = myTestFixture.getReferenceAtCaretPositionWithAssertion("resolve-include-ref-2.rng"); assertTrue("PolyVariantRef", ref instanceof PsiPolyVariantReference); final PsiElement element = ref.resolve(); assertNull(element); final ResolveResult[] results = ((PsiPolyVariantReference)ref).multiResolve(false); assertEquals(2, results.length); for (ResolveResult result : results) { PsiElement e = result.getElement(); assertTrue(e instanceof XmlTag); final int contentLength = ((XmlTag)e).getSubTags().length; if (e.getContainingFile() == ref.getElement().getContainingFile()) { assertEquals(1, contentLength); } else { assertEquals(0, contentLength); } } }
|
testResolveIncludedRef2
|
302,015
|
void () { doHighlightingTest("bad-include.rng"); }
|
testBadInclude
|
302,016
|
void (@NotNull PsiReferenceRegistrar registrar) { XmlUtil.registerXmlAttributeValueReferenceProvider(registrar, new String[]{ "name" }, new PatternFilter(xmlAttributeValue().withParent(Holder.NAME_PATTERN)), true, new PrefixReferenceProvider()); // final XmlAttributeValuePattern id = xmlAttributeValue().withParent(xmlAttribute()).with(IdRefProvider.HAS_ID_REF_TYPE); // final XmlAttributeValuePattern idref = xmlAttributeValue().withParent(xmlAttribute()).with(IdRefProvider.HAS_ID_TYPE); // registry.registerXmlAttributeValueReferenceProvider(null, new PatternFilter(or(id, idref)), false, new IdRefProvider()); }
|
registerReferenceProviders
|
302,017
|
DomElementsAnnotator () { return new ModelAnnotator(); }
|
createAnnotator
|
302,018
|
void (@NotNull Processor<? super String> processor, @NotNull GlobalSearchScope scope, @Nullable IdFilter filter) { FileBasedIndex.getInstance().processAllKeys(RelaxSymbolIndex.NAME, processor, scope, filter); }
|
processNames
|
302,019
|
void (@NotNull String name, @NotNull Processor<? super NavigationItem> processor, @NotNull FindSymbolParameters parameters) { boolean[] result = {true}; PsiManager psiManager = PsiManager.getInstance(parameters.getProject()); FileBasedIndex.getInstance().getFilesWithKey( RelaxSymbolIndex.NAME, Collections.singleton(name), file -> { PsiFile psiFile = psiManager.findFile(file); Grammar grammar = psiFile instanceof XmlFile ? GrammarFactory.getGrammar((XmlFile)psiFile) : null; if (grammar == null) return true; grammar.acceptChildren(new CommonElement.Visitor() { @Override public void visitDefine(Define define) { if (!result[0]) return; if (name.equals(define.getName())) { NavigationItem wrapped = wrap(define.getPsiElement()); result[0] = wrapped == null || processor.process(wrapped); } } }); return result[0]; }, parameters.getSearchScope()); }
|
processElementsWithName
|
302,020
|
void (Define define) { if (!result[0]) return; if (name.equals(define.getName())) { NavigationItem wrapped = wrap(define.getPsiElement()); result[0] = wrapped == null || processor.process(wrapped); } }
|
visitDefine
|
302,021
|
NavigationItem (@Nullable PsiElement item) { if (!(item instanceof NavigationItem)) return null; PsiMetaData metaData0 = item instanceof PsiMetaOwner ? ((PsiMetaOwner)item).getMetaData() : null; PsiPresentableMetaData metaData = metaData0 instanceof PsiPresentableMetaData ? (PsiPresentableMetaData)metaData0 : null; ItemPresentation presentation = metaData != null ? new ColoredItemPresentation() { @Override public String getPresentableText() { return metaData.getName(); } @NotNull @Override public String getLocationString() { return MyNavigationItem.getLocationString(item); } @Override @Nullable public Icon getIcon(boolean open) { return metaData.getIcon(); } @Nullable @Override public TextAttributesKey getTextAttributesKey() { ItemPresentation p = ((NavigationItem)item).getPresentation(); return p instanceof ColoredItemPresentation ? ((ColoredItemPresentation)p).getTextAttributesKey() : null; } } : ((NavigationItem)item).getPresentation(); return presentation == null ? null : new MyNavigationItem((NavigationItem)item, presentation); }
|
wrap
|
302,022
|
String () { return metaData.getName(); }
|
getPresentableText
|
302,023
|
String () { return MyNavigationItem.getLocationString(item); }
|
getLocationString
|
302,024
|
Icon (boolean open) { return metaData.getIcon(); }
|
getIcon
|
302,025
|
TextAttributesKey () { ItemPresentation p = ((NavigationItem)item).getPresentation(); return p instanceof ColoredItemPresentation ? ((ColoredItemPresentation)p).getTextAttributesKey() : null; }
|
getTextAttributesKey
|
302,026
|
String () { return myPresentation.getPresentableText(); }
|
getPresentableText
|
302,027
|
String () { return getLocationString((PsiElement)myItem); }
|
getLocationString
|
302,028
|
String (PsiElement element) { return "(in " + element.getContainingFile().getName() + ")"; }
|
getLocationString
|
302,029
|
Icon (boolean open) { return myPresentation.getIcon(open); }
|
getIcon
|
302,030
|
TextAttributesKey () { return myPresentation instanceof ColoredItemPresentation ? ((ColoredItemPresentation)myPresentation).getTextAttributesKey() : null; }
|
getTextAttributesKey
|
302,031
|
String () { return myItem.getName(); }
|
getName
|
302,032
|
ItemPresentation () { return this; }
|
getPresentation
|
302,033
|
PsiElement () { return (PsiElement)myItem; }
|
getTargetElement
|
302,034
|
void (boolean requestFocus) { myItem.navigate(requestFocus); }
|
navigate
|
302,035
|
boolean () { return myItem.canNavigate(); }
|
canNavigate
|
302,036
|
boolean () { return myItem.canNavigateToSource(); }
|
canNavigateToSource
|
302,037
|
String (CharSequence sb) { if (sb == null) return null; String s = sb.toString().replaceAll("\n", "<br>"); //NON-NLS if (!s.startsWith("<html>")) { s = XmlStringUtil.wrapInHtml(s); } return s; }
|
makeDocumentation
|
302,038
|
StringBuilder (XmlTag tag, String localName, String kind) { if (tag.getNamespace().equals(RelaxNgMetaDataContributor.RNG_NAMESPACE)) { final StringBuilder sb = new StringBuilder(); sb.append(kind).append(": <b>").append(localName).append("</b><br>"); final XmlTag[] docTags = tag.findSubTags("documentation", COMPATIBILITY_ANNOTATIONS_1_0); for (XmlTag docTag : docTags) { sb.append(docTag.getValue().getTrimmedText()); sb.append("\n"); } final XmlTag nextTag = PsiTreeUtil.getNextSiblingOfType(tag, XmlTag.class); if (nextTag != null) { if ("documentation".equals(nextTag.getLocalName()) && COMPATIBILITY_ANNOTATIONS_1_0.equals(nextTag.getNamespace())) { sb.append(nextTag.getValue().getTrimmedText()); } } return sb; } return null; }
|
getDocumentationFromTag
|
302,039
|
int () { return 0; // CompositeDocumentationProvider uses a HashSet that doesn't preserve order. We want to be the first one. }
|
hashCode
|
302,040
|
TextRange (@NotNull RncFileReference element) { return element.getReferenceRange(); }
|
getRangeInElement
|
302,041
|
void (@NotNull MetaDataRegistrar registrar) { registrar.registerMetaData( new AndFilter( new NamespaceFilter(RNG_NAMESPACE), new ClassFilter(XmlDocument.class) ), RngNsDescriptor.class); registrar.registerMetaData( new ClassFilter(RncDocument.class), RngNsDescriptor.class); registrar.registerMetaData(new ElementFilter() { @Override public boolean isAcceptable(Object element, PsiElement context) { if (element instanceof XmlTag tag) { final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag); return domElement instanceof RngDefine; } return false; } @Override public boolean isClassAcceptable(Class hintClass) { return XmlTag.class.isAssignableFrom(hintClass); } }, RngDefineMetaData.class); }
|
contributeMetaData
|
302,042
|
boolean (Object element, PsiElement context) { if (element instanceof XmlTag tag) { final DomElement domElement = DomManager.getDomManager(tag.getProject()).getDomElement(tag); return domElement instanceof RngDefine; } return false; }
|
isAcceptable
|
302,043
|
boolean (Class hintClass) { return XmlTag.class.isAssignableFrom(hintClass); }
|
isClassAcceptable
|
302,044
|
void (ResourceRegistrar registrar) { registrar.addStdResource(RNG_NAMESPACE, "/resources/relaxng.rng", getClass()); registrar.addStdResource(HtmlUtil.SVG_NAMESPACE, "/resources/html5-schema/svg20/svg20.rnc", getClass()); registrar.addStdResource(HtmlUtil.MATH_ML_NAMESPACE, "/resources/html5-schema/mml3/mathml3.rnc", getClass()); registrar.addIgnoredResource("http://relaxng.org/ns/compatibility/annotations/1.0"); }
|
registerResources
|
302,045
|
PsiElement () { final ProcessingContext context = new ProcessingContext(); final ResolvingVisitor visitor = new ResolvingVisitor(PATTERN.with(myCondition).save(TARGET), context) { @Override public void visitXmlTag(@NotNull XmlTag tag) { super.visitXmlTag(tag); if (shouldContinue()) { visitSubTags(tag); } } @Override protected boolean shouldContinue() { return context.get(TARGET) == null; } }; process(visitor); return context.get(TARGET); }
|
resolve
|
302,046
|
void (@NotNull XmlTag tag) { super.visitXmlTag(tag); if (shouldContinue()) { visitSubTags(tag); } }
|
visitXmlTag
|
302,047
|
boolean () { return context.get(TARGET) == null; }
|
shouldContinue
|
302,048
|
void (ResolvingVisitor visitor) { final XmlDocument document = PsiTreeUtil.getParentOfType(getElement(), XmlDocument.class); if (document != null) { visitor.execute(document); } }
|
process
|
302,049
|
void (@NotNull XmlTag tag) { super.visitXmlTag(tag); visitSubTags(tag); }
|
visitXmlTag
|
302,050
|
boolean (XmlAttributeValue xmlAttributeValue) { final XmlAttributeDescriptor descriptor = ((XmlAttribute)xmlAttributeValue.getParent()).getDescriptor(); return descriptor != null && descriptor.hasIdType(); }
|
hasIdType
|
302,051
|
boolean (XmlAttributeValue xmlAttributeValue) { final XmlAttributeDescriptor descriptor = ((XmlAttribute)xmlAttributeValue.getParent()).getDescriptor(); return descriptor != null && descriptor.hasIdRefType(); }
|
hasIdRefType
|
302,052
|
boolean (@NotNull XmlAttributeValue xmlAttributeValue, ProcessingContext context) { return hasIdType(xmlAttributeValue); }
|
accepts
|
302,053
|
boolean (@NotNull XmlAttributeValue xmlAttributeValue, ProcessingContext context) { return hasIdRefType(xmlAttributeValue); }
|
accepts
|
302,054
|
void (@NotNull XmlDocument document) { final XmlTag rootTag = document.getRootTag(); if (rootTag != null) { visitXmlTag(rootTag); } }
|
visitXmlDocument
|
302,055
|
void (XmlNamedElementPattern includePattern) { myIncludePattern = includePattern; }
|
setIncludePattern
|
302,056
|
void (@NotNull XmlAttribute attribute) { if (myIncludePattern != null && myIncludePattern.accepts(attribute, myProcessingContext)) { final String value = attribute.getValue(); if (value == null) return; final XmlFile xmlFile = XmlUtil.findXmlFile(attribute.getContainingFile(), value); if (xmlFile != null) { processInclude(xmlFile, attribute); } } else { processAttribute(attribute); } }
|
visitXmlAttribute
|
302,057
|
void (XmlAttribute attribute) { myPattern.accepts(attribute.getValueElement(), myProcessingContext); }
|
processAttribute
|
302,058
|
void (@NotNull XmlTag tag) { visitAttributes(tag); }
|
visitXmlTag
|
302,059
|
void (XmlTag tag) { final XmlAttribute[] xmlAttributes = tag.getAttributes(); for (XmlAttribute attribute : xmlAttributes) { attribute.accept(this); } }
|
visitAttributes
|
302,060
|
void (XmlTag tag) { final XmlTag[] tags = tag.getSubTags(); for (XmlTag subTag : tags) { if (shouldContinue()) { subTag.accept(this); } } }
|
visitSubTags
|
302,061
|
void (XmlFile xmlFile, XmlAttribute attribute) { final Set<XmlFile> set = myProcessingContext.get(VISITED_KEY); if (set.contains(xmlFile)) { return; } set.add(xmlFile); final XmlDocument document = xmlFile.getDocument(); if (document == null) return; final XmlTag rootTag = document.getRootTag(); if (rootTag == null) return; rootTag.processElements(this, attribute); }
|
processInclude
|
302,062
|
boolean (@NotNull PsiElement element) { element.accept(this); return shouldContinue(); }
|
execute
|
302,063
|
boolean () { return true; }
|
shouldContinue
|
302,064
|
PsiReference[] (FileReferenceSet set, final Condition<? super PsiFile> cond) { return restrict(set, cond, null); }
|
restrict
|
302,065
|
PsiReference[] (FileReferenceSet set, final Condition<? super PsiFile> cond, final Boolean soft) { final FileReference[] references = set.getAllReferences(); return ContainerUtil.map2Array(references, PsiReference.class, (NotNullFunction<FileReference, PsiReference>)fileReference -> new MyFileReference(fileReference, cond, soft)); }
|
restrict
|
302,066
|
Condition<PsiFile> (FileType instance) { return new TypeCondition(instance); }
|
byType
|
302,067
|
Condition<PsiFile> (String ns) { return new PatternCondition(xmlFile().withRootTag(xmlTag().withNamespace(string().equalTo(ns)))); }
|
byNamespace
|
302,068
|
boolean (PsiFile file) { return file.getFileType() == myType; }
|
value
|
302,069
|
boolean (PsiFile o) { return myPattern.accepts(o); }
|
value
|
302,070
|
boolean () { return mySoft == null ? super.isSoft() : mySoft; }
|
isSoft
|
302,071
|
PsiFileSystemItem () { final PsiFileSystemItem result = super.resolve(); if (result instanceof PsiFile) { if (!myCond.value((PsiFile)result)) { return null; } } return result; }
|
resolve
|
302,072
|
boolean (Object o, Condition<? super PsiFile> cond) { return !(o instanceof PsiFileSystemItem) || ((PsiFileSystemItem)o).isDirectory() || (o instanceof PsiFile && cond.value((PsiFile)o)); }
|
match
|
302,073
|
PsiElement () { final String prefix = getCanonicalText(); XmlTag tag = PsiTreeUtil.getParentOfType(getElement(), XmlTag.class); while (tag != null) { if (tag.getLocalNamespaceDeclarations().containsKey(prefix)) { final XmlAttribute attribute = tag.getAttribute("xmlns:" + prefix, ""); final TextRange textRange = TextRange.from("xmlns:".length(), prefix.length()); return new SchemaPrefix(attribute, textRange, prefix); } tag = tag.getParentTag(); } return null; }
|
resolve
|
302,074
|
boolean (@NotNull PsiElement element) { if (element instanceof SchemaPrefix && element.getContainingFile() == myElement.getContainingFile()) { final PsiElement e = resolve(); if (e instanceof SchemaPrefix) { final String s = ((SchemaPrefix)e).getName(); return s != null && s.equals(((SchemaPrefix)element).getName()); } } return super.isReferenceTo(element); }
|
isReferenceTo
|
302,075
|
boolean () { return false; }
|
isSoft
|
302,076
|
String () { //The format substitution is performed at the call site //noinspection UnresolvedPropertyKey return RelaxngBundle.message("relaxng.annotator.unresolved-namespace-prefix"); }
|
getUnresolvedMessagePattern
|
302,077
|
boolean (@NotNull XmlAttributeValue value, ProcessingContext context) { return myRef.equals(value.getValue()); }
|
accepts
|
302,078
|
boolean (@NotNull T value, ProcessingContext context) { context.get(myKey).add(value); return true; }
|
accepts
|
302,079
|
String (XmlAttributeValue value) { return value.getValue(); }
|
fun
|
302,080
|
String[] (Set<? extends XmlAttributeValue> values) { return ContainerUtil.map2Array(values, String.class, new AttributeValueFunction()); }
|
toStrings
|
302,081
|
void (@NotNull CompletionParameters parameters, @NotNull ProcessingContext context, @NotNull CompletionResultSet result) { String[] keywords = getKeywords(parameters.getPosition()); for (String keyword : keywords) { result.addElement(TailTypeDecorator.withTail(LookupElementBuilder.create(keyword).bold(), TailTypes.spaceType())); } }
|
addCompletions
|
302,082
|
String[] (PsiElement context) { final PsiElement next = PsiTreeUtil.skipWhitespacesForward(context); if (next != null && EscapeUtil.unescapeText(next).equals("=")) { return new String[]{ "start" }; } if (DEFAULT_PATTERN.accepts(context)) { return new String[]{ "namespace" }; } else if (DECL_PATTERN.accepts(context)) { return ArrayUtilRt.EMPTY_STRING_ARRAY; } else if (context.getParent() instanceof RncDefine && context.getParent().getFirstChild() == context) { if (DEFINE_PATTERN.accepts(context)) { return ArrayUtilRt.EMPTY_STRING_ARRAY; } if (TOP_LEVEL.accepts(context)) { if (!afterPattern(context)) { return ArrayUtil.mergeArrays(DECL_KEYWORDS, ArrayUtil.mergeArrays(GRAMMAR_CONTENT_KEYWORDS, PATTERN_KEYWORDS)); } } return GRAMMAR_CONTENT_KEYWORDS; } return PATTERN_KEYWORDS; }
|
getKeywords
|
302,083
|
boolean (PsiElement context) { // TODO: recognize all patterns return PsiTreeUtil.getPrevSiblingOfType(context.getParent(), RncDefine.class) != null; }
|
afterPattern
|
302,084
|
String () { return "RNG Compact"; }
|
getName
|
302,085
|
String () { return RelaxngBundle.message("filetype.relaxng.compact-syntax.description"); }
|
getDescription
|
302,086
|
String () { return "rnc"; }
|
getDefaultExtension
|
302,087
|
Icon () { return AllIcons.FileTypes.Text; }
|
getIcon
|
302,088
|
FileType () { return INSTANCE; }
|
getInstance
|
302,089
|
void (RncInclude include) { checkReferences(include.getReferences()); }
|
visitInclude
|
302,090
|
void (RncExternalRef ref) { checkReferences(ref.getReferences()); }
|
visitExternalRef
|
302,091
|
void (RncRef pattern) { checkReferences(pattern.getReferences()); }
|
visitRef
|
302,092
|
void (RncParentRef pattern) { checkReferences(pattern.getReferences()); }
|
visitParentRef
|
302,093
|
void (RncName name) { checkReferences(name.getReferences()); }
|
visitName
|
302,094
|
void (PsiReference[] references) { for (PsiReference reference : references) { if (!reference.isSoft()) { if (reference.resolve() == null) { if (reference instanceof PsiPolyVariantReference pvr) { if (pvr.multiResolve(false).length == 0) { addError(reference); } } else { addError(reference); } } } } }
|
checkReferences
|
302,095
|
void (PsiReference reference) { final TextRange rangeInElement = reference.getRangeInElement(); final TextRange range = TextRange.from(reference.getElement().getTextRange().getStartOffset() + rangeInElement.getStartOffset(), rangeInElement.getLength()); String message; if (reference instanceof EmptyResolveMessageProvider) { message = ((EmptyResolveMessageProvider)reference).getUnresolvedMessagePattern(); } else { //noinspection UnresolvedPropertyKey message = AnalysisBundle.message("cannot.resolve.symbol"); } String description; try { description = BundleBase.format(message, reference.getCanonicalText()); // avoid double formatting NON-NLS } catch (IllegalArgumentException ex) { // unresolvedMessage provided by third-party reference contains wrong format string (e.g. {}), tolerate it description = message; } AnnotationBuilder builder = myHolder.newAnnotation(HighlightSeverity.ERROR, description).range(range) .highlightType(ProblemHighlightType.LIKE_UNKNOWN_SYMBOL); if (reference instanceof LocalQuickFixProvider) { LocalQuickFix[] fixes = ((LocalQuickFixProvider)reference).getQuickFixes(); if (fixes != null) { InspectionManager inspectionManager = InspectionManager.getInstance(reference.getElement().getProject()); for (LocalQuickFix fix : fixes) { ProblemDescriptor descriptor = inspectionManager.createProblemDescriptor(reference.getElement(), message, fix, ProblemHighlightType.LIKE_UNKNOWN_SYMBOL, true); builder = builder.newLocalQuickFix(fix, descriptor).registerFix(); } } } builder.create(); }
|
addError
|
302,096
|
Lexer (Project project) { return new CompactSyntaxLexerAdapter(); }
|
createLexer
|
302,097
|
PsiParser (Project project) { return new RncParser(); }
|
createParser
|
302,098
|
IFileElementType () { return FILE_ELEMENT_TYPE; }
|
getFileNodeType
|
302,099
|
TokenSet () { return TokenSet.create(TokenType.WHITE_SPACE); }
|
getWhitespaceTokens
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.