diff --git a/components/codetools/ide/codyidentifiersdlg.pas b/components/codetools/ide/codyidentifiersdlg.pas index 87c0b02e92..480abf77ac 100644 --- a/components/codetools/ide/codyidentifiersdlg.pas +++ b/components/codetools/ide/codyidentifiersdlg.pas @@ -198,8 +198,8 @@ type function FindSelectedItem(out Identifier, UnitFilename, GroupName, GroupFilename: string): boolean; procedure UpdateCurOwnerOfUnit; - procedure AddToUsesSection; - procedure UpdateTool; + procedure AddToUsesSection(JumpToSrcError: boolean); + function UpdateTool(JumpToSrcError: boolean): boolean; function AddButton: TBitBtn; function GetCurOwnerCompilerOptions: TLazCompilerOptions; public @@ -1366,6 +1366,7 @@ var NewY: integer; NewTopLine: integer; CurUnit: TUDUnit; + MainPath: RawByteString; function OpenDependency: boolean; // returns false to abort @@ -1470,14 +1471,18 @@ begin NewUnitInPath:=true; end else if (CurUnitPath<>'') - and FilenameIsAbsolute(CurMainFilename) - and (FindPathInSearchPath(PChar(CurUnitPath),length(CurUnitPath), - PChar(CurMainFilename),length(CurMainFilename))<>nil) - then begin - // in unit search path - debugln(['TCodyIdentifiersDlg.UseIdentifier in unit search path of owner']); - NewUnitInPath:=true; + and FilenameIsAbsolute(CurMainFilename) then begin + MainPath:=ExtractFilePath(CurMainFilename); + if (FindPathInSearchPath(PChar(MainPath),length(MainPath), + PChar(CurUnitPath),length(CurUnitPath))<>nil) + then begin + // in unit search path + debugln(['TCodyIdentifiersDlg.UseIdentifier in unit search path of owner']); + NewUnitInPath:=true; + end; end; + if not NewUnitInPath then + debugln(['TCodyIdentifiersDlg.UseIdentifier not in unit path: CurMainFilename="',CurMainFilename,'" NewUnitFilename="',NewUnitFilename,'" CurUnitPath="',CurUnitPath,'"']); UnitSet:=CodeToolBoss.GetUnitSetForDirectory(''); if not NewUnitInPath then begin @@ -1571,7 +1576,7 @@ begin end; if not SameUnitName then - AddToUsesSection; + AddToUsesSection(true); finally CurSrcEdit.EndUndoBlock{$IFDEF SynUndoDebugBeginEnd}('TCodyIdentifiersDlg.UseIdentifier'){$ENDIF}; end; @@ -1680,7 +1685,7 @@ begin end; end; -procedure TCodyIdentifiersDlg.AddToUsesSection; +procedure TCodyIdentifiersDlg.AddToUsesSection(JumpToSrcError: boolean); var NewUnitCode: TCodeBuffer; NewUnitName: String; @@ -1691,7 +1696,7 @@ begin debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no tool']); exit; end; - UpdateTool; + UpdateTool(JumpToSrcError); if (CurNode=nil) then begin debugln(['TCodyIdentifiersDlg.AddToUsesSection failed: no node']); exit; @@ -1744,10 +1749,15 @@ begin CodeToolBoss.AddUnitToImplementationUsesSection(CurMainCode,NewUnitName,'') else CodeToolBoss.AddUnitToMainUsesSection(CurMainCode,NewUnitName,''); + if CodeToolBoss.ErrorMessage<>'' then + LazarusIDE.DoJumpToCodeToolBossError; end; -procedure TCodyIdentifiersDlg.UpdateTool; +function TCodyIdentifiersDlg.UpdateTool(JumpToSrcError: boolean): boolean; +var + Tool: TCodeTool; begin + Result:=false; if (CurTool=nil) or (NewUnitFilename='') then exit; if not LazarusIDE.BeginCodeTools then exit; try @@ -1755,6 +1765,17 @@ begin except end; 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; function TCodyIdentifiersDlg.AddButton: TBitBtn; diff --git a/components/codetools/ide/codystrconsts.pas b/components/codetools/ide/codystrconsts.pas index 35c232e3f6..014f0f1036 100644 --- a/components/codetools/ide/codystrconsts.pas +++ b/components/codetools/ide/codystrconsts.pas @@ -229,6 +229,7 @@ resourcestring crsIdentifierNotFoundInUnit = 'Identifier "%s" not found in unit "%s".' +' Maybe the identifier does not exist for this platform or maybe the' +' identifier was deleted/renamed.'; + crsCaretOutsideOfCode = 'Caret outside of code'; crsPackage2 = 'Package: %s'; crsIDEIntegration = 'IDE Integration'; diff --git a/components/codetools/ide/languages/codystrconsts.de.po b/components/codetools/ide/languages/codystrconsts.de.po index af32a106a5..2c9f26dac8 100644 --- a/components/codetools/ide/languages/codystrconsts.de.po +++ b/components/codetools/ide/languages/codystrconsts.de.po @@ -159,6 +159,10 @@ msgstr "" msgid "%s, written by property %s" msgstr "" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "" diff --git a/components/codetools/ide/languages/codystrconsts.fr.po b/components/codetools/ide/languages/codystrconsts.fr.po index bc209b4a81..92016c8bf6 100644 --- a/components/codetools/ide/languages/codystrconsts.fr.po +++ b/components/codetools/ide/languages/codystrconsts.fr.po @@ -160,6 +160,10 @@ msgstr "? visibilité ?" msgid "%s, written by property %s" msgstr "%s, écrit par la propriété %s" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Éditeur Cheetah" diff --git a/components/codetools/ide/languages/codystrconsts.hu.po b/components/codetools/ide/languages/codystrconsts.hu.po index 47ea576ed4..0c22ee01a7 100644 --- a/components/codetools/ide/languages/codystrconsts.hu.po +++ b/components/codetools/ide/languages/codystrconsts.hu.po @@ -160,6 +160,10 @@ msgstr "?láthatóság?" msgid "%s, written by property %s" msgstr "%s, a(z) %s tulajdonság által írva" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Gepárd szerkesztő" diff --git a/components/codetools/ide/languages/codystrconsts.it.po b/components/codetools/ide/languages/codystrconsts.it.po index 59f73e381b..ce6fb55e65 100644 --- a/components/codetools/ide/languages/codystrconsts.it.po +++ b/components/codetools/ide/languages/codystrconsts.it.po @@ -161,6 +161,10 @@ msgstr "?visibilità?" msgid "%s, written by property %s" msgstr "%s, scritto dalla proprietà %s" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Editor Ghepardo" diff --git a/components/codetools/ide/languages/codystrconsts.lt.po b/components/codetools/ide/languages/codystrconsts.lt.po index 4f19acd3da..ce656d63c3 100644 --- a/components/codetools/ide/languages/codystrconsts.lt.po +++ b/components/codetools/ide/languages/codystrconsts.lt.po @@ -160,6 +160,10 @@ msgstr "?matomumas?" msgid "%s, written by property %s" msgstr "%s, įrašė savybė „%s“" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Gepardo rengyklė" diff --git a/components/codetools/ide/languages/codystrconsts.po b/components/codetools/ide/languages/codystrconsts.po index 1d551819a2..6d9aec4ded 100644 --- a/components/codetools/ide/languages/codystrconsts.po +++ b/components/codetools/ide/languages/codystrconsts.po @@ -150,6 +150,10 @@ msgstr "" msgid "%s, written by property %s" msgstr "" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "" diff --git a/components/codetools/ide/languages/codystrconsts.pt_BR.po b/components/codetools/ide/languages/codystrconsts.pt_BR.po index 702b80c05d..7d424d1200 100644 --- a/components/codetools/ide/languages/codystrconsts.pt_BR.po +++ b/components/codetools/ide/languages/codystrconsts.pt_BR.po @@ -159,6 +159,10 @@ msgstr "?visibilidade?" msgid "%s, written by property %s" msgstr "%s, escrito pela propriedade %s" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Editor Guepardo" diff --git a/components/codetools/ide/languages/codystrconsts.ru.po b/components/codetools/ide/languages/codystrconsts.ru.po index e1cc54976d..82999dc7e0 100644 --- a/components/codetools/ide/languages/codystrconsts.ru.po +++ b/components/codetools/ide/languages/codystrconsts.ru.po @@ -160,6 +160,10 @@ msgstr "?видимость?" msgid "%s, written by property %s" msgstr "%s, записывается свойством %s" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Гепардовый редактор" diff --git a/components/codetools/ide/languages/codystrconsts.uk.po b/components/codetools/ide/languages/codystrconsts.uk.po index b3d233e13a..af72ef6a85 100644 --- a/components/codetools/ide/languages/codystrconsts.uk.po +++ b/components/codetools/ide/languages/codystrconsts.uk.po @@ -162,6 +162,10 @@ msgstr "?видимість?" msgid "%s, written by property %s" msgstr "%s, записаний властивістю %s" +#: codystrconsts.crscaretoutsideofcode +msgid "Caret outside of code" +msgstr "" + #: codystrconsts.crscheetaheditor msgid "Cheetah Editor" msgstr "Гепардовий редактор"