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,
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;

View File

@ -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';

View File

@ -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 ""

View File

@ -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"

View File

@ -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ő"

View File

@ -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"

View File

@ -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ė"

View File

@ -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 ""

View File

@ -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"

View File

@ -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 "Гепардовый редактор"

View File

@ -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 "Гепардовий редактор"