當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。