Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a97fcaa
testing git stuff
MehVahdJukaar Nov 23, 2024
9ab67fc
Fancy emoji selector UI
MehVahdJukaar Nov 27, 2024
26daaa1
vcs author avatar emojis
MehVahdJukaar Nov 27, 2024
decba34
fixed author avatar settings
MehVahdJukaar Nov 27, 2024
0d1cb0f
UI things (picker panel and such)
MehVahdJukaar Nov 27, 2024
f3e6ae1
abstract configuration classes
MehVahdJukaar Nov 27, 2024
43771d7
emoji assets
MehVahdJukaar Nov 27, 2024
4252b8d
better recently modified and author avatar
MehVahdJukaar Dec 18, 2024
a8849da
improvements, last commit and better translations
MehVahdJukaar Dec 18, 2024
d9ee40e
more improvements to tooltips
MehVahdJukaar Dec 18, 2024
380f278
configurable emoji refactor
MehVahdJukaar Dec 19, 2024
0e2bc41
refactored vulnerable dependency collectors to not use dynamic builder
MehVahdJukaar Dec 19, 2024
362f69c
big collector refactor
MehVahdJukaar Dec 20, 2024
88f522a
update attempt
MehVahdJukaar Jan 30, 2025
155e517
updated to use declarative hits provider api
MehVahdJukaar Jan 30, 2025
2ad181e
Revert "update attempt"
MehVahdJukaar Jan 30, 2025
1b3dff7
declarative API refactor.
MehVahdJukaar Jan 31, 2025
7c7f183
name violation settings services
MehVahdJukaar Jan 31, 2025
1442b9e
all collectors now get their emoji from settings
MehVahdJukaar Jan 31, 2025
b9f8c48
hooked up settings in xml
MehVahdJukaar Jan 31, 2025
f96b8fa
finalized update
MehVahdJukaar Feb 1, 2025
52a8452
fixed some missing configs
MehVahdJukaar Feb 1, 2025
c494db1
preview code box
MehVahdJukaar Feb 1, 2025
2b86cfa
config screen improvements
MehVahdJukaar Feb 1, 2025
a0b01d4
showing modifiers configurable
MehVahdJukaar Feb 1, 2025
a9c2e5e
cleanups
MehVahdJukaar Feb 1, 2025
f1d1ebf
renamed collector classes to be more consistent.
MehVahdJukaar Feb 1, 2025
0c635e8
author avatar default emojis
MehVahdJukaar Feb 1, 2025
1c955cb
start frequently modified
MehVahdJukaar Feb 1, 2025
810722b
moved preview texts into resources files
MehVahdJukaar Feb 21, 2025
f8a40af
frequently modified
MehVahdJukaar Feb 23, 2025
e1d2692
moved unfinished stuff
MehVahdJukaar Feb 23, 2025
e7288de
InlayVisuals cleanup
MehVahdJukaar Feb 23, 2025
e57c3bc
translations cleanup
MehVahdJukaar Feb 23, 2025
4c7072b
severity enum
MehVahdJukaar Feb 23, 2025
0d7c84e
test
MehVahdJukaar Feb 23, 2025
55eec47
comments
MehVahdJukaar Feb 23, 2025
0dc1fe2
frequently mod name fix
MehVahdJukaar Mar 7, 2025
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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,5 @@ bin/
.vscode/

### Mac OS ###
.DS_Store
.DS_Store
/.idea/
3 changes: 0 additions & 3 deletions .idea/.gitignore

This file was deleted.

3 changes: 1 addition & 2 deletions .idea/compiler.xml

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

2 changes: 1 addition & 1 deletion .idea/gradle.xml

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

3 changes: 0 additions & 3 deletions .idea/kotlinc.xml

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

7 changes: 2 additions & 5 deletions .idea/misc.xml

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

7 changes: 0 additions & 7 deletions .idea/prettier.xml

This file was deleted.

25 changes: 0 additions & 25 deletions .run/Run Plugin.run.xml

This file was deleted.

10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -878,7 +878,7 @@ As can be seen in the diagram above, a class of type _InlayHintProvider_ must im
which will allow you to configure the inlay hint case in the IDE, allowing you to configure it in the appropriate menus
for a
programming language. The most important point concerns the _getCollectorFor(PsiFile, Editor, S,
InlayHintsSink)_ method. This method returns a class of type [
InlayTreeSink)_ method. This method returns a class of type [
_InlayHintsCollector_](https://github.com/JetBrains/intellij-community/blob/idea/232.9921.47/platform/lang-api/src/com/intellij/codeInsight/hints/InlayHintsCollector.kt).
This class that is responsible for scanning
the source code elements and execute the logic to identify the point where the addition of an inlay hint is necessary.
Expand All @@ -896,12 +896,12 @@ class diagram available for this purpose.
![Collector Class Diagram - Example](docs/screenshots/CECollectorDiagram.png)

The _InlayHintsCollector_ framework interface can be implemented in the plugin by the _CECollector_ and
_CECollectorMulti_. The interface defines the _collect(PsiElement, Editor, InlayHintsSink)_ method. _CECollectorMulti_
_CECollectorMulti_. The interface defines the _collect(PsiElement, Editor, InlayTreeSink)_ method. _CECollectorMulti_
allows you to implement this method using a list of collectors, useful for use with _CEProviderMulti_.

The _CECollector_ abstract class is the main class for implementing a collector. It extends the abstract class
_CEInlayBuilder_ which contains all the methods for manipulating inlay hints. Child classes must implement
_processCollect(PsiElement, Editor, InlayHintsSink)_.
_processCollect(PsiElement, Editor, InlayTreeSink)_.

![CECollector Class Diagram - Example](docs/screenshots/CECollectorWithInlayBuilder.png)

Expand Down Expand Up @@ -932,7 +932,7 @@ referenced in the source code: _Reference Class_, _Reference Field_ and _Referen
Example of use:

````java
public class GetMethodDoesNotReturn extends CEProvider<NoSettings> {
public class GetMethodDoesNotReturn extends CEProvider<CEDefaultSettings> {

@Override
public String getPreviewText() {
Expand All @@ -945,7 +945,7 @@ public class GetMethodDoesNotReturn extends CEProvider<NoSettings> {
}

@Override
public @NotNull InlayHintsCollector buildCollector(@NotNull Editor editor) {
public @NotNull InlayHintsCollector createCollector(@NotNull PsiFile psiFile, @NotNull Editor editor) {
return new CEMethodCollector(editor, getKeyId(), CONFUSED) {
@Override
public boolean needsHint(@NotNull PsiMethod element, @NotNull Map<?, ?> externalInfo) {
Expand Down
6 changes: 4 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ dependencies {
compileOnly("org.projectlombok:lombok:1.18.28")
annotationProcessor("org.projectlombok:lombok:1.18.28")
implementation("com.google.code.gson:gson:2.10.1")
implementation("org.json:json:20240303")
}


Expand All @@ -39,7 +38,10 @@ intellij {
updateSinceUntilBuild.set(true)
val platformPlugins = properties("platformPlugins").split(',').map(String::trim).filter(String::isNotEmpty)
plugins.set(
platformPlugins + listOf("com.intellij.java")
platformPlugins + listOf(
"com.intellij.java",
"Git4Idea"
)
)
}

Expand Down
9 changes: 5 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
pluginGroup=codeemoji
pluginVersion=5.0.0
pluginVersion=6.0.0
pluginSinceBuild=231
pluginUntilBuild=232.*
pluginVerifierIdeVersions=2023.1,2023.1.1,2023.1.2,2023.1.3,2023.1.4,2023.1.5,2023.1.6,2023.1.7,2023.2,2023.2.1,2023.2.2,2023.2.3,2023.2.4,2023.2.5,2023.2.6,2023.2.7,2023.2.8
pluginUntilBuild=252.*
pluginVerifierIdeVersions=2023.1,2023.1.1,2023.1.2,2023.1.3,2023.1.4,2023.1.5,2023.1.6,2023.1.7,2023.2,2023.2.1,2023.2.2,2023.2.3,2023.2.4,2023.2.5,2023.2.6,2023.2.7,2023.2.8,2023.3
platformType=IC
platformVersion=2023.2.8
## IC for community
platformVersion= 2023.3
platformDownloadSources=true
platformPlugins=
kotlin.stdlib.default.dependency=false
79 changes: 62 additions & 17 deletions src/main/java/codeemoji/core/collector/CECollector.java
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
package codeemoji.core.collector;

import com.intellij.codeInsight.hints.InlayHintsCollector;
import com.intellij.codeInsight.hints.InlayHintsSink;
import com.intellij.codeInsight.hints.presentation.InlayPresentation;
import codeemoji.core.external.CEExternalAnalyzer;
import codeemoji.core.util.CEBundle;
import codeemoji.core.util.CESymbol;
import com.intellij.codeInsight.hints.declarative.*;
import com.intellij.openapi.editor.Editor;
import com.intellij.openapi.editor.ex.util.EditorUtil;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiElementVisitor;
import com.intellij.psi.PsiJavaFile;
import kotlin.Unit;
import lombok.Getter;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Getter
@SuppressWarnings("UnstableApiUsage")
public abstract non-sealed class CECollector<A extends PsiElement> extends CEInlayBuilder implements InlayHintsCollector {
public abstract class CECollector<H extends PsiElement, A extends PsiElement> implements SharedBypassCollector {

private final Editor editor;
private final String key;

protected CECollector(Editor editor) {
super(editor);
protected CECollector(Editor editor, String key) {
this.editor = editor;
this.key = key;
}

@SuppressWarnings("SameReturnValue")
public abstract boolean processCollect(@NotNull PsiElement psiElement, @NotNull Editor editor, @NotNull InlayHintsSink inlayHintsSink);
public abstract PsiElementVisitor createElementVisitor(@NotNull Editor editor, @NotNull InlayTreeSink InlayTreeSink);

public final boolean collect(@NotNull PsiElement psiElement, @NotNull Editor editor, @NotNull InlayHintsSink inlayHintsSink) {
@Nullable
protected abstract InlayVisuals createInlayFor(@NotNull H element);

@Override
public void collectFromElement(@NotNull PsiElement psiElement, @NotNull InlayTreeSink inlayTreeSink) {
if (isEnabled()) {
return processCollect(psiElement, editor, inlayHintsSink);
if (psiElement instanceof PsiJavaFile) {
psiElement.accept(createElementVisitor(getEditor(), inlayTreeSink));
}
}
return false;
}

protected int calcOffset(@Nullable A element) {
Expand All @@ -39,19 +54,49 @@ protected boolean isEnabled() {
return true;
}

public final void addInlayInline(@Nullable A element, @NotNull InlayHintsSink sink, @NotNull InlayPresentation inlay) {
public final void addInlayInline(@Nullable A element, @NotNull InlayTreeSink sink, @NotNull InlayVisuals inlay) {
if (null != element) {
sink.addInlineElement(calcOffset(element), false, inlay, false);

sink.addPresentation(
new InlineInlayPosition(element.getTextRange().getEndOffset(), true, 0),
List.of(),
inlay.tooltip(),
inlay.hasBackground(),
builder -> {
builder.text(inlay.text(), null);
return Unit.INSTANCE;
}
);
}
}

public final void addInlayBlock(@Nullable A element, @NotNull InlayHintsSink sink, InlayPresentation inlay) {
public final void addInlayBlock(@Nullable A element, @NotNull InlayTreeSink sink, InlayVisuals inlay) {
if (null != element) {
var indentFactor = EditorUtil.getPlainSpaceWidth(getEditor());
var indent = EditorUtil.getTabSize(getEditor()) * indentFactor;
inlay = getFactory().inset(inlay, indent, 0, 0, 0);
sink.addBlockElement(element.getTextOffset(), true, true, 0, inlay);
// inlay = getFactory().inset(inlay, indent, 0, 0, 0);

//TODO: check this
sink.addPresentation(
new InlineInlayPosition(element.getTextRange().getEndOffset()-indent, true, 0),
List.of(),
inlay.tooltip(),
inlay.hasBackground(),
builder -> {
builder.text(inlay.text(), null);
return Unit.INSTANCE;
}
);
}
}

//helper function. we are not feeding this all the time into craete inlay
protected @NotNull Map<?, ?> getExternalInfo(@Nullable H element) {
Map<?, ?> result = new HashMap<>();
if (element != null) {
CEExternalAnalyzer.getInstance().buildExternalInfo(result, element);
}
return result;
}

}
14 changes: 7 additions & 7 deletions src/main/java/codeemoji/core/collector/CECollectorMulti.java
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
package codeemoji.core.collector;

import com.intellij.codeInsight.hints.InlayHintsCollector;
import com.intellij.codeInsight.hints.InlayHintsSink;
import com.intellij.codeInsight.hints.declarative.InlayTreeSink;
import com.intellij.codeInsight.hints.declarative.InlayHintsCollector;
import com.intellij.codeInsight.hints.declarative.InlayTreeSink;
import com.intellij.codeInsight.hints.declarative.SharedBypassCollector;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;

import java.util.List;

@SuppressWarnings("UnstableApiUsage")
public record CECollectorMulti(List<InlayHintsCollector> collectors) implements InlayHintsCollector {
public record CECollectorMulti(List<SharedBypassCollector> collectors) implements SharedBypassCollector {

@Override
public boolean collect(@NotNull PsiElement psiElement, @NotNull Editor editor, @NotNull InlayHintsSink inlayHintsSink) {
public void collectFromElement(@NotNull PsiElement psiElement, @NotNull InlayTreeSink inlayTreeSink) {
if (null != collectors()) {
for (var collector : collectors()) {
collector.collect(psiElement, editor, inlayHintsSink);
collector.collectFromElement(psiElement, inlayTreeSink);
}
}
return false;
}
}
49 changes: 0 additions & 49 deletions src/main/java/codeemoji/core/collector/CEDynamicInlayBuilder.java

This file was deleted.

Loading