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


Java EmptyIterable类代码示例

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


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

示例1: typeParametersIterable

import com.intellij.util.containers.EmptyIterable; //导入依赖的package包/类
@NotNull
public static Iterable<PsiTypeParameter> typeParametersIterable(@NotNull final PsiTypeParameterListOwner owner) {
  List<PsiTypeParameter> result = null;

  PsiTypeParameterListOwner currentOwner = owner;
  while (currentOwner != null) {
    PsiTypeParameter[] typeParameters = currentOwner.getTypeParameters();
    if (typeParameters.length > 0) {
      if (result == null) result = new ArrayList<PsiTypeParameter>(typeParameters.length);
      for (int i = typeParameters.length - 1; i >= 0; i--) {
        result.add(typeParameters[i]);
      }
    }

    if (currentOwner.hasModifierProperty(PsiModifier.STATIC)) break;
    currentOwner = currentOwner.getContainingClass();
  }

  if (result == null) return EmptyIterable.getInstance();
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PsiUtil.java

示例2: typeParametersIterable

import com.intellij.util.containers.EmptyIterable; //导入依赖的package包/类
@NotNull
public static Iterable<PsiTypeParameter> typeParametersIterable(@NotNull final PsiTypeParameterListOwner owner) {
  ArrayList<PsiTypeParameter> result = null;

  PsiTypeParameterListOwner currentOwner = owner;
  while (currentOwner != null) {
    PsiTypeParameter[] typeParameters = currentOwner.getTypeParameters();
    if (typeParameters.length > 0) {
      if (result == null) result = new ArrayList<PsiTypeParameter>(typeParameters.length);
      for (int i = typeParameters.length - 1; i >= 0; i--) {
        result.add(typeParameters[i]);
      }
    }

    if (currentOwner.hasModifierProperty(PsiModifier.STATIC)) break;
    currentOwner = currentOwner.getContainingClass();
  }

  if (result == null) return EmptyIterable.getInstance();
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:PsiUtil.java

示例3: getLineElements

import com.intellij.util.containers.EmptyIterable; //导入依赖的package包/类
private static Iterable<PsiElement> getLineElements(final PsiFile file, int lineNumber) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
  if (document == null || lineNumber >= document.getLineCount()) {
    return EmptyIterable.getInstance();
  }
  final TextRange lineRange = DocumentUtil.getLineTextRange(document, lineNumber);
  return new Iterable<PsiElement>() {
    @Override
    public Iterator<PsiElement> iterator() {
      return new Iterator<PsiElement>() {
        PsiElement myElement = DebuggerUtilsEx.findElementAt(file, lineRange.getStartOffset());

        @Override
        public boolean hasNext() {
          return myElement != null;
        }

        @Override
        public PsiElement next() {
          PsiElement res = myElement;
          do {
            myElement = PsiTreeUtil.nextLeaf(myElement);
            if (myElement == null || myElement.getTextOffset() > lineRange.getEndOffset()) {
              myElement = null;
              break;
            }
          } while (myElement.getTextLength() == 0);
          return res;
        }

        @Override
        public void remove() {}
      };
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:PositionManagerImpl.java

示例4: iterateNames

import com.intellij.util.containers.EmptyIterable; //导入依赖的package包/类
@NotNull
public Iterable<PyElement> iterateNames() {
  PyElement ret = getAsNameElement();
  if (ret == null) {
    final PyReferenceExpression importReference = getImportReferenceExpression();
    if (importReference != null) {
      ret = PyPsiUtils.getFirstQualifier(importReference);
    }
  }
  if (ret == null) {
    return EmptyIterable.getInstance();
  }
  return Collections.singleton(ret);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PyImportElementImpl.java

示例5: typeParametersIterable

import com.intellij.util.containers.EmptyIterable; //导入依赖的package包/类
@NotNull
public static Iterable<PsiTypeParameter> typeParametersIterable(@NotNull final PsiTypeParameterListOwner owner)
{
	List<PsiTypeParameter> result = null;

	PsiTypeParameterListOwner currentOwner = owner;
	while(currentOwner != null)
	{
		PsiTypeParameter[] typeParameters = currentOwner.getTypeParameters();
		if(typeParameters.length > 0)
		{
			if(result == null)
			{
				result = new ArrayList<PsiTypeParameter>(typeParameters.length);
			}
			for(int i = typeParameters.length - 1; i >= 0; i--)
			{
				result.add(typeParameters[i]);
			}
		}

		if(currentOwner.hasModifierProperty(PsiModifier.STATIC))
		{
			break;
		}
		currentOwner = currentOwner.getContainingClass();
	}

	if(result == null)
	{
		return EmptyIterable.getInstance();
	}
	return result;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:35,代码来源:PsiUtil.java

示例6: getLineElements

import com.intellij.util.containers.EmptyIterable; //导入依赖的package包/类
private static Iterable<PsiElement> getLineElements(final PsiFile file, int lineNumber)
{
	ApplicationManager.getApplication().assertReadAccessAllowed();
	Document document = PsiDocumentManager.getInstance(file.getProject()).getDocument(file);
	if(document == null || lineNumber < 0 || lineNumber >= document.getLineCount())
	{
		return EmptyIterable.getInstance();
	}
	final TextRange lineRange = DocumentUtil.getLineTextRange(document, lineNumber);
	return new Iterable<PsiElement>()
	{
		@Override
		public Iterator<PsiElement> iterator()
		{
			return new Iterator<PsiElement>()
			{
				PsiElement myElement = DebuggerUtilsEx.findElementAt(file, lineRange.getStartOffset());

				@Override
				public boolean hasNext()
				{
					return myElement != null;
				}

				@Override
				public PsiElement next()
				{
					PsiElement res = myElement;
					do
					{
						myElement = PsiTreeUtil.nextLeaf(myElement);
						if(myElement == null || myElement.getTextOffset() > lineRange.getEndOffset())
						{
							myElement = null;
							break;
						}
					}
					while(myElement.getTextLength() == 0);
					return res;
				}

				@Override
				public void remove()
				{
				}
			};
		}
	};
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:50,代码来源:PositionManagerImpl.java


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