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

Support for Primitives in Detail Formatter #586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SougandhS
Copy link
Contributor

@SougandhS SougandhS commented Jan 9, 2025

Provides support for primitive types (int,float,char etc) for detail formatter

image

image

image

image

image

image

image

Fixes : #268

What it does

How to test

Author checklist

@SougandhS SougandhS force-pushed the DetalFormatter_for_Primitives_and_Arrays branch from 5fe49cd to e42dd75 Compare January 9, 2025 05:36
@SougandhS
Copy link
Contributor Author

Hi @jukzi , could u pls check this when you have time.

@SougandhS SougandhS changed the title Support for Primitive in Detail Formatter Support for Primitives in Detail Formatter Jan 9, 2025
@jukzi jukzi added enhancement New feature or request noteworthy Noteworthy feature labels Jan 9, 2025
@@ -307,14 +325,13 @@ private void selectType() {
SelectionDialog dialog= null;
try {
dialog= JavaUI.createTypeDialog(shell, PlatformUI.getWorkbench().getProgressService(),
SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false, fTypeNameText.getText());
SearchEngine.createWorkspaceScope(), IJavaElementSearchConstants.CONSIDER_ALL_TYPES, false, fTypeNameText.getText());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks like unintentional space change

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Auto format issue - will resolve it

@@ -254,6 +254,8 @@ DetailFormatterDialog_Add_Detail_Formatter_2=Add Detail Formatter
DetailFormatterDialog_Associated_code_must_not_be_empty_3=Detail formatter code snippet must not be empty
DetailFormatterDialog_Detail_formatter__code_snippet__1=Detail formatter &code snippet:
DetailFormatterDialog_17=Detail formatter &code snippet ({0} for code assist):
DetailFormatterPrimitiveSelect=Select Primitives
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the noun should be low caps. i am not sure

*/
@SuppressWarnings("nls")
private List<String> getPrimitiveTypes() {
return List.of("int", "long", "short", "float", "double", "boolean", "char", "byte", "int[]", "long[]", "short[]", "float[]", "double[]", "boolean[]", "char[]", "byte[]");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does it work with arrays of multiple dimensions? for example char[][]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it works.. added test case for that too

@@ -55,6 +56,10 @@ public interface IRuntimeContext {
*/
IJavaObject getThis() throws CoreException;

default IJavaPrimitiveValue getThisPrimitive() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please add javadoc

@@ -745,22 +745,12 @@
id="org.eclipse.jdt.debug.ui.FilteredJavaVariableActions">
<visibility>
<and>
<objectState
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are this lines removed intantionally?

Copy link
Contributor Author

@SougandhS SougandhS Jan 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.. to get detail formatter option in variables view

@jukzi
Copy link
Contributor

jukzi commented Jan 9, 2025

looks like a cool feature. i would love to see char[] and char[][] fromatted by default

@SougandhS SougandhS force-pushed the DetalFormatter_for_Primitives_and_Arrays branch 2 times, most recently from e4b558b to f06ef02 Compare January 9, 2025 09:35
@SougandhS SougandhS requested a review from jukzi January 9, 2025 10:50
@jukzi
Copy link
Contributor

jukzi commented Jan 9, 2025

00:02:40.204  [ERROR] Failed to execute goal org.eclipse.tycho:tycho-apitools-plugin:4.0.11-SNAPSHOT:verify (verify) on project org.eclipse.jdt.debug: There are API errors:
00:02:40.204  [ERROR] eval/org/eclipse/jdt/debug/eval/IAstEvaluationEngine.java:167 Missing @since tag on evaluateExpression(ICompiledExpression, IJavaPrimitiveValue, IJavaThread, IEvaluationListener, int, boolean)
00:02:40.204  [ERROR] META-INF/MANIFEST.MF:5 The minor version should be incremented in version 3.21.700, since new APIs have been added since version 3.21.600
00:02:40.204  [ERROR] -> [Help 1]
00:02:40.204  [ERROR] 

@jukzi
Copy link
Contributor

jukzi commented Jan 9, 2025

i actually tried this PR for char[][] -> java.util.Arrays.stream(this).map(java.util.Arrays::toString).toList().toString() and get error

Detail formatter error:
		[The package java.lang collides with a type, The package java.lang conflicts with a package accessible from another module: java.base, The type jdk.internal.misc.Blocker is not accessible, The type jdk.internal.vm.annotation.IntrinsicCandidate is not accessible]

what am i am doing wrong?

Copy link
Contributor

@jukzi jukzi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actions "remove Detail formatter" and "edit Detail formatter" are not available if i add a Detail formatter for arrays char[]. Once a Detail formatter for plain char is added it works
image

@SougandhS
Copy link
Contributor Author

what am i am doing wrong?

try this - java.util.Arrays.deepToString(this)

image
image

@jukzi
Copy link
Contributor

jukzi commented Jan 9, 2025

try this - java.util.Arrays.deepToString(this)

but i want a custom format to just concat a chars.

This commit provides support for Primitive types and Primitive arrays in
Detail Formatter for variables view.

Fixes : eclipse-jdt#268
@SougandhS SougandhS force-pushed the DetalFormatter_for_Primitives_and_Arrays branch from f06ef02 to 55c37bf Compare January 10, 2025 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request noteworthy Noteworthy feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Detail formatter does not accept arrays or primitives as type
2 participants