本文整理了Java中com.intellij.psi.xml.XmlTag.getName()
方法的一些代码示例,展示了XmlTag.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlTag.getName()
方法的具体详情如下:
包路径:com.intellij.psi.xml.XmlTag
类名称:XmlTag
方法名:getName
暂无
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static XmlTag getServiceTagValid(@NotNull PsiElement psiElement) {
XmlTag xmlTag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
if(xmlTag == null) {
return null;
}
if("service".equals(xmlTag.getName())) {
return xmlTag;
}
xmlTag = PsiTreeUtil.getParentOfType(xmlTag, XmlTag.class);
if(xmlTag != null && "service".equals(xmlTag.getName())) {
return xmlTag;
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
public static Collection<XmlTag> getXmlContainerServiceDefinition(PsiFile psiFile) {
Collection<XmlTag> xmlTags = new ArrayList<>();
for(XmlTag xmlTag: PsiTreeUtil.getChildrenOfTypeAsList(psiFile.getFirstChild(), XmlTag.class)) {
if(xmlTag.getName().equals("container")) {
for(XmlTag servicesTag: xmlTag.getSubTags()) {
if(servicesTag.getName().equals("services")) {
for(XmlTag parameterTag: servicesTag.getSubTags()) {
if(parameterTag.getName().equals("service")) {
xmlTags.add(parameterTag);
}
}
}
}
}
}
return xmlTags;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
private boolean isValidForFile(@NotNull PsiFile file) {
if(file instanceof XmlFile) {
XmlTag rootTag = ((XmlFile) file).getRootTag();
return !(rootTag == null || !"container".equals(rootTag.getName()));
} else if(file instanceof YAMLFile) {
return
YAMLUtil.getQualifiedKeyInFile((YAMLFile) file, "parameters") != null ||
YAMLUtil.getQualifiedKeyInFile((YAMLFile) file, "services") != null;
}
return false;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public static Set<String> getTags(XmlTag serviceTag) {
Set<String> tags = new HashSet<>();
for(XmlTag serviceSubTag: serviceTag.getSubTags()) {
if("tag".equals(serviceSubTag.getName())) {
XmlAttribute attribute = serviceSubTag.getAttribute("name");
if(attribute != null) {
String tagName = attribute.getValue();
if(tagName != null && StringUtils.isNotBlank(tagName)) {
tags.add(tagName);
}
}
}
}
return tags;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) {
if(!Symfony2ProjectComponent.isEnabled(psiElement.getProject())) {
return false;
}
final XmlTag argumentTag = PsiTreeUtil.getParentOfType(psiElement, XmlTag.class);
if(argumentTag == null || !"argument".equals(argumentTag.getName())) {
return false;
}
return XmlServiceArgumentIntention.getServiceTagValid(psiElement) != null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* Get class attribute from service on every inside element
*
* @param psiInsideService every PsiElement inside service
* @return raw class attribute value
*/
@Nullable
public static String getServiceDefinitionClass(@NotNull PsiElement psiInsideService) {
// search for parent service definition
XmlTag callXmlTag = PsiTreeUtil.getParentOfType(psiInsideService, XmlTag.class);
XmlTag xmlTag = PsiTreeUtil.getParentOfType(callXmlTag, XmlTag.class);
if(xmlTag == null || !xmlTag.getName().equals("service")) {
return null;
}
return getClassFromServiceDefinition(xmlTag);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
private Pair<String, Method> findMethodParameterHint(@NotNull XmlTag argumentTag) {
PsiElement serviceTag = argumentTag.getParent();
if("service".equalsIgnoreCase(((XmlTag) serviceTag).getName())) {
String aClass = XmlHelper.getClassFromServiceDefinition((XmlTag) serviceTag);
if(aClass != null && StringUtils.isNotBlank(aClass)) {
return getParamater(argumentTag.getProject(), aClass, aVoid -> XmlHelper.getArgumentIndex(argumentTag));
}
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static PsiElement getXmlRouteNameTarget(@NotNull XmlFile psiFile,@NotNull String routeName) {
XmlDocumentImpl document = PsiTreeUtil.getChildOfType(psiFile, XmlDocumentImpl.class);
if(document == null) {
return null;
}
for(XmlTag xmlTag: PsiTreeUtil.getChildrenOfTypeAsList(psiFile.getFirstChild(), XmlTag.class)) {
if(xmlTag.getName().equals("routes")) {
for(XmlTag routeTag: xmlTag.getSubTags()) {
if(routeTag.getName().equals("route")) {
XmlAttribute xmlAttribute = routeTag.getAttribute("id");
if(xmlAttribute != null) {
String attrValue = xmlAttribute.getValue();
if(routeName.equals(attrValue)) {
return xmlAttribute;
}
}
}
}
}
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* Returns current index of parent tag
*
* <foo>
* <argument/>
* <arg<caret>ument/>
* </foo>
*/
private static int getArgumentIndexByCount(@NotNull XmlTag xmlTag) {
PsiElement psiElement = xmlTag;
int index = 0;
while (psiElement != null) {
psiElement = psiElement.getPrevSibling();
// ignore: <argument index="0"/>, <argument key="$foobar"/>
if(psiElement instanceof XmlTag && "argument".equalsIgnoreCase(((XmlTag) psiElement).getName()) && ((XmlTag) psiElement).getAttribute("key") == null && ((XmlTag) psiElement).getAttribute("index") == null) {
index++;
}
}
return index;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* <routes><import resource="FOO" /></routes>
*/
private static void visitXmlFile(@NotNull XmlFile psiFile, @NotNull Consumer<FileResourceConsumer> consumer) {
XmlTag rootTag = psiFile.getRootTag();
if(rootTag == null || !"routes".equals(rootTag.getName())) {
return;
}
for (XmlTag xmlTag : rootTag.findSubTags("import")) {
String resource = xmlTag.getAttributeValue("resource");
if(StringUtils.isBlank(resource)) {
continue;
}
consumer.consume(new FileResourceConsumer(xmlTag, xmlTag, normalize(resource)));
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* <route controller="Foo"/>
* <route>
* <default key="_controller">Foo</default>
* </route>
*/
@Nullable
public static String getXmlController(@NotNull XmlTag serviceTag) {
for(XmlTag subTag :serviceTag.getSubTags()) {
if("default".equalsIgnoreCase(subTag.getName())) {
String keyValue = subTag.getAttributeValue("key");
if(keyValue != null && "_controller".equals(keyValue)) {
String actionName = subTag.getValue().getTrimmedText();
if(StringUtils.isNotBlank(actionName)) {
return actionName;
}
}
}
}
String controller = serviceTag.getAttributeValue("controller");
if(controller != null && StringUtils.isNotBlank(controller)) {
return controller;
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static PsiElement getLocalServiceName(PsiFile psiFile, String serviceName) {
if(!(psiFile.getFirstChild() instanceof XmlDocument)) {
return null;
}
XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
if(xmlTags == null) {
return null;
}
for(XmlTag xmlTag: xmlTags) {
if(xmlTag.getName().equals("container")) {
for(XmlTag servicesTag: xmlTag.getSubTags()) {
if(servicesTag.getName().equals("services")) {
for(XmlTag serviceTag: servicesTag.getSubTags()) {
String serviceNameId = serviceTag.getAttributeValue("id");
if(serviceNameId != null && serviceNameId.equalsIgnoreCase(serviceName)) {
return serviceTag;
}
}
}
}
}
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
public static List<String> getXmlMissingArgumentTypes(@NotNull XmlTag xmlTag, boolean collectOptionalParameter, @NotNull ContainerCollectionResolver.LazyServiceCollector collector) {
PhpClass resolvedClassDefinition = getPhpClassFromXmlTag(xmlTag, collector);
if (resolvedClassDefinition == null) {
return Collections.emptyList();
}
Method constructor = resolvedClassDefinition.getConstructor();
if(constructor == null) {
return Collections.emptyList();
}
int serviceArguments = 0;
for (XmlTag tag : xmlTag.getSubTags()) {
if("argument".equals(tag.getName())) {
serviceArguments++;
}
}
Parameter[] parameters = collectOptionalParameter ? constructor.getParameters() : PhpElementsUtil.getFunctionRequiredParameter(constructor);
if(parameters.length <= serviceArguments) {
return Collections.emptyList();
}
final List<String> args = new ArrayList<>();
for (int i = serviceArguments; i < parameters.length; i++) {
Parameter parameter = parameters[i];
String s = parameter.getDeclaredType().toString();
args.add(s);
}
return args;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static PsiElement getLocalParameterName(PsiFile psiFile, String serviceName) {
if(!(psiFile.getFirstChild() instanceof XmlDocumentImpl)) {
return null;
}
XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
if(xmlTags == null) {
return null;
}
for(XmlTag xmlTag: xmlTags) {
if(xmlTag.getName().equals("container")) {
for(XmlTag servicesTag: xmlTag.getSubTags()) {
if(servicesTag.getName().equals("parameters")) {
for(XmlTag serviceTag: servicesTag.getSubTags()) {
XmlAttribute attrValue = serviceTag.getAttribute("key");
if(attrValue != null) {
String serviceNameId = attrValue.getValue();
if(serviceNameId != null && serviceNameId.equals(serviceName)) {
return serviceTag;
}
}
}
}
}
}
}
return null;
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
if(servicesTag instanceof XmlTag && "services".equals(((XmlTag) servicesTag).getName())) {
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
private void getOdmFields(@NotNull XmlTag xmlTag, @NotNull Collection<DoctrineModelField> fields) {
for (XmlTag tag : xmlTag.getSubTags()) {
String tagName = tag.getName();
if("field".equals(tagName)) {
String name = tag.getAttributeValue("name");
if(StringUtils.isNotBlank(name)) {
DoctrineModelField type = new DoctrineModelField(name, tag.getAttributeValue("type"));
type.setColumn(tag.getAttributeValue("fieldName"));
fields.add(type);
}
} else if(RELATIONS.contains(tagName)) {
String field = tag.getAttributeValue("field");
if(StringUtils.isNotBlank(field)) {
DoctrineModelField type = new DoctrineModelField(field);
type.setRelationType(tagName);
type.setRelation(tag.getAttributeValue("target-document"));
fields.add(type);
}
}
}
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
String name = ((XmlTag) psiElement1).getName();
return name.equals("entity") || name.equals("document") || name.equals("embedded") || name.equals("embedded-document");
});
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public static void visitFile(@NotNull XmlFile psiFile, @NotNull Consumer<ServiceConsumer> consumer) {
if(!(psiFile.getFirstChild() instanceof XmlDocument)) {
return;
}
XmlTag xmlTags[] = PsiTreeUtil.getChildrenOfType(psiFile.getFirstChild(), XmlTag.class);
if(xmlTags == null) {
return;
}
for(XmlTag xmlTag: xmlTags) {
if(xmlTag.getName().equals("container")) {
for(XmlTag servicesTag: xmlTag.getSubTags()) {
if("services".equals(servicesTag.getName())) {
// default values:
// <defaults autowire="true" public="false" />
ServiceFileDefaults defaults = createDefaults(servicesTag);
for(XmlTag serviceTag: servicesTag.findSubTags("service")) {
String serviceId = serviceTag.getAttributeValue("id");
if(StringUtils.isBlank(serviceId)) {
continue;
}
consumer.consume(new ServiceConsumer(serviceTag, serviceId, new XmlTagAttributeValue(serviceTag), defaults));
}
}
}
}
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
String xmlMethodName = ((XmlTag) serviceTag).getName();
if("call".equals(xmlMethodName)) {
String methodName = ((XmlTag) serviceTag).getAttributeValue("method");
PsiElement serviceTagParent = serviceTag.getParent();
if(serviceTagParent instanceof XmlTag && "service".equals(((XmlTag) serviceTagParent).getName())) {
String aClass = XmlHelper.getClassFromServiceDefinition((XmlTag) serviceTagParent);
if(aClass != null) {
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
if(!"tag".equals(tag.getName())) {
continue;
内容来源于网络,如有侵权,请联系作者删除!