fixing vs reporting errors

R

Roedy Green

I created a macro called Path for the HTMLMacros system that displays
a fully qualified file or directory name with pretty CSS classes.

I use the convention that directories end in \ or / and files do not.

The program used many techniques to check if the entry was indeed
correctly coded, including asking the OS for files that actually
exist.

It complained about hundreds of miscoded entries. Most were simply
missing the final \ or ones like cacerts missing the trailing dot. I
had generated the macro calls using regexes to extract names, so they
not originally so coded.

I spent hours and hours making corrections. Then it suddenly dawned on
me, if my program can DETECT the errors, surely it can CORRECT them.

I had it emit CSV records of the form

as-it-is-now, as-it-should-be, in-which-file

I then manually pruned and enhanced these records to clean up other
junk, then fed them to the CSVReplaceStrings Utility.

BANG! the work was done!

I just wish I had thought of this earlier.

I wish an IDE could similarly be cleverer, and not just TELL you about
errors, but FIX them.

1. repair spelling errors, especially errors in case.
2. balance () and {} where the insertion point is obvious.
3. insert missing outer ( ) in if and switch
4. change the scope of something up or down.
5. insert/remove static
6. fix _for_ back to canonical form: for ( int i=0; i<n; i++ ) if the
syntax is broken in any way (e.g. missing ; extra ; missing int)
7. for bad exception, ask if you want to catch it or pass it on,
and insert the corresponding code.
8. put () around arithmetic expressions in concatenation chains.

Obviously it will do stupid things from time to time. It should make
you ok each fix, or highlight them for later review. You should also
be able to undo fixes.

Such an IDE would be a great boon to newbies who are often baffled by
error messages. It a waste of valuable expert time correcting this
trivia. see http://mindprod.com/jgloss/compileerrormessages.html
 
A

Andreas Leitgeb

Roedy Green said:
I wish an IDE could similarly be cleverer, and not just TELL you about
errors, but FIX them.
1. repair spelling errors, especially errors in case.

case-autocorrection is usually more prominent in
case-INsensitive languages, like VB.
I admit, some kind of heuristic typing-correction is missing
from eclipse's quick-fixes menu.
2. balance () and {} where the insertion point is obvious.

eclipse usually inserts matching closings either when you type the
opening one "if (", or when hitting the return key after "if (...) {"
I'm not sure where and how eclipse (or other IDE) could guesstimate
the correct insertion position for other cases. When, except upon
typing anew, could it be obvious to a program?
3. insert missing outer ( ) in if and switch
see 2.)
4. change the scope of something up or down.

context menu "refactor" iirc.
5. insert/remove static
and
5a. suggest static imports or auto-qualification in quick-fixes,
if an unknown symbol would exist as a static in another
known class.

I could have used that a lot of times already.
6. fix _for_ back to canonical form: for ( int i=0; i<n; i++ ) if the
syntax is broken in any way (e.g. missing ; extra ; missing int)

Can't judge this. it hardly ever happens to me, but I understand
it in the specific context of a habit to put a ; after i++ ...
7. for bad exception, ask if you want to catch it or pass it on,
and insert the corresponding code.

That's already covered in eclipse's quick-fixes list.
8. put () around arithmetic expressions in concatenation chains.

Might be possible, though a rather sophisticated feature...
Such an IDE would be a great boon to newbies who are often baffled by
error messages. It a waste of valuable expert time correcting this
trivia. see http://mindprod.com/jgloss/compileerrormessages.html

Most of the times the compiler tells me it was expecting a certain
character, the problem is actually somewhere else, at least in my
experience. ymmv
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top