use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method quote.
@Contract(pure = true)
@NotNull
public static OtpErlangObject quote(@NotNull final UnqualifiedBracketOperation unqualifiedBracketOperation) {
ASTNode node = unqualifiedBracketOperation.getNode();
OtpErlangObject quotedIdentifier = new OtpErlangAtom(node.getFirstChildNode().getText());
OtpErlangObject quotedContainer = quotedVariable(quotedIdentifier, metadata(unqualifiedBracketOperation));
Quotable bracketArguments = unqualifiedBracketOperation.getBracketArguments();
OtpErlangObject quotedBrackArguments = bracketArguments.quote();
return quotedFunctionCall("Elixir.Access", "get", metadata(bracketArguments), quotedContainer, quotedBrackArguments);
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method quote.
@Contract(pure = true)
@NotNull
public static OtpErlangObject quote(@NotNull final ElixirMultipleAliases multipleAliases) {
PsiElement[] children = multipleAliases.getChildren();
OtpErlangObject[] quotedChildren = new OtpErlangObject[children.length];
int i = 0;
for (PsiElement child : children) {
Quotable quotableChild = (Quotable) child;
quotedChildren[i++] = quotableChild.quote();
}
return quotedFunctionArguments(quotedChildren);
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method quote.
@Contract(pure = true)
@NotNull
public static OtpErlangObject quote(@NotNull final ElixirAtom atom) {
OtpErlangObject quoted;
ElixirCharListLine charListLine = atom.getCharListLine();
if (charListLine != null) {
quoted = charListLine.quoteAsAtom();
} else {
ElixirStringLine stringLine = atom.getStringLine();
if (stringLine != null) {
quoted = stringLine.quoteAsAtom();
} else {
ASTNode atomNode = atom.getNode();
ASTNode atomFragmentNode = atomNode.getLastChildNode();
assert atomFragmentNode.getElementType() == ElixirTypes.ATOM_FRAGMENT;
quoted = new OtpErlangAtom(atomFragmentNode.getText());
}
}
return quoted;
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method resolvedFinalArityRange.
@Contract(pure = true)
@NotNull
public static IntRange resolvedFinalArityRange(@NotNull final Call call) {
IntRange arityRange;
PsiElement[] finalArguments = ElixirPsiImplUtil.finalArguments(call);
if (finalArguments != null) {
int defaultCount = defaultArgumentCount(finalArguments);
int maximum = finalArguments.length;
int minimum = maximum - defaultCount;
arityRange = new IntRange(minimum, maximum);
} else {
arityRange = new IntRange(0);
}
return arityRange;
}
use of org.jetbrains.annotations.Contract in project intellij-elixir by KronicDeth.
the class ElixirPsiImplUtil method arguments.
@Contract(pure = true)
@NotNull
public static PsiElement[] arguments(@NotNull final ElixirNoParenthesesOneArgument noParenthesesOneArgument) {
PsiElement[] children = noParenthesesOneArgument.getChildren();
PsiElement[] arguments = children;
if (children.length == 1) {
PsiElement child = children[0];
if (child instanceof Arguments) {
Arguments childArguments = (Arguments) child;
arguments = childArguments.arguments();
}
}
return arguments;
}
Aggregations