use of org.elixir_lang.psi.QuotableKeywordPair in project intellij-elixir by KronicDeth.
the class Exception method putQuotableKeywordList.
private void putQuotableKeywordList(Map<PsiElement, PsiElement> defaultValueElementByKeyElement, QuotableKeywordList quotableKeywordList) {
for (QuotableKeywordPair quotableKeywordPair : quotableKeywordList.quotableKeywordPairList()) {
PsiElement keyElement = quotableKeywordPair.getKeywordKey();
PsiElement valueElement = quotableKeywordPair.getKeywordValue();
defaultValueElementByKeyElement.put(keyElement, valueElement);
}
}
use of org.elixir_lang.psi.QuotableKeywordPair 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 = ElixirPsiImplUtil.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.QuotableKeywordPair in project intellij-elixir by KronicDeth.
the class Model method isSuitable.
@Override
protected boolean isSuitable(PsiElement element) {
boolean suitable = false;
// checks if the class is good
if (super.isSuitable(element)) {
// calls can be nested in calls, so need to check for sure
if (element instanceof Call) {
Call call = (Call) element;
suitable = isSuitable(call);
} else if (element instanceof ElixirAtom) {
ElixirAtom atom = (ElixirAtom) element;
suitable = Field.is(atom);
} else if (element instanceof QuotableKeywordPair) {
QuotableKeywordPair quotableKeywordPair = (QuotableKeywordPair) element;
suitable = FieldWithDefaultValue.is(quotableKeywordPair);
}
}
return suitable;
}
Aggregations