Instant breakpoint with debugger instruction in PhpStorm / WebStorm

I am looking into the possibilities to instantly set a breakpoint when debugging JavaScript

for (...) {
  for (...) {
    ...
  }
  // need a breakpoint here
}

      

The problem is that the breakpoint cannot be toggled on the comment line, it needs an instruction.

And when the statement is debugger

added to the line, another problem appears - it does not switch to the Debug tab automatically. It looks like an application is pending, no indication.

And I try to avoid adding dummy operators because they can be neglected (as for debugger

, there is a validation rule to highlight it).

Are there any tricks to achieve this? Can the operator debugger

behave like a normal breakpoint, at least?

+3


source to share


1 answer


Speaking of the general question, there is only one answer, and this is the one you don't want to hear:

You must have a breakpoint statement

There are no tricks that are widely applicable (although there may be some IDE that allows a quick hack right after the loop ... weird)

Unfortunately, what you want is usually done with temp / dummy assertions (exactly the kind you are trying to avoid):



for (...) {
  for (...) {
    ...
  }
  // TODO: editors like Eclipse flag TODO lines so they are not lost in the source forest
  setTimeout(Function.prototype, 10000);
}

      

This is due to the way (debuggers) of most debuggers work: base file and line numbers are stored as debugger information (hints) in the compiled code and then matched against an available source during debugging. For non-compiled languages ​​like JS / PHP, similar techniques are used with a string that is parsed from the source code, but lines with comments or parentheses are not actually executed.

This issue has sometimes raised its ugly head during my own journey as a developer. This is just part of debugging. I hope you find a coding solution that gives you comfort and peace of mind.

+1


source







All Articles