Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure View #243

Merged
merged 39 commits into from
Feb 25, 2016
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
00a10fa
Module structure view
KronicDeth Jan 21, 2016
c7525c9
Kernel.def/2 structure view
KronicDeth Jan 23, 2016
cacd8c6
Group function clauses together in Structure View
KronicDeth Jan 24, 2016
23adbcf
defdelegate structure view
KronicDeth Jan 26, 2016
20f0a57
Fix tests after removal of NoParenthesesExpression
KronicDeth Jan 27, 2016
6ff7cbd
Optimize imports
KronicDeth Jan 27, 2016
67c0e2a
Fix ambiguous_op quoting by skiping identifier element
KronicDeth Jan 27, 2016
62c12cd
Compress implements and methods for InfixOperation
KronicDeth Jan 28, 2016
4b6320b
Handle operations for `def/2` names
KronicDeth Jan 30, 2016
48547b5
Group callbacks under defexception
KronicDeth Jan 31, 2016
eb22a14
Always show default values for exception fields
KronicDeth Feb 1, 2016
7223cd1
defimpl structure view
KronicDeth Feb 2, 2016
ae8fda8
defmacro in structure
KronicDeth Feb 3, 2016
6b9fd78
Collapse Function and Macro structure view
KronicDeth Feb 5, 2016
0897759
Time sort
KronicDeth Feb 6, 2016
7a7f353
Fake new RowIcon(Icon... icon) with factory
KronicDeth Feb 6, 2016
0b5d686
defp and defmacrop structure
KronicDeth Feb 6, 2016
821f40e
Visibility sorter
KronicDeth Feb 6, 2016
cbcf038
Show structure inside of quote calls
KronicDeth Feb 7, 2016
c835a82
defoverridable structure
KronicDeth Feb 8, 2016
00a1bd8
Mark function CallDefinition as overridable
KronicDeth Feb 9, 2016
df5829d
`use` in Structure
KronicDeth Feb 9, 2016
41ff2c6
Default arguments generate entry for each arity
KronicDeth Feb 13, 2016
1a9415f
Provide __using__ quote's function to use location
KronicDeth Feb 15, 2016
5e5abb2
Show "use <ALIAS>" for location of injected functions
KronicDeth Feb 15, 2016
d5d3dde
Mark function overrides for use overriddable functions
KronicDeth Feb 17, 2016
202c156
Remove unused import that fails on travis-ci
KronicDeth Feb 17, 2016
3f7f02b
Callbacks using implemented method icon
KronicDeth Feb 20, 2016
6b892fc
@spec in structure view
KronicDeth Feb 20, 2016
8d8871a
Use NameArity for callback presentation
KronicDeth Feb 21, 2016
1d4b939
Callbacks split into name/arity and spec
KronicDeth Feb 21, 2016
6d62b16
Fix case-sensitive naming
KronicDeth Feb 22, 2016
b0731c6
@type, @typep and @opaque in Structure
KronicDeth Feb 22, 2016
6116b4b
defprotocol in Structure
KronicDeth Feb 22, 2016
935ba90
Structure with defstruct and its fields
KronicDeth Feb 23, 2016
5d2a393
Qualified alias support for defimpl
KronicDeth Feb 23, 2016
b236449
Fix Scroll From Source
KronicDeth Feb 24, 2016
ea00323
Better Scroll From Source
KronicDeth Feb 24, 2016
f693070
Show implicit Structure for Exception
KronicDeth Feb 24, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Better Scroll From Source
Don't just override `#getSuitableClasses`, but also `#isSuitable`, so
that the class can be checked with `#is` static functions, which ensures
that clicking in the body of Call scrolls to the clause, which was not
the case previously because the inner most Call would be used.
  • Loading branch information
KronicDeth committed Feb 25, 2016
commit ea003238e03061f84964d6b6f987957b5ea0652c
45 changes: 44 additions & 1 deletion src/org/elixir_lang/structure_view/Model.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,18 @@
import com.intellij.ide.util.treeView.smartTree.NodeProvider;
import com.intellij.ide.util.treeView.smartTree.Sorter;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import org.elixir_lang.psi.ElixirAtom;
import org.elixir_lang.psi.ElixirFile;
import org.elixir_lang.psi.QuotableKeywordPair;
import org.elixir_lang.psi.call.Call;
import org.elixir_lang.structure_view.element.File;
import org.elixir_lang.structure_view.element.*;
import org.elixir_lang.structure_view.element.Exception;
import org.elixir_lang.structure_view.element.modular.Module;
import org.elixir_lang.structure_view.element.modular.Protocol;
import org.elixir_lang.structure_view.element.structure.Field;
import org.elixir_lang.structure_view.element.structure.FieldWithDefaultValue;
import org.elixir_lang.structure_view.element.structure.Structure;
import org.elixir_lang.structure_view.node_provider.Used;
import org.elixir_lang.structure_view.sorter.Time;
import org.elixir_lang.structure_view.sorter.Visibility;
Expand Down Expand Up @@ -87,6 +94,42 @@ public boolean isAlwaysLeaf(StructureViewTreeElement element) {
return element instanceof ElixirFile;
}

@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;
// everything in {@link Module#childCallTreeElements}
suitable = CallDefinitionClause.isFunction(call) ||
CallDefinitionClause.isMacro(call) ||
CallDefinitionSpecification.is(call) ||
Callback.is(call) ||
Delegation.is(call) ||
Exception.is(call) ||
Implementation.is(call) ||
Module.is(call) ||
Overridable.is(call) ||
Protocol.is(call) ||
Quote.is(call) ||
Structure.is(call) ||
Type.is(call) ||
Use.is(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;
}

/**
* Returns the root element of the structure view tree.
*
Expand Down
38 changes: 38 additions & 0 deletions src/org/elixir_lang/structure_view/element/structure/Field.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@

import com.intellij.ide.util.treeView.smartTree.TreeElement;
import com.intellij.navigation.ItemPresentation;
import com.intellij.psi.PsiElement;
import org.elixir_lang.navigation.item_presentation.Parent;
import org.elixir_lang.psi.ElixirAccessExpression;
import org.elixir_lang.psi.ElixirAtom;
import org.elixir_lang.psi.ElixirList;
import org.elixir_lang.psi.ElixirNoParenthesesOneArgument;
import org.elixir_lang.psi.call.Call;
import org.elixir_lang.structure_view.element.Element;
import org.jetbrains.annotations.NotNull;

Expand All @@ -18,6 +23,39 @@ public class Field extends Element<ElixirAtom> {
@NotNull
private final Structure structure;

/*
* 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;
}

/*
* Constructors
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
import com.intellij.navigation.ItemPresentation;
import com.intellij.psi.PsiElement;
import org.elixir_lang.navigation.item_presentation.Parent;
import org.elixir_lang.psi.ElixirNoParenthesesKeywords;
import org.elixir_lang.psi.ElixirNoParenthesesOneArgument;
import org.elixir_lang.psi.QuotableKeywordList;
import org.elixir_lang.psi.QuotableKeywordPair;
import org.elixir_lang.psi.call.Call;
import org.elixir_lang.psi.call.arguments.NoParenthesesOneArgument;
import org.elixir_lang.structure_view.element.Element;
import org.jetbrains.annotations.NotNull;

Expand All @@ -19,6 +24,31 @@ public class FieldWithDefaultValue extends Element<QuotableKeywordPair> {
@NotNull
private final Structure structure;

/*
* 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;
}

/*
* Constructors
*/
Expand Down