use of org.elixir_lang.psi.QuotableKeywordList in project intellij-elixir by KronicDeth.
the class Overridable method getChildren.
/**
* Returns the list of children of the tree element.
*
* @return the list of children.
*/
@NotNull
@Override
public TreeElement[] getChildren() {
QuotableKeywordList keywordArguments = keywordArguments(navigationItem);
TreeElement[] children;
if (keywordArguments != null) {
List<QuotableKeywordPair> quotableKeywordPairList = keywordArguments.quotableKeywordPairList();
List<TreeElement> treeElementList = new ArrayList<TreeElement>(quotableKeywordPairList.size());
for (QuotableKeywordPair quotableKeywordPair : quotableKeywordPairList) {
Quotable keywordKey = quotableKeywordPair.getKeywordKey();
OtpErlangObject quotedKeywordKey = keywordKey.quote();
String name;
if (quotedKeywordKey instanceof OtpErlangAtom) {
OtpErlangAtom keywordKeyAtom = (OtpErlangAtom) quotedKeywordKey;
name = keywordKeyAtom.atomValue();
} else {
name = keywordKey.getText();
}
Quotable keywordValue = quotableKeywordPair.getKeywordValue();
OtpErlangObject quotedKeywordValue = keywordValue.quote();
Integer arity = null;
if (quotedKeywordValue instanceof OtpErlangLong) {
OtpErlangLong keywordValueErlangLong = (OtpErlangLong) quotedKeywordValue;
try {
arity = keywordValueErlangLong.intValue();
} catch (OtpErlangRangeException e) {
arity = null;
}
}
boolean overridable = true;
// noinspection ConstantConditions
treeElementList.add(new CallReference(modular, quotableKeywordPair, Timed.Time.RUN, overridable, name, arity));
}
children = treeElementList.toArray(new TreeElement[treeElementList.size()]);
} else {
children = new TreeElement[0];
}
return children;
}
use of org.elixir_lang.psi.QuotableKeywordList 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 = 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.QuotableKeywordList in project intellij-elixir by KronicDeth.
the class FieldWithDefaultValue method is.
/*
* Static Methods
*/
public static boolean is(QuotableKeywordPair quotableKeywordPair) {
boolean fieldWithDefaultValue = false;
PsiElement parent = quotableKeywordPair.getParent();
if (parent instanceof QuotableKeywordList) {
PsiElement grandParent = parent.getParent();
if (grandParent instanceof ElixirNoParenthesesOneArgument) {
PsiElement greatGrandParent = grandParent.getParent();
if (greatGrandParent instanceof Call) {
Call greatGrandParentCall = (Call) greatGrandParent;
fieldWithDefaultValue = Structure.is(greatGrandParentCall);
}
}
}
return fieldWithDefaultValue;
}
Aggregations