当前位置: 首页>>代码示例>>Java>>正文


Java XmlTag.getProject方法代码示例

本文整理汇总了Java中com.intellij.psi.xml.XmlTag.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java XmlTag.getProject方法的具体用法?Java XmlTag.getProject怎么用?Java XmlTag.getProject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.psi.xml.XmlTag的用法示例。


在下文中一共展示了XmlTag.getProject方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findFlowRefsForFlow

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public static List<XmlTag> findFlowRefsForFlow(@NotNull XmlTag flow) {
    List<XmlTag> flowRefs = new ArrayList<>();

    final Project project = flow.getProject();
    final String flowName = flow.getAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE);

    Collection<VirtualFile> vFiles = FileTypeIndex.getFiles(StdFileTypes.XML, ProjectScope.getContentScope(project));
    for (VirtualFile virtualFile : vFiles) {
        PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile);
        if (psiFile != null) {
            XmlFile xmlFile = (XmlFile) psiFile;
            XmlTag mule = xmlFile.getRootTag();

            FlowRefsFinder finder = new FlowRefsFinder(flowName);
            mule.accept(finder);
            flowRefs.addAll(finder.getFlowRefs());
        }
    }
    return flowRefs;
}
 
开发者ID:machaval,项目名称:mule-intellij-plugins,代码行数:21,代码来源:MuleConfigUtils.java

示例2: getDescriptor

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
@Override
public XmlElementDescriptor getDescriptor(XmlTag xmlTag) {
  final Project project = xmlTag.getProject();
  CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(project);

  if (!(xmlTag instanceof HtmlTag && manager.isCatberryEnabled())) return null;

  final XmlNSDescriptor nsDescriptor = xmlTag.getNSDescriptor(xmlTag.getNamespace(), false);
  final XmlElementDescriptor descriptor = nsDescriptor != null ? nsDescriptor.getElementDescriptor(xmlTag) : null;
  final boolean special = CatberryConstants.SPECIAL_COMPONENT_NAMES.contains(xmlTag.getName());
  if (descriptor != null && !(descriptor instanceof AnyXmlElementDescriptor || special)) return null;

  final String name = CatberryComponentUtils.normalizeName(xmlTag.getName());
  final PsiFile file = CatberryComponentUtils.findComponent(project, name);
  return file != null ? new CatberryComponentTagDescriptor(xmlTag.getName(), file) : null;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:18,代码来源:CatberryComponentTagDescriptorsProvider.java

示例3: getDescriptor

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
@Nullable
public XmlElementDescriptor getDescriptor(final XmlTag tag) {
  Project project = tag.getProject();
  if (project.isDefault()) return null;
  
  final DomInvocationHandler<?,?> handler = DomManagerImpl.getDomManager(project).getDomHandler(tag);
  if (handler != null) {
    final DefinesXml definesXml = handler.getAnnotation(DefinesXml.class);
    if (definesXml != null) {
      return new DomElementXmlDescriptor(handler);
    }
    final PsiElement parent = tag.getParent();
    if (parent instanceof XmlTag) {
      final XmlElementDescriptor descriptor = ((XmlTag)parent).getDescriptor();

      if (descriptor instanceof DomElementXmlDescriptor) {
        return descriptor.getElementDescriptor(tag, (XmlTag)parent);
      }
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:DomDescriptorProvider.java

示例4: getAttributeDescriptors

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public XmlAttributeDescriptor[] getAttributeDescriptors(XmlTag xmlTag) {
  final Project project = xmlTag.getProject();
  CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(project);

  if (manager.isCatberryEnabled() && (xmlTag.getDescriptor() instanceof CatberryComponentTagDescriptor)) {
    return new CatberryAttributeDescriptor[] {new CatberryAttributeDescriptor(project, "cat-store")};
  }
  return XmlAttributeDescriptor.EMPTY;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:11,代码来源:CatberryAttributeDescriptorsProvider.java

示例5: getAttributeDescriptor

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
@Override
public XmlAttributeDescriptor getAttributeDescriptor(final String attrName, XmlTag xmlTag) {
  if (xmlTag != null && "cat-store".equals(attrName)) {
    return new CatberryAttributeDescriptor(xmlTag.getProject(), "cat-store");
  }
  return null;
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:9,代码来源:CatberryAttributeDescriptorsProvider.java

示例6: addTagNameVariants

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void addTagNameVariants(final List<LookupElement> elements, @NotNull XmlTag xmlTag, String prefix) {
  CatberryProjectConfigurationManager manager = CatberryProjectConfigurationManager.getInstance(xmlTag.getProject());
  
  if (!(xmlTag instanceof HtmlTag && manager.isCatberryEnabled())) return;

  final Project project = xmlTag.getProject();
  Map<String, PsiFile> map = CatberryComponentUtils.findComponents(project);
  for(Map.Entry<String, PsiFile> entry : map.entrySet()) {
    String key = entry.getKey();
    if(!CatberryConstants.SPECIAL_COMPONENT_NAMES.contains(entry.getKey()))
      key = CatberryConstants.CATBERRY_COMPONENT_TAG_PREFIX + key;
    elements.add(LookupElementBuilder.create(entry.getValue(), key).withInsertHandler(XmlTagInsertHandler.INSTANCE));
  }
}
 
开发者ID:catberry,项目名称:catberry-idea-plugin,代码行数:16,代码来源:CatberryComponentTagDescriptorsProvider.java

示例7: createFindStyleApplicationsProcessor

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public static AndroidFindStyleApplicationsProcessor createFindStyleApplicationsProcessor(XmlTag tag,
                                                                                          MyStyleData styleData,
                                                                                          PsiFile context) {
  final ErrorReporter errorReporter = new ProjectBasedErrorReporter(tag.getProject());
  final Style style = styleData.getStyle();
  final Map<AndroidAttributeInfo, String> attrMap =
    AndroidRefactoringUtil.computeAttributeMap(style, new ProjectBasedErrorReporter(tag.getProject()),
                                               AndroidBundle.message("android.find.style.applications.title"));

  if (attrMap == null || attrMap.size() == 0) {
    return null;
  }
  final AndroidFacet facet = styleData.getFacet();
  final StyleRefData parentStyleRef = AndroidRefactoringUtil.getParentStyle(style);
  PsiElement parentStyleAttrName = null;

  if (parentStyleRef != null) {
    parentStyleAttrName = resolveStyleRef(parentStyleRef, facet);

    if (parentStyleAttrName == null) {
      errorReporter.report("Cannot resolve parent style '" + parentStyleRef.getStyleName() + "'",
                           AndroidBundle.message("android.find.style.applications.title"));
      return null;
    }
  }
  return new AndroidFindStyleApplicationsProcessor(styleData.getFacet().getModule(), attrMap, styleData.getName(), tag,
                                                   styleData.getNameAttrValue(), parentStyleAttrName, context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:AndroidFindStyleApplicationsAction.java

示例8: getLayoutUsageData

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
static LayoutUsageData getLayoutUsageData(@NotNull XmlTag tag) {
  final Project project = tag.getProject();
  final DomElement domElement = DomManager.getDomManager(project).getDomElement(tag);

  if (domElement instanceof Include) {
    final GenericAttributeValue<ResourceValue> layoutAttribute = ((Include)domElement).getLayout();
    final AndroidResourceReferenceBase reference = AndroidDomUtil.getAndroidResourceReference(layoutAttribute, true);

    if (reference != null) {
      return new LayoutUsageData(project, tag, reference);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:AndroidInlineUtil.java

示例9: assignId

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
/**
 * Assign a suitable new and unique id to the given component. The set of
 * existing id's is provided in the given list.
 */
@NotNull
public String assignId(RadViewComponent component, Collection<String> idList) {
  String idValue = StringUtil.decapitalize(component.getMetaModel().getTag());

  XmlTag tag = component.getTag();
  Module module = AndroidPsiUtils.getModuleSafely(tag);
  if (module != null) {
    idValue = ResourceHelper.prependResourcePrefix(module, idValue);
  }

  String nextIdValue = idValue;
  int index = 0;

  // Ensure that we don't create something like "switch" as an id, which won't compile when used
  // in the R class
  NamesValidator validator = LanguageNamesValidation.INSTANCE.forLanguage(JavaLanguage.INSTANCE);

  Project project = tag.getProject();
  while (idList.contains(nextIdValue) || validator != null && validator.isKeyword(nextIdValue, project)) {
    ++index;
    if (index == 1 && (validator == null || !validator.isKeyword(nextIdValue, project))) {
      nextIdValue = idValue;
    } else {
      nextIdValue = idValue + Integer.toString(index);
    }
  }

  String newId = NEW_ID_PREFIX + idValue + (index == 0 ? "" : Integer.toString(index));
  tag.setAttribute(ATTR_ID, ANDROID_URI, newId);
  return newId;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:36,代码来源:IdManager.java

示例10: fillCompletionVariants

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Override
public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
  PsiElement xmlText = parameters.getPosition().getParent();

  if (!(xmlText instanceof XmlText)) return;

  PsiElement eDependencyTag = xmlText.getParent();
  if (!(eDependencyTag instanceof XmlTag)) return;

  XmlTag dependencyTag = (XmlTag)eDependencyTag;

  if (!"dependency".equals(dependencyTag.getName())) return;

  if (!PsiImplUtil.isLeafElementOfType(xmlText.getPrevSibling(), XmlTokenType.XML_TAG_END)
    || !PsiImplUtil.isLeafElementOfType(xmlText.getNextSibling(), XmlTokenType.XML_END_TAG_START)) {
    return;
  }

  Project project = dependencyTag.getProject();

  DomElement domElement = DomManager.getDomManager(project).getDomElement(dependencyTag);
  if (!(domElement instanceof MavenDomDependency)) {
    return;
  }

  MavenProjectIndicesManager indicesManager = MavenProjectIndicesManager.getInstance(project);

  for (String groupId : indicesManager.getGroupIds()) {
    for (String artifactId : indicesManager.getArtifactIds(groupId)) {
      LookupElement builder = LookupElementBuilder.create(groupId + ':' + artifactId)
        .withIcon(AllIcons.Nodes.PpLib).withInsertHandler(MavenDependencyInsertHandler.INSTANCE);

      result.addElement(builder);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:MavenDependenciesCompletionProvider.java

示例11: getRootTagDescriptor

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public JavaFxClassBackedElementDescriptor getRootTagDescriptor(XmlTag context) {
  if (context != null && FxmlConstants.FX_ROOT.equals(getName())) {
    final XmlAttribute typeAttr = context.getAttribute(FxmlConstants.TYPE);
    if (typeAttr != null) {
      final String rootClassName = typeAttr.getValue();
      final Project project = context.getProject();
      final PsiClass rootClass = rootClassName != null ? JavaPsiFacade.getInstance(project).findClass(rootClassName, GlobalSearchScope.allScope(project)) : null;
      if (rootClass != null) {
        return new JavaFxClassBackedElementDescriptor(getName(), rootClass);
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaFxDefaultPropertyElementDescriptor.java

示例12: LineMarkerXmlTagDecorator

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public LineMarkerXmlTagDecorator(XmlTag xmlTag) {
    this.xmlTag = xmlTag;
    this.project = xmlTag.getProject();
}
 
开发者ID:magento,项目名称:magento2-phpstorm-plugin,代码行数:5,代码来源:LineMarkerXmlTagDecorator.java

示例13: getElementDescriptor

import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
@Nullable
@Override
public XmlElementDescriptor getElementDescriptor(XmlTag childTag, XmlTag contextTag) {
  final String name = childTag.getName();
  if (FxmlConstants.FX_DEFAULT_ELEMENTS.contains(name)) {
    return new JavaFxDefaultPropertyElementDescriptor(name, childTag);
  }
  final String shortName = StringUtil.getShortName(name);
  if (!name.equals(shortName)) { //static property
    final PsiMethod propertySetter = JavaFxPsiUtil.findPropertySetter(name, childTag);
    if (propertySetter != null) {
      return new JavaFxPropertyElementDescriptor(propertySetter.getContainingClass(), shortName, true);
    }

    final Project project = childTag.getProject();
    if (JavaPsiFacade.getInstance(project).findClass(name, GlobalSearchScope.allScope(project)) == null) {
      return null;
    }
  }

  final String parentTagName = contextTag.getName();
  if (myPsiClass != null) {
    if (!FxmlConstants.FX_DEFINE.equals(parentTagName)) {
      JavaFxPropertyElementDescriptor elementDescriptor = new JavaFxPropertyElementDescriptor(myPsiClass, name, false);
      if (FxmlConstants.FX_ROOT.equals(parentTagName)) {
        final PsiField fieldByName = myPsiClass.findFieldByName(name, true);
        if (fieldByName != null) {
          return elementDescriptor;
        }
      } else {
        final JavaFxPropertyElementDescriptor defaultPropertyDescriptor = getDefaultPropertyDescriptor();
        if (defaultPropertyDescriptor != null) {
          final String defaultPropertyName = defaultPropertyDescriptor.getName();
          if (StringUtil.equalsIgnoreCase(defaultPropertyName, name) && !StringUtil.equals(defaultPropertyName, name)) {
            final XmlElementDescriptor childDescriptor = defaultPropertyDescriptor.getElementDescriptor(childTag, contextTag);
            if (childDescriptor != null) {
              return childDescriptor;
            }
          }
        }
        final PsiElement declaration = elementDescriptor.getDeclaration();
        if (declaration != null) {
          if (declaration instanceof PsiField && ((PsiField)declaration).getType() instanceof PsiPrimitiveType) {
            return null;
          }
          return elementDescriptor;
        }
      }
    }
  }
  return new JavaFxClassBackedElementDescriptor(name, childTag);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:53,代码来源:JavaFxClassBackedElementDescriptor.java


注:本文中的com.intellij.psi.xml.XmlTag.getProject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。