ishchenko / idea-navigate-from-literal

11 stars 11 forks source link

Guess file extension if not set in string literal #6

Closed victor-homyakov closed 10 years ago

victor-homyakov commented 10 years ago

In RequireJS filenames are specified without extension .js, e.g.

define([
    'path/module' // actual filename is path/module.js
], function(module) {
    // code...
});

Is it possible to add missing extension in this case, i.e. navigate to module.js when Ctrl-clicking on string 'path/module'?

ishchenko commented 10 years ago

Nice idea! I can treat a string literal like a filename without extension. The only problem I see is too many files with same name but different extension in your project.

victor-homyakov commented 10 years ago

AFAIK that's the only case when extension is omitted, at least I cannot remember similar cases for other languages. Therefore I think that '.js' would be preferred extension, especially if current file is JavaScript.

In case when information about language is unavailable, plugin may use list of preferred extensions.

ishchenko commented 10 years ago

I can give another example - resolving views in Spring MVC. That happens in my projects, and IDEA Spring support plugin fails to discover my ViewResolver and would not jump to templates by name.

I think, the best way is to start searching using source file extension, if it is not found - search files with any extension.

victor-homyakov commented 10 years ago

Yep, that would be great.

ishchenko commented 10 years ago

Now it finds and shows variants in the following order: exact name + extension match, name + source tile type match, name without extension match. Also made it is case insensetive. Uploaded 1.6 to repo, check it out and comment if it works for you.

victor-homyakov commented 10 years ago

Works fine. Thanks!!!