use of org.elixir_lang.structure_view.element.modular.Modular in project intellij-elixir by KronicDeth.
the class EnclosingModularByCall method putNew.
/**
* Generates a {@link Modular} for the given {@code call} if it does not exist.
*
* @param call
* @return {@code null} if {@code call} is top-level and has no enclosing modular.
*/
@Nullable
public Modular putNew(@NotNull Call call) {
Modular modular;
if (containsKey(call)) {
modular = get(call);
} else {
modular = CallDefinitionClause.enclosingModular(call);
put(call, modular);
}
return modular;
}
use of org.elixir_lang.structure_view.element.modular.Modular in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsFromImplementation.
private void getItemsFromImplementation(@NotNull String name, @NotNull List<NavigationItem> items, @NotNull EnclosingModularByCall enclosingModularByCall, @NotNull Call call) {
Modular modular = enclosingModularByCall.putNew(call);
Collection<String> forNameCollection = Implementation.forNameCollection(modular, call);
if (forNameCollection != null) {
for (String forName : forNameCollection) {
Implementation forNameOverriddenImplementation = new Implementation(modular, call, forName);
String implementationName = forNameOverriddenImplementation.getName();
if (implementationName != null && implementationName.contains(name)) {
items.add(forNameOverriddenImplementation);
}
}
}
if (forNameCollection == null || forNameCollection.size() < 2) {
Implementation implementation = new Implementation(modular, call);
items.add(implementation);
}
}
use of org.elixir_lang.structure_view.element.modular.Modular in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsFromCallDefinitionClause.
private void getItemsFromCallDefinitionClause(@NotNull List<NavigationItem> items, @NotNull EnclosingModularByCall enclosingModularByCall, @NotNull Map<CallDefinition.Tuple, CallDefinition> callDefinitionByTuple, @NotNull Call call) {
Pair<String, IntRange> nameArityRange = CallDefinitionClause.nameArityRange(call);
if (nameArityRange != null) {
String callName = nameArityRange.first;
IntRange arityRange = nameArityRange.second;
Timed.Time time = CallDefinitionClause.time(call);
Modular modular = enclosingModularByCall.putNew(call);
if (modular == null) {
// don't throw an error if really EEX, but has wrong extension
if (!call.getText().contains("<%=")) {
error("Cannot find enclosing Modular", call);
}
} else {
for (int arity = arityRange.getMinimumInteger(); arity <= arityRange.getMaximumInteger(); arity++) {
CallDefinition.Tuple tuple = new CallDefinition.Tuple(modular, time, callName, arity);
CallDefinition callDefinition = callDefinitionByTuple.get(tuple);
if (callDefinition == null) {
callDefinition = new CallDefinition(tuple.modular, tuple.time, tuple.name, tuple.arity);
items.add(callDefinition);
callDefinitionByTuple.put(tuple, callDefinition);
}
CallDefinitionClause callDefinitionClause = callDefinition.clause(call);
items.add(callDefinitionClause);
}
}
}
}
use of org.elixir_lang.structure_view.element.modular.Modular in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsFromCallDefinitionHead.
private void getItemsFromCallDefinitionHead(@NotNull List<NavigationItem> items, @NotNull EnclosingModularByCall enclosingModularByCall, @NotNull Map<CallDefinition.Tuple, CallDefinition> callDefinitionByTuple, @NotNull Call call) {
Call delegationCall = CallDefinitionHead.enclosingDelegationCall(call);
if (delegationCall != null) {
Modular modular = enclosingModularByCall.putNew(delegationCall);
if (modular != null) {
String callDefinitionName = call.functionName();
if (callDefinitionName != null) {
int callDefinitionArity = call.resolvedFinalArity();
CallDefinition.Tuple tuple = new CallDefinition.Tuple(modular, // Delegation can't delegate macros
Timed.Time.RUN, callDefinitionName, callDefinitionArity);
CallDefinition callDefinition = callDefinitionByTuple.get(tuple);
if (callDefinition == null) {
callDefinition = new CallDefinition(tuple.modular, tuple.time, tuple.name, tuple.arity);
items.add(callDefinition);
callDefinitionByTuple.put(tuple, callDefinition);
}
// Delegation is always public as import should be used for private
Visible.Visibility visibility = Visible.Visibility.PUBLIC;
//noinspection ConstantConditions
CallDefinitionHead callDefinitionHead = new CallDefinitionHead(callDefinition, visibility, call);
items.add(callDefinitionHead);
} else {
error("Call for CallDefinitionHead does not have function name", call);
}
} else {
error("Cannot find enclosing Modular for Delegation call", delegationCall);
}
} else {
error("Cannot find enclosing delegation call for CallDefinitionHead", call);
}
}
use of org.elixir_lang.structure_view.element.modular.Modular in project intellij-elixir by KronicDeth.
the class GotoSymbolContributor method getItemsFromProtocol.
private void getItemsFromProtocol(@NotNull List<NavigationItem> items, @NotNull EnclosingModularByCall enclosingModularByCall, @NotNull Call call) {
Modular modular = enclosingModularByCall.putNew(call);
Protocol protocol = new Protocol(modular, call);
items.add(protocol);
}
Aggregations