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


Java StubBasedPsiElement类代码示例

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


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

示例1: LocalSearchScope

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
public LocalSearchScope(@NotNull PsiElement[] scope, @Nullable final String displayName, final boolean ignoreInjectedPsi) {
  myIgnoreInjectedPsi = ignoreInjectedPsi;
  myDisplayName = displayName;
  Set<PsiElement> localScope = new LinkedHashSet<PsiElement>(scope.length);

  for (final PsiElement element : scope) {
    LOG.assertTrue(element != null, "null element");
    LOG.assertTrue(element.getContainingFile() != null, element.getClass().getName());
    if (element instanceof PsiFile) {
      for (PsiFile file : ((PsiFile)element).getViewProvider().getAllFiles()) {
        if (file == null) throw new IllegalArgumentException("file "+element+" returned null in its getAllFiles()");
        localScope.add(file);
      }
    }
    else if (element instanceof StubBasedPsiElement || element.getTextRange() != null){
      localScope.add(element);
    }
  }
  myScope = PsiUtilCore.toPsiElementArray(localScope);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:LocalSearchScope.java

示例2: createElementInfo

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Override
@Nullable
public SmartPointerElementInfo createElementInfo(@NotNull PsiElement element, @NotNull PsiFile containingFile) {
  if (element instanceof StubBasedPsiElement && containingFile instanceof PsiFileWithStubSupport) {
    PsiFileWithStubSupport stubFile = (PsiFileWithStubSupport)containingFile;
    StubTree stubTree = stubFile.getStubTree();
    if (stubTree != null) {
      // use stubs when tree is not loaded
      StubBasedPsiElement stubPsi = (StubBasedPsiElement)element;
      int stubId = PsiAnchor.calcStubIndex(stubPsi);
      IStubElementType myStubElementType = stubPsi.getElementType();
      IElementType contentElementType = ((PsiFileImpl)containingFile).getContentElementType();
      if (stubId != -1 && contentElementType instanceof IStubFileElementType) { // TemplateDataElementType is not IStubFileElementType
        return new AnchorElementInfo(element, stubFile, stubId, myStubElementType);
      }
    }
  }

  PsiElement anchor = getAnchor(element);
  if (anchor != null) {
    return new AnchorElementInfo(anchor, containingFile);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AnchorElementInfoFactory.java

示例3: getContainingClass

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
public PyClass getContainingClass() {
  final PyFunctionStub stub = getStub();
  if (stub != null) {
    final StubElement parentStub = stub.getParentStub();
    if (parentStub instanceof PyClassStub) {
      return ((PyClassStub)parentStub).getPsi();
    }

    return null;
  }

  final PsiElement parent = PsiTreeUtil.getParentOfType(this, StubBasedPsiElement.class);
  if (parent instanceof PyClass) {
    return (PyClass)parent;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PyFunctionImpl.java

示例4: createStub

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Nullable
private StubElement createStub(StubElement parentStub, ASTNode node) {
  IElementType nodeType = node.getElementType();

  if (nodeType instanceof IStubElementType) {
    final IStubElementType type = (IStubElementType)nodeType;

    if (type.shouldCreateStub(node)) {
      PsiElement element = node.getPsi();
      if (!(element instanceof StubBasedPsiElement)) {
        LOG.error("Non-StubBasedPsiElement requests stub creation. Stub type: " + type + ", PSI: " + element);
      }
      @SuppressWarnings("unchecked") StubElement stub = type.createStub(element, parentStub);
      //noinspection ConstantConditions
      LOG.assertTrue(stub != null, element);
      return stub;
    }
  }
  return null;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:21,代码来源:DefaultStubBuilder.java

示例5: findStubbedElementAtOffset

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Override
public StubBasedPsiElement findStubbedElementAtOffset(final int offset, final Class<? extends StubBasedPsiElement> clazz)
{
	final StubElement stub = getStub();

	if(stub != null)
	{
		final List<StubElement> children = stub.getChildrenStubs();

		for(StubElement child : children)
		{
			final PsiElement psi = child.getPsi();

			if(psi.getTextRange().getStartOffset() == offset && clazz.isInstance(psi))
			{
				return (StubBasedPsiElement) psi;
			}
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:22,代码来源:JSFileImpl.java

示例6: findTypeElement

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Nullable
@RequiredReadAction
public static JavaScriptTypeElement findTypeElement(@NotNull PsiElement element)
{
	if(element instanceof StubBasedPsiElement)
	{
		StubElement<?> stub = ((StubBasedPsiElement) element).getStub();
		if(stub != null)
		{
			List<StubElement> childrenStubs = stub.getChildrenStubs();
			for(StubElement childrenStub : childrenStubs)
			{
				IStubElementType stubType = childrenStub.getStubType();
				if(stubType instanceof BaseJavaScriptElementType)
				{
					return (JavaScriptTypeElement) stub.getPsi();
				}
			}
		}
	}

	return findChildrenByClass(element, JavaScriptTypeElement.class);
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:24,代码来源:JSPsiImplUtils.java

示例7: buildStubTreeFor

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@NotNull
protected StubElement buildStubTreeFor(@NotNull ASTNode root, @NotNull StubElement parentStub) {
  Stack<StubElement> parentStubs = new Stack<StubElement>();
  Stack<ASTNode> parentNodes = new Stack<ASTNode>();
  parentNodes.push(root);
  parentStubs.push(parentStub);

  while (!parentStubs.isEmpty()) {
    StubElement stub = parentStubs.pop();
    ASTNode node = parentNodes.pop();
    IElementType nodeType = node.getElementType();

    if (nodeType instanceof IStubElementType) {
      final IStubElementType type = (IStubElementType)nodeType;

      if (type.shouldCreateStub(node)) {
        PsiElement element = node.getPsi();
        if (!(element instanceof StubBasedPsiElement)) {
          LOG.error("Non-StubBasedPsiElement requests stub creation. Stub type: " + type + ", PSI: " + element);
        }
        @SuppressWarnings("unchecked") StubElement s = type.createStub(element, stub);
        stub = s;
        LOG.assertTrue(stub != null, element);
      }
    }

    for (ASTNode childNode = node.getLastChildNode(); childNode != null; childNode = childNode.getTreePrev()) {
      if (!skipChildProcessingWhenBuildingStubs(node, childNode)) {
        parentNodes.push(childNode);
        parentStubs.push(stub);
      }
    }
  }

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

示例8: getChildren

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Override
@NotNull
public Collection<AbstractTreeNode> getChildren() {
  if (ourSettingsModificationCount != modificationCountForChildren) {
    resetChildren();
    modificationCountForChildren = ourSettingsModificationCount;
  }

  final Object o = unwrapValue(getValue());
  long currentStamp = -1;
  if (o instanceof StubBasedPsiElement && ((StubBasedPsiElement)o).getStub() != null) {
    currentStamp = ((StubBasedPsiElement)o).getContainingFile().getModificationStamp();
  } else if (o instanceof PsiElement && ((PsiElement)o).getNode() instanceof CompositeElement) {
    currentStamp = ((CompositeElement)((PsiElement)o).getNode()).getModificationCount();
  } else if (o instanceof ModificationTracker) {
    currentStamp = ((ModificationTracker)o).getModificationCount();
  }
  if (childrenStamp != currentStamp) {
    resetChildren();
    childrenStamp = currentStamp;
  }
  try {
    return super.getChildren();
  }
  catch (IndexNotReadyException ignore) {
    return Collections.emptyList();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:StructureViewComponent.java

示例9: getContainer

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Nullable
@Override
public PsiElement getContainer(@NotNull PsiElement item) {
  if (item instanceof PyElement && item instanceof StubBasedPsiElement) {
    return getContainerByStub((StubBasedPsiElement)item);
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:PyContainerProvider.java

示例10: getContainerByStub

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Nullable
private static PsiElement getContainerByStub(@NotNull StubBasedPsiElement element) {
  final StubElement stub = element.getStub();
  if (stub != null) {
    final StubElement parentStub = stub.getParentStub();
    if (parentStub != null) {
      return parentStub.getPsi();
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PyContainerProvider.java

示例11: buildStubTreeFor

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
protected StubElement buildStubTreeFor(@NotNull ASTNode root, @NotNull StubElement parentStub) {
  Stack<StubElement> parentStubs = new Stack<StubElement>();
  Stack<ASTNode> parentNodes = new Stack<ASTNode>();
  parentNodes.push(root);
  parentStubs.push(parentStub);

  while (!parentStubs.isEmpty()) {
    StubElement stub = parentStubs.pop();
    ASTNode node = parentNodes.pop();
    IElementType nodeType = node.getElementType();

    if (nodeType instanceof IStubElementType) {
      final IStubElementType type = (IStubElementType)nodeType;

      if (type.shouldCreateStub(node)) {
        PsiElement element = node.getPsi();
        if (!(element instanceof StubBasedPsiElement)) {
          LOG.error("Non-StubBasedPsiElement requests stub creation. Stub type: " + type + ", PSI: " + element);
        }
        @SuppressWarnings("unchecked") StubElement s = type.createStub(element, stub);
        stub = s;
        LOG.assertTrue(stub != null, element);
      }
    }

    for (ASTNode childNode = node.getLastChildNode(); childNode != null; childNode = childNode.getTreePrev()) {
      if (!skipChildProcessingWhenBuildingStubs(node, childNode)) {
        parentNodes.push(childNode);
        parentStubs.push(stub);
      }
    }
  }

  return parentStub;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:36,代码来源:DefaultStubBuilder.java

示例12: createMaybeStubType

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@NotNull
public static DotNetType createMaybeStubType(@NotNull Project project, @NotNull String typeText, @Nullable DotNetType oldType)
{
	if(oldType instanceof StubBasedPsiElement)
	{
		CSharpFieldDeclaration field = createField(project, typeText + " _dummy");
		return field.getType();
	}
	else
	{
		CSharpLocalVariableDeclarationStatement statement = (CSharpLocalVariableDeclarationStatement) createStatement(project, typeText + " i;");
		CSharpLocalVariable localVariable = statement.getVariables()[0];
		return localVariable.getType();
	}
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:16,代码来源:CSharpFileFactory.java

示例13: isMemberInplaceRenameAvailable

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@Override
@RequiredReadAction
public boolean isMemberInplaceRenameAvailable(PsiElement element, PsiElement context)
{
	if(element instanceof DotNetParameter && element instanceof StubBasedPsiElement)
	{
		return true;
	}
	if(element instanceof CSharpTypeDeclaration && ((CSharpTypeDeclaration) element).hasModifier(CSharpModifier.PARTIAL))
	{
		return false;
	}
	return element instanceof DotNetQualifiedElement && !(element instanceof DotNetNamespaceAsElement);
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:15,代码来源:CSharpRefactoringSupportProvider.java

示例14: countChildrenOfType

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
public static int countChildrenOfType(@NotNull StubBasedPsiElement<?> psiElement, @NotNull Class<? extends PsiElement> classOfElement)
{
	StubElement stub = psiElement.getStub();
	if(stub != null)
	{
		return countChildrenOfType(stub, classOfElement);
	}
	return countChildrenOfType(psiElement.getNode(), classOfElement);
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:10,代码来源:DotNetPsiCountUtil.java

示例15: hasAttribute

import com.intellij.psi.StubBasedPsiElement; //导入依赖的package包/类
@RequiredReadAction
public static boolean hasAttribute(@NotNull final PsiElement owner, @NotNull final String qName)
{
	ConcurrentMap<String, CachedValue<Boolean>> map = owner.getUserData(ourAttributesKey);
	if(map == null)
	{
		owner.putUserData(ourAttributesKey, map = new ConcurrentHashMap<String, CachedValue<Boolean>>());
	}

	CachedValue<Boolean> provider = map.get(qName);
	if(provider != null)
	{
		return provider.getValue();
	}
	else
	{
		provider = CachedValuesManager.getManager(owner.getProject()).createCachedValue(new CachedValueProvider<Boolean>()
		{
			@Nullable
			@Override
			@RequiredReadAction
			public Result<Boolean> compute()
			{
				Key key =  PsiModificationTracker.MODIFICATION_COUNT;
				if(owner instanceof StubBasedPsiElement)
				{
					key = PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT;
				}
				return Result.create(findAttribute(owner, qName) != null, key);
			}
		}, false);
		map.putIfAbsent(qName, provider);
		return provider.getValue();
	}
}
 
开发者ID:consulo,项目名称:consulo-dotnet,代码行数:36,代码来源:DotNetAttributeUtil.java


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