Skip to content

Commit

Permalink
#59
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Vanusanik committed Mar 2, 2023
1 parent 23e7b38 commit 5e19307
Show file tree
Hide file tree
Showing 56 changed files with 5,533 additions and 45 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.5.0

### Changes


## 0.4.1 230218

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.en_circle.slt"
version = "0.4.1-rev1"
version = "0.5.0"

repositories {
mavenCentral()
Expand Down
26 changes: 19 additions & 7 deletions src/main/gen/com/en_circle/slt/plugin/lisp/impl/LispListImpl.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions src/main/gen/com/en_circle/slt/plugin/lisp/psi/LispList.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 30 additions & 20 deletions src/main/java/com/en_circle/slt/plugin/SltStructureAwareNavbar.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
import com.en_circle.slt.plugin.lisp.psi.LispToplevel;
import com.intellij.ide.navigationToolbar.StructureAwareNavBarModelExtension;
import com.intellij.lang.Language;
import com.intellij.psi.PsiElement;
import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

Expand All @@ -26,19 +28,14 @@ protected Language getLanguage() {
if (object instanceof LispFile) {
return SltIconProvider.getFileIcon();
}
if (object instanceof LispToplevel toplevel) {
LispSexpressionInfo info = LispParserUtil.determineTopLevelType(toplevel.getSexpr());
if (info.getType() != SexpressionType.EXPRESSION) {
return info.getIcon();
}
return SltIconProvider.getFileIcon();
LispSexpressionInfo topLevelInfo = getTopLevelForObject(object);
if (topLevelInfo != null) {
return topLevelInfo.getIcon();
}
if (object instanceof LispSexpr sexpr) {
LispSexpressionInfo info = LispParserUtil.determineTopLevelType(sexpr);
if (info.getType() != SexpressionType.EXPRESSION) {
return info.getIcon();
if (object instanceof PsiElement psiElement) {
if (psiElement.getContainingFile() instanceof LispFile) {
return SltIconProvider.getFileIcon();
}
return SltIconProvider.getFileIcon();
}
return null;
}
Expand All @@ -48,20 +45,33 @@ protected Language getLanguage() {
if (object instanceof LispFile file) {
return file.getName();
}
if (object instanceof LispToplevel toplevel) {
LispSexpressionInfo info = LispParserUtil.determineTopLevelType(toplevel.getSexpr());
if (info.getType() != SexpressionType.EXPRESSION) {
return info.getLongForm();
LispSexpressionInfo topLevelInfo = getTopLevelForObject(object);
if (topLevelInfo != null) {
return topLevelInfo.getLongForm();
}
if (object instanceof PsiElement psiElement) {
if (psiElement.getContainingFile() instanceof LispFile file) {
return file.getName();
}
return toplevel.getContainingFile().getName();
}
return null;
}

private LispSexpressionInfo getTopLevelForObject(Object object) {
if (object instanceof LispToplevel toplevel) {
return LispParserUtil.determineTopLevelType(toplevel.getSexpr());
}
if (object instanceof LispSexpr sexpr) {
LispSexpressionInfo info = LispParserUtil.determineTopLevelType(sexpr);
if (info.getType() != SexpressionType.EXPRESSION) {
return info.getLongForm();
LispSexpressionInfo info = LispParserUtil.determineTopLevelType(sexpr);
if (info != null && info.getType() != SexpressionType.EXPRESSION) {
return info;
}
return sexpr.getContainingFile().getName();
}
if (object instanceof PsiElement psiElement) {
LispSexpr sexpr = PsiTreeUtil.getParentOfType(psiElement, LispSexpr.class);
return getTopLevelForObject(sexpr);
}
return null;
}

}
7 changes: 6 additions & 1 deletion src/main/java/com/en_circle/slt/plugin/lisp/Lisp.bnf
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,12 @@ array ::= ARRAY_START list

structure ::= STRUCTURE_TOKEN list

list ::= LPAREN sexpr* RPAREN { pin = 2 recoverWhile=list_recovery }
list ::= LPAREN sexpr* RPAREN {
pin = 2
recoverWhile=list_recovery
implements="com.intellij.psi.NavigatablePsiElement"
methods=[getName getPresentation]
}
private list_recovery ::= !(sexpr | RPAREN)

string ::= STRING_TOKEN {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.en_circle.slt.plugin.lisp.lisp.components;

public class LispArguments {



}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.en_circle.slt.plugin.lisp.lisp.components;

public class LispFunctionCall {



}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.en_circle.slt.plugin.SltCommonLispFileType;
import com.en_circle.slt.plugin.lisp.LispParserUtil;
import com.en_circle.slt.plugin.lisp.LispParserUtil.LispSexpressionInfo;
import com.en_circle.slt.plugin.lisp.LispParserUtil.SexpressionType;
import com.en_circle.slt.plugin.lisp.LispSymbolPresentation;
import com.en_circle.slt.plugin.lisp.psi.*;
import com.intellij.lang.ASTNode;
Expand Down Expand Up @@ -70,6 +71,16 @@ public static String getName(LispToplevel element) {
return LispParserUtil.determineTopLevelType(element.getSexpr()).getShortForm();
}

public static String getName(LispList element) {
if (element.getParent() instanceof LispDatum && element.getParent().getParent() instanceof LispSexpr) {
LispSexpressionInfo type = LispParserUtil.determineTopLevelType((LispSexpr) element.getParent().getParent());
if (type.getType() != SexpressionType.EXPRESSION)
return type.getShortForm();
return null;
}
return null;
}

public static PsiElement setName(LispComment element, String newName) {
ASTNode commentLineNode = element.getNode().findChildByType(LispTypes.LINE_COMMENT);
if (commentLineNode != null) {
Expand Down Expand Up @@ -159,4 +170,24 @@ public static ItemPresentation getPresentation(LispToplevel toplevel) {
};
}

public static ItemPresentation getPresentation(LispList list) {
if (list.getParent() instanceof LispDatum && list.getParent().getParent() instanceof LispSexpr) {
LispSexpressionInfo type = LispParserUtil.determineTopLevelType((LispSexpr) list.getParent().getParent());
if (type.getType() != SexpressionType.EXPRESSION) {
return new ItemPresentation() {
@Override
public @NlsSafe @Nullable String getPresentableText() {
return type.getShortForm();
}

@Override
public @Nullable Icon getIcon(boolean unused) {
return type.getIcon();
}
};
}
}
return null;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import com.en_circle.slt.plugin.lisp.LispParserUtil.LispSexpressionInfo;
import com.en_circle.slt.plugin.lisp.LispParserUtil.SexpressionType;
import com.en_circle.slt.plugin.lisp.psi.LispFile;
import com.en_circle.slt.plugin.lisp.psi.LispList;
import com.en_circle.slt.plugin.lisp.psi.LispSexpr;
import com.en_circle.slt.plugin.lisp.psi.LispToplevel;
import com.intellij.ide.structureView.StructureViewTreeElement;
import com.intellij.ide.util.treeView.smartTree.SortableTreeElement;
Expand Down Expand Up @@ -80,10 +82,24 @@ public Object getValue() {
LispSexpressionInfo sexpressionInfo = LispParserUtil.determineTopLevelType(toplevel.getSexpr());
if (sexpressionInfo.getType() != SexpressionType.EXPRESSION) {
elementList.add(new LispStructureViewElement(toplevel, sexpressionInfo));
} else {
LispSexpr sexpr = toplevel.getSexpr();
if (sexpr.getDatum() != null) {
if (sexpr.getDatum().getList() != null) {
for (LispSexpr element : sexpr.getDatum().getList().getSexprList()) {
if (element.getDatum() != null && element.getDatum().getList() != null) {
LispList sublist = element.getDatum().getList();
LispSexpressionInfo subInfo = LispParserUtil.determineTopLevelType(element);
if (subInfo.getType() != SexpressionType.EXPRESSION) {
elementList.add(new LispStructureViewElement(sublist, subInfo));
}
}
}
}
}
}
}
}

return elementList.toArray(new TreeElement[0]);
}
return EMPTY_ARRAY;
Expand All @@ -103,4 +119,10 @@ public boolean canNavigate() {
public boolean canNavigateToSource() {
return psiElement.canNavigateToSource();
}

public boolean isDefinition() {
if (psiElement instanceof LispFile)
return true;
return false;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.en_circle.slt.plugin.structure;

import com.en_circle.slt.plugin.lisp.psi.LispList;
import com.en_circle.slt.plugin.lisp.psi.LispToplevel;
import com.intellij.ide.structureView.StructureViewModel;
import com.intellij.ide.structureView.StructureViewModelBase;
Expand All @@ -23,7 +24,7 @@ public LispStructureViewModel(PsiFile psiFile, Editor editor) {

@Override
public boolean isAlwaysLeaf(StructureViewTreeElement element) {
return element.getValue() instanceof LispToplevel;
return !((LispStructureViewElement) element).isDefinition();
}

@Override
Expand All @@ -33,6 +34,6 @@ public boolean isAlwaysShowsPlus(StructureViewTreeElement element) {

@Override
protected Class<?> @NotNull [] getSuitableClasses() {
return new Class[]{ LispToplevel.class };
return new Class[]{ LispToplevel.class, LispList.class };
}
}
11 changes: 11 additions & 0 deletions src/main/lisp/libs/eclector/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.aux
*.bbl
*.blg
*.cb
*.cb2
*.idx
*.ilg
*.ind
*.log
*.pdf
*.toc
12 changes: 12 additions & 0 deletions src/main/lisp/libs/eclector/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Copyright (c) 2010 - 2018 Robert Strandh ([email protected])
Copyright (c) 2018 - 2020 Jan Moringen

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 5e19307

Please sign in to comment.