mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 17:39:22 +02:00
IDE: quick fix identifier not found add local variable: search for identifier in front of position, bug #17362
git-svn-id: trunk@29221 -
This commit is contained in:
parent
cf3bbda78a
commit
c0dcbdcf4e
@ -38,7 +38,7 @@ unit MsgQuickFixes;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LCLProc, Controls, Dialogs, FileUtil,
|
Classes, SysUtils, LCLProc, Controls, Dialogs, FileUtil, KeywordFuncLists,
|
||||||
BasicCodeTools, CodeTree, CodeAtom, CodeCache, CodeToolManager,
|
BasicCodeTools, CodeTree, CodeAtom, CodeCache, CodeToolManager,
|
||||||
IDEMsgIntf, TextTools, ProjectIntf, LazIDEIntf,
|
IDEMsgIntf, TextTools, ProjectIntf, LazIDEIntf,
|
||||||
AbstractsMethodsDlg, LazarusIDEStrConsts;
|
AbstractsMethodsDlg, LazarusIDEStrConsts;
|
||||||
@ -604,6 +604,9 @@ var
|
|||||||
Caret: TPoint;
|
Caret: TPoint;
|
||||||
NewCode: TCodeBuffer;
|
NewCode: TCodeBuffer;
|
||||||
NewX, NewY, NewTopLine: integer;
|
NewX, NewY, NewTopLine: integer;
|
||||||
|
Tool: TCodeTool;
|
||||||
|
CleanPos: integer;
|
||||||
|
CodeXY: TCodeXYPosition;
|
||||||
begin
|
begin
|
||||||
if Step=imqfoMenuItem then begin
|
if Step=imqfoMenuItem then begin
|
||||||
DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute Dir=',Msg.Directory,' Msg=',Msg.Msg]);
|
DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute Dir=',Msg.Directory,' Msg=',Msg.Msg]);
|
||||||
@ -618,6 +621,19 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if (Filename='') or (Caret.X<1) or (Caret.Y<1) then exit;
|
||||||
|
CodeBuf:=CodeToolBoss.LoadFile(Filename,true,false);
|
||||||
|
if CodeBuf=nil then exit;
|
||||||
|
if not CodeToolBoss.Explore(CodeBuf,Tool,false) then exit;
|
||||||
|
if Tool.CaretToCleanPos(CodeXYPosition(Caret.X,Caret.Y,CodeBuf),CleanPos)<>0 then exit;
|
||||||
|
if CleanPos>Tool.SrcLen then CleanPos:=Tool.SrcLen;
|
||||||
|
if (CleanPos>1) and (not IsIdentChar[Tool.Src[CleanPos]]) then dec(CleanPos);
|
||||||
|
Tool.MoveCursorToCleanPos(CleanPos);
|
||||||
|
Tool.ReadPriorAtom;
|
||||||
|
CleanPos:=Tool.CurPos.StartPos;
|
||||||
|
if CleanPos<1 then exit;
|
||||||
|
if not Tool.CleanPosToCaret(CleanPos,CodeXY) then exit;
|
||||||
|
|
||||||
// get identifier
|
// get identifier
|
||||||
if not REMatches(Msg.Msg,'Error: Identifier not found "([a-z_0-9]+)"','I') then begin
|
if not REMatches(Msg.Msg,'Error: Identifier not found "([a-z_0-9]+)"','I') then begin
|
||||||
DebugLn('TQuickFixIdentifierNotFoundAddLocal invalid message ',Msg.Msg);
|
DebugLn('TQuickFixIdentifierNotFoundAddLocal invalid message ',Msg.Msg);
|
||||||
@ -625,15 +641,15 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
Identifier:=REVar(1);
|
Identifier:=REVar(1);
|
||||||
//DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute Identifier=',Identifier]);
|
DebugLn(['TQuickFixIdentifierNotFoundAddLocal.Execute Identifier=',Identifier,' ',DbgsCXY(CodeXY)]);
|
||||||
|
|
||||||
if not IsIdentifierInCode(CodeBuf,Caret.X,Caret.Y,Identifier,
|
if not IsIdentifierInCode(CodeXY.Code,CodeXY.X,CodeXY.Y,Identifier,
|
||||||
Identifier+' not found in '+CodeBuf.Filename
|
Identifier+' not found in '+CodeBuf.Filename
|
||||||
+' at line '+IntToStr(Caret.Y)+', column '+IntToStr(Caret.X)+'.'#13
|
+' at line '+IntToStr(Caret.Y)+', column '+IntToStr(Caret.X)+'.'#13
|
||||||
+'Maybe the message is outdated.')
|
+'Maybe the message is outdated.')
|
||||||
then exit;
|
then exit;
|
||||||
|
|
||||||
if not CodeToolBoss.CreateVariableForIdentifier(CodeBuf,Caret.X,Caret.Y,-1,
|
if not CodeToolBoss.CreateVariableForIdentifier(CodeXY.Code,CodeXY.X,CodeXY.Y,-1,
|
||||||
NewCode,NewX,NewY,NewTopLine)
|
NewCode,NewX,NewY,NewTopLine)
|
||||||
then begin
|
then begin
|
||||||
LazarusIDE.DoJumpToCodeToolBossError;
|
LazarusIDE.DoJumpToCodeToolBossError;
|
||||||
|
Loading…
Reference in New Issue
Block a user