-
Notifications
You must be signed in to change notification settings - Fork 11
Extend Jython auto-completion to instantiated classes #51
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
Merged
Merged
Changes from all commits
Commits
Show all changes
39 commits
Select commit
Hold shift + click to select a range
3ef7091
Jython: Add auto-completion support for non-static methods!
tferr f7899f6
Warn user on invalid imports
tferr 422f160
Add parameters and definitions to the description of completions
tferr 092a86c
Fix visibility of field
tferr 686f15b
auto-complete words that contain a term
haesleinhuepf b7d5201
added compatibility for import-as statements
haesleinhuepf 77c3664
allow classes and aliases with lower case first character
haesleinhuepf d2a6256
Merge pull request #1 from haesleinhuepf/autocomplete_commands_that_c…
tferr 121ad9c
Suggestion list: Ensure entries starting with seed remain on top of list
tferr 1f3bea6
Fix formatting issues
tferr 721fe91
Revert "added compatibility for import-as statements"
haesleinhuepf f9c6a69
Restrict allowed whitespace in variable declaration
tferr 9a584df
Merge pull request #2 from haesleinhuepf/import-as_statment
tferr 0d076ff
Merge remote-tracking branch 'tferr/autocompletion-vars' into autocom…
tferr daff927
Improve autocompletions
tferr e7870c0
Refactoring: move generic code to ClassUtil...
tferr 89f5e08
Use frames when accessing javadocs
tferr b7c51fc
Revert "Merge pull request #2 from haesleinhuepf/import-as_statment"
tferr 155c8aa
Revert "Merge pull request #2 from haesleinhuepf/import-as_statment"
tferr 0050715
Merge remote-tracking branch 'tferr/autocompletion-vars' into autocom…
tferr 96da72a
[maven-release-plugin] prepare release script-editor-0.5.9
frauzufall 34a2e05
Jython: Add auto-completion support for non-static methods!
tferr b17cd7a
Warn user on invalid imports
tferr 49d37b0
Add parameters and definitions to the description of completions
tferr ce3bb7a
Fix visibility of field
tferr 92dfdb3
auto-complete words that contain a term
haesleinhuepf 1a3ffaa
added compatibility for import-as statements
haesleinhuepf 8d155fa
allow classes and aliases with lower case first character
haesleinhuepf 8b4bf53
Suggestion list: Ensure entries starting with seed remain on top of list
tferr 05ee489
Fix formatting issues
tferr 0dfa760
Revert "added compatibility for import-as statements"
haesleinhuepf 1d1f255
Restrict allowed whitespace in variable declaration
tferr 1e46e56
Improve autocompletions
tferr ae945c0
Refactoring: move generic code to ClassUtil...
tferr 3751e7c
Use frames when accessing javadocs
tferr 2ce9f88
Revert "Merge pull request #2 from haesleinhuepf/import-as_statment"
tferr cd732e2
Implement CompletionText and modify ClassUtil for upcoming changes ...
tferr 0e90654
Merge remote-tracking branch 'tferr/autocompletion-vars' into autocom…
tferr 04e945c
Merge branch 'master' into autocompletion-vars
tferr File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| #release configuration | ||
| #Wed Dec 16 10:56:44 CET 2020 | ||
| project.scm.org.scijava\:script-editor.developerConnection=scm\:git\:git@github.com\:scijava/script-editor | ||
| scm.tagNameFormat=@{project.artifactId}-@{project.version} | ||
| scm.tag=script-editor-0.5.9 | ||
| pushChanges=false | ||
| scm.url=scm\:git\:git\://github.com/scijava/script-editor | ||
| preparationGoals=clean verify | ||
| project.scm.org.scijava\:script-editor.tag=HEAD | ||
| project.scm.org.scijava\:script-editor.url=https\://github.com/scijava/script-editor | ||
| remoteTagging=true | ||
| projectVersionPolicyId=default | ||
| scm.commentPrefix=[maven-release-plugin] | ||
| project.scm.org.scijava\:script-editor.connection=scm\:git\:git\://github.com/scijava/script-editor | ||
| project.dev.org.scijava\:script-editor=0.5.10-SNAPSHOT | ||
| exec.snapshotReleasePluginAllowed=false | ||
| exec.additionalArguments=-Dgpg.skip\=true -P deploy-to-scijava | ||
| completedPhase=end-release | ||
| project.rel.org.scijava\:script-editor=0.5.9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/main/java/org/scijava/ui/swing/script/autocompletion/CompletionText.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| package org.scijava.ui.swing.script.autocompletion; | ||
|
|
||
| import java.lang.reflect.Field; | ||
| import java.lang.reflect.Method; | ||
|
|
||
| import org.fife.ui.autocomplete.AbstractCompletion; | ||
| import org.fife.ui.autocomplete.BasicCompletion; | ||
| import org.fife.ui.autocomplete.CompletionProvider; | ||
|
|
||
| public class CompletionText { | ||
|
|
||
| private String replacementText; | ||
| private String description; | ||
| private String summary; | ||
|
|
||
| public CompletionText(final String replacementText) { | ||
| this(replacementText, (String)null, (String)null); | ||
| } | ||
|
|
||
| public CompletionText(final String replacementText, final String summary, final String description) { | ||
| this.replacementText = replacementText; | ||
| this.summary = summary; | ||
| this.description = description; | ||
| } | ||
|
|
||
| public CompletionText(final String replacementText, final Class<?> c, final Field f) { | ||
| this(replacementText, ClassUtil.getSummaryCompletion(f, c), null); | ||
| } | ||
|
|
||
| public CompletionText(final String replacementText, final Class<?> c, final Method m) { | ||
| this(replacementText, ClassUtil.getSummaryCompletion(m, c), null); | ||
| } | ||
|
|
||
| public String getReplacementText() { | ||
| return replacementText; | ||
| } | ||
|
|
||
| public String getDescription() { | ||
| return description; | ||
| } | ||
|
|
||
| public String getSummary() { | ||
| return summary; | ||
| } | ||
|
|
||
| public AbstractCompletion getCompletion(final CompletionProvider provider, final String replacementText) { | ||
| return new BasicCompletion(provider, replacementText, description, summary); | ||
| } | ||
|
|
||
| public void setReplacementText(final String replacementText) { | ||
| this.replacementText = replacementText; | ||
| } | ||
|
|
||
| public void setDescription(final String description) { | ||
| this.description = description; | ||
| } | ||
|
|
||
| public void setSummary(final String summary) { | ||
| this.summary = summary; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return replacementText + " | " + description + " | " + summary; | ||
| } | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This approach is dangerous in that it doesn't consider the scope of the variable. I would do it differently, by parsing the code like jython's interpreter with a ParserFacade, see e.g. https://github.com/acardona/scripts/blob/master/python/imagej/jython/parse_code.py
Uh oh!
There was an error while loading. Please reload this page.
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.
Good point. Are you able to work on this? To me the priority would be to support he return type of the static method so I'd prefer to work on that instead (unless you say otherwise)
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, proper jython code parsing is something I've been working on but haven't committed yet. Will lead to:
For the latter case, the
AutoCompletionListenerinterface will allow e.g. @haesleinhuepf's update site to add variable name-based imports (e.g. for imp, ip, fp, etc.)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.
@acardona, Great! On a second thought I will hold for now, as you are likely to revamp a bunch of things. But do let me know if there is something you want me too look into. I won't work on this until I hear from you (so feel free to merge), but do let me know if you want me to look into something. I will post below a summary of what this (snowballed) PR now has.