Unnamed: 0
int64
0
305k
body
stringlengths
7
52.9k
name
stringlengths
1
185
304,700
void (@NotNull TextEditorHighlightingPassRegistrar registrar, @NotNull Project project) { registrar.registerTextEditorHighlightingPass(this, new int[]{Pass.UPDATE_ALL}, null, false, -1); }
registerHighlightingPassFactory
304,701
TextEditorHighlightingPass (final @NotNull PsiFile file, final @NotNull Editor editor) { if (editor.isOneLineMode()) return null; if (!XmlTagTreeHighlightingUtil.isTagTreeHighlightingActive(file)) return null; if (!(editor instanceof EditorEx)) return null; return new XmlTagTreeHighlightingPass(file, (EditorEx)editor); }
createHighlightingPass
304,702
boolean (@NotNull PsiElement deepestElement) { final PsiFile file = deepestElement.getContainingFile(); if (file == null || !XmlTagTreeHighlightingUtil.isTagTreeHighlightingActive(file)) { return false; } return true; }
isMyContext
304,703
CrumbPresentation[] (PsiElement @NotNull [] elements) { if (elements.length == 0 || !isMyContext(elements[elements.length - 1])) { return null; } if (!XmlTagTreeHighlightingUtil.containsTagsWithSameName(elements)) { return null; } final CrumbPresentation[] result = new CrumbPresentation[elements.length]; final Color[] baseColors = XmlTagTreeHighlightingUtil.getBaseColors(); int index = 0; for (int i = result.length - 1; i >= 0; i--) { if (elements[i] instanceof XmlTag) { final Color color = baseColors[index % baseColors.length]; result[i] = new MyCrumbPresentation(color); index++; } } return result; }
getCrumbPresentations
304,704
Color (boolean selected, boolean hovered, boolean light) { final Color baseColor = super.getBackgroundColor(selected, hovered, light); return baseColor == null ? XmlTagTreeHighlightingPass.toLineMarkerColor(0x92, myColor) : myColor != null ? UIUtil.makeTransparent(myColor, baseColor, 0.1) : baseColor; }
getBackgroundColor
304,705
String () { return KEY; }
getQuickFixKeyId
304,706
boolean () { return false; }
startInWriteAction
304,707
String () { return KEY; }
getQuickFixKeyId
304,708
boolean () { return false; }
startInWriteAction
304,709
void (final @NotNull String currentUri, final String url) { if (currentUri.equals(uri) && url != null) schemaLocations.add(url); }
process
304,710
boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof XmlFile)) return false; PsiElement element = file.findElementAt(editor.getCaretModel().getOffset()); XmlAttributeValue value = PsiTreeUtil.getParentOfType(element, XmlAttributeValue.class); if (value == null) return false; XmlAttribute attribute = PsiTreeUtil.getParentOfType(value, XmlAttribute.class); if (attribute != null && attribute.isNamespaceDeclaration()) { setText(XmlBundle.message(getQuickFixKeyId())); return true; } return false; }
isAvailable
304,711
Set<String> (@NotNull Project project) { String path = getExternalResourcesPath(); Path file = checkExists(path); return Collections.singleton(file.toAbsolutePath().toString()); }
getRootsToWatch
304,712
String () { return KEY; }
getQuickFixKeyId
304,713
boolean (final String uri) { return uri.startsWith(HTTP_PROTOCOL) || uri.startsWith(FTP_PROTOCOL) || uri.startsWith(HTTPS_PROTOCOL); }
isAcceptableUri
304,714
String (PsiFile file, int offset, String uri) { final PsiElement currentElement = file.findElementAt(offset); final XmlAttribute attribute = PsiTreeUtil.getParentOfType(currentElement, XmlAttribute.class); if (attribute != null) { final XmlTag tag = PsiTreeUtil.getParentOfType(currentElement, XmlTag.class); if (tag != null) { final String prefix = tag.getPrefixByNamespace(XmlUtil.XML_SCHEMA_INSTANCE_URI); if (prefix != null) { final String attrValue = tag.getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT, XmlUtil.XML_SCHEMA_INSTANCE_URI); if (attrValue != null) { final StringTokenizer tokenizer = new StringTokenizer(attrValue); while (tokenizer.hasMoreElements()) { if (uri.equals(tokenizer.nextToken())) { if (!tokenizer.hasMoreElements()) return uri; final String url = tokenizer.nextToken(); return url.startsWith(HTTP_PROTOCOL) ? url : uri; } if (!tokenizer.hasMoreElements()) return uri; tokenizer.nextToken(); // skip file location } } } } } return uri; }
findUrl
304,715
Path (String dir) { Path path = Paths.get(dir); try { Files.createDirectories(path); } catch (IOException e) { LOG.warn("Unable to create: " + path, e); } return path; }
checkExists
304,716
boolean () { return false; }
startInWriteAction
304,717
void (@NotNull ProgressIndicator indicator) { while (true) { try { HttpConfigurable.getInstance().prepareURL(url); fetchDtd(project, uri, url, indicator); ApplicationManager.getApplication().invokeLater(() -> DaemonCodeAnalyzer.getInstance(project).restart(file)); return; } catch (IOException ex) { LOG.info(ex); @SuppressWarnings("InstanceofCatchParameter") String problemUrl = ex instanceof FetchingResourceIOException ? ((FetchingResourceIOException)ex).url : url; String message = XmlBundle.message("xml.intention.fetch.error.fetching.title"); if (!url.equals(problemUrl)) { message = XmlBundle.message("xml.intention.fetch.error.fetching.dependent.resource"); } if (!IOExceptionDialog.showErrorDialog(message, XmlBundle.message("xml.intention.fetch.error.fetching.resource", problemUrl))) { break; // cancel fetching } } } }
run
304,718
VirtualFile (final String resPath, final @Nullable String dtdUrl, Project project) { final Ref<VirtualFile> ref = new Ref<>(); ApplicationManager.getApplication().invokeAndWait(() -> ApplicationManager.getApplication().runWriteAction(() -> { ref.set(LocalFileSystem.getInstance().refreshAndFindFileByPath(resPath.replace(File.separatorChar, '/'))); if (dtdUrl != null) { ExternalResourceManager.getInstance().addResource(dtdUrl, resPath); } else if (!project.isDisposed()){ ExternalResourceManager.getInstance().incModificationCount(); PsiManager.getInstance(project).dropPsiCaches(); } })); return ref.get(); }
findFileByPath
304,719
String () { return PathManager.getSystemPath() + File.separator + EXT_RESOURCES_FOLDER; }
getExternalResourcesPath
304,720
void (final List<String> resourceUrls, final List<String> downloadedResources) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { for (String resourcesUrl : resourceUrls) { ExternalResourceManager.getInstance().removeResource(resourcesUrl); } for (String downloadedResource : downloadedResources) { VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(downloadedResource)); if (virtualFile != null) { try { virtualFile.delete(this); } catch (IOException ignore) { } } } } }); } }); }
cleanup
304,721
void () { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { for (String resourcesUrl : resourceUrls) { ExternalResourceManager.getInstance().removeResource(resourcesUrl); } for (String downloadedResource : downloadedResources) { VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(downloadedResource)); if (virtualFile != null) { try { virtualFile.delete(this); } catch (IOException ignore) { } } } } }); }
run
304,722
void () { for (String resourcesUrl : resourceUrls) { ExternalResourceManager.getInstance().removeResource(resourcesUrl); } for (String downloadedResource : downloadedResources) { VirtualFile virtualFile = LocalFileSystem.getInstance().findFileByIoFile(new File(downloadedResource)); if (virtualFile != null) { try { virtualFile.delete(this); } catch (IOException ignore) { } } } }
run
304,723
boolean (final Project project, ProgressIndicator indicator, final String resourceUrl, FetchResult result) { if (myForceResultIsValid) { return true; } if (!ApplicationManager.getApplication().isUnitTestMode() && result.contentType != null && result.contentType.contains(HTML_MIME) && new String(result.bytes, StandardCharsets.UTF_8).contains("<html")) { ApplicationManager.getApplication().invokeLater(() -> Messages.showMessageDialog(project, XmlBundle.message( "xml.intention.fetch.error.invalid.url.no.xml.file.at.location", resourceUrl), XmlBundle.message( "xml.intention.fetch.error.invalid.url.title"), Messages.getErrorIcon()), indicator.getModalityState()); return false; } return true; }
resultIsValid
304,724
Set<String> (XmlFile file, XmlFile context, final String url) { if (context != null) { XmlEntityCache.copyEntityCaches(file, context); } Set<String> result = new LinkedHashSet<>(); XmlUtil.processXmlElements( file, element -> { if (element instanceof XmlEntityDecl) { String candidateName = null; for (PsiElement e = element.getLastChild(); e != null; e = e.getPrevSibling()) { if (e instanceof XmlAttributeValue && candidateName == null) { candidateName = e.getText().substring(1, e.getTextLength() - 1); } else if (e instanceof XmlToken && candidateName != null && (((XmlToken)e).getTokenType() == XmlTokenType.XML_DOCTYPE_PUBLIC || ((XmlToken)e).getTokenType() == XmlTokenType.XML_DOCTYPE_SYSTEM ) ) { result.add(candidateName); break; } } } else if (element instanceof XmlTag tag) { String schemaLocation = tag.getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT); if (schemaLocation != null) { // processing xsd:import && xsd:include final PsiReference[] references = tag.getAttribute(XmlUtil.SCHEMA_LOCATION_ATT).getValueElement().getReferences(); if (references.length > 0) { String extension = FileUtilRt.getExtension(new File(url).getName()); final String namespace = tag.getAttributeValue("namespace"); if (namespace != null && schemaLocation.indexOf('/') == -1 && !extension.equals(FileUtilRt.getExtension(schemaLocation))) { result.add(namespace.substring(0, namespace.lastIndexOf('/') + 1) + schemaLocation); } else { result.add(schemaLocation); } } } else { schemaLocation = tag.getAttributeValue(XmlUtil.SCHEMA_LOCATION_ATT, XmlUtil.XML_SCHEMA_INSTANCE_URI); if (schemaLocation != null) { final StringTokenizer tokenizer = new StringTokenizer(schemaLocation); while (tokenizer.hasMoreTokens()) { tokenizer.nextToken(); if (!tokenizer.hasMoreTokens()) break; String location = tokenizer.nextToken(); result.add(location); } } } } return true; }, true, true ); return result; }
extractEmbeddedFileReferences
304,725
Set<String> (final VirtualFile vFile, final @Nullable VirtualFile contextVFile, final PsiManager psiManager, final String url) { return ReadAction.compute(() -> { PsiFile file = psiManager.findFile(vFile); if (file instanceof XmlFile) { PsiFile contextFile = contextVFile != null ? psiManager.findFile(contextVFile) : null; return extractEmbeddedFileReferences((XmlFile)file, contextFile instanceof XmlFile ? (XmlFile)contextFile : null, url); } return Collections.emptySet(); }); }
extractEmbeddedFileReferences
304,726
String () { return KEY; }
getQuickFixKeyId
304,727
IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { int offset = editor.getCaretModel().getOffset(); final String uri = findUri(file, offset); if (uri == null) { return IntentionPreviewInfo.EMPTY; } String pathToConfigurable = ConfigurableExtensionPointUtil.getConfigurablePath(ExternalResourceConfigurable.class, project); String text = new HtmlBuilder().wrapWithHtmlBody() .child(HtmlChunk.body().child(HtmlChunk.template(XmlBundle.message("ignore.ext.resource.preview", "$uri$", "$path$"), Map.entry("uri", HtmlChunk.link("uri", uri)), Map.entry("path", HtmlChunk.text(pathToConfigurable).italic())))).toString(); return new IntentionPreviewInfo.Html(text); }
generatePreview
304,728
boolean () { return false; }
startInWriteAction
304,729
boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof XmlFile)) return false; int offset = editor.getCaretModel().getOffset(); String uri = findUri(file, offset); if (uri == null || !isAcceptableUri(uri)) return false; setText(XmlBundle.message(getQuickFixKeyId())); return true; }
isAvailable
304,730
boolean (final String uri) { return true; }
isAcceptableUri
304,731
String () { return XmlBundle.message(getQuickFixKeyId()); }
getFamilyName
304,732
XmlFile () { return (XmlFile)myElement.getFile(); }
getFile
304,733
String () { final String alias = getXmlNamespaceHelper().getNamespaceAlias(getFile()); return XmlPsiBundle.message("xml.quickfix.create.namespace.declaration.text", alias); }
getText
304,734
XmlNamespaceHelper () { return XmlNamespaceHelper.getHelper(getFile()); }
getXmlNamespaceHelper
304,735
String () { return XmlPsiBundle.message("xml.quickfix.create.namespace.declaration.family"); }
getFamilyName
304,736
void (final @NotNull Project project, final @NotNull ProblemDescriptor descriptor) { final PsiFile containingFile = descriptor.getPsiElement().getContainingFile(); Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor(); final PsiFile file = editor != null ? PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()) : null; if (file == null || !Comparing.equal(file.getVirtualFile(), containingFile.getVirtualFile())) return; try { invoke(project, editor, containingFile); } catch (IncorrectOperationException ex) { LOG.error(ex); } }
applyFix
304,737
IntentionPreviewInfo (@NotNull Project project, @NotNull ProblemDescriptor previewDescriptor) { return doPreview(project, previewDescriptor.getPsiElement(), null); }
generatePreview
304,738
IntentionPreviewInfo (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { PsiElement element = myElement.retrieve(); if (element == null) return IntentionPreviewInfo.EMPTY; return doPreview(project, PsiTreeUtil.findSameElementInCopy(element, file), editor); }
generatePreview
304,739
IntentionPreviewInfo (@NotNull Project project, PsiElement element, @Nullable Editor editor) { PsiFile file = element.getContainingFile(); if (!(file instanceof XmlFile xmlFile)) return IntentionPreviewInfo.EMPTY; List<String> namespaces = getNamespaces(element, xmlFile); String namespace = namespaces.isEmpty() ? "" : namespaces.get(0); new MyStringToAttributeProcessor(element, project, editor, xmlFile) .doSomethingWithGivenStringToProduceXmlAttributeNowPlease(namespace); return IntentionPreviewInfo.DIFF; }
doPreview
304,740
boolean (@NotNull Project project, Editor editor, PsiFile file) { if (!(file instanceof XmlFile)) return false; PsiElement element = myElement.retrieve(); XmlTag rootTag = ((XmlFile)file).getRootTag(); return element != null && rootTag != null && !PsiUtilCore.hasErrorElementChild(rootTag); }
isAvailable
304,741
List<String> (PsiElement element, XmlFile xmlFile) { if (element instanceof XmlAttribute) { element = element.getParent(); } Set<String> set = getXmlNamespaceHelper().guessUnboundNamespaces(element, xmlFile); final String match = getUnboundNamespaceForPrefix(myNamespacePrefix, xmlFile, set); if (match != null) { return Collections.singletonList(match); } List<String> namespaces = new ArrayList<>(set); Collections.sort(namespaces); return namespaces; }
getNamespaces
304,742
boolean () { return true; }
startInWriteAction
304,743
boolean (final @NotNull Editor editor) { XmlToken token = null; if (myToken != null) { token = (XmlToken)myToken.retrieve(); if (token == null) return false; } if (!XmlSettings.getInstance().SHOW_XML_ADD_IMPORT_HINTS || myNamespacePrefix.isEmpty()) { return false; } final PsiElement element = myElement.retrieve(); if (element == null) return false; final List<String> namespaces = getNamespaces(element, getFile()); if (!namespaces.isEmpty()) { final String message = ShowAutoImportPass.getMessage(namespaces.size() > 1, XmlPsiBundle.message("xml.terms.namespace.alias"), namespaces.iterator().next()); final String title = getSelectNSActionTitle(); final ImportNSAction action = new ImportNSAction(namespaces, getFile(), element, editor, title); if (element instanceof XmlTag && token != null) { if (editor.calculateVisibleRange().contains(token.getTextRange())) { HintManager.getInstance().showQuestionHint(editor, message, token.getTextOffset(), token.getTextOffset() + myNamespacePrefix.length(), action); return true; } } else { HintManager.getInstance().showQuestionHint(editor, message, element.getTextOffset(), element.getTextRange().getEndOffset(), action); return true; } } return false; }
showHint
304,744
boolean (final String name, final XmlFile tldFileByUri) { if (name == null || name.isEmpty()) return true; final List<String> list = StringUtil.getWordsIn(name); final String[] words = ArrayUtilRt.toStringArray(list); final boolean[] wordsFound = new boolean[words.length]; final int[] wordsFoundCount = new int[1]; IdTableBuilding.ScanWordProcessor wordProcessor = new IdTableBuilding.ScanWordProcessor() { @Override public void run(final CharSequence chars, char @Nullable [] charsArray, int start, int end) { if (wordsFoundCount[0] == words.length) return; final int foundWordLen = end - start; Next: for (int i = 0; i < words.length; ++i) { final String localName = words[i]; if (wordsFound[i] || localName.length() != foundWordLen) continue; for (int j = 0; j < localName.length(); ++j) { if (chars.charAt(start + j) != localName.charAt(j)) continue Next; } wordsFound[i] = true; wordsFoundCount[0]++; break; } } }; final CharSequence contents = tldFileByUri.getViewProvider().getContents(); IdTableBuilding.scanWords(wordProcessor, contents, 0, contents.length()); return wordsFoundCount[0] == words.length; }
checkIfGivenXmlHasTheseWords
304,745
void (final CharSequence chars, char @Nullable [] charsArray, int start, int end) { if (wordsFoundCount[0] == words.length) return; final int foundWordLen = end - start; Next: for (int i = 0; i < words.length; ++i) { final String localName = words[i]; if (wordsFound[i] || localName.length() != foundWordLen) continue; for (int j = 0; j < localName.length(); ++j) { if (chars.charAt(start + j) != localName.charAt(j)) continue Next; } wordsFound[i] = true; wordsFoundCount[0]++; break; } }
run
304,746
void (final MetaHandler metaHandler, final PsiFile file, final ExternalUriProcessor processor) { ProgressManager.getInstance().runProcessWithProgressSynchronously( () -> ReadAction.run(() -> processExternalUrisImpl(metaHandler, file, processor)), XmlPsiBundle.message("xml.progress.finding.acceptable.uri"), false, file.getProject() ); }
processExternalUris
304,747
boolean (final PsiMetaData metaData, final String url) { if (metaData instanceof XmlNSDescriptorImpl nsDescriptor) { final XmlElementDescriptor descriptor = nsDescriptor.getElementDescriptor(searchFor(), url); return descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor); } return false; }
isAcceptableMetaData
304,748
String () { return myName; }
searchFor
304,749
void (final MetaHandler metaHandler, final PsiFile file, final ExternalUriProcessor processor) { final ProgressIndicator pi = ProgressManager.getInstance().getProgressIndicator(); final String searchFor = metaHandler.searchFor(); if (pi != null) { pi.setText(XmlPsiBundle.message("xml.progress.looking.in.schemas")); pi.setIndeterminate(false); } final ExternalResourceManager instanceEx = ExternalResourceManager.getInstance(); final String[] availableUrls = instanceEx.getResourceUrls(null, true); int i = 0; for (@NlsSafe String url : availableUrls) { if (pi != null) { pi.setFraction((double)i / availableUrls.length); pi.setText2(url); ++i; } final XmlFile xmlFile = XmlUtil.findNamespace(file, url); if (xmlFile != null) { final boolean wordFound = checkIfGivenXmlHasTheseWords(searchFor, xmlFile); if (!wordFound) continue; final XmlDocument document = xmlFile.getDocument(); assert document != null; final PsiMetaData metaData = document.getMetaData(); if (metaHandler.isAcceptableMetaData(metaData, url)) { final XmlNSDescriptorImpl descriptor = metaData instanceof XmlNSDescriptorImpl ? (XmlNSDescriptorImpl)metaData : null; final String defaultNamespace = descriptor != null ? descriptor.getDefaultNamespace() : url; // Skip rare stuff if (!XmlUtil.XML_SCHEMA_URI2.equals(defaultNamespace) && !XmlUtil.XML_SCHEMA_URI3.equals(defaultNamespace)) { processor.process(defaultNamespace, url); } } } } }
processExternalUrisImpl
304,750
boolean (@NotNull Project project, Editor editor, PsiFile file) { return file.getLanguage().isKindOf(XMLLanguage.INSTANCE) && getText(editor, file) != null && !file.getLanguage().isKindOf(HTMLLanguage.INSTANCE); }
isAvailable
304,751
PsiElement (Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); PsiElement parent = element != null ? element.getParent() : null; if (isText(parent)) return parent; element = file.findElementAt(offset - 1); parent = element != null ? element.getParent() : null; if (isText(parent)) return parent; return null; }
getText
304,752
boolean (PsiElement element) { if (element instanceof XmlText) return true; if (element instanceof XmlEntityRef && element.getParent() instanceof XmlText) return true; return false; }
isText
304,753
boolean () { return true; }
startInWriteAction
304,754
String () { return XmlPsiBundle.message("xml.quickfix.insert.required.attribute.text", myAttrName); }
getText
304,755
String () { return XmlPsiBundle.message("xml.quickfix.insert.required.attribute.family"); }
getFamilyName
304,756
void (final @NotNull Project project, @NotNull PsiFile file, final @Nullable Editor editor, @NotNull PsiElement startElement, @NotNull PsiElement endElement) { XmlTag myTag = (XmlTag)startElement; ASTNode treeElement = SourceTreeToPsiMap.psiElementToTree(myTag); final XmlElementDescriptor descriptor = myTag.getDescriptor(); if (descriptor == null) { return; } final XmlAttributeDescriptor attrDescriptor = descriptor.getAttributeDescriptor(myAttrName, myTag); final boolean indirectSyntax = XmlExtension.getExtension(myTag.getContainingFile()).isIndirectSyntax(attrDescriptor); boolean insertShorthand = myTag instanceof HtmlTag && attrDescriptor != null && HtmlUtil.isBooleanAttribute(attrDescriptor, myTag); PsiElement anchor = SourceTreeToPsiMap.treeElementToPsi( XmlChildRole.EMPTY_TAG_END_FINDER.findChild(treeElement) ); final boolean anchorIsEmptyTag = anchor != null; if (anchor == null) { anchor = SourceTreeToPsiMap.treeElementToPsi( XmlChildRole.START_TAG_END_FINDER.findChild(treeElement) ); } if (anchor == null) return; final Template template = TemplateManager.getInstance(project).createTemplate("", ""); String valuePostfix = "\""; if (indirectSyntax) { if (anchorIsEmptyTag) template.addTextSegment(">"); template.addTextSegment("<jsp:attribute name=\"" + myAttrName + "\">"); } else { template.addTextSegment(" " + myAttrName); if (!insertShorthand) { String quote = XmlEditUtil.getAttributeQuote(file); AttributeValuePresentation presentation = XmlExtension.getExtension(file).getAttributeValuePresentation(myTag, myAttrName, quote); valuePostfix = presentation.getPostfix(); template.addTextSegment("=" + presentation.getPrefix()); } } Expression expression = new ConstantNode("").withLookupStrings(myValues); if (!insertShorthand) template.addVariable(NAME_TEMPLATE_VARIABLE, expression, expression, true); if (indirectSyntax) { template.addTextSegment("</jsp:attribute>"); template.addEndVariable(); if (anchorIsEmptyTag) template.addTextSegment("</" + myTag.getName() + ">"); } else if (!insertShorthand) { template.addTextSegment(valuePostfix); } int textOffset = anchor.getTextOffset(); if (!anchorIsEmptyTag && indirectSyntax) ++textOffset; editor.getCaretModel().moveToOffset(textOffset); if (anchorIsEmptyTag && indirectSyntax) { editor.getDocument().deleteString(textOffset, textOffset + 2); } TemplateManager.getInstance(project).startTemplate(editor, template); }
invoke
304,757
String () { return getText(); }
getFamilyName
304,758
boolean () { return false; }
startInWriteAction
304,759
boolean (String inputString) { return !ns.contains(inputString) && isValidPrefix(inputString, project); }
checkInput
304,760
boolean (String inputString) { return checkInput(inputString); }
canClose
304,761
void (@NotNull XmlTag tag) { if (tag.getNamespace().equals(namespace) && tag.getNamespacePrefix().isEmpty()) { tags.add(tag); } super.visitXmlTag(tag); }
visitXmlTag
304,762
void (@NotNull XmlAttributeValue value) { PsiReference ref = null; boolean skip = false; for (PsiReference reference : value.getReferences()) { if (reference instanceof TypeOrElementOrAttributeReference) { ref = reference; } else if (reference instanceof SchemaPrefixReference) { skip = true; break; } } if (!skip && ref != null) { final PsiElement xmlElement = ref.resolve(); if (xmlElement instanceof XmlElement) { final XmlTag tag = PsiTreeUtil.getParentOfType(xmlElement, XmlTag.class, false); if (tag != null) { if (tag.getNamespace().equals(namespace)) { if (ref.getRangeInElement().getLength() == value.getValue().length()) { //no ns prefix values.add(value); } } } } } }
visitXmlAttributeValue
304,763
boolean (String prefix, Project project) { try { XmlTag tag = XmlElementFactory.getInstance(project).createTagFromText("<" + prefix + ":foo/>"); return "foo".equals(tag.getLocalName()); } catch (IncorrectOperationException e) { return false; } }
isValidPrefix
304,764
boolean (@NotNull Project project, Editor editor, @NotNull PsiElement element) { return getXmlnsDeclaration(element) != null; }
isAvailable
304,765
void (@NotNull XmlTag tag) { if (ns.equals(tag.getNamespacePrefix())) { tags.add(tag); } super.visitXmlTag(tag); }
visitXmlTag
304,766
void (@NotNull XmlAttributeValue value) { if (value.getValue().startsWith(ns + ":")) { for (PsiReference ref : value.getReferences()) { if (ref instanceof SchemaPrefixReference && ref.isReferenceTo(prefix)) { attrs.add((XmlAttribute)value.getParent()); } } } }
visitXmlAttributeValue
304,767
void (String ns, final List<? extends XmlTag> tags, final List<? extends XmlAttribute> attrs, Project project) { final int localNameIndex = ns.length() + 1; final int totalCount = tags.size() + attrs.size(); final SequentialModalProgressTask progressTask = new SequentialModalProgressTask( project, XmlBundle.message("xml.progress.changing.to.default.namespace"), true); progressTask.setTask(new SequentialTask() { int tagIndex = 0; int attrIndex = 0; @Override public boolean isDone() { return tagIndex + attrIndex >= totalCount; } @Override public boolean iteration() { progressTask.getIndicator().setFraction(((double)(tagIndex + attrIndex)) / totalCount); ApplicationManager.getApplication().runWriteAction(() -> { if (tagIndex < tags.size()) { XmlTag tag = tags.get(tagIndex++); final String s = tag.getName().substring(localNameIndex); if (!s.isEmpty()) { tag.setName(s); } } else if (attrIndex < attrs.size()) { XmlAttribute attr = attrs.get(attrIndex++); //noinspection ConstantConditions attr.setValue(attr.getValue().substring(localNameIndex)); } }); return isDone(); } }); ProgressManager.getInstance().run(progressTask); }
convertTagsAndAttributes
304,768
boolean () { return tagIndex + attrIndex >= totalCount; }
isDone
304,769
boolean () { progressTask.getIndicator().setFraction(((double)(tagIndex + attrIndex)) / totalCount); ApplicationManager.getApplication().runWriteAction(() -> { if (tagIndex < tags.size()) { XmlTag tag = tags.get(tagIndex++); final String s = tag.getName().substring(localNameIndex); if (!s.isEmpty()) { tag.setName(s); } } else if (attrIndex < attrs.size()) { XmlAttribute attr = attrs.get(attrIndex++); //noinspection ConstantConditions attr.setValue(attr.getValue().substring(localNameIndex)); } }); return isDone(); }
iteration
304,770
boolean (@NotNull Project project, Editor editor, @NotNull PsiElement element) { return getXmlnsDeclaration(element) != null; }
isAvailable
304,771
String () { return getText(); }
getFamilyName
304,772
boolean () { return false; }
startInWriteAction
304,773
void (final @NotNull JList<? extends String> list, final @NlsSafe String value, final int index, final boolean selected, final boolean hasFocus) { append(value, SimpleTextAttributes.REGULAR_ATTRIBUTES); setIcon(AllIcons.Nodes.Static); setPaintFocusBorder(false); }
customizeCellRenderer
304,774
boolean (@NotNull Project project, Editor editor, PsiFile file) { XmlTag tag = getTag(editor, file); if (tag == null) return false; if (tag.getAttributes().length <= 1) return false; int offset = editor.getCaretModel().getOffset(); ASTNode startEnd = XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode()); if (startEnd == null || offset <= startEnd.getTextRange().getEndOffset()) return true; return false; }
isAvailable
304,775
Collection<TextRange> (@NotNull PsiFile file, boolean processChangedTextOnly) { return Collections.singleton(marker.getTextRange()); }
getRangesToFormat
304,776
boolean () { return true; }
startInWriteAction
304,777
XmlTag (@Nullable Editor editor, PsiFile file) { if (!(file instanceof XmlFile)) return null; int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); XmlTag parent = PsiTreeUtil.getParentOfType(element, XmlTag.class); if (parent != null) return parent; element = file.findElementAt(offset - 1); parent = PsiTreeUtil.getParentOfType(element, XmlTag.class); if (parent != null) return parent; return null; }
getTag
304,778
boolean () { final int offset = myElement.getTextOffset(); final RangeMarker marker = myEditor.getDocument().createRangeMarker(offset, offset); Consumer<String> consumer = (namespace) -> { if (namespace != null) { final Project project = myFile.getProject(); WriteCommandAction.writeCommandAction(project, myFile) . run(() -> { final XmlNamespaceHelper extension = XmlNamespaceHelper.getHelper(myFile); final String prefix = extension.getNamespacePrefix(myElement); extension.insertNamespaceDeclaration(myFile, myEditor, Collections.singleton(namespace), prefix, new XmlNamespaceHelper.Runner<>() { @Override public void run(final String s) throws IncorrectOperationException { PsiDocumentManager.getInstance(myFile.getProject()) .doPostponedOperationsAndUnblockDocument(myEditor.getDocument()); PsiElement element = myFile.findElementAt(marker.getStartOffset()); if (element != null) { extension.qualifyWithPrefix(s, element, myEditor.getDocument()); } } } ); } ); } }; if (myNamespaces.size() == 1) { consumer.consume(myNamespaces.get(0)); } else { JBPopupFactory.getInstance() .createPopupChooserBuilder(myNamespaces) .setItemChosenCallback(consumer) .setRenderer(XmlNSRenderer.INSTANCE) .setTitle(myTitle) .createPopup() .showInBestPositionFor(myEditor); } return true; }
execute
304,779
boolean (@NotNull Project project, Editor editor, PsiFile file) { return getCData(editor, file) != null; }
isAvailable
304,780
PsiElement (Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); PsiElement parent = element != null ? element.getParent() : null; if (parent != null && parent.getNode() != null && parent.getNode().getElementType() == XmlElementType.XML_CDATA) return parent; element = file.findElementAt(offset - 1); parent = element != null ? element.getParent() : null; if (parent != null && parent.getNode() != null && parent.getNode().getElementType() == XmlElementType.XML_CDATA) return parent; return null; }
getCData
304,781
boolean () { return true; }
startInWriteAction
304,782
boolean (@NotNull Project project, Editor editor, PsiFile file) { XmlTag tag = getTag(editor, file); if (tag == null) return false; int offset = editor.getCaretModel().getOffset(); ASTNode startEnd = XmlChildRole.START_TAG_END_FINDER.findChild(tag.getNode()); if (startEnd == null || offset <= startEnd.getStartOffset()) return true; ASTNode endStart = XmlChildRole.CLOSING_TAG_START_FINDER.findChild(tag.getNode()); if (endStart == null || offset >= startEnd.getStartOffset()) return true; return false; }
isAvailable
304,783
boolean () { return true; }
startInWriteAction
304,784
XmlTag (Editor editor, PsiFile file) { int offset = editor.getCaretModel().getOffset(); PsiElement element = file.findElementAt(offset); PsiElement parent = element != null ? element.getParent() : null; if (parent instanceof XmlTag) return (XmlTag)parent; if (parent instanceof XmlAttribute) return null; element = file.findElementAt(offset - 1); parent = element != null ? element.getParent() : null; if (parent instanceof XmlTag) return (XmlTag)parent; return null; }
getTag
304,785
TextRange (final XmlAttributeValue xmlAttributeValue) { ASTNode valueNode = XmlChildRole.ATTRIBUTE_VALUE_VALUE_FINDER.findChild(xmlAttributeValue.getNode()); PsiElement toHighlight = valueNode == null ? xmlAttributeValue : valueNode.getPsi(); TextRange childRange = toHighlight.getTextRange(); TextRange range = xmlAttributeValue.getTextRange(); return childRange.shiftRight(-range.getStartOffset()); }
xmlAttributeValueRange
304,786
PsiReference[] (final XmlAttributeValue value) { boolean hasNonStandardTokens = ContainerUtil.exists(value.getChildren(), ch -> !ATTRIBUTE_VALUE_STD_TOKENS.contains(ch.getNode().getElementType())); if (hasNonStandardTokens) return PsiReference.EMPTY_ARRAY; String text = value.getValue(); int start = text.indexOf(CHARSET_PREFIX); if (start != -1) { start += CHARSET_PREFIX.length(); int end = text.indexOf(';', start); if (end == -1) end = text.length(); String charsetName = text.substring(start, end); TextRange textRange = new TextRange(start, end).shiftRight(xmlAttributeValueRange(value).getStartOffset()); return new PsiReference[]{new XmlEncodingReference(value, charsetName, textRange, 0)}; } return PsiReference.EMPTY_ARRAY; }
extractFromContentAttribute
304,787
int (@NotNull XmlEncodingReference ref) { return myPriority - ref.myPriority; }
compareTo
304,788
String (final Object element) { if (element instanceof XmlTag) { return ((XmlTag)element).getLocalName(); } else { return super.getTextByElement(element); } }
getTextByElement
304,789
Block (@NotNull ASTNode node, @NotNull Block originalBlock, Indent indent, int offset, TextRange range, @Nullable Language language) { return new AnotherLanguageBlockWrapper(node, myXmlFormattingPolicy, originalBlock, indent, offset, range); }
createInjectedBlock
304,790
Block (ASTNode node, Wrap wrap, Alignment alignment, Indent indent, TextRange range) { return new XmlBlock(node, wrap, alignment, myXmlFormattingPolicy, indent, range); }
createBlockBeforeInjection
304,791
Block (ASTNode node, Wrap wrap, Alignment alignment, Indent indent, TextRange range) { return new XmlBlock(node, wrap, alignment, myXmlFormattingPolicy, indent, range); }
createBlockAfterInjection
304,792
CodeStyleSettings () { return myXmlFormattingPolicy.getSettings(); }
getSettings
304,793
boolean (String text, final ASTNode injectionHost) { IElementType type = injectionHost.getElementType(); if (type == XmlElementType.XML_TEXT) { return true; } else if (type == XmlElementType.XML_COMMENT) { // <!--[if IE]>, <![endif]--> of conditional comments injection return true; } return text.isEmpty(); }
canProcessFragment
304,794
Spacing (Block child1, @NotNull Block child2) { return null; }
getSpacing
304,795
boolean () { return true; }
isLeaf
304,796
List<Block> () { return EMPTY; }
buildChildren
304,797
boolean (final XmlTag parentTag) { if (parentTag == null) { return true; } final PsiElement firstChild = findFirstNonEmptyChild(parentTag); if (firstChild == null) { return false; } if (firstChild.getNode().getElementType() != XmlTokenType.XML_START_TAG_START) { return false; } if (myHtmlCodeStyleSettings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES > 0 && getLines(parentTag) > myHtmlCodeStyleSettings.HTML_DO_NOT_ALIGN_CHILDREN_OF_MIN_LINES) { return false; } else { return !checkName(parentTag, myHtmlCodeStyleSettings.HTML_DO_NOT_INDENT_CHILDREN_OF); } }
indentChildrenOf
304,798
PsiElement (final XmlTag parentTag) { PsiElement result = parentTag.getFirstChild(); while (result != null && result.getTextLength() == 0) { result = result.getNextSibling(); } return result; }
findFirstNonEmptyChild
304,799
int (final XmlTag parentTag) { final TextRange textRange = parentTag.getTextRange(); return myDocumentModel.getLineNumber(textRange.getEndOffset()) - myDocumentModel.getLineNumber(textRange.getStartOffset()) + 1; }
getLines