use of org.elixir_lang.psi.ElixirList in project intellij-elixir by KronicDeth.
the class Exception method defaultValueElementByKeyElement.
/**
* The default value elements for the struct defined for the exception.
*
* @return Maps the element for the key in the struct to the element in the default value. When the list form of
* fields without default values is used, the Map value element is {@code null}.
*/
@NotNull
public Map<PsiElement, PsiElement> defaultValueElementByKeyElement() {
PsiElement[] finalArguments = ElixirPsiImplUtil.finalArguments(navigationItem);
assert finalArguments != null;
assert finalArguments.length == 1;
PsiElement finalArgument = finalArguments[0];
Map<PsiElement, PsiElement> defaultValueElementByKeyElement = new HashMap<PsiElement, PsiElement>(finalArguments.length);
if (finalArgument instanceof ElixirAccessExpression) {
PsiElement accessExpressionChild = stripAccessExpression(finalArgument);
assert accessExpressionChild instanceof ElixirList;
ElixirList list = (ElixirList) accessExpressionChild;
PsiElement[] listChildren = list.getChildren();
if (listChildren.length == 1) {
PsiElement listChild = listChildren[0];
if (listChild instanceof QuotableKeywordList) {
QuotableKeywordList quotableKeywordList = (QuotableKeywordList) listChild;
putQuotableKeywordList(defaultValueElementByKeyElement, quotableKeywordList);
} else {
defaultValueElementByKeyElement.put(listChild, null);
}
} else {
for (PsiElement key : list.getChildren()) {
defaultValueElementByKeyElement.put(key, null);
}
}
} else if (finalArgument instanceof QuotableKeywordList) {
QuotableKeywordList quotableKeywordList = (QuotableKeywordList) finalArgument;
putQuotableKeywordList(defaultValueElementByKeyElement, quotableKeywordList);
} else {
assert finalArgument != null;
}
return defaultValueElementByKeyElement;
}
use of org.elixir_lang.psi.ElixirList in project intellij-elixir by KronicDeth.
the class Delegation method callDefinitionHeadCallList.
/*
* Static Methods
*/
public static List<Call> callDefinitionHeadCallList(Call defdelegateCall) {
List<Call> callDefinitionHeadCallList = null;
PsiElement[] finalArguments = ElixirPsiImplUtil.finalArguments(defdelegateCall);
assert finalArguments != null;
assert finalArguments.length > 0;
PsiElement firstFinalArgument = finalArguments[0];
if (firstFinalArgument instanceof ElixirAccessExpression) {
PsiElement accessExpressionChild = stripAccessExpression(firstFinalArgument);
if (accessExpressionChild instanceof ElixirList) {
ElixirList list = (ElixirList) accessExpressionChild;
Call[] listCalls = PsiTreeUtil.getChildrenOfType(list, Call.class);
callDefinitionHeadCallList = filterCallDefinitionHeadCallList(listCalls);
}
} else if (firstFinalArgument instanceof Call) {
Call call = (Call) firstFinalArgument;
callDefinitionHeadCallList = filterCallDefinitionHeadCallList(call);
}
if (callDefinitionHeadCallList == null) {
callDefinitionHeadCallList = Collections.emptyList();
}
return callDefinitionHeadCallList;
}
use of org.elixir_lang.psi.ElixirList in project intellij-elixir by KronicDeth.
the class Field method is.
/*
* Static Methods
*/
public static boolean is(ElixirAtom atom) {
boolean field = false;
PsiElement parent = atom.getParent();
if (parent instanceof ElixirAccessExpression && parent.getChildren().length == 1) {
PsiElement grandParent = parent.getParent();
if (grandParent instanceof ElixirList) {
PsiElement greatGrandParent = grandParent.getParent();
if (greatGrandParent instanceof ElixirAccessExpression && greatGrandParent.getChildren().length == 1) {
PsiElement greatGreatGrandParent = greatGrandParent.getParent();
if (greatGreatGrandParent instanceof ElixirNoParenthesesOneArgument) {
PsiElement greatGreatGreatGrandParent = greatGreatGrandParent.getParent();
if (greatGreatGreatGrandParent instanceof Call) {
Call greatGreatGreatGrandParentCall = (Call) greatGreatGreatGrandParent;
field = Structure.is(greatGreatGreatGrandParentCall);
}
}
}
}
}
return field;
}
Aggregations