-
Notifications
You must be signed in to change notification settings - Fork 5
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
dependency doesn't track path below base directory #103
Comments
Great find @dkebler. Thanks for contributing. This is import resolution behavior that differs from JavaScript-centric dependency loaders. This is definitely a bug; my hunch is that both sublime-dependents and node-dependents will need this fix. I'll ping you when it's done. Thanks again! |
Along this line for those using bower/compass like I do there i have @imports that reference paths in the config.rb used by bower. So for example if look at my _packages.scss So your package to to be useful in the sense of being able to follow a sass dependency into an "external" package (outside the root) you'd have to parse the config.rb file. I guess that would mean another setting which would be path to compass config.rb file. If set then you'd know the person was using compass. I don't use grunt or other sass compilers but I imagine it's a similar issue. |
@dkebler This was fixed in version 2.4.6 (submitted to package_control and pending release within the hour). The lookup order is detailed here: https://github.com/mrjoelkemp/sublime-dependents/releases/tag/v2.4.6. I have to make sure this bug doesn't affect the Find Dependents feature. Thanks again for contributing. |
With latest version I can now drill down dependencies multiple But As an example. Drill down from the sass root, main file of my repo Just for grins I put a 'test' dependency in the /base/layout/_page.scss full repo here For dependents to work properly (well they way I think it should work) it Looking "down" a path tree for a dependent is not necessary despite working Hope this feedback helps On Mon, Feb 9, 2015 at 8:45 PM, Joel Kemp [email protected] wrote:
Cheers, Cuidate, TTFN http://www.youtube.com/watch?v=5Gu50vq5ux4 |
another thought. If sublime provides a hook to the currently open files On Tue, Feb 10, 2015 at 9:00 PM, David Kebler [email protected] wrote:
Cheers, Cuidate, TTFN http://www.youtube.com/watch?v=5Gu50vq5ux4 |
Thanks @dkebler! Your feedback is invaluable and highly appreciated.
Good catch. I need to fix that in node-dependents: dependents/node-dependents#49. There's also an outstanding bug: #42 that might have been fixed for Sass but not JS.
I think this is the best solution for "jump to dependency" as it would be great to navigate anywhere (both inside and outside the root). The whole purpose of going with user-specified locations was for performance and to avoid recursively looking through lots of directories (as is the case with larger projects). I'll prototype this idea and see how it really impacts performance.
As a heuristic, that makes sense, but it's an incomplete view of the dependency tree and also has a big assumption on the way people use the plugin. |
To avoid confusion between dependents and dependencies I think I'll opt for In the case of dependent(parent) lookup I assume your code opens and reads if so then I understand the performance hit of parsing too many files and Settings could take care of someone wanting to look more places and So my solution is to have these defaults:
These defaults would would satisfy me and they make sense in terms of not BUT if you want to write more code....any of these could be overridden to On Wed, Feb 11, 2015 at 10:19 AM, Joel Kemp [email protected]
Cheers, Cuidate, TTFN http://www.youtube.com/watch?v=5Gu50vq5ux4 |
Yes, exactly.
I'm going to add tests for this in node-dependents. This style is heavily based on relative pathing, which nodejs programs are somewhat close to, but perhaps not as deeply nested. This case should surface some problems with path resolution.
Thanks for laying out some suggestions. Ideally, for dependents, I'd like no root settings and when you want to find a file(s), just search for all JS or Sass files in the current project and do a proper path resolution on each file's dependencies to yield an absolute path per dependency. After that, you have an accurate mapping from the dependency tree to the filesystem tree and can return the parents that have the current file's path as a child. For jump to dependency, I'd like to take the clicked path and perform the file lookup (different algorithm per language).
Sorry for the length, but writing it out was pretty helpful. Thanks for the brainstorm. |
If you are able to store a map of all dependencies then clearly this is The map (a json file?) also solves the problem of dependencies whose Question is when/how to trigger building the map. (any or all of these??) TRIGGER MAP BUILDING
SCOPE OF SEARCH FOR MAP BUILDING. Yes the best scope is the open root folder/project. In which case maybe This means a map would be created and stored for each folder opened. I On the off chance someone has a library outside the scope of the open root I would still keep that path setting to override using the project DISPLAY THE MAP Glad to help out with brainstorming. When it comes to all this map making On Wed, Feb 11, 2015 at 8:45 PM, Joel Kemp [email protected] wrote:
Cheers, Cuidate, TTFN http://www.youtube.com/watch?v=5Gu50vq5ux4 |
I'm thinking of generating the map (if it doesn't exist) on save of a file or when a feature is triggered and no map exists. If a map does exist and a file is saved, that file's portion of the map would be recomputed likely using: https://github.com/mrjoelkemp/node-dependency-tree. Then, with an updated map, Find Dependents and other tree-based features would only be limited by the map-search algorithm. I'll have to see the hooks available in the ST api. I know that linters lint on save, so there has to be something there. I'll see how this approach goes. |
If one of my imports directs to a code file in subdirectory below the set "root" directory and then that file contains yet another import. Jumping to that dependency the plugin is unaware that it is in a subfolder and should include that subfolder in the path. Instead it looks back in the root. I confirmed this by simply moving the dependency file to the root.
In the console output below _base-theme.scss is in the subdirectory /base (@import 'base/base-theme') as is _color.scss, but the plugin is not looking in /base but rather the scss root I set which was "framework/scss".
I have a copy of what I am working on at github. You can see for yourself. Take a look at the path structure of my scss there.
https://github.com/dkebler/hugo-quickstart-site/tree/master/framework/scss
sitestyle.scss is the root dependent.
Not sure I would call this a bug so much as an enhancement, but organizing code guidelines encourage using subdirectories and thus import paths are relative. Seems like you have to grab the open file's path and compare it to the root set path and strip out and insert any subdirectory path(s) for use. Dependants will be a problem too. Right now that only works only because I am one subdirectory deep. Guess you could keep stripping out subdirectories looking for the file until you arrive at the root. Searching the entire tree at once would not be a good idea since identical file names could be used in different path branches (and I do!) although if you hit the root and don't find it then other branches could be searched.
The text was updated successfully, but these errors were encountered: