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


Java PsiElementFilter类代码示例

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


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

示例1: resolve

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public RegExpGroup resolve() {
    final int index = getIndex();

    final PsiElementProcessor.FindFilteredElement<RegExpElement> processor = new PsiElementProcessor.FindFilteredElement<RegExpElement>(new PsiElementFilter() {
        int groupCount;

        public boolean isAccepted(PsiElement element) {
            if (element instanceof RegExpGroup) {
                if (((RegExpGroup)element).isCapturing() && ++groupCount == index) {
                    return true;
                }
            }
            return element == RegExpBackrefImpl.this;
        }
    });

    PsiTreeUtil.processElements(getContainingFile(), processor);
    if (processor.getFoundElement() instanceof RegExpGroup) {
        return (RegExpGroup)processor.getFoundElement();
    }
    return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:RegExpBackrefImpl.java

示例2: resolve

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
@Nullable
public RegExpGroup resolve() {
  final PsiElementProcessor.FindFilteredElement<RegExpGroup> processor = new PsiElementProcessor.FindFilteredElement<RegExpGroup>(
    new PsiElementFilter() {
      public boolean isAccepted(PsiElement element) {
        if (!(element instanceof RegExpGroup)) {
          return false;
        }
        final RegExpGroup regExpGroup = (RegExpGroup)element;
        return (regExpGroup.isPythonNamedGroup() || regExpGroup.isRubyNamedGroup()) &&
               Comparing.equal(getGroupName(), regExpGroup.getGroupName());
      }
    }
  );
  PsiTreeUtil.processElements(getContainingFile(), processor);
  return processor.getFoundElement();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:RegExpNamedGroupRefImpl.java

示例3: loadImportedTags

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static List<String> loadImportedTags(@NotNull XmlFile file, @NotNull XmlTag context) {
//        PsiElement[] arr = file.getRootTag().getChildren();
//        Collection<HtmlTag> tags = PsiTreeUtil.findChildrenOfType(file, HtmlTag.class);
        PsiElement[] reqTags = PsiTreeUtil.collectElements(file, new PsiElementFilter() {
            @Override
            public boolean isAccepted(PsiElement element) {
                return element instanceof HtmlTag && (((HtmlTag) element).getName().equals(RTTagDescriptorsProvider.RT_REQUIRE) || ((HtmlTag) element).getName().equals(RTTagDescriptorsProvider.RT_IMPORT));
            }
        });

        List<String> importedTags = new ArrayList<String>();
        for (PsiElement elem : reqTags) {
            String as = ((HtmlTag) elem).getAttributeValue("as");
            if (!Strings.isNullOrEmpty(as)) {
                importedTags.add(as);
            }
        }
        return importedTags;
    }
 
开发者ID:idok,项目名称:react-templates-plugin,代码行数:20,代码来源:RTHtmlExtension.java

示例4: getMethodParameterReferences

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
@Nullable
public static PsiElement[] getMethodParameterReferences(Method method, int parameterIndex) {

    // we dont have a parameter on resolved method
    Parameter[] parameters = method.getParameters();
    if(parameters.length == 0 || parameterIndex >= parameters.length) {
        return null;
    }

    final String tempVariableName = parameters[parameterIndex].getName();
    return PsiTreeUtil.collectElements(method.getLastChild(), new PsiElementFilter() {
        @Override
        public boolean isAccepted(PsiElement element) {
            return element instanceof Variable && tempVariableName.equals(((Variable) element).getName());
        }
    });

}
 
开发者ID:Haehnchen,项目名称:idea-php-laravel-plugin,代码行数:19,代码来源:PhpElementsUtil.java

示例5: resolve

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
@Nullable
public RegExpGroup resolve() {
  final PsiElementProcessor.FindFilteredElement<RegExpElement> processor = new PsiElementProcessor.FindFilteredElement<RegExpElement>(new PsiElementFilter() {
      public boolean isAccepted(PsiElement element) {
          if (element instanceof RegExpGroup) {
              if (((RegExpGroup)element).isPythonNamedGroup() && Comparing.equal(getGroupName(), ((RegExpGroup)element).getGroupName())) {
                  return true;
              }
          }
          return element == RegExpPyNamedGroupRefImpl.this;
      }
  });

  PsiTreeUtil.processElements(getContainingFile(), processor);
  if (processor.getFoundElement() instanceof RegExpGroup) {
      return (RegExpGroup) processor.getFoundElement();
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:RegExpPyNamedGroupRefImpl.java

示例6: collectPackageLocalMembers

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
private static PsiElement[] collectPackageLocalMembers(PsiElement classToMove) {
  return PsiTreeUtil.collectElements(classToMove, new PsiElementFilter() {
    public boolean isAccepted(final PsiElement element) {
      if (element instanceof PsiMember) {
        PsiMember member = (PsiMember) element;
        if (VisibilityUtil.getVisibilityModifier(member.getModifierList()) == PsiModifier.PACKAGE_LOCAL) {
          return true;
        }
      }
      return false;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:MoveClassToInnerProcessor.java

示例7: checkReturnValueAllowed

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
private void checkReturnValueAllowed(PyCallable callable, PsiElement beingChecked, boolean allowed, String message) {
  // TODO: use a real flow analysis to check all exit points
  boolean hasReturns;
  if (callable instanceof PyFunction) {
    final PsiElement[] returnStatements = PsiTreeUtil.collectElements(callable, new PsiElementFilter() {
      @Override
      public boolean isAccepted(PsiElement element) {
        return (element instanceof PyReturnStatement && ((PyReturnStatement)element).getExpression() != null) ||
               (element instanceof PyYieldExpression);
      }
    });
    hasReturns = returnStatements.length > 0;
  }
  else {
    final PyType type = myTypeEvalContext.getReturnType(callable);
    hasReturns = !(type instanceof PyNoneType);
  }
  if (allowed ^ hasReturns) {
    if (allowed && callable instanceof PyFunction) {
      if (PyUtil.isDecoratedAsAbstract(((PyFunction)callable))) {
        return;
      }
      // one last chance: maybe there's no return but a 'raise' statement, see PY-4043, PY-5048
      PyStatementList statementList = ((PyFunction)callable).getStatementList();
      for (PyStatement stmt : statementList.getStatements()) {
        if (stmt instanceof PyRaiseStatement) {
          return;
        }
      }
    }
    registerProblem(beingChecked, message);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:PyPropertyDefinitionInspection.java

示例8: suggestVariableNameFromLiterals

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
@Nullable
private String[] suggestVariableNameFromLiterals(PsiExpression expr, VariableKind variableKind, boolean correctKeywords) {
  final PsiElement[] literals = PsiTreeUtil.collectElements(expr, new PsiElementFilter() {
    @Override
    public boolean isAccepted(PsiElement element) {
      if (isStringPsiLiteral(element) && StringUtil.isJavaIdentifier(StringUtil.unquoteString(element.getText()))) {
        final PsiElement exprList = element.getParent();
        if (exprList instanceof PsiExpressionList) {
          final PsiElement call = exprList.getParent();
          if (call instanceof PsiNewExpression) {
            return true;
          } else if (call instanceof PsiMethodCallExpression) {
            //TODO: exclude or not getA().getB("name").getC(); or getA(getB("name").getC()); It works fine for now in the most cases
            return true;
          }
        }
      }
      return false;
    }
  });

  if (literals.length == 1) {
    final String text = StringUtil.unquoteString(literals[0].getText());
    return getSuggestionsByName(text, variableKind, expr.getType() instanceof PsiArrayType, correctKeywords);
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:28,代码来源:JavaCodeStyleManagerImpl.java

示例9: findChildrenOfType

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static PsiElement[] findChildrenOfType(PsiElement startingElement, final IElementType elementType) {
    return PsiTreeUtil.collectElements(startingElement, new PsiElementFilter() {
        @Override
        public boolean isAccepted(PsiElement element) {
            return element.getNode() != null && element.getNode().getElementType() == elementType;
        }
    });
}
 
开发者ID:ligasgr,项目名称:intellij-xquery,代码行数:9,代码来源:XQueryPsiImplUtil.java

示例10: findRuleSpecNode

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static PsiElement findRuleSpecNode(final String ruleName, RulesNode rules) {
	PsiElementFilter defnode = new PsiElementFilter() {
		@Override
		public boolean isAccepted(PsiElement element) {
			PsiElement nameNode = element.getFirstChild();
			if ( nameNode==null ) return false;
			return (element instanceof ParserRuleSpecNode || element instanceof LexerRuleSpecNode) &&
				   nameNode.getText().equals(ruleName);
		}
	};
	PsiElement[] ruleSpec = PsiTreeUtil.collectElements(rules, defnode);
	if ( ruleSpec.length>0 ) return ruleSpec[0];
	return null;
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:15,代码来源:MyPsiUtils.java

示例11: collectAtActions

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static PsiElement[] collectAtActions(PsiElement root, final String tokenText) {
	return PsiTreeUtil.collectElements(root, new PsiElementFilter() {
		@Override
		public boolean isAccepted(PsiElement element) {
			PsiElement p = element.getContext();
			if (p != null) p = p.getContext();
			return p instanceof AtAction &&
				element instanceof ParserRuleRefNode &&
				element.getText().equals(tokenText);
		}
	});
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:13,代码来源:MyPsiUtils.java

示例12: collectNodesWithName

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
/** Search all internal and leaf nodes looking for token or internal node
 *  with specific text.
 *  This saves having to create lots of java classes just to identify psi nodes.
 */
public static PsiElement[] collectNodesWithName(PsiElement root, final String tokenText) {
	return PsiTreeUtil.collectElements(root, new PsiElementFilter() {
		@Override
		public boolean isAccepted(PsiElement element) {
			String tokenTypeName = element.getNode().getElementType().toString();
			return tokenTypeName.equals(tokenText);
		}
	});
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:14,代码来源:MyPsiUtils.java

示例13: collectNodesWithText

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static PsiElement[] collectNodesWithText(PsiElement root, final String text) {
	return PsiTreeUtil.collectElements(root, new PsiElementFilter() {
		@Override
		public boolean isAccepted(PsiElement element) {
			return element.getText().equals(text);
		}
	});
}
 
开发者ID:antlr,项目名称:intellij-plugin-v4,代码行数:9,代码来源:MyPsiUtils.java

示例14: getValues

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static PsiElement[] getValues(LIDValues element) {
  return PsiTreeUtil.collectElements(element, new PsiElementFilter() {
    @Override
    public boolean isAccepted(PsiElement e) {
      return (e.getNode().getElementType() == LIDTypes.VALUE);
    }
  });
}
 
开发者ID:dylan-foundry,项目名称:DeftIDEA,代码行数:9,代码来源:LIDPsiImplUtil.java

示例15: getValues

import com.intellij.psi.util.PsiElementFilter; //导入依赖的package包/类
public static PsiElement[] getValues(DylanHeaderValues element) {
  return PsiTreeUtil.collectElements(element, new PsiElementFilter() {
    @Override
    public boolean isAccepted(PsiElement e) {
      return (e.getNode().getElementType() == DylanTypes.VALUE);
    }
  });
}
 
开发者ID:dylan-foundry,项目名称:DeftIDEA,代码行数:9,代码来源:DylanPsiImplUtil.java


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