本文整理汇总了Java中com.intellij.util.ArrayUtil.getLastElement方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayUtil.getLastElement方法的具体用法?Java ArrayUtil.getLastElement怎么用?Java ArrayUtil.getLastElement使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.util.ArrayUtil
的用法示例。
在下文中一共展示了ArrayUtil.getLastElement方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildAlignment
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private Alignment getChildAlignment() {
if (ourListElementTypes.contains(myNode.getElementType())) {
if (isInControlStatement()) {
return null;
}
if (myNode.getPsi() instanceof PyParameterList && !myContext.getSettings().ALIGN_MULTILINE_PARAMETERS) {
return null;
}
if (myNode.getPsi() instanceof PyDictLiteralExpression) {
final PyKeyValueExpression lastElement = ArrayUtil.getLastElement(((PyDictLiteralExpression)myNode.getPsi()).getElements());
if (lastElement == null || lastElement.getValue() == null /* incomplete */) {
return null;
}
}
return getAlignmentForChildren();
}
return null;
}
示例2: checkReferences
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static void checkReferences(PsiElement psiElement, ProblemsHolder holder) {
PsiReference[] references = psiElement.getReferences();
PsiReference last = ArrayUtil.getLastElement(references);
if (last != null && (!(last instanceof ResolvingHint) || ((ResolvingHint)last).canResolveTo(PsiDocCommentOwner.class))) {
PsiElement resolve = last.resolve();
DeprecationInspection.checkDeprecated(resolve, psiElement, last.getRangeInElement(), holder);
}
}
示例3: doApply
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public void doApply(@NotNull Editor editor, @NotNull PySmartEnterProcessor processor, @NotNull PyWithStatement withStatement) throws IncorrectOperationException {
final PsiElement colonToken = PyPsiUtils.getFirstChildOfType(withStatement, PyTokenTypes.COLON);
final PsiElement withToken = PyPsiUtils.getFirstChildOfType(withStatement, PyTokenTypes.WITH_KEYWORD);
final Document document = editor.getDocument();
if (colonToken == null && withToken != null) {
int insertAt = withToken.getTextRange().getEndOffset();
String textToInsert = ":";
final PyWithItem lastItem = ArrayUtil.getLastElement(withStatement.getWithItems());
if (lastItem == null || lastItem.getExpression() == null) {
textToInsert = " :";
processor.registerUnresolvedError(insertAt + 1);
}
else {
final PyExpression expression = lastItem.getExpression();
insertAt = expression.getTextRange().getEndOffset();
final PsiElement asToken = PyPsiUtils.getFirstChildOfType(lastItem, PyTokenTypes.AS_KEYWORD);
if (asToken != null) {
insertAt = asToken.getTextRange().getEndOffset();
final PyExpression target = lastItem.getTarget();
if (target != null) {
insertAt = target.getTextRange().getEndOffset();
}
else {
textToInsert = " :";
processor.registerUnresolvedError(insertAt + 1);
}
}
}
document.insertString(insertAt, textToInsert);
}
}
示例4: isLastStatementOfMethodOrClosure
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
private static boolean isLastStatementOfMethodOrClosure(GrStatement[] statements) {
final GrStatement statement0 = statements[0];
PsiElement returnFrom = PsiTreeUtil.getParentOfType(statement0, GrMethod.class, GrClosableBlock.class, GroovyFile.class);
if (returnFrom instanceof GrMethod) {
returnFrom = ((GrMethod)returnFrom).getBlock();
}
LOG.assertTrue(returnFrom instanceof GrStatementOwner);
final GrStatement[] blockStatements = ((GrStatementOwner)returnFrom).getStatements();
final GrStatement lastFromBlock = ArrayUtil.getLastElement(blockStatements);
final GrStatement lastStatement = ArrayUtil.getLastElement(statements);
return statement0.getManager().areElementsEquivalent(lastFromBlock, lastStatement);
}
示例5: getAnchorForArgument
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Nullable
private static GrExpression getAnchorForArgument(GrExpression[] oldArgs, boolean isVarArg, PsiParameterList parameterList) {
if (!isVarArg) return ArrayUtil.getLastElement(oldArgs);
final PsiParameter[] parameters = parameterList.getParameters();
if (parameters.length > oldArgs.length) return ArrayUtil.getLastElement(oldArgs);
final int lastNonVararg = parameters.length - 2;
return lastNonVararg >= 0 ? oldArgs[lastNonVararg] : null;
}
示例6: getModuleDefinitions
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@NotNull
private List<MuleModuleDefinition> getModuleDefinitions(Project project, GlobalSearchScope searchScope) {
final List<MuleModuleDefinition> result = new ArrayList<>();
final Collection<VirtualFile> files = FileTypeIndex.getFiles(XmlFileType.INSTANCE, searchScope);
for (VirtualFile file : files) {
final PsiFile xmlFile = PsiManager.getInstance(project).findFile(file);
if (xmlFile != null && isMuleSchema(xmlFile)) {
// System.out.println("xmlFile = " + xmlFile.getName());
final PsiElement[] children = xmlFile.getChildren();
final XmlTag rootTag = ((XmlDocument) children[0]).getRootTag();
if (rootTag != null) {
final String namespace = getNamespace(rootTag);
final String name = ArrayUtil.getLastElement(namespace.split("/"));
// System.out.println("namespace = " + namespace);
// System.out.println("name = " + name);
final XmlTag[] elements = rootTag.findSubTags("element", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA);
final List<MuleElementDefinition> definitions = new ArrayList<>();
for (XmlTag element : elements) {
final String elementName = element.getAttributeValue("name");
// System.out.println("name = " + elementName);
final MuleElementType muleElementType = MuleSchemaUtils.getMuleElementTypeFromElement(element);
if (muleElementType != null) {
String description = "";
final XmlTag annotation = ArrayUtil.getFirstElement(element.findSubTags("annotation", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA));
if (annotation != null) {
final XmlTag documentation = ArrayUtil.getFirstElement(annotation.findSubTags("documentation", MuleSchemaUtils.HTTP_WWW_W3_ORG_2001_XMLSCHEMA));
if (documentation != null) {
description = documentation.getValue().getText();
}
}
definitions.add(new MuleElementDefinition(element, elementName, description, muleElementType));
// System.out.println("muleElementType = " + muleElementType);
// System.out.println("description = " + description);
}
}
result.add(new MuleModuleDefinition(name, StringUtil.capitalize(name), namespace, xmlFile, definitions));
}
}
}
return result;
}
示例7: isCertainlyReturnStatement
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
/**
* check whether statement is return (the statement which provides return value) statement of method or closure.
*
* @param st
* @return
*/
public static boolean isCertainlyReturnStatement(GrStatement st) {
final PsiElement parent = st.getParent();
if (parent instanceof GrOpenBlock) {
if (st != ArrayUtil.getLastElement(((GrOpenBlock)parent).getStatements())) return false;
PsiElement pparent = parent.getParent();
if (pparent instanceof GrMethod) {
return true;
}
if (pparent instanceof GrBlockStatement || pparent instanceof GrCatchClause || pparent instanceof GrLabeledStatement) {
pparent = pparent.getParent();
}
if (pparent instanceof GrIfStatement || pparent instanceof GrControlStatement || pparent instanceof GrTryCatchStatement) {
return isCertainlyReturnStatement((GrStatement)pparent);
}
}
else if (parent instanceof GrClosableBlock) {
return st == ArrayUtil.getLastElement(((GrClosableBlock)parent).getStatements());
}
else if (parent instanceof GroovyFileBase) {
return st == ArrayUtil.getLastElement(((GroovyFileBase)parent).getStatements());
}
else if (parent instanceof GrForStatement ||
parent instanceof GrIfStatement && st != ((GrIfStatement)parent).getCondition() ||
parent instanceof GrSynchronizedStatement && st != ((GrSynchronizedStatement)parent).getMonitor() ||
parent instanceof GrWhileStatement && st != ((GrWhileStatement)parent).getCondition() ||
parent instanceof GrConditionalExpression && st != ((GrConditionalExpression)parent).getCondition() ||
parent instanceof GrElvisExpression) {
return isCertainlyReturnStatement((GrStatement)parent);
}
else if (parent instanceof GrCaseSection) {
final GrStatement[] statements = ((GrCaseSection)parent).getStatements();
final GrStatement last = ArrayUtil.getLastElement(statements);
final GrSwitchStatement switchStatement = (GrSwitchStatement)parent.getParent();
if (last instanceof GrBreakStatement && statements.length > 1 && statements[statements.length - 2] == st) {
return isCertainlyReturnStatement(switchStatement);
}
else if (st == last) {
if (st instanceof GrBreakStatement || isLastStatementInCaseSection((GrCaseSection)parent, switchStatement)) {
return isCertainlyReturnStatement(switchStatement);
}
}
}
return false;
}
示例8: isVarargs
import com.intellij.util.ArrayUtil; //导入方法依赖的package包/类
@Override
public boolean isVarargs() {
GrParameter last = ArrayUtil.getLastElement(myBlock.getAllParameters());
return last != null && last.getType() instanceof PsiArrayType;
}