is refactoring available in Adobe brackets - javascript

It is so great that code completion is already there but two things are also important to have
1- refactoring ( renaming all the incidents of same variable/ function )
2- when you select a variable it to highlight all the occurrences of that variable
I wonder if the 1,2 are available yet as I need a JavaScript IDE to have both plus code-completion. I badly searched for all three Eclipse too. but then Eclipse doesn't have code-completion

1) Check out the "Rename JavaScript Identifier" extension. (The Replace All command built into Brackets is more powerful than what most text editors give you, but it's not a true 'rename refactoring' -- it's not type-aware and currently only replaces within a single file).
2) Check out the "Quick Search" extension.

I use Ternific ("JavaScript hinting and refactoring powered by Tern") which can do more than the above mentioned extension. Still renames on Ctrl+R.

Related

Visual Studio Code Intellisense Method Definitions Javascript

Apparently no one else has wanted this feature, or I'm missing something. Intellisense works as normal, but I'm wondering if I'm missing a setting somewhere, if there is an extension, or if this functionality just isn't offered in VS Code... I would like to have the purpose of the method display when I start typing it as you can see in Adobe Brackets:
As opposed to how it shows in VS Code(which just shows the parameter requirements):
Is this possible?
VSCode is able to use the typescript language server to infer some information about the javascript that you're writing. The types for window/document etc are provided by the typescript team.
Here's where the type information for elements comes from. Compare that with the types for the document object. Notice that the properties here have comments above them, while the element properties do not. Type document.getElementById in VSCode, you'll see extra info like you do in brackets:
So for this information to appear about properties on Elements, someone would need to go through and add the comments. I have no idea if the typescript team is open to this, though.

Syntax folding in JavaScript files does not work in Vim

I've started using Vim 7.4 on Ubuntu and am very pleased with it but there is just one thing driving me crazy: code folding doesn't work (at least for JavaScript)!
The syntax is automatically set to JavaScript when a js file is opened and syntax highlight works so I don't get it. The foldmethod is initially set to "manual" and setting it to "syntax" doesn't make a difference, which puzzles me. I did add let javaScript_fold=1 to my .vimrc file.
Any clue? I'd be very grateful. Thanks!
It's tough to say the exact cause of this issue, but if you don't have a javascript.vim file you probably should. I suggest starting with this enhanced javascript syntax config. It is likely to fix your javascript folding issue, and much more.
If you just want to focus on the folding issue you might try creating your own javascript.vim file in ~/.vim/syntax/javascript.vim that contains code along the lines of what I have given below. You may want to adjust the fold level to your liking (0 is completely folded). However, this simple version will not play well with comments containing curly bracket characters, which is where you will want to go with a more robust javascript.vim like the one I have linked.
syntax region foldBraces start=/{/ end=/}/ transparent fold keepend extend
setlocal foldmethod=syntax
setlocal foldlevel=0
I should add that both myself and the other responder are suggesting that you need a javascript.vim, and in fact by some of the same contributors. However, the one I am suggesting was last updated in December of 2015 as opposed to 2009.
I don't know why your solution isn't working, but a possible solution is to use a user-created vimscript available at http://www.vim.org/scripts/script.php?script_id=1491
Just had this same issue answered on Vim Stack Exchange, and the answer is that if you do use the stock syntax/javascript.vim file, then you have to set
vv
let g:javaScript_fold = 1
^^
The difference between the command in the question and here is the g: part (highlighted above). I'm new to Vim scripting, but I believe the difference is that let javaScript_fold=1 sets a script-local variable, making it confined to your .vimrc file, and the example above makes it global (which seems to be confirmed by this Stackoverflow thread). See more on this at section 41.2 Variables in :help usr_41.txt and :help internal-variables.
This Reddit thread was also enlightening; it's not JavaScript-related but the folding seems to be useful for JS files as well.

Renaming variables in JavaScript

I've been stuck with the unpleasant task of "unminifying" a minified JavaScript code file. Using JSBeautifier, the resulting file is about 6000 lines long.
Ordinarily, the variable and parameter names would be permanently lost, but in this case, I have an obsolete version of the original file that the minified JavaScript code file was generated from. This obsolete version of the original file contains most of the code comments and variable names, but absolutely cannot be used in place of the current version.
I would like to know if there is some way of renaming all instances of a particular parameter or variable in JavaScript. Since minification reduces the names to a single character, find-and-replace is impossible.
Is there some tool out there, which I can tell, in this file, the parameter a to function foo should be clientName and have it semantically rename all instances of that parameter to clientName?
Unfortunately, I work for a large organization with an approved list of software and I am stuck with Visual Studio 2010 for the forseeable future (no VS 2012).
Update: #Kos, we don't use Git, but we do use source control. The problem is that a developer who doesn't work for my organization anymore once made changes to the file, minified it, and only checked in the minified version to source control, so his changes to the original have been lost.
I'm a year late for this answer, but I had a similar problem to yours so I built this: https://github.com/zertosh/beautify-with-words. It unminifies code using UglifyJS2 but uses a phonetic word generator to rename variables. You get "long-ish" variable names so it's a breeze to do a find-and-replace. Hope this helps someone else!
You might have another way out.
Check out the last unminified version of the code. Compare to the minified version. Arguably most of it should be the same modulo consistent variable renaming. The differences you'll have to rename and remerge.
Diff won't do this kind of compare; you need tools that compare the programs as code, not text. Our SmartDifferencer tool will do this (by using language-specific full parsers to generate ASTs, and then comparing the ASTs); in effect, it compares the programs in spite of whitepspacing. SmartDifferencer also handles renaming; if two file are identical modulo a single renaming, that's what SmartDifferencer tell you.
I don't know how well this work work out; we haven't tried SmartDifferencer with 6000 lines of "consistently renamed" variables.
I found that a Visual Studio extension we've licensed here called "Telerik JustCode" has functionality to do what I want.

How can you set up Eclipse to remove trailing whitespace when saving a JavaScript file?

I am running Eclipse 3.6 (Helios 20110218-0911) on Ubuntu 11.04. Under Preferences, I have gone to the following panel:
JavaScript -> Editor -> Save Actions.
The "Additional actions" checkbox is checked and "Remove trailing whitespaces on all lines" is selected.
Nevertheless, when I save my JavaScript file in Eclipse, there is still trailing whitespace at the end of my lines.
What am I missing?
'Save Actions' for JavaScript is available in the JavaScript project(the project with JavaScript nature) only.
(If you can see 'Convert to JavaScript Project' in 'Configure' menu when right-click the project, try it)
I recently faced the same problem. The only way I found is to convert your project to Javascript project. Right click your project folder in the Explorer, choose [Configure] -> [Convert to Javascript project] and the Javascript Save Action will start to work.
Unfortunately, I don't know how to convert it back.
Since it's not a big problem for me, the way Converting it to javascript project indeed helps me a lot.
For the latest Eclipse -
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200
The default key-binding shift+ctrl+backspace, which binds to the function "Removes the trailing whitespace of each line" will remove trailing space chars for the entire file.
(The key-binding shift+ctrl+backspace is probably already there in many earlier releases as well.)

How to find functions/operators/methods in JS files quickly and easily

I'm looking for an app or a command line tool that can help me quickly find a defined function in a file. The file in question here is the EXT-debug.js file. I want to override some methods(in this case onRender) however I need to figure out the signature of said functions.
I've yet to try Eclipse or Aptana; I'm looking for a more lightweight solution.
I use agent ransack. It's able to search for files as well as content. I also like the fact that you can run it on demand as it does not use an invasive, indexing service.
Agent Ransack
Visual Studio is not exactly a lightweight solution, but I have to recommend it. It's come a long way towards becoming an excellent JavaScript editor.
Visual Studio's IntelliSense is able to infer JavaScript types and give you a dropdown of the functions and values in your object (works pretty well).
Of course, I always have my handy little muscle memory spasm: double-click-select -> Ctrl-C -> Ctrl-Shift-F -> Ctrl-V -> ENTER
And here's a plugin that pre-searches for exact string matches in your entire solution and highlights them for you, so jumping to a function definition is instantaneous. Whole Tomato's Visual Assist X

Categories