leonmatthes / autocompletion Goto Github PK
View Code? Open in Web Editor NEWA modern Autocompletion for your Squeak image
A modern Autocompletion for your Squeak image
Currently the simple untyped model is used when the receiver is not known.
This could be split into an untyped model with receiver and one without receiver.
As currently the untyped model contains way too many symbols like classes which are usually nonsense when there is a receiver.
Maybe connects to #14 because we would only want to include method names in this list.
But this would mean finding out all possible method names in the image.
I updated Autocompletion during the last several days. Today I wanted to open a new Workspace window. When I hit the first key in it to type something, I get MessageNotUnderstood: UndefinedObject>>model:
from Workspace>>createCompletionController. That method references the class ECWorkspaceController, which no longer exists in my image.
The preference is set so that it accesses the undefined binding, so nil becomes the receiver of the model: self
message send.
Scenario:
Now, the Autocompletion menu slowly fades out. However, as it parent has abandoned, I would expect it to abandon immediately.
Scenario:
Bug:
(Not that I wanted to turn my back on Autocompletion, but I wanted to test downward compatibility of our tool for users who have not yet had the pleasure of this cool package!)
Two related issues:
When typing something like Transcript showln: #completio
, symbols (here: #completion
) are not suggested, but only class names.
When typing something like 123<linebreak>#compareSafel
, #compareSafely:
is suggested correctly, but expanding it inserts placeholders for the arguments (___
) even though the symbol was meant to be entered as a symbol indeed.
(This example may also reveal another usage problem: In this example, I am taking notes in a syntax-highlighting workspace and actually would not expect to continue the expression from the first line in the second line - but unfortunately, this is how Smalltalk works ...) Anyway, I think when the symbol is prefixed with a hash, it should actually also be completed as a symbol.
Wdyt? As far as it concerns my personal usage, this area might be one of my (probably: the) most annoying behavior when working Autocompletion which I otherwise find great :-)
Referring to the extension method #image:at:sourceRect:rule:
in AlphaBlendingCanvas
(which, btw, is missing the -override
suffix in the extension category name), see ced5677#diff-f8e09250df8680dcca55dfd0177755ff:
Could you please provide a short description of this fix? I'd love to see this in Trunk because it shadows the original method version and thus keeps a "removed method" in my Monticello working copy.
Imagine I want to type the following code:
1 to: 5 do: [...]
.
If I type 1 to
and use the autocompletion I get 1 to:
. If I now continue typing the d
I get several suggestions but not the do:
which would be the second part of the to: do:
message. But that would be a cool feature.
I tried to search for this repository today using the GitHub search, but could not find it with the terms "autocompletion squeak". Could you please add Squeak somehow in the project description, so that this repository will show up with these search terms?
Currently the Untyped Model uses either the Symbols from the current environment or ALL symbols.
Both are usually not what you want. All symbols are way too many, especially in images that use symbols for anything other than code. But the environment usually contains only class names and not selectors, which is not enough.
So we should implement a custom tracking, that saves all symbols that are currently part of methods. This could be updated whenever a method is compiled.
Open questions:
Type guessing is a very nice feature, but I think in some cases, information about the actual accessed instance could be useful for further type guessing.
There are many quick methods in Squeak (accessors or magic number returns) which are very fast and side-effect-free. We could guess the instance of the last typed expression in some cases and then perform a possible quick method, to "guess" the type of its return value.
One popular scenario might be Autocompletion in Inspector: Do Morph new inspect
, then type bounds origin sqr
. Currently, there is no suggestion for sqrt
, but as Rectangle>>#bounds is quick, it would be possible to find out the type of bounds origin
and so to suggest sqrt
. It would be even possible to suggest self bounds origin x sqrt
etc.
(self guessObjectForName: aString) class
These are only some thoughts by someone who is not deep into the implementation, so I would be very happy about your feedback! So long, best success for your thesis, @MrModder :)
Scenario:
bounds
correctlybounds
will not be suggested -- but instead, origin
and corner
bounds
, not origin
Reason:
Questions and solution approaches:
object class
?object class
.As the developer of a Squeak Tool, it would be great to have the ability to define my own Autocompletion entries so that for example search bars could have custom fitted Autocompletion support.
Goal:
Define an API that allows TextMorph-model programmers to provide their own entries to the Autocompletion.
Secondary Goal:
Keep the API generic enough, so that anyone could implement the API hooks without instantly adding the Autocompletion as a dependency
Implementation notes
It is already possible to select a custom ECModel subclass, maybe just provide an ECModel subclass that asks the TextMorph-model for the necessary entries
It would be nice if there is no space inserted after autocompletion, because you get extra spaces before '.' and sometimes before other code (if you insert code somewhere), that you must delete manually
Might fix some of the worse completions when typing in the middle of text
As a developer, when I type a concrete class name and press space, I would like to see the selectors from the "instance creation" protocol (class side) proposed immediately. It would save me opening a browser, selecting the class side, and looking up the names of those methods because I often forget them.
The more specific methods (further down in the class hierarchy), specialized constructors, should come first, then the more general ones. Proposing the constructors from Object (#new, #new:, #newFrom:) is obviously not so important. You could investigate about not showing the proposal if there are no specialized constructors.
More generally, all methods from the class side could be proposed immediately. But constructor selectors are probably the most common continuation after a class name.
Add a big on: Error do:
so users don't get debuggers.
After loading 8cc9dfc, Autocompletion will no longer be shown in Debugger (but flashes for a very short time). This can be solved by overriding #wantsToCloseAutocompletion
in Inspector as follows:
^ self containingMorphicModels isEmpty
But when I overrided this selector locally, I wondered why not to change the implementation in StringHolder itself, so that all containing morphs are considered in every case? Is there any case where this would be an unwanted behavior?
Currently the roles of the main classes (controller, context, menu and models) are pretty mixed into each other.
They should however all perform just one role, these should be:
Controller
Responsible for directing user input, to open/close the menu and to provide the menu with the appropriate model.
Currently the controller is Smalltalk-specific, there are even subclasses for browsers and workspaces, that provide functionality that should probably belong to the context.
Current sins:
#allowOverriding, #completionAdditionals, keeps a permanent reference to the context
Context
The context should be responsible for detecting in what context Autocompletion was opened.
Is there a receiver? What class is it? etc.
Therefore this should be the first Smalltalk-specific part of the system, not the controller.
The context should then be the first part that the Textfield-Model has controller over, basically deciding whether it is a Smalltalk-Textfield or something else.
This would make it possible to implement #23
The context should therefore also be the one responsible for checking whether it is parsing a method, not the controller.
Possible sin: Contains a reference to the model, not necessarily a problem, but who knows
Model
The Model is responsible for collecting all the entries, storing and filtering them
There should be Smalltalk-specific models as well as general purpose ones.
Current issue: Pretty slow, otherwise the models code is pretty solid.
Menu
The menu is responsible for displaying the model data.
It should be as smalltalk-agnostic as possible.
Current sins: Keeps a permanent reference to the context which it uses to access the model instead of communicating with the model directly.
Refactoring needed to remove the context from the model
While investigating recent issues with the auto enclose functionality in Squeak 6.0Alpha Trunk1, @j4yk identified some overlapping preferences of Autocompletion related to the term "smart characters". Without having analyzed their functionality and behavior in-depth, I just wanted to note this down here and propose to revise these preferences to address the following concerns:
HNY :-)
after completing a message, it should be possible to jump to the next argument input (after : ) using tab
Not sure if this is a bug, but in our project, we want to close the Autocompletion when the containing model has lost its focus. Now, when I type something into this model and the Autocompletion opens under the hand, our model looses the focus in favor of the ECMenuMorph. Thus, our model wants to close the Autocompletion. The ECMenuMorph forwards the focus, but our model still has received a mouse leave event before.
After some spiking, I suppose there is currently no comfortable way to reject any focus for a morph in advance? Maybe this would be a proposal for the inbox? The only other morph class whose instances usually never gains focus is HaloMorph, where the initial event is handled directly in PasteUpMorph>>#filterEvent:for:, so it would be quite ugly to intervene there.
It would be nice to have the ability to create custom entries in the autocompletion that gets suggested and extended if you choose them.
example: in webstorm I have a clg entry in my autocompletion that expands to console.log
Maybe it would be possible to create general entries (e.g. tsl => Transcript showln: ) and for classes and their subclasses (e.g. itf => ifTrue: ifFalse: for the Boolean class)
Match not the whole string, but separated parts too
This is probably caused by ECMenuMorphs>>editor being a WeakArray
Currently, the type guesser only analyses the method it is started on and a few methods used to access local variables.
Whenever it hits an unknown method, it stops.
Of course, this could be changed to simply start analysis if the return value of the found method.
Problems:
writing while having selected text should delete the selected text and insert new input at its position
the selection is deselected and new input is inserted at the front of the selection
check for selections before handling the input events
I'm used to this behavior from other text/code editors.
It is useful when replacing e.g. spelling mistakes.
Not sure if this already in: for the case where I'm editing code in the debugger, there is already a lot of type information available. Using this could provide very accurate and helpful completions.
The current protocol for a Model that supports Autocompletion includes the following information:
Almost always when I want to equip a model with a range of cool Squeak features - mainly DoIt & Co., Shout, and Autocompletion - I also need to provide the following details:
Moreover, many classes already specify #selectedClassOrMetaClass for miscellaneous purposes.
I find there is some protocol duplication. When would a model want different types for DoIt, Shout and Autocompletion? I would welcome a simplification and unification of these protocols!
when I compile a new method or change an existing one, it should be ranked higher in the Autocompletion list, as it is likely to be used in the near future
After a given time of inactivity or loosing the focus the autocompletion should close its suggestions.
Scenario:
I have a trait TConsumer
with a single method consume:
.
I implement a method with a parameter named aConsumer
or aTConsumer
.
Expected Behavior:
The completion suggests the method consume:
, as it guesses the type TConsumer.
Actual Behavior:
No type is guessed
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.