Git Product home page Git Product logo

jdt-codemining's Introduction

jdt-codemining

Build Status

Eclipse plugin for JDT Java Code Mining and Git Code Mining (Experimental)

JUnit CodeMining Demo

JDT CodeMining is a an Eclipse plugin which requires Eclipse Photon based on JFace Text which provides CodeMining support.

JUnit CodeMining Demo

Requirements

JDT Java CodeMining requires Eclipse Photon (4.8) or above.

It is compatible with Eclipse 2018-12 (4.10) in which basic CodeMining features are provided and enriched by JDT Java CodeMining.

Install and activation

To install JDT Java CodeMining:

By default minings are disabled, you must activate them with preferences:

Show variable values inline while debugging

To show the result of the toString() method of an Object instead of for example myObject= Integer (id=20) it is recommended to enable the following option:

Go to Preferences > Java > Debug > Detail Formatters. On the section Show variable details ('toString()' value) select As the label for all variables.

Before:

JUnit CodeMining Debugging ToString() Before

After:

JUnit CodeMining Debugging ToString() After

Features

Java

jdt-codemining provides several JDT Java CodeMining:

  • General
    • Show references
    • Show implementations
    • Show method parameter names
    • Show method parameter types
    • Show end statement
  • JUnit
    • Show JUnit status
    • Show JUnit run
    • Show JUnit debug
  • Debugging
    • Show variable values inline while debugging

EGit

  • Show revision recent change
    • Show avatar
    • Show date ago
  • Show authors

Help us to get this into the Eclipse standard

Please star this project if you want to have those CodeMinings inside JDT. After discussing with JDT Team, this CodeMining support will not included for Photon release in June but perhaps in september if jdt-codemining receives good feedback. Indeed as CodeMining is a new feature which could cause some trouble (like performance) and JDT Team are very busy, they prefer not include my work on Java CodeMining for Photon release in June.

So please star this github project and create any issues to know your feelings and bugs. Thanks!

Issues can be about:

  • performance: indeed StyledText is not performant with big file and variable line height mode. As CodeMining can affect the line height (variable line height) to draw the mining before a line (like references), you could have trouble with performance. StyledText was improved to have better performance with variable line height, but it's not perfect yet. So please fill issues if you have troubles by describing your case (attach the big Java file, describes what you do, which version of Eclipse Photon you are using).
  • regression: StyledText was improved to have better performance in variable line height, please fill issue if you find regression (like scrollbar not well computed, focus problem after apply of completion, etc).
  • new feature: if you wish more settings to manage Java CodeMining, display other kind of mining, change the behaviour of mining when you click on it, etc, please create issues.

Demos

Here several demos with:

  • References:

Java CodeMining Demo

  • Method Parameter CodeMining

JUnit CodeMining Demo

  • JUnit CodeMining

JUnit CodeMining Demo

jdt-codemining's People

Contributors

angelozerr avatar bananeweizen avatar gayanper avatar kaiwinter avatar olivierjaquemet avatar pascalleclercq avatar vogella avatar yashtef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jdt-codemining's Issues

No update after preference change

When preferences are changed the minings are not updated, only when the text is reconciled again.

Steps to reproduce:

  • Open a Java file
  • Open Code Mining preferences
  • Enable or disable something
  • Press Apply
    => Expected: The minings appear or disappear

Parameter name codemining: Selection on double-click off by one character

When I double-click on a parameter name or the parameter itself, the selection is set incorrectly.
It seems that the parameter name codemining is overlapping with the parameter itself by one character:

bug

I also changed the background color with an org.eclipse.swt.custom.LineBackgroundListener for the attached screenshot.

Ability to register a menu on a code mining

This may already be possible, if that is the case, please close.

It would be nice to register a popup menu on a code mining. For example, this could allow to jump to the preference to configure the code mining or to select that a test should run as PDE test.

Git Code mining wrong for new methods

If I add a new method the code mining are wrong:

E.g., open org.eclipse.core.commands.AbstractHandler in source and add a new execute method overriding the Interface method.

image

Line numbering and collapse/expand aligned with code lines

It would be nice to have line numbers and collapse/expand icons aligned with the "real code", so the user can immediately understand where is "real code", and where is "meta-information" looking at the ruler on the left side.

Currently, the line number and the collapse/expand icon are vertically aligned in the middle of the area contanining both code and meta-annotation.

image

Empty space usage to high

See screenshot.

selection_249

Tested with Eclipse SDK
Version: Photon (4.8)
Build id: I20180322-0645
OS: Linux, v.4.13.0-36-generic, x86_64 / gtk 3.22.25, WebKit 2.18.6

Fails to install on Eclipse 4.9

Error:
Cannot complete the install because one or more required items could not be found.
Software being installed: JDT CodeMining 1.0.0.201806221018 (jdt-codemining-feature.feature.group 1.0.0.201806221018)
Missing requirement: Egit CodeMining 1.0.0.201806221018 (org.eclipse.egit.codemining 1.0.0.201806221018) requires 'osgi.bundle; org.eclipse.egit.core 0.0.0' but it could not be found
Cannot satisfy dependency:
From: JDT CodeMining 1.0.0.201806221018 (jdt-codemining-feature.feature.group 1.0.0.201806221018)
To: org.eclipse.equinox.p2.iu; org.eclipse.egit.codemining [1.0.0.201806221018,1.0.0.201806221018]

Possibility to restrict "Show method parameter names" to primitives

I'd like to have a possiblity to restrict "Show method parameter names" in a way that the names are only displayed on primitives (boolean,int,long...) and strings.

I think mostly by passing complex objects one can derive their meaning from the type.
Assume the following editor-view:

File dir = new File(pathname: "/tmp/test/");
doSomething(directory: dir, create: true);

The "directory:" parameter-name does not provide any useful additional information but uses a lot of space.
With the suggested feature enabled it would look like:

File dir = new File(pathname: "/tmp/test/");
doSomething(dir, create: true);

Hard to click Run and Debug in recent build

The mouse pointer seems to react delayed. I need to position the mouse and wait a while before the mouse pointer changes. This is irritating and prevents me from moving and clicking immediately.

mouse-delayed

Weird Editor behaviors: random split editor and NPE when splitting the editor

I captured this screenshot during a debug session. Without executing any particular command, the editor split in two. I was just in the middle of a debug session, and I edited the code under debug.
(The below screenshot is not what happens when you open a split editor)

image

On the opposite, this screenshot shows what happens when you open a split editor. The split editor seems not working. (tested via Window > Editor > Vertical Split Editor)

image

Attached, you can see the stack trace for the reproducible issue: when you open a split editor.

split-editor-stack-trace.txt

Feature request: Draw opening statement for brackets

IMHO it would be really nice to have the option to draw the opening statement of closing curley brackets:

For example:

if (parent != null) {
//lots of code here
} (-> draw this via code mining) //if (parent != null) {

Code mining for diffs

If I have a merge conflict adding coding mining about the authors would be nice.

<<<<<< HEAD
-Stacy
-Alexander

Marketing team

  • Collins
  • Linda
  • Patricia
  • Morgan
  • Amanda
    =======

master

Cannot select first letter

If code mining are active, I cannot select the first letter of the work via the mouse. See screencast.

selection-code-mining

Allow to hide 0 references

I think it would be nice to allow to hide 0 reference. I think it would also make a good default to only show the reference is there is one.

selection_250

Wrong drawing of code minining if I use a small resolution

During my Eclipse RCP training sessions I'm using typically a very small resolution, e.g., 1024 x 768
Code mining annotations are not drawn correctly, see screenshot.

image

I'm using Eclipse SDK
Version: Photon (4.8)
Build id: I20180513-2000
OS: Linux, v.4.15.0-20-generic, x86_64 / gtk 3.22.30, WebKit 2.20.2
and JDT CodeMining 1.0.0.201805120953
To test, create the following test classes and activate code minining.

package com.example.e4.rcp.todo;

import javax.annotation.PostConstruct;

import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;

import com.example.e4.rcp.todo.model.ITodoService;


public class TodoOverviewPart {

	@PostConstruct
	public void name(Composite parent, ITodoService todoService) {
		parent.setLayout(new GridLayout(1, false));
		int i = 0;
		i++;
		LabelAndText.create(parent).setTextForLabel("Hello").setTextForText("This is a text");
		LabelAndText.create(parent).setTextForLabel("Hello").setTextForText("This is a text");
		LabelAndText.create(parent).setTextForLabel("Hello").setTextForText("This is a text");
		LabelAndText.create(parent).setTextForLabel("Hello").setTextForText("This is a text");
		LabelAndText.create(parent).setTextForLabel("Hello").setTextForText("This is a text");
		LabelAndText.create(parent).setTextForLabel("Hello").setTextForText("This is a text");

	}

}

package com.example.e4.rcp.todo;

import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

public class LabelAndText extends Composite {

	private Label label;
	private Text text;

	private LabelAndText(Composite parent, int style) {
		super(parent, style);
		GridLayout gridLayout = new GridLayout(2, true);
		gridLayout.marginWidth = 5;
		gridLayout.marginHeight = 5;
		gridLayout.verticalSpacing = 0;
		gridLayout.horizontalSpacing = 0;
		this.setLayout(gridLayout);

		label = new Label(this, SWT.NONE);
		label.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, false));

		text = new Text(this, SWT.SINGLE | SWT.LEAD | SWT.BORDER);
		text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
	}

	public static LabelAndText create(Composite parent, int style) {
		return new LabelAndText(parent, style);
	}

	public static LabelAndText create(Composite parent) {
		return new LabelAndText(parent, SWT.NONE);
	}

	public LabelAndText setTextForLabel(String labelText) {
		label.setText(labelText);
		GridData gridData = new GridData(SWT.NONE, SWT.FILL, true, true);
		return this;
	}

	public LabelAndText setTextForText(String textText) {
		text.setText(textText);
		return this;
	}
}

Show end statement does not react to preference changes

Using latest and greatest code mininig I still have to close the editor to see the end brackets
JDT CodeMining 1.0.0.201805161036 jdt-codemining-feature.feature.group Angelo ZERR

Example editor after activating the setting.

selection_351

If I close and re-open I see the code mininig

selection_352

Please add support for junit 5 test methods with no access modifier

Junit Jupiter (Junit 5) supports methods with out access modifier or default access modifier scope (same package).

looks like the Access Specifier for junit 5 test should be public for code mining to show Run|Debug options.

Working:
working

Not Wortking:
notworking

Junit 5 allows to write unit tests with out access specifier.

junit5

Varargs not shown

During the fix of Bug 533156, I noticed that the type for varargs is shown as array.

image

Only "show method parameter names" for highlighted line

I love this plugin! (starred now)

But I think I would like to have the option to only see the parameter names for the line the cursor is currently placed in (or maybe also the surrounding lines, if a method call spans multiple lines).

NPE in logs

I tried to test your plugin today with Photon M6 and it did not work at all. Not sure what the cause is, but I have found the following exception in the workspace logs:

java.lang.NullPointerException
at org.eclipse.jdt.junit.codemining.JUnitCodeMiningProvider$CodeMiningTestRunListener.sessionFinished(JUnitCodeMiningProvider.java:59)
at org.eclipse.jdt.internal.junit.model.TestRunListenerAdapter.fireSessionFinished(TestRunListenerAdapter.java:45)
at org.eclipse.jdt.internal.junit.model.TestRunListenerAdapter.sessionEnded(TestRunListenerAdapter.java:69)
at org.eclipse.jdt.internal.junit.model.TestRunSession$TestSessionNotifier.testRunEnded(TestRunSession.java:656)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient$3.run(RemoteTestRunnerClient.java:516)
at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.testRunEnded(RemoteTestRunnerClient.java:513)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.access$9(RemoteTestRunnerClient.java:508)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient$DefaultProcessingState.readMessage(RemoteTestRunnerClient.java:106)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.receiveMessage(RemoteTestRunnerClient.java:381)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient.access$27(RemoteTestRunnerClient.java:380)
at org.eclipse.jdt.internal.junit.model.RemoteTestRunnerClient$ServerConnection.run(RemoteTestRunnerClient.java:278)

Maybe it helps you in fixing some issues.

Annotation misplacement/overlapping with MacOS.

When I startup Eclipse, or after setting the preferences to enable codemining, I see strange overlappings in the text, as you can see in the left of the attached image. The issue is fixed after clicking on the TextArea. (I obseved this behavior on Mac)

Is this something we should fix on jdt.codemining or in eclipse.text ?

image

Toolbar button to toggle codemining on/off

Sometimes when browsing through the code it would be good to disable the code mining temporarily.
Having toolbar button e.g. next to 'Toggle Breadcrumb' buttonto quickly switch it on and off would be a realy nice feature.

Git code mining for methods

I'm not 100 % sure here but I think the code mining annotations should show the last changed date of the whole method and the last changer. AFAICS it currently shows the author and date of the change for the method signature which is less useful to me.

git-code-mining

Closing statement wrong if brackets are missing

Closing statement annotation is wrong if brackets are missing.

Example:

In org.eclipse.ui.texteditor.MarkerRulerAction#markersUserEditable

private boolean markersUserEditable(List<IMarker> markers) {
		Iterator<IMarker> iter= markers.iterator();
		while (iter.hasNext()) {
			if (!isUserEditable(iter.next()))
				return false;
		}
		return true;
	}

For the if statement close comment I see:

\\ if (!isUserEditable(iter.next())) return false;

It should be

\\ if (!isUserEditable(iter.next()))

Editor not updated after changing the preferences

I had an editor open and activated the preferences.

preferences _336

After apply and close the code minining annotations are not shown.

selection_337

If I close and reopen the editor they are shown.

I would expect to see them after I press "Apply and Close" in the preferences.

selection_338

End statement mining offset

The end statement is rendered slightly below the line which contains the end statement. The problem gets more visible if you increase the font size.

screenshot 175

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.