Skip to content
This repository was archived by the owner on Aug 27, 2025. It is now read-only.

Integrate in the ANSI Escapes in the Eclipse Console plugin (issue #47) - #50

Merged
SarikaSinha merged 1 commit into
eclipse-platform:masterfrom
mihnita:master
Aug 4, 2022
Merged

SarikaSinha merged 1 commit into
eclipse-platform:masterfrom
mihnita:master

Conversation

@mihnita

@mihnita mihnita commented Jul 4, 2022

Copy link
Copy Markdown
Contributor

Hello!

This PR integrates AnsiConsole into org.eclipse.ui.console.

I've changed the namespace, removed AnsiConsoleMavenLaunchParticipant, removed the links to the plugin pages, setup the proper bindings of events so that everything works like with the standalone plugin, externalized the localizable strings.

This takes it to step 4 in the tracking issue:
#47

I've preserved the commit trail, as it might make the review easier.
Your call if you want to preserve or squash when merging (or ask me to squash it).

Regards,
Mihai

@mickaelistria mickaelistria left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Some minor comments (not blocking for a merge, but need to be considered very soon as it may affect API and doc) inline = ansiconlogo.png is not used and can be removed.\

I'm opening a contribution request for this contribution. We'll get some guidance about how to deal with dual-license (we never had it in Platform so far, let's see what happens...)

/**
* @since 3.12
*/
public void removeViewerWithPageParticipant(IConsolePageParticipant participant) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Does it have to be a public API? Couldn't it be internal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

removeViewerWithPageParticipant is called from AnsiConsolePageParticipant.init
And addViewer is called from AnsiConsolePageParticipant.dispose

They add / remove a IConsolePageParticipant to
private final Map<StyledText, IConsolePageParticipant> viewers
Which I've also added to ConsolePlugin

I think that everything (map + the methods to add / remove) can be moved to AnsiConsolePageParticipant
But I am not sure about the lifespan of AnsiConsolePageParticipant.
Maybe make the viewers map static? A singleton?
The plugin I knew it can "survive" as long as it is needed.

I welcome any advice.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Or, is there a way to tag a public method (from Java perspective) as internal for Eclipse?
Some annotation?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think that everything (map + the methods to add / remove) can be moved to AnsiConsolePageParticipant

Let's try that.

Maybe make the viewers map static? A singleton?

Yes, keeping a static map should be good enough.

Or, is there a way to tag a public method (from Java perspective) as internal for Eclipse?

There is @noreference in the javadoc but it's not really good to use in general. So moving code to an internal class is greatly preferred.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Hmm, it looks like @noreference does the job.

I've added @noreference to addViewer and removeViewerWithPageParticipant, removed @since,
and reverted the Bundle-Version in MANIFEST.MF to 3.11.300.qualifier (as it was before I touched it)

But moving the two methods to AnsiConsolePageParticipant would be cleaner, if that is safe to do.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

As mentioned, @reference is to be avoided. Please move to an internal class instead.

@mihnita mihnita Jul 5, 2022 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Moved the 2 methods + map to AnsiConsolePageParticipant
Thank you,
M

</extension>

<extension point="org.eclipse.ui.preferencePages">
<page name="%ansicon.prefpage.name"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you please set a parent category so it becomes a child of the existing console preference page?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I'm not sure what the rules are for Eclipse.
In other projects I've worked on the one who opened the comment / issue gets to accept it and resolve it.
So I marked all entries that I've solved with "Done", and you resolve it.
If the rule is that I resolve, then I'll do that next round.

context.consoleview.description=In Console View No newline at end of file
context.consoleview.description=In Console View

ansicon.prefpage.name = Ansi Console

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

"Ansi support" would be better here is we place the preference page under the more general "Console" one.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

@mickaelistria

Copy link
Copy Markdown
Contributor

1 important question we need for IP clearance, as stated in the submission form: "please provide contact details for each of the contributors: name, organization, email address and/or phone number, percent of contribution authored.". Can you please provide those infos as accurately as possible?

@laeubi

laeubi commented Jul 5, 2022

Copy link
Copy Markdown
Contributor

We'll get some guidance about how to deal with dual-license (we never had it in Platform so far, let's see what happens...)

The console has moved to EPL 2.0 so I don't think there is any dual license if we say it is EPL OR Apcahe we should choose now to use ELP 2.0 instead of letting the user choose in the past... that's just too confusing.

@mihnita would you mind to chose EPL 2.0 over Apache here, I don'T think it makes much sense to mix or let users choose here.

@laeubi

laeubi commented Jul 5, 2022

Copy link
Copy Markdown
Contributor

1 important question we need for IP clearance, as stated in the submission form: "please provide contact details for each of the contributors: name, organization, email address and/or phone number, percent of contribution authored."

We have not provided that for the recent m2-archiver adoption, so maybe you have chosen a different License type here?

@mickaelistria

Copy link
Copy Markdown
Contributor

We have not provided that for the recent m2-archiver adoption

We should probably have done it for m2e-archiver as well, at least the submission form does request that information.

@laeubi

laeubi commented Jul 5, 2022

Copy link
Copy Markdown
Contributor

We have not provided that for the recent m2-archiver adoption

We should probably have done it for m2e-archiver as well, at least the submission form does request that information.

Maybe but obviously it is not a requirement. And collecting that information has several problems:

  1. collecting this detailed information might fall under GDPR, and I'm not sure we like to open that can of worms for @mihnita
  2. all contributors have already give consent and if EF feels it still needs to contact them all it should be their obligation because of (1), don't think an individual can request such sensitive information
  3. percent of contribution authored might be open to discussions, e.g. especially as not all code was contributed one could not just use the stats from github, if I edit a line several times, do it count as one or multiple and so on...

So if there is a real issue, I would suspect it is raised in the CQ ...

@mickaelistria

Copy link
Copy Markdown
Contributor

@mihnita

mihnita commented Jul 5, 2022

Copy link
Copy Markdown
Contributor Author

I've changed the license in the header to EPL 2 only.


"please provide contact details for each of the contributors: name, organization, email address and/or phone number, percent of contribution authored."

I can do that for myself (but ideally not in a public place like this :-)
Although I have never had to do anything like that before, for any open source project I've contributed to.

I can't do that for the other contributors, as I don't have that info.
All I have is the GitHub IDs (and whatever names they choose to use on GitHub)

And for the percent of the contributions, I can get them from the GitHub commits.
But they are really small.
Here is the list of merged PRs

@mickaelistria

Copy link
Copy Markdown
Contributor

No need to worry about the contributors anymore, I've gathered data from the "insights" of initial repo.

@mihnita

mihnita commented Jul 5, 2022

Copy link
Copy Markdown
Contributor Author

No need to worry about the contributors anymore, I've gathered data from the "insights" of initial repo.

Thank you.

Although that is a bit deceiving.
The biggest contribution (+164/-60) was a full file reformatted because it added 2 lines,
and another existing file copy-pasted and slightly changed.
And I ended up reverting the merge 4 minutes later :-)
Probably does not matter, but just making sure.

@mihnita

mihnita commented Jul 21, 2022 •

Copy link
Copy Markdown
Contributor Author

Hi all,

I am in no rush, or try to put any pressure.
But since this was quiet for a bit more than 2 weeks, I wanted to make sure that I am not the blocker.
I've checked the messages here and in the associated issue (#47) and I didn't find anything actionable for me.
But I though it is better to ask.
Do I have to sign some CLA, do anything else?

Thanks,
Mihai

@mickaelistria

Copy link
Copy Markdown
Contributor

We're waiting from Eclipse Foundation staff to process an IP review before we can merge it: https://dev.eclipse.org/ipzilla/show_bug.cgi?id=24173 ; and it's not very fast these days...

@mihnita

mihnita commented Jul 22, 2022

Copy link
Copy Markdown
Contributor Author

Absolutely no problem. I just wanted to be sure it is not on me to do something
Thank you,
Mihai

@mickaelistria

Copy link
Copy Markdown
Contributor

Seems like we're finally good to merge from IP perspective. What we need now is a green CI build and a clearer history.
Can you please:

  • Squash all 12 commits in this PR
  • Rebase the 1 commit on top of master
  • git push force to your topic branch to refresh this PR
    ?
    Thanks in advance.

@mickaelistria mickaelistria added noteworthy Noteworthy feature enhancement New feature or request labels Jul 26, 2022
@mickaelistria mickaelistria added this to the 4.25 M3 milestone Jul 26, 2022
@mihnita

mihnita commented Jul 27, 2022

Copy link
Copy Markdown
Contributor Author

Done.
Thank you.

@mickaelistria

Copy link
Copy Markdown
Contributor

It looks like the org.eclipse.debug.tests suite now takes too long with this patch: ~30minutes as opposed to 1 minute for master.

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

Sorry, this is completely unexpected.
How can I run that?
Thanks,
M.

@mickaelistria

Copy link
Copy Markdown
Contributor

You can try mvn clean verify -Pbuild-individual-bundles (it's the usual command to build/test any subpart of Eclipse SDK)

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

Thanks.

I think I got the cause.

The "Console performance warning" dialog shows up.
And if nobody closes it (of course :-), probably stays open until something times-out.

I am reading Console.lowWaterMark and if it is smaller than 150000 then I recommend to increase it to 1000000.
The default is 80000.

Option 1 is to tinker with the test.
Lower the number to be below the default of 80000, or remove the test completely.
So the dialog does not show anymore.
But the risk is that people will get low performance in some cases.

Option 2 would be to increase the default from 80000 to something that passes that test.
If my recommendation of 1 million seems excessive then we can compromise somewhere in between.
Maybe 500K, or 200K?

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

To test Option 1 (increase default size) I've changed org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/DebugUIPreferenceInitializer.java

From

prefs.setDefault(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK, 80000);
prefs.setDefault(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK, 100000);

to

prefs.setDefault(IDebugPreferenceConstants.CONSOLE_LOW_WATER_MARK, 1000000);
prefs.setDefault(IDebugPreferenceConstants.CONSOLE_HIGH_WATER_MARK, 1008000);

And it does not seem to work. The dialog still complains about 80000.
I suspect there are some other places that affect that. But I could not (easily) find anything.


For Option 2 I've changed the test limit in
eclipse.platform.debug\org.eclipse.ui.console\src\org\eclipse\ui\internal\console\ansi\AnsiConsoleUtils.java
From:

private static final int MINIMAL_CONSOLE_BUFFER_SIZE = 150_000;

to

private static final int MINIMAL_CONSOLE_BUFFER_SIZE = 79_999;

That works.

But my preference would be option 1.

@mickaelistria

Copy link
Copy Markdown
Contributor

But the risk is that people will get low performance in some cases.

How "bad" is the performance? and in which cases?
What is the operation that cost so much performance overhead? Can we optimize that?
If this is harmful for overall usability (too long delays or ever freezes) and no solution is found, then we should guard the extra coloring with a preference (there is actually already 1 existing I believe), keeping the option turned off by default so it doesn't become "worse" by default.

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

How "bad" is the performance? and in which cases?
What is the operation that cost so much performance overhead? Can we optimize that?

To be fair, that test is pretty old.
Meantime I did a lot of performance improvement.
So it might not be that bad. I don't have good numbers. Not recently.

Also, Eclipse had a bug in dark mode where the style listener was invoked a lot more than in light mode.
And was on Windows only.
That is what triggered my addition of the test and the recommendation to increase the buffer size:
mihnita/ansi-econsole#27 (comment)

And that seems to be recently fixed in Eclipse:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=579406


I've changed my buffer test to just a bit under the default of 80000.
That way the integration tests pass.

@laeubi

laeubi commented Jul 29, 2022

Copy link
Copy Markdown
Contributor

Can we maybe just remove the Dialog?

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

Sorry, I'll call it a day.
It's 4:50 am for me :-)
M.

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

I currently test for 2 things that I know to affect performance:

  1. Console.lowWaterMark ("Limit console output" & "Console buffer size")
  2. org.eclipse.ui.console.P_CONSOLE_WORD_WRAP ("Enable word wrap")

I didn't measure them in a while, but at the time the word wrap made things up to 20 times slower.
With or without escapes, nothing to do with the ansi plugin.

We can remove the dialog before the merge, or after.
If we merge first we can measure performance a lot better, with the latest Eclipse (the current "in the works" one) before making a decision.

In fact I had this dialog to review on my "to do" list (#47 (comment)):
"Performance tests & warnings: should we keep them?"
I don't see this merge as "the end" :-)

Your call.

@laeubi

laeubi commented Jul 29, 2022

Copy link
Copy Markdown
Contributor

I think the dialog could be removed as it somewhat disturbs the user, if a higher mark is required we should change it (but not with this PR) instead of asking every user to change its preferences (by the way I always increase this anyways ...)

@mickaelistria

Copy link
Copy Markdown
Contributor

I agree with @laeubi that we should remove the pop-up. If it is really useful, then logging is enough.

@mihnita

mihnita commented Jul 29, 2022

Copy link
Copy Markdown
Contributor Author

OK, removed the pop-up.

@mickaelistria

Copy link
Copy Markdown
Contributor

CI fails because of

21:51:28.399 [INFO] --- tycho-compiler-plugin:3.0.0-SNAPSHOT:compile (default-compile) @ org.eclipse.ui.console ---
21:51:28.405 [INFO] Compiling 78 source files to /home/jenkins/agent/workspace/eclipse.platform.debug_PR-50/org.eclipse.ui.console/target/classes
21:51:29.520 [WARNING] /home/jenkins/agent/workspace/eclipse.platform.debug_PR-50/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ansi/AnsiConsoleUtils.java:[15] 
	import org.eclipse.swt.SWT;
	       ^^^^^^^^^^^^^^^^^^^
The import org.eclipse.swt.SWT is never used

Can you please fix that?

@mihnita

mihnita commented Jul 30, 2022

Copy link
Copy Markdown
Contributor Author

Done.

Sorry, I should have seen that.
But I removed something outside the IDE, which would have warned me.
Lesson learned.

@mihnita

mihnita commented Jul 30, 2022

Copy link
Copy Markdown
Contributor Author

Ah, clicking "Show all checks" in this PR I could have seen the link to Jenkins.

@mihnita

mihnita commented Aug 3, 2022

Copy link
Copy Markdown
Contributor Author

Gentle ping :-)
I know my fix was over the week-end, so maybe the notification was missed.

@akurtakov

Copy link
Copy Markdown
Member

Can someone please take this over as @mickaelistria is on vacation and most likely won't be able to finish this one for 4.25 M3?

@laeubi laeubi left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Concerns seem to be addressed, builds are green, I think we are ready to go and improvements can be done on top of this change!

@SarikaSinha

Copy link
Copy Markdown
Member

I will review/test tomorrow before the final merge.

@SarikaSinha SarikaSinha left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Please provide images with 2x size also and place them under eview16 directory.

Good to have in the future:

  1. Tests added under org.eclipse.debug.tests.console
  2. Commands added in the right click after may be Word Wrap

* Bring in Ansi Console, no changes, at 3ed6a5a29b1a3d896f5d0b4e0531b4d1290077ce
* Move them to the org.eclipse.ui.internal.console.ansi namespace
* Disable check for localizable strings (for now)
* Remove AnsiConsoleMavenLaunchParticipant. This compiles.
* Glue everything together, ANSI escapes work in console
* Remove the links to the standalone plugin sites
* Pref page: remove the settings to check for M2E Chromatic
* Externalize the localizable strings
* Warning messages split into lines to prevent translation damage
* Implement code review feedback
* Change license header to EPL 2 only
* Move two methods from ConsolePlugin to AnsiConsolePageParticipant
* Remove the performance checking
* Add icons to eview16 and add x2 versions
@mihnita

mihnita commented Aug 4, 2022

Copy link
Copy Markdown
Contributor Author

Thank you very much.

@SarikaSinha
SarikaSinha merged commit eee2da6 into eclipse-platform:master Aug 4, 2022
@SarikaSinha

Copy link
Copy Markdown
Member

Thank you @mihnita

We will also need the documentation to be added for the Help explaining the preferences and the Console Commands.
This needs to be done at least by 4.25 RC1.

@HannesWell

Copy link
Copy Markdown
Member

I somehow missed this PR.
Thank you very much @mihnita and the others for assisting him. Looking forward to use it directly in Eclipse.

@mihnita do you plan to contribute enabling the colored print-out for Maven builds to M2E? Otherwise I can do that little change.

@mihnita

mihnita commented Aug 12, 2022

Copy link
Copy Markdown
Contributor Author

Thank you Hannes!

I'll take a shot at it over the weekend.
It's probably a small change...
Once you know where to do it :-)

Mihai

@mihnita

mihnita commented Aug 12, 2022

Copy link
Copy Markdown
Contributor Author

@HannesWell

I've tried to get the sources and setup the build environment using the Eclipse Installed
(and managed to do it only after adding xtext, not only m2e)
But now I can't build (missing dependencies)

Rather than debugging my setup it might be more expedient if you do the change,
so that it makes the M3 cut.
Sorry.

I would like to figure it out though, because I would like to improve coloring a bit in m2e :-)

Setting style.color to always enables colors only partially.

The log level is still not colored with the internal Eclipse maven.
But it is colored with an external Maven, see
https://mihai-nita.net/2020/08/23/force-maven-colors-in-eclipse-console/

Maybe we (you? me?) should open a separate issue for that (once style.color=always is in)

Thank you,
M.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request noteworthy Noteworthy feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants