mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-18 09:19:45 +02:00
codetools: not reparsing when cursor in valid interface
git-svn-id: trunk@15064 -
This commit is contained in:
parent
2b9cb9182b
commit
5122d3eaaf
@ -3385,7 +3385,7 @@ begin
|
|||||||
|
|
||||||
ActivateGlobalWriteLock;
|
ActivateGlobalWriteLock;
|
||||||
try
|
try
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanPos,[]);
|
BuildTreeAndGetCleanPos(trTillCursorSection,CursorPos,CleanPos,[]);
|
||||||
|
|
||||||
NodeList:=TFPList.Create;
|
NodeList:=TFPList.Create;
|
||||||
NewTool:=Self;
|
NewTool:=Self;
|
||||||
|
@ -90,7 +90,7 @@ type
|
|||||||
TProcHeadExtractPos = (phepNone, phepStart, phepName, phepParamList,
|
TProcHeadExtractPos = (phepNone, phepStart, phepName, phepParamList,
|
||||||
phepResultType, phepSpecifiers);
|
phepResultType, phepSpecifiers);
|
||||||
|
|
||||||
TTreeRange = (trInterface, trAll, trTillCursor);
|
TTreeRange = (trInterface, trAll, trTillCursor, trTillCursorSection);
|
||||||
|
|
||||||
TBuildTreeFlag = (
|
TBuildTreeFlag = (
|
||||||
btSetIgnoreErrorPos,
|
btSetIgnoreErrorPos,
|
||||||
@ -210,7 +210,6 @@ type
|
|||||||
InterfaceSectionFound: boolean;
|
InterfaceSectionFound: boolean;
|
||||||
ImplementationSectionFound: boolean;
|
ImplementationSectionFound: boolean;
|
||||||
EndOfSourceFound: boolean;
|
EndOfSourceFound: boolean;
|
||||||
|
|
||||||
|
|
||||||
procedure BuildTree(OnlyInterfaceNeeded: boolean); virtual;
|
procedure BuildTree(OnlyInterfaceNeeded: boolean); virtual;
|
||||||
procedure BuildTreeAndGetCleanPos(TreeRange: TTreeRange;
|
procedure BuildTreeAndGetCleanPos(TreeRange: TTreeRange;
|
||||||
@ -3931,7 +3930,11 @@ procedure TPascalParserTool.BuildTreeAndGetCleanPos(
|
|||||||
var
|
var
|
||||||
CaretType: integer;
|
CaretType: integer;
|
||||||
IgnorePos: TCodePosition;
|
IgnorePos: TCodePosition;
|
||||||
|
RealTreeRange: TTreeRange;
|
||||||
|
Node: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
|
RealTreeRange:=TreeRange;
|
||||||
|
|
||||||
//DebugLn(['TPascalParserTool.BuildTreeAndGetCleanPos ',MainFilename,' btSetIgnoreErrorPos=',btSetIgnoreErrorPos in BuildTreeFlags,' btKeepIgnoreErrorPos=',btKeepIgnoreErrorPos in BuildTreeFlags,' CursorPos=x=',CursorPos.X,',y=',CursorPos.Y]);
|
//DebugLn(['TPascalParserTool.BuildTreeAndGetCleanPos ',MainFilename,' btSetIgnoreErrorPos=',btSetIgnoreErrorPos in BuildTreeFlags,' btKeepIgnoreErrorPos=',btKeepIgnoreErrorPos in BuildTreeFlags,' CursorPos=x=',CursorPos.X,',y=',CursorPos.Y]);
|
||||||
if (btSetIgnoreErrorPos in BuildTreeFlags) then begin
|
if (btSetIgnoreErrorPos in BuildTreeFlags) then begin
|
||||||
// ignore errors after cursor position
|
// ignore errors after cursor position
|
||||||
@ -3947,7 +3950,34 @@ begin
|
|||||||
else if not (btKeepIgnoreErrorPos in BuildTreeFlags) then
|
else if not (btKeepIgnoreErrorPos in BuildTreeFlags) then
|
||||||
ClearIgnoreErrorAfter;
|
ClearIgnoreErrorAfter;
|
||||||
|
|
||||||
if (TreeRange=trTillCursor) and (not UpdateNeeded(false)) then begin
|
|
||||||
|
if (RealTreeRange in [trTillCursor,trTillCursorSection]) then begin
|
||||||
|
// find out, if interface is enough
|
||||||
|
if (Tree<>nil) and (Tree.Root<>nil) then begin
|
||||||
|
Node:=Tree.Root;
|
||||||
|
while (Node<>nil) and (Node.Desc<>ctnImplementation) do
|
||||||
|
Node:=Node.NextBrother;
|
||||||
|
if Node<>nil then begin
|
||||||
|
// start of implementation section found
|
||||||
|
// => whole interface was read
|
||||||
|
CaretType:=CaretToCleanPos(CursorPos, CleanCursorPos);
|
||||||
|
if (CaretType=0) or (CaretType=-1) then begin
|
||||||
|
if (CleanCursorPos<=Node.StartPos)
|
||||||
|
and (not UpdateNeeded(true)) then begin
|
||||||
|
// interface section is already parsed, is still valid and
|
||||||
|
// cursor is in this section
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
if RealTreeRange=trTillCursorSection then begin
|
||||||
|
// interface is no enough => parse whole unit
|
||||||
|
RealTreeRange:=trAll;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
if (RealTreeRange=trTillCursor) and (not UpdateNeeded(false)) then begin
|
||||||
// tree is valid
|
// tree is valid
|
||||||
// -> if there was an error, raise it again
|
// -> if there was an error, raise it again
|
||||||
if (LastErrorPhase in [CodeToolPhaseScan,CodeToolPhaseParse])
|
if (LastErrorPhase in [CodeToolPhaseScan,CodeToolPhaseParse])
|
||||||
@ -3971,7 +4001,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
// parse code
|
// parse code
|
||||||
BuildTree(TreeRange=trInterface);
|
BuildTree(RealTreeRange=trInterface);
|
||||||
if (not IgnoreErrorAfterValid) and (not EndOfSourceFound) then
|
if (not IgnoreErrorAfterValid) and (not EndOfSourceFound) then
|
||||||
SaveRaiseException(ctsEndOfSourceNotFound);
|
SaveRaiseException(ctsEndOfSourceNotFound);
|
||||||
// find the CursorPos in cleaned source
|
// find the CursorPos in cleaned source
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
Author: Mattias Gaertner
|
Author: Mattias Gaertner
|
||||||
|
|
||||||
Abstract:
|
Abstract:
|
||||||
This unit is part of the IDE's help system. It implements the help for sources via
|
This unit is part of the IDE's help system. It implements the help for
|
||||||
fpdoc files and pascal comments.
|
sources via fpdoc files and pascal comments.
|
||||||
}
|
}
|
||||||
unit CodeHelp;
|
unit CodeHelp;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user