• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PsiMetaOwner类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.psi.meta.PsiMetaOwner的典型用法代码示例。如果您正苦于以下问题:Java PsiMetaOwner类的具体用法?Java PsiMetaOwner怎么用?Java PsiMetaOwner使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



PsiMetaOwner类属于com.intellij.psi.meta包,在下文中一共展示了PsiMetaOwner类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getStringToReplace

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
private static String getStringToReplace(PsiElement element, String newName, boolean nonJava, final RenamePsiElementProcessor theProcessor) {
  if (element instanceof PsiMetaOwner) {
    final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element;
    final PsiMetaData metaData = psiMetaOwner.getMetaData();
    if (metaData != null) {
      return metaData.getName();
    }
  }

  if (theProcessor != null) {
    String result = theProcessor.getQualifiedNameAfterRename(element, newName, nonJava);
    if (result != null) {
      return result;
    }
  }

  if (element instanceof PsiNamedElement) {
    return newName;
  }
  else {
    LOG.error("Unknown element type : " + element);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RenameUtil.java


示例2: bindToElement

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
  PsiMetaData metaData = null;

  if (element instanceof PsiMetaOwner){
    final PsiMetaOwner owner = (PsiMetaOwner)element;
    metaData = owner.getMetaData();

    if (metaData instanceof XmlElementDescriptor){
      return getTagElement().setName(metaData.getName(getElement())); // TODO: need to evaluate new ns prefix
    }
  } else if (element instanceof PsiFile) {
    final XmlTag tagElement = getTagElement();
    if (tagElement == null || !myStartTagFlag) return tagElement;
    String newElementName = ((PsiFile)element).getName();
    final int index = newElementName.lastIndexOf('.');

    // TODO: need to evaluate new ns prefix
    newElementName = prependNamespacePrefix(newElementName.substring(0, index), tagElement.getNamespacePrefix());

    return getTagElement().setName(newElementName);
  }

  final XmlTag tag = getTagElement();
  throw new IncorrectOperationException("Cant bind to not a xml element definition!"+element+","+metaData + "," + tag + "," + (tag != null ? tag.getDescriptor() : "unknown descriptor"));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:TagNameReference.java


示例3: getStringToReplace

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
private static String getStringToReplace(PsiElement element, String newName, boolean nonJava, final RenamePsiElementProcessor theProcessor) {
  if (element instanceof PsiMetaOwner) {
    final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element;
    final PsiMetaData metaData = psiMetaOwner.getMetaData();
    if (metaData != null) {
      return metaData.getName();
    }
  }

  if (theProcessor != null) {
    String result = theProcessor.getQualifiedNameAfterRename(element, newName, nonJava);
    if (result != null) {
      return result;
    }
  }

  if (element instanceof PsiNamedElement) {
    return newName;
  }
  else {
    LOG.error("Unknown element type");
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:RenameUtil.java


示例4: bindToElement

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
  PsiMetaData metaData = null;

  if (element instanceof PsiMetaOwner){
    final PsiMetaOwner owner = (PsiMetaOwner)element;
    metaData = owner.getMetaData();

    if (metaData instanceof XmlElementDescriptor){
      return getTagElement().setName(metaData.getName(getElement())); // TODO: need to evaluate new ns prefix
    }
  } else if (element instanceof PsiFile) {
    final XmlTag tagElement = getTagElement();
    if (tagElement == null || !myStartTagFlag) return tagElement;
    String newElementName = ((PsiFile)element).getName();
    final int index = newElementName.lastIndexOf('.');

    // TODO: need to evaluate new ns prefix
    newElementName = prependNamespacePrefix(newElementName.substring(0, index), tagElement.getNamespacePrefix());

    return getTagElement().setName(newElementName);
  }

  final XmlTag tag = getTagElement();
  throw new IncorrectOperationException("Cant bind to not a xml element definition!"+element+","+metaData + "," + tag + "," + (tag != null ? tag.getDescriptor() : "unknown descriptor"));
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:TagNameReference.java


示例5: getNSDescriptorFromMetaData

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Nullable
private XmlNSDescriptor getNSDescriptorFromMetaData(@Nullable PsiMetaOwner metaOwner, boolean nonEmpty)
{
	if(metaOwner == null)
	{
		return null;
	}
	XmlNSDescriptor descriptor = (XmlNSDescriptor) metaOwner.getMetaData();
	if(descriptor == null)
	{
		return null;
	}
	if(nonEmpty && descriptor.getRootElementsDescriptors(this).length == 0)
	{
		return null;
	}
	return descriptor;
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:19,代码来源:XmlDocumentImpl.java


示例6: canFindUsagesFor

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public boolean canFindUsagesFor(@NotNull PsiElement element)
{
	if(element instanceof PsiDirectory)
	{
		PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory) element);
		return psiPackage != null && psiPackage.getQualifiedName().length() != 0;
	}

	return element instanceof PsiClass ||
			element instanceof PsiVariable ||
			element instanceof PsiMethod ||
			element instanceof PsiPackage ||
			element instanceof PsiLabeledStatement ||
			ThrowSearchUtil.isSearchable(element) ||
			element instanceof PsiMetaOwner && ((PsiMetaOwner) element).getMetaData() != null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:JavaFindUsagesProvider.java


示例7: checkName

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
public static boolean checkName(@NotNull PsiElement element, @NotNull String name, final PsiElement context) {
  if (element instanceof PsiMetaOwner) {
    final PsiMetaData data = ((PsiMetaOwner) element).getMetaData();
    if (data != null) return name.equals(data.getName(context));
  }
  return element instanceof PsiNamedElement && name.equals(((PsiNamedElement)element).getName());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:PsiUtil.java


示例8: canFindUsagesFor

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public boolean canFindUsagesFor(@NotNull PsiElement element) {
  if (element instanceof PsiDirectory) {
    PsiPackage psiPackage = JavaDirectoryService.getInstance().getPackage((PsiDirectory)element);
    return psiPackage != null && psiPackage.getQualifiedName().length() != 0;
  }

  return element instanceof PsiClass ||
         element instanceof PsiVariable ||
         element instanceof PsiMethod ||
         element instanceof PsiPackage ||
         element instanceof PsiLabeledStatement ||
         ThrowSearchUtil.isSearchable(element) ||
         element instanceof PsiMetaOwner && ((PsiMetaOwner)element).getMetaData() != null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:16,代码来源:JavaFindUsagesProvider.java


示例9: withMetaData

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
public Self withMetaData(final ElementPattern<? extends PsiMetaData> metaDataPattern) {
  return with(new PatternCondition<T>("withMetaData") {
    @Override
    public boolean accepts(@NotNull final T t, final ProcessingContext context) {
      return t instanceof PsiMetaOwner && metaDataPattern.accepts(((PsiMetaOwner)t).getMetaData(), context);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PsiElementPattern.java


示例10: getName

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
/**
 * @return name for element using element structure info
 */
@Nullable
public static String getName(PsiElement element) {
  String name = null;
  if (element instanceof PsiMetaOwner) {
    final PsiMetaData data = ((PsiMetaOwner) element).getMetaData();
    if (data != null) {
      name = data.getName(element);
    }
  }
  if (name == null && element instanceof PsiNamedElement) {
    name = ((PsiNamedElement) element).getName();
  }
  return name;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiUtilCore.java


示例11: getElementDescription

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public String getElementDescription(@NotNull final PsiElement psiElement, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof UsageViewTypeLocation)) return null;

  if (psiElement instanceof PsiMetaOwner) {
    final PsiMetaData metaData = ((PsiMetaOwner)psiElement).getMetaData();
    if (metaData instanceof PsiPresentableMetaData) {
      return ((PsiPresentableMetaData)metaData).getTypeName();
    }
  }

  if (psiElement instanceof PsiFile) {
    return LangBundle.message("terms.file");
  }
  if (psiElement instanceof PsiDirectory) {
    return LangBundle.message("terms.directory");
  }

  final Language lang = psiElement.getLanguage();
  FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(lang);
  final String type = provider.getType(psiElement);
  if (StringUtil.isNotEmpty(type)) {
    return type;
  }

  return TypePresentationService.getService().getTypePresentableName(psiElement.getClass());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:UsageViewTypeLocation.java


示例12: getElementDescription

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof UsageViewShortNameLocation)) return null;

  if (element instanceof PsiMetaOwner) {
    PsiMetaData metaData = ((PsiMetaOwner)element).getMetaData();
    if (metaData!=null) return DescriptiveNameUtil.getMetaDataName(metaData);
  }

  if (element instanceof PsiNamedElement) {
    return ((PsiNamedElement)element).getName();
  }
  return "";
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:UsageViewShortNameLocation.java


示例13: update

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
private void update(PsiElement element) {
  if (element != null && element.isValid()) {
    final ItemPresentation presentation = ((NavigationItem)element).getPresentation();
    myIconOpen = presentation == null ? null : ComputableIcon.create(presentation, true);
    myIconClosed = presentation == null ? null : ComputableIcon.create(presentation, false);
    myPresentableText = presentation == null ? UsageViewUtil.createNodeText(element) : presentation.getPresentableText();
    if (myIconOpen == null || myIconClosed == null) {
      if (element instanceof PsiMetaOwner) {
        final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element;
        final PsiMetaData metaData = psiMetaOwner.getMetaData();
        if (metaData instanceof PsiPresentableMetaData) {
          final PsiPresentableMetaData psiPresentableMetaData = (PsiPresentableMetaData)metaData;
          if (myIconOpen == null) myIconOpen = ComputableIcon.create(psiPresentableMetaData);
          if (myIconClosed == null) myIconClosed = ComputableIcon.create(psiPresentableMetaData);
        }
      }
      else if (element instanceof PsiFile) {
        final PsiFile psiFile = (PsiFile)element;
        final VirtualFile virtualFile = psiFile.getVirtualFile();
        if (virtualFile != null) {
          myIconOpen = ComputableIcon.create(virtualFile);
          myIconClosed = ComputableIcon.create(virtualFile);
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:PsiElement2UsageTargetAdapter.java


示例14: getElementDescription

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public String getElementDescription(@NotNull final PsiElement element, @NotNull final ElementDescriptionLocation location) {
  if (!(location instanceof NonCodeSearchDescriptionLocation)) return null;
  final NonCodeSearchDescriptionLocation ncdLocation = (NonCodeSearchDescriptionLocation)location;

  if (element instanceof PsiDirectory) {
    if (ncdLocation.isNonJava()) {
      final String qName = PsiDirectoryFactory.getInstance(element.getProject()).getQualifiedName((PsiDirectory)element, false);
      if (qName.length() > 0) return qName;
      return null;
    }
    return ((PsiDirectory) element).getName();
  }

  if (element instanceof PsiMetaOwner) {
    final PsiMetaOwner psiMetaOwner = (PsiMetaOwner)element;
    final PsiMetaData metaData = psiMetaOwner.getMetaData();
    if (metaData != null) {
      return metaData.getName();
    }
  }
  if (element instanceof PsiNamedElement) {
    return ((PsiNamedElement)element).getName();
  }
  else {
   // LOG.error("Unknown element type: " + element);
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:DefaultNonCodeSearchElementDescriptionProvider.java


示例15: getSuggestedNames

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public SuggestedNameInfo getSuggestedNames(final PsiElement element, final PsiElement nameSuggestionContext, final Set<String> result) {
  if (element instanceof PsiMetaOwner) {
    final PsiMetaData psiMetaData = ((PsiMetaOwner)element).getMetaData();
    if (psiMetaData instanceof DomMetaData) {
      final DomMetaData domMetaData = (DomMetaData)psiMetaData;
      final GenericDomValue value = domMetaData.getNameElement(domMetaData.getElement());
      ContainerUtil.addIfNotNull(getNameFromNameValue(value, true), result);
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:DomNameSuggestionProvider.java


示例16: retrieveOwner

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Nullable
private PsiMetaOwner retrieveOwner(final XmlFile file, @NotNull final String namespace) {
  if (file == null) {
    return namespace.equals(XmlUtil.getTargetSchemaNsFromTag(this)) ? this : null;
  }
  return file.getDocument();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XmlTagImpl.java


示例17: getNSDescriptorFromMetaData

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Nullable
private XmlNSDescriptor getNSDescriptorFromMetaData(@Nullable PsiMetaOwner metaOwner, boolean nonEmpty) {
  if (metaOwner == null) return null;
  XmlNSDescriptor descriptor = (XmlNSDescriptor)metaOwner.getMetaData();
  if (descriptor == null) return null;
  if (nonEmpty && descriptor.getRootElementsDescriptors(this).length == 0) {
    return null;
  }
  return descriptor;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:XmlDocumentImpl.java


示例18: bindToElement

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
public PsiElement bindToElement(@NotNull PsiElement element) throws IncorrectOperationException {
  if (element instanceof PsiMetaOwner) {
    final PsiMetaOwner owner = (PsiMetaOwner)element;
    if (owner.getMetaData() instanceof XmlElementDescriptor) {
      myAttribute.setName(owner.getMetaData().getName());
    }
  }
  throw new IncorrectOperationException("Cant bind to not a xml element definition!");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:XmlAttributeReference.java


示例19: getVariants

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
@Override
@NotNull
public Object[] getVariants() {
  final RngGrammar scope = getScope();
  if (scope == null) {
    return ResolveResult.EMPTY_ARRAY;
  }

  final Map<String, Set<Define>> map = DefinitionResolver.getAllVariants(scope);
  if (map == null || map.size() == 0) return ArrayUtil.EMPTY_OBJECT_ARRAY;

  return ContainerUtil.mapNotNull(map.values(), new Function<Set<Define>, Object>() {
    @Override
    public Object fun(Set<Define> defines) {
      final Define define = defines.iterator().next();
      if (defines.size() == 0) {
        return null;
      } else {
        final PsiElement element = define.getPsiElement();
        if (element != null) {
          final PsiPresentableMetaData data = (PsiPresentableMetaData)((PsiMetaOwner)element).getMetaData();
          if (data != null) {
            return LookupValueFactory.createLookupValue(data.getName(), data.getIcon());
          } else {
            return define.getName();
          }
        } else {
          return define.getName();
        }
      }
    }
  }).toArray();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:DefinitionReference.java


示例20: ValueResourceElementWrapper

import com.intellij.psi.meta.PsiMetaOwner; //导入依赖的package包/类
public ValueResourceElementWrapper(@NotNull XmlAttributeValue wrappeeElement) {
  if (!(wrappeeElement instanceof NavigationItem)) {
    throw new IllegalArgumentException();
  }
  if (!(wrappeeElement instanceof PsiMetaOwner)) {
    throw new IllegalArgumentException();
  }
  myWrappee = wrappeeElement;
  final PsiFile file = getContainingFile();
  myFileName = file != null ? file.getName() : null;
  final PsiDirectory dir = file != null ? file.getContainingDirectory() : null;
  myDirName = dir != null ? dir.getName() : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:ValueResourceElementWrapper.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java XSTerm类代码示例发布时间:2022-05-22
下一篇:
Java BlockDoorBirch类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap