cody: identifier dictionary: use identifier: jump to syntax error

git-svn-id: trunk@54690 -
This commit is contained in:
mattias 2017-04-22 17:39:01 +00:00
parent 0bde8fa043
commit 3ca49ceb2b
11 changed files with 71 additions and 13 deletions

View File

@ -198,8 +198,8 @@ type
function FindSelectedItem(out Identifier, UnitFilename, function FindSelectedItem(out Identifier, UnitFilename,
GroupName, GroupFilename: string): boolean; GroupName, GroupFilename: string): boolean;
procedure UpdateCurOwnerOfUnit; procedure UpdateCurOwnerOfUnit;
procedure AddToUsesSection; procedure AddToUsesSection(JumpToSrcError: boolean);
procedure UpdateTool; function UpdateTool(JumpToSrcError: boolean): boolean;
function AddButton: TBitBtn; function AddButton: TBitBtn;
function GetCurOwnerCompilerOptions: TLazCompilerOptions; function GetCurOwnerCompilerOptions: TLazCompilerOptions;
public public
@ -1366,6 +1366,7 @@ var
NewY: integer; NewY: integer;
NewTopLine: integer; NewTopLine: integer;
CurUnit: TUDUnit; CurUnit: TUDUnit;
MainPath: RawByteString;
function OpenDependency: boolean; function OpenDependency: boolean;
// returns false to abort // returns false to abort
@ -1470,14 +1471,18 @@ begin
NewUnitInPath:=true; NewUnitInPath:=true;
end end
else if (CurUnitPath<>'') else if (CurUnitPath<>'')
and FilenameIsAbsolute(CurMainFilename) and FilenameIsAbsolute(CurMainFilename) then begin
and (FindPathInSearchPath(PChar(CurUnitPath),length(CurUnitPath), MainPath:=ExtractFilePath(CurMainFilename);
PChar(CurMainFilename),length(CurMainFilename))<>nil) if (FindPathInSearchPath(PChar(MainPath),length(MainPath),
then begin PChar(CurUnitPath),length(CurUnitPath))<>nil)
// in unit search path then begin
debugln(['TCodyIdentifiersDlg.UseIdentifier in unit search path of owner']); // in unit search path
NewUnitInPath:=true; debugln(['TCodyIdentifiersDlg.UseIdentifier in unit search path of owner']);
NewUnitInPath:=true;
end;
end; end;
if not NewUnitInPath then
debugln(['TCodyIdentifiersDlg.UseIdentifier not in unit path: CurMainFilename="',CurMainFilename,'" NewUnitFilename="',NewUnitFilename,'" CurUnitPath="',CurUnitPath,'"']);
UnitSet:=CodeToolBoss.GetUnitSetForDirectory(''); UnitSet:=CodeToolBoss.GetUnitSetForDirectory('');
if not NewUnitInPath then begin if not NewUnitInPath then begin
@ -1571,7 +1576,7 @@ begin
end; end;
if not SameUnitName then if not SameUnitName then
AddToUsesSection; AddToUsesSection(true);
finally finally
CurSrcEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodyIdentifiersDlg.UseIdentifier'){$ENDIF}; CurSrcEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodyIdentifiersDlg.UseIdentifier'){$ENDIF};
end; end;
@ -1680,7 +1685,7 @@ begin
end; end;
end; end;
procedure TCodyIdentifiersDlg.AddToUsesSection; procedure TCodyIdentifiersDlg.AddToUsesSection(JumpToSrcError: boolean);
var var
NewUnitCode: TCodeBuffer; NewUnitCode: TCodeBuffer;
NewUnitName: String; NewUnitName: String;
@ -1691,7 +1696,7 @@ begin
debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no tool']); debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no tool']);
exit; exit;
end; end;
UpdateTool; UpdateTool(JumpToSrcError);
if (CurNode=nil) then begin if (CurNode=nil) then begin
debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no node']); debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no node']);
exit; exit;
@ -1744,10 +1749,15 @@ begin
CodeToolBoss.AddUnitToImplementationUsesSection(CurMainCode,NewUnitName,'') CodeToolBoss.AddUnitToImplementationUsesSection(CurMainCode,NewUnitName,'')
else else
CodeToolBoss.AddUnitToMainUsesSection(CurMainCode,NewUnitName,''); CodeToolBoss.AddUnitToMainUsesSection(CurMainCode,NewUnitName,'');
if CodeToolBoss.ErrorMessage<>'' then
LazarusIDE.DoJumpToCodeToolBossError;
end; end;
procedure TCodyIdentifiersDlg.UpdateTool; function TCodyIdentifiersDlg.UpdateTool(JumpToSrcError: boolean): boolean;
var
Tool: TCodeTool;
begin begin
Result:=false;
if (CurTool=nil) or (NewUnitFilename='') then exit; if (CurTool=nil) or (NewUnitFilename='') then exit;
if not LazarusIDE.BeginCodeTools then exit; if not LazarusIDE.BeginCodeTools then exit;
try try
@ -1755,6 +1765,17 @@ begin
except except
end; end;
CurNode:=CurTool.FindDeepestNodeAtPos(CurCleanPos,false); CurNode:=CurTool.FindDeepestNodeAtPos(CurCleanPos,false);
if CurNode<>nil then
Result:=true
else if JumpToSrcError then begin
CodeToolBoss.Explore(CurCodePos.Code,Tool,false);
if CodeToolBoss.ErrorCode=nil then
IDEMessageDialog(crsCaretOutsideOfCode, CurTool.CleanPosToStr(
CurCleanPos, true),
mtError,[mbOk])
else
LazarusIDE.DoJumpToCodeToolBossError;
end;
end; end;
function TCodyIdentifiersDlg.AddButton: TBitBtn; function TCodyIdentifiersDlg.AddButton: TBitBtn;

View File

@ -229,6 +229,7 @@ resourcestring
crsIdentifierNotFoundInUnit = 'Identifier "%s" not found in unit "%s".' crsIdentifierNotFoundInUnit = 'Identifier "%s" not found in unit "%s".'
+' Maybe the identifier does not exist for this platform or maybe the' +' Maybe the identifier does not exist for this platform or maybe the'
+' identifier was deleted/renamed.'; +' identifier was deleted/renamed.';
crsCaretOutsideOfCode = 'Caret outside of code';
crsPackage2 = 'Package: %s'; crsPackage2 = 'Package: %s';
crsIDEIntegration = 'IDE Integration'; crsIDEIntegration = 'IDE Integration';

View File

@ -159,6 +159,10 @@ msgstr ""
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "" msgstr ""
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "" msgstr ""

View File

@ -160,6 +160,10 @@ msgstr "? visibilité ?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, écrit par la propriété %s" msgstr "%s, écrit par la propriété %s"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Éditeur Cheetah" msgstr "Éditeur Cheetah"

View File

@ -160,6 +160,10 @@ msgstr "?láthatóság?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, a(z) %s tulajdonság által írva" msgstr "%s, a(z) %s tulajdonság által írva"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Gepárd szerkesztő" msgstr "Gepárd szerkesztő"

View File

@ -161,6 +161,10 @@ msgstr "?visibilità?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, scritto dalla proprietà %s" msgstr "%s, scritto dalla proprietà %s"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Editor Ghepardo" msgstr "Editor Ghepardo"

View File

@ -160,6 +160,10 @@ msgstr "?matomumas?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, įrašė savybė „%s“" msgstr "%s, įrašė savybė „%s“"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Gepardo rengyklė" msgstr "Gepardo rengyklė"

View File

@ -150,6 +150,10 @@ msgstr ""
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "" msgstr ""
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "" msgstr ""

View File

@ -159,6 +159,10 @@ msgstr "?visibilidade?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, escrito pela propriedade %s" msgstr "%s, escrito pela propriedade %s"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Editor Guepardo" msgstr "Editor Guepardo"

View File

@ -160,6 +160,10 @@ msgstr "?видимость?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, записывается свойством %s" msgstr "%s, записывается свойством %s"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Гепардовый редактор" msgstr "Гепардовый редактор"

View File

@ -162,6 +162,10 @@ msgstr "?видимість?"
msgid "%s, written by property %s" msgid "%s, written by property %s"
msgstr "%s, записаний властивістю %s" msgstr "%s, записаний властивістю %s"
#: codystrconsts.crscaretoutsideofcode
msgid "Caret outside of code"
msgstr ""
#: codystrconsts.crscheetaheditor #: codystrconsts.crscheetaheditor
msgid "Cheetah Editor" msgid "Cheetah Editor"
msgstr "Гепардовий редактор" msgstr "Гепардовий редактор"