本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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));
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
}
}
示例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;
}
示例12: LineMarkerXmlTagDecorator
import com.intellij.psi.xml.XmlTag; //导入方法依赖的package包/类
public LineMarkerXmlTagDecorator(XmlTag xmlTag) {
this.xmlTag = xmlTag;
this.project = xmlTag.getProject();
}
示例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);
}