Recent

Author Topic: Automatic code fixation (Visual Studio feature)  (Read 7097 times)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8267
  • Programming + Glam Metal + Tae Kwon Do = Me
Automatic code fixation (Visual Studio feature)
« on: October 24, 2007, 11:54:28 am »
Instead of fixing common errors (unclosed block, forgotten semicolon) manually, I think it's better if when we click "build" then the code tools will check our source and fix those things automatically. This will cut development times quite a bit.

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Automatic code fixation (Visual Studio feature)
« Reply #1 on: October 25, 2007, 04:09:02 am »
I think it could be made with some standard error messages of Delphi ('missing operator or semicolon', 'unterminated string', etc), but I don't know much about standard FPC error messages.

I think it is a good idea.

If the compiler can say exactly what is wrong, IDE can fix it too.

You could make a feature request on bugtracker.

Almindor

  • Sr. Member
  • ****
  • Posts: 412
    • http://www.astarot.tk
RE: Automatic code fixation (Visual Studio feature)
« Reply #2 on: October 26, 2007, 11:10:26 am »
FPC has virtually same error messages although wording might differ a bit. But this is only usable on basic 100% "both-way" errors. Eg: some errors can be more things, and thus corrected by more actions. Only errors which represent one specific thing, correctable by one specific action (other than deleting the offending code of course) can be fixed as such.

I guess the answer would be "feel free to implement" :)

Leledumbo

  • Hero Member
  • *****
  • Posts: 8267
  • Programming + Glam Metal + Tae Kwon Do = Me
RE: Automatic code fixation (Visual Studio feature)
« Reply #3 on: October 26, 2007, 12:00:32 pm »
To the best of my knowledge, Lazarus don't have to use that compiler messages to determine the correct structure of pascal program/unit. It uses pascal parser/scanner provided by codetools, mpaslex, and fcl-passrc. Read this, and find
Quote
Lazarus does not use the compiler to get code information. It parses the sources directly.
From here, we know that Lazarus should be able to find the error and fix it.

Vincent Snijders

  • Administrator
  • Hero Member
  • *
  • Posts: 2661
    • My Lazarus wiki user page
RE: Automatic code fixation (Visual Studio feature)
« Reply #4 on: October 26, 2007, 12:22:18 pm »
You can improve and extend the quick fixes, the infrastructure is there.

For example:
Create a new custom program. In the compiler options check: "Show hints for unused units ...".
Compile the program. Right click on the message and choose QuickFix. It should remove the unit from the uses clause. (It didn't work in my tests though).

antonio

  • Hero Member
  • *****
  • Posts: 605
RE: Automatic code fixation (Visual Studio feature)
« Reply #5 on: October 30, 2007, 06:38:49 pm »
This would be a better solution.

 

TinyPortal © 2005-2018