Unnamed: 0 int64 0 305k | body stringlengths 7 52.9k | name stringlengths 1 185 |
|---|---|---|
301,200 | void () { myFixture.configureByFile("spring-beans_3.0.xsd"); doTest("springAtCaret.xml", "bean"); } | testSpringAtCaret |
301,201 | void () { myFixture.configureByFile("spring-beans_3.0.xsd"); doTest("springAfterBean.xml", "bean"); } | testSpringAfterBean |
301,202 | void () { myFixture.configureByFile("spring-beans_3.0.xsd"); doTest("springAlias.xml", "alias"); } | testSpringAlias |
301,203 | void () { doTest("initParam.xml", "context-param"); } | testInitParam |
301,204 | void () { doTest("try_to_generate_in_tag_name.xml", "context-param"); } | testInTagName |
301,205 | void (String file, String tagName) { GenerateXmlTagAction.TEST_THREAD_LOCAL.set(tagName); CodeInsightTestUtil.doActionTest(new GenerateXmlTagAction(), file, myFixture); } | doTest |
301,206 | String () { return "/xml/tests/testData/generateTag"; } | getBasePath |
301,207 | String () { return PlatformTestUtil.getCommunityPath().replace(File.separatorChar, '/') + getBasePath(); } | getTestDataPath |
301,208 | void () { myFixture.copyDirectoryToProject("", ""); Project project = getProject(); Collection<String> tags = XmlTagNamesIndex.getAllTagNames(project); assertTrue(tags.size() > 26); Collection<VirtualFile> files = XmlTagNamesIndex.getFilesByTagName("bean", project); assertEquals(1, files.size()); Module module = ModuleUtilCore.findModuleForFile(files.iterator().next(), project); assert module != null; final Collection<VirtualFile> files1 = FileBasedIndex.getInstance().getContainingFiles(XmlTagNamesIndex.NAME, "web-app", module.getModuleContentScope()); assertEquals(new ArrayList<>(files1).toString(), 2, files1.size()); List<String> names = new ArrayList<>(ContainerUtil.map(files1, virtualFile -> virtualFile.getName())); Collections.sort(names); assertEquals(Arrays.asList("web-app_2_5.xsd", "web-app_3_0.xsd"), names); } | testTagNameIndex |
301,209 | void () { myFixture.copyDirectoryToProject("", ""); final List<IndexedRelevantResource<String, XsdNamespaceBuilder>> files = XmlNamespaceIndex.getResourcesByNamespace(NS, getProject(), getModule()); assertEquals(2, files.size()); IndexedRelevantResource<String, XsdNamespaceBuilder> resource = XmlNamespaceIndex.guessSchema(NS, "web-app", "3.0", null, getModule(), getProject()); assertNotNull(resource); XsdNamespaceBuilder builder = resource.getValue(); assertEquals(NS, builder.getNamespace()); assertEquals("3.0", builder.getVersion()); assertEquals(Collections.singletonList("web-app"), builder.getTags()); resource = XmlNamespaceIndex.guessSchema(NS, "web-app", "2.5", null, getModule(), getProject()); assertNotNull(resource); builder = resource.getValue(); assertEquals(NS, builder.getNamespace()); assertEquals("2.5", builder.getVersion()); assertEquals(Collections.singletonList("web-app"), builder.getTags()); resource = XmlNamespaceIndex.guessSchema(NS, "foo-bar", "2.5", null, getModule(), getProject()); assertNull(resource); } | testNamespaceIndex |
301,210 | void () { myFixture.copyDirectoryToProject("", ""); final List<IndexedRelevantResource<String, XsdNamespaceBuilder>> files = XmlNamespaceIndex.getResourcesByNamespace("foo.dtd", getProject(), getModule()); assertEquals(2, files.size()); PsiFile file = myFixture.configureByFile("foo.xml"); assertTrue(XmlNamespaceIndex.guessDtd("foo://bar/1/foo.dtd", file).getVirtualFile().getPath().endsWith("/1/foo.dtd")); assertTrue(XmlNamespaceIndex.guessDtd("foo://bar/2/foo.dtd", file).getVirtualFile().getPath().endsWith("/2/foo.dtd")); } | testGuessDTD |
301,211 | void () { myFixture.copyDirectoryToProject("", ""); String namespace = "http://www.liquibase.org/xml/ns/dbchangelog"; List<IndexedRelevantResource<String, XsdNamespaceBuilder>> resources = XmlNamespaceIndex.getResourcesByNamespace(namespace, getProject(), getModule()); assertEquals(2, resources.size()); assertEquals("dbchangelog-3.3.xsd", XmlNamespaceIndex .guessSchema(namespace, null, null, "http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.3.xsd", getModule(), getProject()) .getFile().getName()); assertEquals("dbchangelog-3.1.xsd", XmlNamespaceIndex .guessSchema(namespace, null, null, "http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd", getModule(), getProject()) .getFile().getName()); } | testGuessByLocation |
301,212 | String () { return "/xml/tests/testData/index"; } | getBasePath |
301,213 | void () { myFixture.copyDirectoryToProject("", ""); final Project project = getProject(); final List<Set<SchemaTypeInfo>> childrenOfType = SchemaTypeInheritanceIndex.getWorker(project, null).apply("http://a.b.c", "baseSimpleType"); Assert.assertNotNull(childrenOfType); final Set<SchemaTypeInfo> expected = new HashSet<>(); expected.add(new SchemaTypeInfo("extSimple4", true, "http://a.b.c")); expected.add(new SchemaTypeInfo("extSimple1", true, "http://a.b.c")); expected.add(new SchemaTypeInfo("extComplex2", true, "http://a.b.c")); expected.add(new SchemaTypeInfo("extComplex2", true, "http://a.b.c.d")); for (Set<SchemaTypeInfo> infos : childrenOfType) { for (SchemaTypeInfo info : infos) { expected.remove(info); } } Assert.assertTrue(expected.isEmpty()); // final List<Set<SchemaTypeInfo>> childrenOfSimple4Type = SchemaTypeInheritanceIndex.getWorker(project, null).apply("http://a.b.c", "extSimple4"); Assert.assertNotNull(childrenOfSimple4Type); final Set<SchemaTypeInfo> expectedSimple4 = new HashSet<>(); expectedSimple4.add(new SchemaTypeInfo("extSimple5", true, "http://a.b.c")); expectedSimple4.add(new SchemaTypeInfo("wiseElement", false, "http://a.b.c")); for (Set<SchemaTypeInfo> infos : childrenOfSimple4Type) { for (SchemaTypeInfo info : infos) { expectedSimple4.remove(info); } } Assert.assertTrue(expectedSimple4.isEmpty()); } | testIndex |
301,214 | String () { return "/xml/tests/testData/index"; } | getBasePath |
301,215 | boolean () { return true; } | isCommunity |
301,216 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root xmlns:ns="http://ns.com" attr2="value2" attr1="value1" attr3="value3"/>"""); map.put("expected", """ <root attr1="value1" attr2="value2" attr3="value3" xmlns:ns="http://ns.com"/>"""); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSorting1 |
301,217 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr3="value3" attr2="value2" attr1="value1" xmlns:ns="http://ns.com"/>"""); map.put("expected", """ <root attr1="value1" attr2="value2" attr3="value3" xmlns:ns="http://ns.com"/>"""); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSorting2 |
301,218 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" attr2="value2" attr1="value1"> <tag1 attr2="value2" attr1="value1"> <tag2 attr1="value1" attr2="value2"/> <tag3 attr2="value2" attr1="value1" xmlns:ns3="http://ns.com"/> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" attr1="value1" attr2="value2"> <tag1 attr1="value1" attr2="value2"> <tag2 attr1="value1" attr2="value2"/> <tag3 xmlns:ns3="http://ns.com" attr1="value1" attr2="value2"/> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSorting3 |
301,219 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr3="value3" attr2="value2" attr1="value1" xmlns:ns="http://ns.com"/>"""); map.put("expected", """ <root xmlns:ns="http://ns.com" attr1="value1" attr2="value2" attr3="value3"/>"""); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSorting4 |
301,220 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1"> <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1"> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" attr1="value1" ns1:attr1="value1" ns1:attr2="value2"> <tag1 attr1="value1" attr2="value2" ns1:attr1="value1" ns1:attr2="value2" ns2:attr1="value1" ns2:attr2="value2"> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule(".*"))))); doTest(map); } | testAttributeSortingByNamespace1 |
301,221 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1"> <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1"> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1" ns1:attr2="value2" attr1="value1"> <tag1 ns1:attr1="value1" ns1:attr2="value2" ns2:attr1="value1" ns2:attr2="value2" attr2="value2" attr1="value1"> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns.*"))))); doTest(map); } | testAttributeSortingByNamespace2 |
301,222 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1"> <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1"> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1" ns1:attr2="value2" attr1="value1"> <tag1 ns1:attr1="value1" ns1:attr2="value2" ns2:attr1="value1" ns2:attr2="value2" attr1="value1" attr2="value2"> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns.*")), ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSortingByNamespace3 |
301,223 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1"> <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1"> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" attr1="value1" ns1:attr1="value1" ns1:attr2="value2"> <tag1 ns2:attr1="value1" ns2:attr2="value2" attr1="value1" attr2="value2" ns1:attr1="value1" ns1:attr2="value2"> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns2.com")), ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSortingByNamespace4 |
301,224 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1"> <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1"> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1" ns1:attr2="value2" attr1="value1"> <tag1 ns2:attr1="value1" ns2:attr2="value2" ns1:attr1="value1" ns1:attr2="value2" attr2="value2" attr1="value1"> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, namespaceRule("http://ns2.com")), ruleWithOrder(BY_NAME, namespaceRule("http://ns1.com"))))); doTest(map); } | testAttributeSortingByNamespace5 |
301,225 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root attr1="value1" ns1:attr2="value2" xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr1="value1"> <tag1 ns2:attr2="value2" attr2="value2" attr1="value1" ns2:attr1="value1" ns1:attr2="value2" ns1:attr1="value1"> </tag1> </root> """); map.put("expected", """ <root xmlns:ns1="http://ns1.com" xmlns:ns2="http://ns2.com" ns1:attr2="value2" attr1="value1" ns1:attr1="value1"> <tag1 ns1:attr2="value2" ns2:attr2="value2" attr1="value1" attr2="value2" ns1:attr1="value1" ns2:attr1="value1"> </tag1> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("xmlns:.*")), ruleWithOrder(BY_NAME, compositeRule(".*:attr2", "http://ns.*")), ruleWithOrder(BY_NAME, nameRule(".*"))))); doTest(map); } | testAttributeSortingByNamespace6 |
301,226 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root> <meta></meta> <title></title> </root> """); map.put("expected", """ <root> <title></title> <meta></meta> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("title"))))); doTest(map); } | testTagSorting |
301,227 | void () { LinkedHashMap<String, Serializable> map = new LinkedHashMap<>(3); map.put("initial", """ <root beta=""> <meta></meta> <title></title> </root> """); map.put("expected", """ <root beta=""> <title></title> <meta></meta> </root> """); map.put("rules", new ArrayList<>( Arrays.asList(ruleWithOrder(BY_NAME, nameRule("title"))))); doTest(map); } | testTagAndAttrSorting |
301,228 | StdArrangementMatchRule (@NotNull String filter) { return new StdArrangementMatchRule( new StdArrangementEntryMatcher(new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, filter))); } | namespaceRule |
301,229 | StdArrangementMatchRule (@NotNull String nameFilter, @NotNull String namespaceFilter) { return AbstractRearrangerTest.rule(new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.NAME, nameFilter), new ArrangementAtomMatchCondition(StdArrangementTokens.Regexp.XML_NAMESPACE, namespaceFilter)); } | compositeRule |
301,230 | boolean () { return ENABLED && super.shouldRunTest(); } | shouldRunTest |
301,231 | void () { PropertyChecker.checkScenarios(actionsOnXmlFiles(CheckHighlighterConsistency.randomEditsWithHighlighterChecks)); } | testIncrementalHighlighterUpdate |
301,232 | void () { PropertyChecker.checkScenarios(actionsOnXmlFiles(MadTestingUtil::randomEditsWithReparseChecks)); } | testReparse |
301,233 | Supplier<MadTestingAction> (Function<? super PsiFile, ? extends Generator<? extends MadTestingAction>> fileActions) { return MadTestingUtil.actionsOnFileContents(myFixture, PathManager.getHomePath(), f -> FileTypeManager.getInstance().getFileTypeByFileName(f.getName()) == XmlFileType.INSTANCE, fileActions); } | actionsOnXmlFiles |
301,234 | String (String[] args) { var flags = new HashSet<String>(); var opts = new HashSet<String>(); flags.add("h"); flags.add("help"); flags.add("usage"); flags.add("license"); flags.add("version"); flags.add("dl"); flags.add("noupa"); flags.add("nopvr"); flags.add("partial"); opts.add("name"); CommandLine cl = new CommandLine(args, flags, opts); String[] badOpts = cl.getBadOpts(); if (badOpts.length > 0) { throw new IllegalArgumentException("Unrecognized option: " + badOpts[0]); } boolean dl = (cl.getOpt("dl") != null); boolean nopvr = (cl.getOpt("nopvr") != null); boolean noupa = (cl.getOpt("noupa") != null); File[] schemaFiles = cl.filesEndingWith(".xsd"); String rootName = cl.getOpt("name"); if (rootName == null) { throw new IllegalArgumentException("Required option \"-name\" must be present"); } // Process Schema files var sdocs = new ArrayList<XmlObject>(); for (File schemaFile : schemaFiles) { try { sdocs.add(XmlObject.Factory.parse(schemaFile, (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest())); } catch (Exception e) { throw new IllegalArgumentException("Can not load schema file: " + schemaFile + ": " + e.getLocalizedMessage()); } } XmlObject[] schemas = sdocs.toArray(new XmlObject[0]); SchemaTypeSystem sts = null; if (schemas.length > 0) { XmlOptions compileOptions = new XmlOptions(); if (dl) { compileOptions.setCompileDownloadUrls(); } if (nopvr) { compileOptions.setCompileNoPvrRule(); } if (noupa) { compileOptions.setCompileNoUpaRule(); } try { sts = XmlBeans.compileXsd(schemas, XmlBeans.getBuiltinTypeSystem(), compileOptions); } catch (XmlException e) { StringBuilder out = new StringBuilder("Schema compilation errors: "); var errors = e.getErrors(); for (Object error : errors) { out.append("\n").append(error); } throw new IllegalArgumentException(out.toString()); } } if (sts == null) { throw new IllegalArgumentException("No Schemas to process."); } SchemaType[] globalElems = sts.documentTypes(); SchemaType elem = null; for (SchemaType globalElem : globalElems) { if (rootName.equals(globalElem.getDocumentElementName().getLocalPart())) { elem = globalElem; break; } } if (elem == null) { throw new IllegalArgumentException("Could not find a global element with name \"" + rootName + "\""); } // Now generate it return SampleXmlUtil.createSampleForType(elem); } | generate |
301,235 | XmlElementDescriptor (XmlTag tag, String elementName) { final PsiMetaData metaData = tag.getMetaData(); if (metaData instanceof XmlNSDescriptorImpl nsDescriptor) { return nsDescriptor.getElementDescriptor(elementName, nsDescriptor.getDefaultNamespace()); } return null; } | getDescriptor |
301,236 | List<String> (XmlTag rootTag) { PsiMetaData metaData = rootTag.getMetaData(); if (metaData instanceof XmlNSDescriptorImpl nsDescriptor) { List<String> elementDescriptors = new ArrayList<>(); XmlElementDescriptor[] rootElementsDescriptors = nsDescriptor.getRootElementsDescriptors(PsiTreeUtil.getParentOfType(rootTag, XmlDocument.class)); for (XmlElementDescriptor e : rootElementsDescriptors) { elementDescriptors.add(e.getName()); } return elementDescriptors; } return Collections.emptyList(); } | addVariantsFromRootTag |
301,237 | String (@NotNull XmlFile file, @NotNull final Map<String, String> scannedToFileName, final @NotNull SchemaReferenceProcessor schemaReferenceProcessor) { final String fileName = file.getName(); String previous = scannedToFileName.get(fileName); if (previous != null) return previous; scannedToFileName.put(fileName, fileName); final StringBuilder result = new StringBuilder(); file.acceptChildren(new XmlRecursiveElementVisitor() { @Override public void visitElement(@NotNull PsiElement psiElement) { super.visitElement(psiElement); if (psiElement instanceof LeafPsiElement) { final String text = psiElement.getText(); result.append(text); } } @Override public void visitXmlAttribute(@NotNull XmlAttribute xmlAttribute) { boolean replaced = false; if (xmlAttribute.isNamespaceDeclaration()) { replaced = true; final String value = xmlAttribute.getValue(); result.append(xmlAttribute.getText()).append(" "); if (!scannedToFileName.containsKey(value)) { final XmlNSDescriptor nsDescriptor = xmlAttribute.getParent().getNSDescriptor(value, true); if (nsDescriptor != null) { processAndSaveAllSchemas(Objects.requireNonNull(nsDescriptor.getDescriptorFile()), scannedToFileName, schemaReferenceProcessor); } } } else if ("schemaLocation".equals(xmlAttribute.getName())) { PsiReference[] references = Objects.requireNonNull(xmlAttribute.getValueElement()).getReferences(); PsiReference reference = ArrayUtil.getLastElement(references); if (reference != null) { PsiElement psiElement = reference.resolve(); if (psiElement instanceof XmlFile) { final String s = processAndSaveAllSchemas(((XmlFile)psiElement), scannedToFileName, schemaReferenceProcessor); result.append(xmlAttribute.getName()).append("='").append(s).append('\''); replaced = true; } } } if (!replaced) result.append(xmlAttribute.getText()); } }); final VirtualFile virtualFile = file.getVirtualFile(); final String content = result.toString(); byte[] bytes; if (virtualFile != null) { bytes = content.getBytes(virtualFile.getCharset()); } else { try { final String charsetName = XmlUtil.extractXmlEncodingFromProlog(content.getBytes(StandardCharsets.UTF_8)); bytes = charsetName != null ? content.getBytes(charsetName) : content.getBytes(StandardCharsets.UTF_8); } catch (UnsupportedEncodingException e) { bytes = content.getBytes(StandardCharsets.UTF_8); } } schemaReferenceProcessor.processSchema(fileName, bytes); return fileName; } | processAndSaveAllSchemas |
301,238 | void (@NotNull PsiElement psiElement) { super.visitElement(psiElement); if (psiElement instanceof LeafPsiElement) { final String text = psiElement.getText(); result.append(text); } } | visitElement |
301,239 | void (@NotNull XmlAttribute xmlAttribute) { boolean replaced = false; if (xmlAttribute.isNamespaceDeclaration()) { replaced = true; final String value = xmlAttribute.getValue(); result.append(xmlAttribute.getText()).append(" "); if (!scannedToFileName.containsKey(value)) { final XmlNSDescriptor nsDescriptor = xmlAttribute.getParent().getNSDescriptor(value, true); if (nsDescriptor != null) { processAndSaveAllSchemas(Objects.requireNonNull(nsDescriptor.getDescriptorFile()), scannedToFileName, schemaReferenceProcessor); } } } else if ("schemaLocation".equals(xmlAttribute.getName())) { PsiReference[] references = Objects.requireNonNull(xmlAttribute.getValueElement()).getReferences(); PsiReference reference = ArrayUtil.getLastElement(references); if (reference != null) { PsiElement psiElement = reference.resolve(); if (psiElement instanceof XmlFile) { final String s = processAndSaveAllSchemas(((XmlFile)psiElement), scannedToFileName, schemaReferenceProcessor); result.append(xmlAttribute.getName()).append("='").append(s).append('\''); replaced = true; } } } if (!replaced) result.append(xmlAttribute.getText()); } | visitXmlAttribute |
301,240 | CodeInsightActionHandler () { return new CodeInsightActionHandler(){ @Override public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final XmlDocument document = findSuitableXmlDocument(file); if (document != null) { final @NonNls StringBuilder buffer = new StringBuilder(); buffer.append("<!DOCTYPE ").append(document.getRootTag().getName()).append(" [\n"); buffer.append(XmlUtil.generateDocumentDTD(document, true)); buffer.append("]>\n"); XmlFile tempFile; try{ final XmlProlog prolog = document.getProlog(); final PsiElement childOfType = PsiTreeUtil.getChildOfType(prolog, XmlProcessingInstruction.class); if (childOfType != null) { final String text = childOfType.getText(); buffer.insert(0,text); final PsiElement nextSibling = childOfType.getNextSibling(); if (nextSibling instanceof PsiWhiteSpace) { buffer.insert(text.length(),nextSibling.getText()); } } tempFile = (XmlFile)PsiFileFactory.getInstance(file.getProject()).createFileFromText("dummy.xml", buffer.toString()); prolog.replace(tempFile.getDocument().getProlog()); } catch (IncorrectOperationException e) { LOG.error(e); } } } }; } | getHandler |
301,241 | void (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { final XmlDocument document = findSuitableXmlDocument(file); if (document != null) { final @NonNls StringBuilder buffer = new StringBuilder(); buffer.append("<!DOCTYPE ").append(document.getRootTag().getName()).append(" [\n"); buffer.append(XmlUtil.generateDocumentDTD(document, true)); buffer.append("]>\n"); XmlFile tempFile; try{ final XmlProlog prolog = document.getProlog(); final PsiElement childOfType = PsiTreeUtil.getChildOfType(prolog, XmlProcessingInstruction.class); if (childOfType != null) { final String text = childOfType.getText(); buffer.insert(0,text); final PsiElement nextSibling = childOfType.getNextSibling(); if (nextSibling instanceof PsiWhiteSpace) { buffer.insert(text.length(),nextSibling.getText()); } } tempFile = (XmlFile)PsiFileFactory.getInstance(file.getProject()).createFileFromText("dummy.xml", buffer.toString()); prolog.replace(tempFile.getDocument().getProlog()); } catch (IncorrectOperationException e) { LOG.error(e); } } } | invoke |
301,242 | void (@NotNull AnActionEvent event) { super.update(event); if (ActionPlaces.isPopupPlace(event.getPlace())) { Presentation presentation = event.getPresentation(); presentation.setVisible(presentation.isEnabled()); } } | update |
301,243 | boolean (@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) { return file.getLanguage() == XMLLanguage.INSTANCE && findSuitableXmlDocument(file) != null; } | isValidForFile |
301,244 | String (String filename) { File f = new File(filename); if (! f.exists()) return filename; int dot = filename.lastIndexOf('.'); // we believe file has some ext. For instance, ".wsdl" String name = filename.substring(0, dot); String ext = filename.substring(dot); int num = 0; do { f = new File(name + ++num + ext); } while (f.exists()); return name + num + ext; } | findFreeFileName |
301,245 | void () { String msg = doValidateWithData(); setOKActionEnabled(msg == null); status.setText(msg == null ? "" : msg); status.setForeground(JBColor.RED); } | validateData |
301,246 | void (JComboBox combo, List<String> lastValues) { combo.setModel(new DefaultComboBoxModel(ArrayUtilRt.toStringArray(lastValues))); if (combo.getItemCount() != 0) { combo.setSelectedIndex(0); combo.getEditor().selectAll(); } } | configureComboBox |
301,247 | void (@NlsSafe String url) { generateFromUrl.setText(url); } | setFileUrl |
301,248 | void () { super.doOKAction(); if (myOkAction != null) { myOkAction.run(); } } | doOKAction |
301,249 | void (Runnable okAction) { myOkAction = okAction; } | setOkAction |
301,250 | void (JLabel textComponent, JComponent component) { textComponent.setLabelFor(component); if (component instanceof JTextField) { ((JTextField)component).getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { validateData(); } @Override public void removeUpdate(DocumentEvent e) { validateData(); } @Override public void changedUpdate(DocumentEvent e) { validateData(); } }); } else if (component instanceof JComboBox jComboBox) { jComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { validateData(); } }); if (jComboBox.isEditable()) { jComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { validateData(); } }); } } } | doInitFor |
301,251 | void (DocumentEvent e) { validateData(); } | insertUpdate |
301,252 | void (DocumentEvent e) { validateData(); } | removeUpdate |
301,253 | void (DocumentEvent e) { validateData(); } | changedUpdate |
301,254 | void (ActionEvent e) { validateData(); } | actionPerformed |
301,255 | void (KeyEvent e) { validateData(); } | keyTyped |
301,256 | JLabel () { return generateFromUrlText; } | getUrlText |
301,257 | JLabel () { return statusText; } | getStatusTextField |
301,258 | JLabel () { return status; } | getStatusField |
301,259 | JComponent () { return panel; } | createCenterPanel |
301,260 | String () { return resultSchemaFileName.getText(); } | getTargetSchemaName |
301,261 | String () { if (! new File(generateFromUrl.getText()).exists()) { return XmlBundle.message("instance.document.file.is.not.exist"); } if (!generateFromUrl.getText().endsWith(".xml")) { return XmlBundle.message("instance.document.file.should.have.xml.extension"); } try { int i = Integer.parseInt(getEnumerationsLimit()); if (i < 0) return XmlBundle.message("negative.number.validation.problem"); } catch(NumberFormatException ex) { return XmlBundle.message("invalid.number.validation.problem"); } if (getTargetSchemaName() == null || getTargetSchemaName().length() == 0) { return XmlBundle.message("result.schema.file.name.is.empty.validation.problem"); } return null; } | doValidateWithData |
301,262 | String () { return "webservices.GenerateSchemaFromInstanceDocument"; } | getHelpId |
301,263 | String () { return XmlBundle.message("local.elements.global.complex.types.option.name"); } | getLocalElementsGlobalComplexTypes |
301,264 | String () { return XmlBundle.message("local.elements.types.option.name"); } | getLocalElementsTypes |
301,265 | String () { return XmlBundle.message("global.elements.local.types.option.name"); } | getGlobalElementsLocalTypes |
301,266 | void (@NotNull AnActionEvent e) { final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); final boolean enabled = isAcceptableFile(file); e.getPresentation().setEnabled(enabled); if (ActionPlaces.isPopupPlace(e.getPlace())) { e.getPresentation().setVisible(enabled); } } | update |
301,267 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
301,268 | void (@NotNull AnActionEvent e) { final Project project = e.getProject(); final VirtualFile file = e.getData(CommonDataKeys.VIRTUAL_FILE); final GenerateSchemaFromInstanceDocumentDialog dialog = new GenerateSchemaFromInstanceDocumentDialog(project, file); dialog.setOkAction(() -> doAction(project, dialog)); dialog.show(); } | actionPerformed |
301,269 | void (final Project project, final GenerateSchemaFromInstanceDocumentDialog dialog) { FileDocumentManager.getInstance().saveAllDocuments(); final String url = dialog.getUrl().getText(); final VirtualFile relativeFile = VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(url), null); VirtualFile relativeFileDir; if (relativeFile == null) { Messages.showErrorDialog(project, XmlBundle.message("file.doesnt.exist", url), XmlBundle.message("error")); return; } else { relativeFileDir = relativeFile.getParent(); } if (relativeFileDir == null) { Messages.showErrorDialog(project, XmlBundle.message("file.doesnt.exist", url), XmlBundle.message("error")); return; } @NonNls List<String> parameters = new LinkedList<>(); parameters.add("-design"); parameters.add(Holder.DESIGN_TYPES.get(dialog.getDesignType())); parameters.add("-simple-content-types"); parameters.add(Holder.CONTENT_TYPES.get(dialog.getSimpleContentType())); parameters.add("-enumerations"); String enumLimit = dialog.getEnumerationsLimit(); parameters.add("0".equals(enumLimit) ? "never" : enumLimit); parameters.add("-outDir"); final String dirPath = relativeFileDir.getPath(); parameters.add(dirPath); final File expectedSchemaFile = new File(dirPath + File.separator + relativeFile.getName() + "0.xsd"); if (expectedSchemaFile.exists()) { if (!expectedSchemaFile.delete()) { Messages.showErrorDialog(project, XmlBundle.message("cant.delete.file", expectedSchemaFile.getPath()), XmlBundle.message("error")); return; } } parameters.add("-outPrefix"); parameters.add(relativeFile.getName()); parameters.add(url); File xsd = new File(dirPath + File.separator + dialog.getTargetSchemaName()); final VirtualFile xsdFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(xsd); if (xsdFile != null) { ApplicationManager.getApplication().runWriteAction(() -> { try { xsdFile.delete(null); } catch (IOException e) {// } }); } // Inst2Xsd.main contains exit() calls, so we need to prevent this SecurityManager old = System.getSecurityManager(); try { System.setSecurityManager(new SecurityManager() { @Override public void checkExit(int status) { throw new SecurityException(); } @Override public void checkPermission(Permission perm) { } }); Inst2Xsd.main(ArrayUtilRt.toStringArray(parameters)); } catch (Exception e) { Messages.showErrorDialog(project, XmlBundle.message("xml2xsd.generator.error.message"), XmlBundle.message("xml2xsd.generator.error")); return; } finally { System.setSecurityManager(old); } if (expectedSchemaFile.exists()) { final boolean renamed = expectedSchemaFile.renameTo(xsd); if (! renamed) { Messages.showErrorDialog(project, XmlBundle.message("cant.rename.file", expectedSchemaFile.getPath(), xsd.getPath()), XmlBundle.message("error")); } } VirtualFile xsdVFile = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(xsd); if (xsdVFile != null) { FileEditorManager.getInstance(project).openFile(xsdVFile, true); } else { Messages.showErrorDialog(project, XmlBundle.message("xml2xsd.generator.error.message"), XmlBundle.message("xml2xsd.generator.error")); } } | doAction |
301,270 | void (int status) { throw new SecurityException(); } | checkExit |
301,271 | void (Permission perm) { } | checkPermission |
301,272 | boolean (VirtualFile file) { return file != null && "xml".equalsIgnoreCase(file.getExtension()); } | isAcceptableFile |
301,273 | ValidateXmlHandler (final @NotNull PsiFile file) { for (ValidateXmlHandler handler : ValidateXmlHandler.EP_NAME.getExtensionList()) { if (handler.isAvailable((XmlFile)file)) { return handler; } } ValidateXmlActionHandler handler = new ValidateXmlActionHandler(true); handler.setErrorReporter(new StdErrorReporter(handler, file, () -> doRunAction(file))); return handler; } | getHandler |
301,274 | void (@NotNull AnActionEvent e) { final PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE); if (psiFile != null && psiFile.getVirtualFile() != null) { doRunAction(psiFile); } } | actionPerformed |
301,275 | void (final @NotNull PsiFile psiFile) { CommandProcessor.getInstance().executeCommand( psiFile.getProject(), () -> { final Runnable action = () -> { try { psiFile.putUserData(runningValidationKey, ""); PsiDocumentManager.getInstance(psiFile.getProject()).commitAllDocuments(); getHandler(psiFile).doValidate((XmlFile)psiFile); } finally { psiFile.putUserData(runningValidationKey, null); } }; ApplicationManager.getApplication().runWriteAction(action); }, getCommandName(), null ); } | doRunAction |
301,276 | void (@NotNull AnActionEvent event) { Presentation presentation = event.getPresentation(); PsiElement psiElement = event.getData(CommonDataKeys.PSI_FILE); boolean visible = psiElement instanceof XmlFile; presentation.setVisible(visible); boolean enabled = psiElement instanceof XmlFile; if (enabled) { final PsiFile containingFile = psiElement.getContainingFile(); if (containingFile != null && containingFile.getVirtualFile() != null && (containingFile.getFileType() == XmlFileType.INSTANCE || containingFile.getFileType() == XHtmlFileType.INSTANCE )) { enabled = containingFile.getUserData(runningValidationKey) == null; } else { enabled = false; } } presentation.setEnabled(enabled); if (ActionPlaces.isPopupPlace(event.getPlace())) { presentation.setVisible(enabled); } } | update |
301,277 | ActionUpdateThread () { return ActionUpdateThread.BGT; } | getActionUpdateThread |
301,278 | void (JLabel textComponent, JComponent component) { textComponent.setLabelFor(component); if (component instanceof JTextField) { ((JTextField)component).getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { validateData(); } @Override public void removeUpdate(DocumentEvent e) { validateData(); } @Override public void changedUpdate(DocumentEvent e) { validateData(); } }); } else if (component instanceof JComboBox jComboBox) { jComboBox.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { validateData(); } }); ((JTextField)jComboBox.getEditor().getEditorComponent()).getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { validateData(); } @Override public void removeUpdate(DocumentEvent e) { validateData(); } @Override public void changedUpdate(DocumentEvent e) { validateData(); } }); if (jComboBox.isEditable()) { jComboBox.getEditor().getEditorComponent().addKeyListener(new KeyAdapter() { @Override public void keyTyped(KeyEvent e) { validateData(); } }); } } } | doInitFor |
301,279 | void (DocumentEvent e) { validateData(); } | insertUpdate |
301,280 | void (DocumentEvent e) { validateData(); } | removeUpdate |
301,281 | void (DocumentEvent e) { validateData(); } | changedUpdate |
301,282 | void (ActionEvent e) { validateData(); } | actionPerformed |
301,283 | void (DocumentEvent e) { validateData(); } | insertUpdate |
301,284 | void (DocumentEvent e) { validateData(); } | removeUpdate |
301,285 | void (DocumentEvent e) { validateData(); } | changedUpdate |
301,286 | void (KeyEvent e) { validateData(); } | keyTyped |
301,287 | void () { String msg = doValidateWithData(); setOKActionEnabled(msg == null); status.setText(msg == null ? "" : msg); status.setForeground(JBColor.RED); } | validateData |
301,288 | void (JComboBox combo, List<String> lastValues) { // without -editor.selectAll- no focus combo.setModel(new DefaultComboBoxModel(ArrayUtilRt.toStringArray(lastValues))); } | configureComboBox |
301,289 | void () { String uri = generateFromUrl.getText(); boolean hasPrevious = (previousUri != null && previousUri.equals(uri)); final PsiFile psifile = findFile(uri); List<String> myRootValues; if (psifile == null) { configureComboBox(rootElementChooser, Collections.emptyList()); return; } final XmlTag rootTag = getRootTag(psifile); if (rootTag == null) { configureComboBox(rootElementChooser, Collections.emptyList()); rootElementChooser.setSelectedIndex(-1); previousUri = uri; return; } myRootValues = Xsd2InstanceUtils.addVariantsFromRootTag(rootTag); Object selectedItem = rootElementChooser.getSelectedItem(); configureComboBox(rootElementChooser, myRootValues); if (hasPrevious) { rootElementChooser.setSelectedItem(selectedItem); } else { rootElementChooser.setSelectedIndex(myRootValues.size() > 0 ? 0 : -1); } previousUri = uri; } | updateFile |
301,290 | XmlTag (PsiFile psifile) { XmlFile xmlFile = null; if (psifile instanceof XmlFile) { xmlFile = (XmlFile)psifile; } else if (psifile.getViewProvider() instanceof TemplateLanguageFileViewProvider viewProvider) { if (viewProvider.getPsi(viewProvider.getTemplateDataLanguage()) instanceof XmlFile) { xmlFile = (XmlFile)viewProvider.getPsi(viewProvider.getTemplateDataLanguage()); } } if (xmlFile != null) { return xmlFile.getDocument().getRootTag(); } else { return null; } } | getRootTag |
301,291 | PsiFile (String uri) { final VirtualFile file = uri != null ? VfsUtilCore.findRelativeFile(ExternalResourceManager.getInstance().getResourceLocation(uri), null) : null; return file != null ? PsiManager.getInstance(myProject).findFile(file) : null; } | findFile |
301,292 | String () { return outputFileName.getText(); } | getOutputFileName |
301,293 | Boolean () { updateFile(); return rootElementChooser.getSelectedItem() != null; } | areCurrentParametersStillValid |
301,294 | String () { String rootElementName = getElementName(); if (rootElementName == null || rootElementName.isEmpty()) { return XmlBundle.message("schema2.instance.no.valid.root.element.name.validation.error"); } final PsiFile psiFile = findFile(getUrl().getText()); if (psiFile instanceof XmlFile) { final XmlTag tag = getRootTag(psiFile); if (tag != null) { final XmlElementDescriptor descriptor = Xsd2InstanceUtils.getDescriptor(tag, rootElementName); if (descriptor == null) { return XmlBundle.message("schema2.instance.no.valid.root.element.name.validation.error"); } } } final String fileName = getOutputFileName(); if (fileName == null || fileName.isEmpty()) { return XmlBundle.message("schema2.instance.output.file.name.is.empty.validation.problem"); } return null; } | doValidateWithData |
301,295 | boolean (VirtualFile virtualFile) { return GenerateInstanceDocumentFromSchemaAction.isAcceptableFileForGenerateSchemaFromInstanceDocument(virtualFile); } | isAcceptableFile |
301,296 | JLabel () { return generateFromUrlText; } | getUrlText |
301,297 | JLabel () { return statusText; } | getStatusTextField |
301,298 | JLabel () { return status; } | getStatusField |
301,299 | JComponent () { return panel; } | createCenterPanel |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.