本文整理汇总了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;
}
示例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;
}
示例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() {}
};
}
};
}
示例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);
}
示例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;
}
示例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()
{
}
};
}
};
}