本文整理汇总了Java中com.intellij.psi.xml.XmlFile类的典型用法代码示例。如果您正苦于以下问题:Java XmlFile类的具体用法?Java XmlFile怎么用?Java XmlFile使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
XmlFile类属于com.intellij.psi.xml包,在下文中一共展示了XmlFile类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createDictionaryFromInfo
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@Nullable
private ApplicationDictionary createDictionaryFromInfo(final @NotNull DictionaryInfo dInfo) {
if (!dInfo.isInitialized()) {
//dictionary terms must be ridden from the dictionary file before creating a PSI for it
LOG.error("Attempt to create dictionary for not initialized Dictionary Info for application" + dInfo.getApplicationName());
return null;
}
String applicationName = dInfo.getApplicationName();
VirtualFile vFile = LocalFileSystem.getInstance().findFileByIoFile(dInfo.getDictionaryFile());
if (vFile != null && vFile.isValid()) {
PsiFile psiFile = PsiManager.getInstance(project).findFile(vFile);
XmlFile xmlFile = (XmlFile) psiFile;
if (xmlFile != null) {
ApplicationDictionary dictionary = new ApplicationDictionaryImpl(project, xmlFile, applicationName, dInfo.getApplicationFile());
dictionaryMap.put(applicationName, dictionary);
return dictionary;
}
}
LOG.warn("Failed to create dictionary from info for application: " + applicationName + ". Reason: file is null");
return null;
}
示例2: getComponentDeclarations
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
private static List<XmlTag> getComponentDeclarations(String componentValue, String componentType, ID<String, Void> id, Project project, ComponentMatcher componentMatcher) {
List<XmlTag> results = new ArrayList<XmlTag>();
Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
.getContainingFiles(
id,
componentValue,
GlobalSearchScope.allScope(project)
);
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile virtualFile: containingFiles) {
XmlFile xmlFile = (XmlFile)psiManager.findFile(virtualFile);
if (xmlFile == null) {
continue;
}
XmlTag rootTag = xmlFile.getRootTag();
if (rootTag == null) {
continue;
}
collectComponentDeclarations(rootTag, results, componentValue, componentType, componentMatcher);
}
return results;
}
示例3: getLayoutFiles
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
public static List<XmlFile> getLayoutFiles(Project project, @Nullable String fileName) {
List<XmlFile> results = new ArrayList<XmlFile>();
Collection<VirtualFile> xmlFiles = FilenameIndex.getAllFilesByExt(project, "xml");
PsiManager psiManager = PsiManager.getInstance(project);
for (VirtualFile xmlFile: xmlFiles) {
if (isLayoutFile(xmlFile)) {
if (fileName != null && !xmlFile.getNameWithoutExtension().equals(fileName)) {
continue;
}
PsiFile file = psiManager.findFile(xmlFile);
if (file != null) {
results.add((XmlFile)file);
}
}
}
return results;
}
示例4: addCompletions
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters,
ProcessingContext context,
@NotNull CompletionResultSet result) {
PsiElement position = parameters.getPosition().getOriginalElement();
if (position == null) {
return;
}
List<XmlFile> targets = LayoutIndex.getLayoutFiles(position.getProject());
if (targets.size() > 0) {
for (XmlFile file : targets) {
result.addElement(
LookupElementBuilder
.create(file.getVirtualFile().getNameWithoutExtension())
.withIcon(PhpIcons.XML_TAG_ICON)
);
}
}
}
示例5: getClassConfigurations
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
public static List<XmlTag> getClassConfigurations(PhpClass phpClass) {
String classFqn = phpClass.getPresentableFQN();
Collection<VirtualFile> containingFiles = FileBasedIndex.getInstance()
.getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject())
);
PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());
List<XmlTag> tags = new ArrayList<XmlTag>();
for (VirtualFile virtualFile: containingFiles) {
XmlFile file = (XmlFile)psiManager.findFile(virtualFile);
if (file == null) {
continue;
}
XmlTag rootTag = file.getRootTag();
fillRelatedTags(classFqn, rootTag, tags);
}
return tags;
}
示例6: getWebApiRoutes
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
/**
* Get list of Web API routes associated with the provided method.
*
* Parent classes are not taken into account.
*/
public static List<XmlTag> getWebApiRoutes(Method method) {
List<XmlTag> tags = new ArrayList<>();
if (!method.getAccess().isPublic()) {
return tags;
}
PhpClass phpClass = method.getContainingClass();
String methodFqn = method.getName();
if (phpClass == null) {
return tags;
}
String classFqn = phpClass.getPresentableFQN();
Collection<VirtualFile> containingFiles = FileBasedIndex
.getInstance().getContainingFiles(KEY, classFqn, GlobalSearchScope.allScope(phpClass.getProject()));
PsiManager psiManager = PsiManager.getInstance(phpClass.getProject());
for (VirtualFile virtualFile : containingFiles) {
XmlFile file = (XmlFile) psiManager.findFile(virtualFile);
if (file == null) {
continue;
}
XmlTag rootTag = file.getRootTag();
fillRelatedTags(classFqn, methodFqn, rootTag, tags);
}
return tags;
}
示例7: getIndexer
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@NotNull
@Override
public DataIndexer<String, Void, FileContent> getIndexer() {
return inputData -> {
Map<String, Void> map = new HashMap<>();
PsiFile psiFile = inputData.getPsiFile();
if (!Settings.isEnabled(psiFile.getProject())) {
return map;
}
if (psiFile instanceof PhpFile) {
grabEventNamesFromPhpFile((PhpFile) psiFile, map);
} else if (psiFile instanceof XmlFile) {
grabEventNamesFromXmlFile((XmlFile) psiFile, map);
}
return map;
};
}
示例8: getMagentoName
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@Override
public String getMagentoName() {
if (moduleName != null) {
return moduleName;
}
PsiDirectory configurationDir = directory.findSubdirectory(CONFIGURATION_PATH);
if (configurationDir != null) {
PsiFile configurationFile = configurationDir.findFile("module.xml");
if (configurationFile != null && configurationFile instanceof XmlFile) {
XmlTag rootTag = ((XmlFile) configurationFile).getRootTag();
if (rootTag != null) {
XmlTag module = rootTag.findFirstSubTag("module");
if (module != null && module.getAttributeValue("name") != null) {
moduleName = module.getAttributeValue("name");
return moduleName;
}
}
}
}
return DEFAULT_MODULE_NAME;
}
示例9: TSStructureViewTreeModel
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
public TSStructureViewTreeModel(
@NotNull XmlFile file,
@NotNull Function<DomElement, DomService.StructureViewMode> descriptor,
@Nullable Editor editor
) {
super(
file,
DomElementsNavigationManager.getManager(file.getProject())
.getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME),
descriptor,
editor
);
myNavigationProvider = DomElementsNavigationManager.getManager(file.getProject())
.getDomElementsNavigateProvider(DomElementsNavigationManager.DEFAULT_PROVIDER_NAME);
myDescriptor = descriptor;
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:TSStructureViewTreeModel.java
示例10: getRoot
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@Override
@NotNull
public StructureViewTreeElement getRoot() {
XmlFile myFile = getPsiFile();
final DomFileElement<DomElement> fileElement = DomManager.getDomManager(myFile.getProject()).getFileElement(
myFile,
DomElement.class
);
return fileElement == null ?
new XmlFileTreeElement(myFile) :
new TSStructureTreeElement(
fileElement.getRootElement().createStableCopy(),
myDescriptor,
myNavigationProvider
);
}
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:17,代码来源:TSStructureViewTreeModel.java
示例11: testTagData2
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
public void testTagData2() throws Exception {
String s1 = "<a><b>\nSomeDataHere";
String s2 = "\n</b></a>";
prepareFile(s1, s2);
PsiElement element1 = ((XmlFile)myDummyFile).getDocument().getRootTag();
insert("x");
insert(" ");
insert("xxxxx");
insert("\n");
insert("xxxxx");
assertSame(element1, ((XmlFile)myDummyFile).getDocument().getRootTag());
}
示例12: doRenameXmlAttributeValue
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
private static void doRenameXmlAttributeValue(@NotNull XmlAttributeValue value,
String newName,
UsageInfo[] infos,
@Nullable RefactoringElementListener listener)
throws IncorrectOperationException {
LOG.assertTrue(value.isValid());
renameAll(value, infos, newName, value.getValue());
PsiManager psiManager = value.getManager();
LOG.assertTrue(psiManager != null);
XmlFile file = (XmlFile)PsiFileFactory.getInstance(psiManager.getProject()).createFileFromText("dummy.xml", XMLLanguage.INSTANCE, "<a attr=\"" + newName + "\"/>");
@SuppressWarnings("ConstantConditions")
PsiElement element = value.replace(file.getRootTag().getAttributes()[0].getValueElement());
if (listener != null) {
listener.elementRenamed(element);
}
}
示例13: getFlowsInScope
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@NotNull
private static List<DomElement> getFlowsInScope(Project project, GlobalSearchScope searchScope) {
final List<DomElement> result = new ArrayList<>();
final Collection<VirtualFile> files = FileTypeIndex.getFiles(StdFileTypes.XML, searchScope);
final DomManager manager = DomManager.getDomManager(project);
for (VirtualFile file : files) {
final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
if (isMuleFile(xmlFile)) {
final DomFileElement<Mule> fileElement = manager.getFileElement((XmlFile) xmlFile, Mule.class);
if (fileElement != null) {
final Mule rootElement = fileElement.getRootElement();
result.addAll(rootElement.getFlows());
result.addAll(rootElement.getSubFlows());
}
}
}
return result;
}
示例14: findExistingByElement
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location,
@NotNull List<RunnerAndConfigurationSettings> existingConfigurations,
ConfigurationContext context) {
final XmlFile file = PsiTreeUtil.getParentOfType(location.getPsiElement(), XmlFile.class, false);
if (file != null && file.isPhysical() && XsltSupport.isXsltFile(file)) {
for (RunnerAndConfigurationSettings existingConfiguration : existingConfigurations) {
final RunConfiguration configuration = existingConfiguration.getConfiguration();
if (configuration instanceof XsltRunConfiguration) {
if (file.getVirtualFile().getPath().replace('/', File.separatorChar)
.equals(((XsltRunConfiguration)configuration).getXsltFile())) {
return existingConfiguration;
}
}
}
}
return null;
}
示例15: doValidateWithData
import com.intellij.psi.xml.XmlFile; //导入依赖的package包/类
@Nullable
protected String doValidateWithData() {
String rootElementName = getElementName();
if (rootElementName == null || rootElementName.length() == 0) {
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.length() == 0) {
return XmlBundle.message("schema2.instance.output.file.name.is.empty.validation.problem");
}
return null;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:GenerateInstanceDocumentFromSchemaDialog.java