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
#514 Add Gradle editor #564
Conversation
eclipse#560 Add editor contribution Signed-off-by: Christophe Moine <christophe.moine@free.fr>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to give your PR a go, but it seems to be that the changes don't compile ATM.
Could you please try building your project locally (./gradlew build
should do the trick) and update the PR?
Besides, there are a lot of style issues: missing headers, tabs instead of spaces, and so on. The build process will indicate those problems, so fixing should be straightforward.
There is some cleanup needed in the code, but first, let me see it in action :)
Sorry, I setup a new environment properly with Oomph :) I tried also to rebase on master branch, I hope there will be no trouble with that... :O |
The FixedRequestAttributesBuilder class was removed in the 2.1.0 release, even though it's used by existing STS releases. To resolve the situation we re-added and deprecateted this class.
The Spring Tool Suite has a dependency to Guava 15 and to Buildship. Due to how the dependencies are currently set up, the only way to make STS and Buildship work together is to use Guava 15 everywhere. This reverts commit c7f47e5.
This commit fixes a regression introduced in Buildship 2.1. The new preferences API ignored the project location and always executed all tasks on the root project. As a result, task selectors were always executed on all projects, even if they were started from a subproject. The fix changes the RunConfiguration interface such that it references a project config as opposed to a build configuration. This commit fixes eclipse#520
Until 2.1 Buildship accepted absolute root project location in the import preferences.
Signed-off-by: Andy Wu <andy.wu@liferay.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We are getting closer! I've tried out the editor and it feels so much nicer than using the simple text editor.
I've added a couple of suggestions how to clean up the code and how to make the new functionality simpler.
There's one thing besides my review comments. Can you please rebase your branch to the latest master so that only your files appear in the review? It's a bit annoying that I have to go through 65 files, even though your change touches ~6 files. Plus, there's already a merge conflict in one of the manifest files.
<extension point="org.eclipse.core.contenttype.contentTypes"> | ||
<content-type | ||
file-extensions="gradle" | ||
id="org.eclipse.buildship.core.gradleScript" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
org.eclipse.buildship.core.files.gradlebuildscript
<content-type | ||
file-extensions="gradle" | ||
id="org.eclipse.buildship.core.gradleScript" | ||
name="Gradle Build File" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Gradle Build Script
@@ -0,0 +1,29 @@ | |||
package org.eclipse.buildship.ui.editor; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing header.
import org.eclipse.ui.handlers.IHandlerService; | ||
import org.eclipse.ui.part.EditorActionBarContributor; | ||
|
||
public class GradleEditorContributor extends EditorActionBarContributor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing javadoc. Please run the build and fix all these issues. If you have any problems running the build (should be as easy as executing ./gradlew build
) just let me know and I'll help.
import org.eclipse.ui.part.EditorActionBarContributor; | ||
|
||
public class GradleEditorContributor extends EditorActionBarContributor { | ||
private static final String REFRESHPROJECT_COMMAND_ID = "org.eclipse.buildship.ui.commands.refreshproject"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this ID to the UiPluginConstants
class.
org.eclipse.buildship.ui/plugin.xml
Outdated
class="org.eclipse.ui.editors.text.TextEditor" | ||
icon="icons/full/obj16/gradle_file.png" | ||
name="Gradle Build Script Editor" | ||
class="org.eclipse.ui.internal.genericeditor.ExtensionBasedTextEditor" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really have to use an internal class here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, good point, but I don't see other way to define an icon for the editor, and most important: an editorcontributor to add "Refresh Gradle Project" action in the toolbar.
|
||
public class GradlePresentationReconciler extends PresentationReconciler { | ||
private static final List<String> GRADLE_IDENTIFIERS=Arrays.asList( | ||
// Java keywords |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please clean up the indentation and remove the comments.
* @author Benjamin gurok | ||
* @author Paul Verest | ||
*/ | ||
public class GradleEditorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have a simple editor and thus we should keep it simple. How about we
- remove the preference page
- reuse the colors from the Java editor (
org.eclipse.jdt.ui.PreferenceConstants
) - Add a preference listener to update the colors when the Java editor colors changed.
This way we can provide a consistent color scheme without adding more complexity to the UI.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I hesitated reusing Java Colors. I will see if that fits.
Ok, no pb. Do you mind if I create a new PR ? I would like to create a clean new branch on my fork. |
Aure, go ahead. Actually, it makes sense as changing this PR might mess up the review comments. |
It seems that colors for Java Syntax depends on the used Theme. With dark theme, keywords are orange instead of violet. Do you know how to take the Theme into account ? I had a look yesterday, but I haven't found in a "reasonable" timing :) If you already know, I would be very interested, thanks. |
eclipse#560 Add editor contribution Signed-off-by: Christophe Moine <christophe.moine@free.fr>
You can attach a listener to the JDT UI plugin preferences. Here's an example:
A small note: The |
Can we help anything regarding this PR? |
Thanks but I haven't much time this week, but don't worry, I'm on it :) Also the current implementation of the PresentationReconcilier don't support the addPreferenceChangeListener.
But as expected, the setData with a new TextAttribute doesn't refresh the editor... JDT use setData with string (token ids) instead of TextAttribute, and I need to use something similar I guess. |
Ok, I made some progress, but it seems a long way home :( It seems that we need a "Reconcilier". The PresentationReconcilier is not sufficient. unfortunately, only genericeditor v1.1 let us define a Reconcilier... Either I need to get ride of genericeditor, or we need to migrate to genericeditor 1.1. What do you think ? |
Hmm, sorry, but it seems that genericeditor it too far from what you expect: the editor doesn't override affectsTextPresentation which allows colors changing "on the fly" |
I think it would be already fine if the editor colors would be updated after the editor is closed and reopened. Theme updates are not that frequent anyway. But there's yet another problem with the generic editor. Since the dependency is relatively new, we can only ship with it Buildship only for the latest version. So, if we set the That being said, I think I'm leaning towards going back to the initial idea of having a discrete editor definition. That way we can support previous Eclipse versions and we have full control over the color preferences. How does that sound to you? In any case, thanks for sticking with us! We are super grateful that you invest your time into this feature. |
I totally agree. My experiments with genericeditor are not conclusive unfortunately :( |
I love Eclipse, but... the Syntax Hightlighthing mechanism with Reconcilier/Damager/Partitioner is just a nightmare !!! |
Damned, I found the magic method to make it work with genericeditor: What do you think ? PS: both solution are almost working, we simply need to choose, but I am less confident with the solution without genericeditor, because there is so much bunch of code I took from other that am not in full control :( |
I'd prefer genericeditor if we can use |
omg, spent one day figuring out with Generic Editor doesn't work... It definitely doesn't fit. The partitionning/damager/reconciler is definitely complex stuff, and Generic Editor doesn't fit. I will switch back the plain old implementation again :'-( (without generic editor) If somebody interested, the limitation comes from this (in SourceViewerConfiguration), which is not properly extendable within GenericEditor:
Now I think I understand why there is not Gradle editor :D |
I am almost ready to push the "non generic editor" solution, is it ok ? |
Sure, please go ahead. |
types + Reuse Java syntax color highlighting Signed-off-by: Christophe Moine <christophe.moine@free.fr>
types + Reuse Java syntax color highlighting Signed-off-by: Christophe Moine <christophe.moine@free.fr>
Pushed. |
Sorry for my clumpsy usage of Git :( |
Thanks for the change, I'll have a look shortly. In the meanwhile, here's what I usually do on the command line when I want to produce a PR with a single commit:
|
I find out my mistake with Git: I told that I woudl create a new PR :) |
New PR: #585 |
I have used the genericeditor. It was almost too simple :)
Appart from the joke, I wanted to use a more sophisticated highlighter rules... For example "task" is defined as a keyword but it is not. It is related to Gradle DSL.... So if you invoke a task like for instance:
task will be highlighted :( It seems we need some kind of semantic parser to do that. I tried (https://github.com/danielsun1106/groovy-parser), but I am not sure parsing the document for highlight syntax is good (I think I can imagine the answer :D ).
If you of someone else have experience on that, I am very interested with these problematic :)
I know Gradle DSL is complex, and it is probably the reason why there is not bundled Gradle editor in Eclipse :D Even if Eclipse seem to bet more on Kotlin DSL to provide an editor, I don't think it will be quickly the most used editor...
It is why I kept it simple so far :)
I also took the opportunity to add a EditorContributor for #560 :)