mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 04:59:20 +02:00
fixed targetos for clean all
git-svn-id: trunk@4329 -
This commit is contained in:
parent
d6126baede
commit
3cfdaeef38
@ -2017,7 +2017,7 @@ var CleanCursorPos, Indent, insertPos: integer;
|
|||||||
// -> find it and jump to
|
// -> find it and jump to
|
||||||
|
|
||||||
// reparse code
|
// reparse code
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
|
||||||
// find CodeTreeNode at cursor
|
// find CodeTreeNode at cursor
|
||||||
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||||
|
|
||||||
@ -2400,7 +2400,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
if (SourceChangeCache=nil) then
|
if (SourceChangeCache=nil) then
|
||||||
RaiseException('need a SourceChangeCache');
|
RaiseException('need a SourceChangeCache');
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos, CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos, CleanCursorPos,[]);
|
||||||
|
|
||||||
// find CodeTreeNode at cursor
|
// find CodeTreeNode at cursor
|
||||||
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||||
|
@ -36,6 +36,7 @@ interface
|
|||||||
{$I codetools.inc}
|
{$I codetools.inc}
|
||||||
|
|
||||||
{ $DEFINE ShowIgnoreError}
|
{ $DEFINE ShowIgnoreError}
|
||||||
|
{$DEFINE ShowDirtySrc}
|
||||||
|
|
||||||
uses
|
uses
|
||||||
{$IFDEF MEM_CHECK}
|
{$IFDEF MEM_CHECK}
|
||||||
@ -74,8 +75,10 @@ type
|
|||||||
|
|
||||||
TDirtySource = class
|
TDirtySource = class
|
||||||
public
|
public
|
||||||
|
CursorPos: TCodeXYPosition;
|
||||||
Src: string;
|
Src: string;
|
||||||
GapSrc: string;
|
GapSrc: string;
|
||||||
|
GapUpperSrc: string;
|
||||||
Code: TCodeBuffer;
|
Code: TCodeBuffer;
|
||||||
Valid: boolean;
|
Valid: boolean;
|
||||||
CurPos: TAtomPosition;
|
CurPos: TAtomPosition;
|
||||||
@ -83,11 +86,24 @@ type
|
|||||||
GapStart: integer;
|
GapStart: integer;
|
||||||
GapEnd: integer;
|
GapEnd: integer;
|
||||||
LockCount: integer;
|
LockCount: integer;
|
||||||
|
Owner: TCustomCodeTool;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
procedure SetCode(NewCode: TCodeBuffer);
|
procedure SetGap(const NewCursorPos: TCodeXYPosition;
|
||||||
procedure SetGap(NewDirtyStartPos,NewDirtyGapStart,NewDirtyGapEnd: integer);
|
NewDirtyStartPos, NewDirtyGapStart, NewDirtyGapEnd: integer);
|
||||||
|
constructor Create(TheOwner: TCustomCodeTool);
|
||||||
|
procedure Clear;
|
||||||
|
procedure SetCursorToIdentStartEndAtPosition;
|
||||||
|
function GetCursorSrcPos: PChar;
|
||||||
|
function IsPCharInSrc(p: PChar): boolean;
|
||||||
|
procedure MoveCursorToPos(APos: integer);
|
||||||
|
procedure MoveCursorToPos(APos: PChar);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
THybridCursorType = (
|
||||||
|
hcClean,
|
||||||
|
hcDirty
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
// types for user aborts
|
// types for user aborts
|
||||||
@ -160,6 +176,7 @@ type
|
|||||||
CursorBeyondEOL: boolean;
|
CursorBeyondEOL: boolean;
|
||||||
|
|
||||||
DirtySrc: TDirtySource;
|
DirtySrc: TDirtySource;
|
||||||
|
HybridCursorType: THybridCursorType;
|
||||||
|
|
||||||
ErrorPosition: TCodeXYPosition;
|
ErrorPosition: TCodeXYPosition;
|
||||||
|
|
||||||
@ -196,20 +213,28 @@ type
|
|||||||
procedure BeginParsingAndGetCleanPos(DeleteNodes,
|
procedure BeginParsingAndGetCleanPos(DeleteNodes,
|
||||||
OnlyInterfaceNeeded: boolean; CursorPos: TCodeXYPosition;
|
OnlyInterfaceNeeded: boolean; CursorPos: TCodeXYPosition;
|
||||||
var CleanCursorPos: integer);
|
var CleanCursorPos: integer);
|
||||||
|
function IsDirtySrcValid: boolean;
|
||||||
|
|
||||||
function StringIsKeyWord(const Word: string): boolean;
|
function StringIsKeyWord(const Word: string): boolean;
|
||||||
|
|
||||||
|
// cursor moving
|
||||||
procedure MoveCursorToNodeStart(ANode: TCodeTreeNode);
|
procedure MoveCursorToNodeStart(ANode: TCodeTreeNode);
|
||||||
procedure MoveCursorToCleanPos(ACleanPos: integer);
|
procedure MoveCursorToCleanPos(ACleanPos: integer);
|
||||||
procedure MoveCursorToCleanPos(ACleanPos: PChar);
|
procedure MoveCursorToCleanPos(ACleanPos: PChar);
|
||||||
function IsPCharInSrc(ACleanPos: PChar): boolean;
|
function IsPCharInSrc(ACleanPos: PChar): boolean;
|
||||||
function ReadTilBracketClose(ExceptionOnNotFound: boolean): boolean;
|
procedure MoveHybridCursorToPos(DirtyPos: PChar);
|
||||||
function ReadBackTilBracketOpen(ExceptionOnNotFound: boolean): boolean;
|
function GetHybridCursorStart: integer;
|
||||||
procedure ReadTillCommentEnd;
|
|
||||||
function DoAtom: boolean; virtual;
|
// read atoms
|
||||||
procedure ReadNextAtom;
|
procedure ReadNextAtom;
|
||||||
procedure UndoReadNextAtom;
|
procedure UndoReadNextAtom;
|
||||||
procedure ReadPriorAtom;
|
procedure ReadPriorAtom;
|
||||||
|
|
||||||
|
// read blocks
|
||||||
|
function ReadTilBracketClose(ExceptionOnNotFound: boolean): boolean;
|
||||||
|
function ReadBackTilBracketOpen(ExceptionOnNotFound: boolean): boolean;
|
||||||
|
procedure ReadTillCommentEnd;
|
||||||
|
|
||||||
function AtomIs(const AnAtom: shortstring): boolean;
|
function AtomIs(const AnAtom: shortstring): boolean;
|
||||||
function UpAtomIs(const AnAtom: shortstring): boolean;
|
function UpAtomIs(const AnAtom: shortstring): boolean;
|
||||||
function ReadNextAtomIs(const AnAtom: shortstring): boolean;
|
function ReadNextAtomIs(const AnAtom: shortstring): boolean;
|
||||||
@ -246,7 +271,8 @@ type
|
|||||||
|
|
||||||
procedure CreateChildNode;
|
procedure CreateChildNode;
|
||||||
procedure EndChildNode;
|
procedure EndChildNode;
|
||||||
|
function DoAtom: boolean; virtual;
|
||||||
|
|
||||||
procedure ActivateGlobalWriteLock; virtual;
|
procedure ActivateGlobalWriteLock; virtual;
|
||||||
procedure DeactivateGlobalWriteLock; virtual;
|
procedure DeactivateGlobalWriteLock; virtual;
|
||||||
property OnGetGlobalWriteLockInfo: TOnGetWriteLockInfo
|
property OnGetGlobalWriteLockInfo: TOnGetWriteLockInfo
|
||||||
@ -386,14 +412,15 @@ var
|
|||||||
BestLinkIndex: Integer;
|
BestLinkIndex: Integer;
|
||||||
BestLink: TSourceLink;
|
BestLink: TSourceLink;
|
||||||
begin
|
begin
|
||||||
if DirtySrc=nil then DirtySrc:=TDirtySource.Create;
|
writeln('TCustomCodeTool.LoadDirtySource X=',CursorPos.X,' Y=',CursorPos.Y,
|
||||||
DirtySrc.SetCode(CursorPos.Code);
|
' ',ExtractFilename(CursorPos.Code.Filename));
|
||||||
|
if DirtySrc=nil then DirtySrc:=TDirtySource.Create(Self);
|
||||||
CursorPos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,NewDirtyStartPos);
|
CursorPos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,NewDirtyStartPos);
|
||||||
if NewDirtyStartPos<1 then
|
if NewDirtyStartPos<1 then
|
||||||
RaiseCatchableException('NewDirtyStartPos<1');
|
RaiseCatchableException('NewDirtyStartPos<1');
|
||||||
CursorInLink:=false;
|
CursorInLink:=false;
|
||||||
BestLinkIndex:=Scanner.LinkIndexNearCursorPos(NewDirtyStartPos,
|
BestLinkIndex:=Scanner.LinkIndexNearCursorPos(NewDirtyStartPos,
|
||||||
DirtySrc.Code,CursorInLink);
|
CursorPos.Code,CursorInLink);
|
||||||
if BestLinkIndex<0 then
|
if BestLinkIndex<0 then
|
||||||
RaiseCatchableException('BestLinkIndex<0');
|
RaiseCatchableException('BestLinkIndex<0');
|
||||||
if CursorInLink then
|
if CursorInLink then
|
||||||
@ -403,8 +430,8 @@ begin
|
|||||||
if BestLinkIndex<Scanner.LinkCount then
|
if BestLinkIndex<Scanner.LinkCount then
|
||||||
NewDirtyGapEnd:=Scanner.Links[BestLinkIndex+1].SrcPos
|
NewDirtyGapEnd:=Scanner.Links[BestLinkIndex+1].SrcPos
|
||||||
else
|
else
|
||||||
NewDirtyGapEnd:=DirtySrc.Code.SourceLength;
|
NewDirtyGapEnd:=CursorPos.Code.SourceLength;
|
||||||
DirtySrc.SetGap(NewDirtyStartPos,NewDirtyGapStart,NewDirtyGapEnd);
|
DirtySrc.SetGap(CursorPos,NewDirtyStartPos,NewDirtyGapStart,NewDirtyGapEnd);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -1582,6 +1609,11 @@ begin
|
|||||||
RaiseException(ctsCursorPosOutsideOfCode);
|
RaiseException(ctsCursorPosOutsideOfCode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomCodeTool.IsDirtySrcValid: boolean;
|
||||||
|
begin
|
||||||
|
Result:=(DirtySrc<>nil) and (DirtySrc.Code<>nil);
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomCodeTool.IgnoreErrAfterPositionIsInFrontOfLastErrMessage: boolean;
|
function TCustomCodeTool.IgnoreErrAfterPositionIsInFrontOfLastErrMessage: boolean;
|
||||||
var
|
var
|
||||||
IgnoreErrorAfterCleanPos: integer;
|
IgnoreErrorAfterCleanPos: integer;
|
||||||
@ -1688,6 +1720,7 @@ begin
|
|||||||
LastAtoms.Clear;
|
LastAtoms.Clear;
|
||||||
NextPos.StartPos:=-1;
|
NextPos.StartPos:=-1;
|
||||||
CurNode:=nil;
|
CurNode:=nil;
|
||||||
|
HybridCursorType:=hcClean;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomCodeTool.MoveCursorToCleanPos(ACleanPos: PChar);
|
procedure TCustomCodeTool.MoveCursorToCleanPos(ACleanPos: PChar);
|
||||||
@ -1723,6 +1756,23 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomCodeTool.MoveHybridCursorToPos(DirtyPos: PChar);
|
||||||
|
begin
|
||||||
|
if IsDirtySrcValid and (not IsPCharInSrc(DirtyPos)) then begin
|
||||||
|
DirtySrc.MoveCursorToPos(DirtyPos);
|
||||||
|
HybridCursorType:=hcDirty;
|
||||||
|
end else
|
||||||
|
MoveCursorToCleanPos(DirtyPos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomCodeTool.GetHybridCursorStart: integer;
|
||||||
|
begin
|
||||||
|
if HybridCursorType=hcDirty then
|
||||||
|
Result:=DirtySrc.CurPos.StartPos
|
||||||
|
else
|
||||||
|
Result:=CurPos.StartPos;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomCodeTool.CreateChildNode;
|
procedure TCustomCodeTool.CreateChildNode;
|
||||||
var NewNode: TCodeTreeNode;
|
var NewNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
@ -2280,26 +2330,113 @@ begin
|
|||||||
dec(LockCount);
|
dec(LockCount);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TDirtySource.SetCode(NewCode: TCodeBuffer);
|
procedure TDirtySource.SetGap(const NewCursorPos: TCodeXYPosition;
|
||||||
|
NewDirtyStartPos, NewDirtyGapStart, NewDirtyGapEnd: integer);
|
||||||
begin
|
begin
|
||||||
if (LockCount>0) and (Code<>NewCode) then
|
// check for conflicts
|
||||||
RaiseCatchableException('TDirtySource.SetCode');
|
if (LockCount>0) then begin
|
||||||
Code:=NewCode;
|
if (Code<>nil) and (Code<>NewCursorPos.Code) then
|
||||||
Src:=Code.Source;
|
RaiseCatchableException('TDirtySource.SetGap Code change');
|
||||||
end;
|
if (GapStart>0) then
|
||||||
|
if (NewDirtyStartPos<>StartPos)
|
||||||
|
or (NewDirtyGapStart<>GapStart)
|
||||||
|
or (NewDirtyGapEnd<>GapEnd) then
|
||||||
|
RaiseCatchableException('TDirtySource.SetGap Gap change');
|
||||||
|
end;
|
||||||
|
if (NewDirtyGapStart>NewDirtyStartPos)
|
||||||
|
or (NewDirtyStartPos>NewDirtyGapEnd) then
|
||||||
|
RaiseCatchableException('TDirtySource.SetGap Gap Bounds');
|
||||||
|
|
||||||
procedure TDirtySource.SetGap(NewDirtyStartPos, NewDirtyGapStart,
|
// set values
|
||||||
NewDirtyGapEnd: integer);
|
CursorPos:=NewCursorPos;
|
||||||
begin
|
Code:=CursorPos.Code;
|
||||||
if (LockCount>0) then
|
|
||||||
if (NewDirtyStartPos<>StartPos)
|
|
||||||
or (NewDirtyGapStart<>GapStart)
|
|
||||||
or (NewDirtyGapEnd<>GapEnd) then
|
|
||||||
RaiseCatchableException('TDirtySource.SetGap');
|
|
||||||
StartPos:=NewDirtyStartPos;
|
StartPos:=NewDirtyStartPos;
|
||||||
GapStart:=NewDirtyGapStart;
|
GapStart:=NewDirtyGapStart;
|
||||||
GapEnd:=NewDirtyGapEnd;
|
GapEnd:=NewDirtyGapEnd;
|
||||||
GapSrc:=copy(Src,GapStart,GapEnd-GapStart);
|
CurPos.StartPos:=StartPos;
|
||||||
|
CurPos.EndPos:=StartPos;
|
||||||
|
CurPos.Flag:=cafNone;
|
||||||
|
|
||||||
|
// get source
|
||||||
|
if Code<>nil then
|
||||||
|
Src:=Code.Source
|
||||||
|
else
|
||||||
|
Src:='';
|
||||||
|
if (GapStart>0) then begin
|
||||||
|
GapSrc:=copy(Src,GapStart,GapEnd-GapStart);
|
||||||
|
GapUpperSrc:=UpperCaseStr(GapSrc);
|
||||||
|
{$IFDEF ShowDirtySrc}
|
||||||
|
writeln('TDirtySource.SetGap Owner=',ExtractFilename(Owner.MainFilename),
|
||||||
|
' Code=',ExtractFilename(Code.Filename),
|
||||||
|
' Gap(',GapStart,',',StartPos,',',GapEnd,')',
|
||||||
|
'"',StringToPascalConst(copy(GapSrc,1,20)),'"..',
|
||||||
|
'"',StringToPascalConst(copy(GapSrc,length(GapSrc)-19,20)),'"'
|
||||||
|
);
|
||||||
|
{$ENDIF}
|
||||||
|
end else begin
|
||||||
|
GapSrc:='';
|
||||||
|
GapUpperSrc:='';
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TDirtySource.Create(TheOwner: TCustomCodeTool);
|
||||||
|
begin
|
||||||
|
Owner:=TheOwner;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDirtySource.Clear;
|
||||||
|
begin
|
||||||
|
SetGap(CodeXYPosition(0,0,nil),0,0,0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDirtySource.SetCursorToIdentStartEndAtPosition;
|
||||||
|
begin
|
||||||
|
GetIdentStartEndAtPosition(GapSrc,CurPos.StartPos,
|
||||||
|
CurPos.StartPos,CurPos.EndPos);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDirtySource.GetCursorSrcPos: PChar;
|
||||||
|
begin
|
||||||
|
Result:=@Src[CurPos.StartPos];
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDirtySource.IsPCharInSrc(p: PChar): boolean;
|
||||||
|
var NewPos: integer;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if Src='' then exit;
|
||||||
|
NewPos:=Integer(p)-Integer(@Src[1])+1;
|
||||||
|
if (NewPos<1) or (NewPos>length(Src)) then exit;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDirtySource.MoveCursorToPos(APos: integer);
|
||||||
|
begin
|
||||||
|
CurPos.StartPos:=APos;
|
||||||
|
CurPos.EndPos:=APos;
|
||||||
|
CurPos.Flag:=cafNone;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDirtySource.MoveCursorToPos(APos: PChar);
|
||||||
|
|
||||||
|
procedure RaiseSrcEmpty;
|
||||||
|
begin
|
||||||
|
RaiseCatchableException('[TDirtySource.MoveCursorToPos - PChar] Src empty');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure RaiseNotInSrc;
|
||||||
|
begin
|
||||||
|
RaiseCatchableException('[TDirtySource.MoveCursorToPos - PChar] Pos not in Src');
|
||||||
|
end;
|
||||||
|
|
||||||
|
var NewPos: integer;
|
||||||
|
begin
|
||||||
|
if Src='' then
|
||||||
|
RaiseSrcEmpty;
|
||||||
|
NewPos:=Integer(APos)-Integer(@Src[1])+1;
|
||||||
|
if (NewPos<1) or (NewPos>length(Src)) then
|
||||||
|
RaiseNotInSrc;
|
||||||
|
MoveCursorToPos(NewPos);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
@ -925,6 +925,8 @@ var CleanCursorPos: integer;
|
|||||||
|
|
||||||
var
|
var
|
||||||
CleanPosInFront: integer;
|
CleanPosInFront: integer;
|
||||||
|
CursorAtIdentifier: boolean;
|
||||||
|
IdentifierStart: Pchar;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
SkipChecks:=false;
|
SkipChecks:=false;
|
||||||
@ -934,9 +936,10 @@ begin
|
|||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
writeln(DebugPrefix,'TFindDeclarationTool.FindDeclaration A CursorPos=',CursorPos.X,',',CursorPos.Y);
|
writeln(DebugPrefix,'TFindDeclarationTool.FindDeclaration A CursorPos=',CursorPos.X,',',CursorPos.Y);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
if DirtySrc<>nil then DirtySrc.Clear;
|
||||||
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
||||||
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}],
|
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}
|
||||||
false);
|
btLoadDirtySource,btCursorPosOutAllowed]);
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
writeln(DebugPrefix,'TFindDeclarationTool.FindDeclaration C CleanCursorPos=',CleanCursorPos);
|
writeln(DebugPrefix,'TFindDeclarationTool.FindDeclaration C CleanCursorPos=',CleanCursorPos);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -948,7 +951,8 @@ begin
|
|||||||
CleanPosInFront:=1;
|
CleanPosInFront:=1;
|
||||||
CursorNode:=nil;
|
CursorNode:=nil;
|
||||||
end;
|
end;
|
||||||
if IsIncludeDirectiveAtPos(CleanCursorPos,CleanPosInFront,NewPos.Code)
|
if (not IsDirtySrcValid)
|
||||||
|
and IsIncludeDirectiveAtPos(CleanCursorPos,CleanPosInFront,NewPos.Code)
|
||||||
then begin
|
then begin
|
||||||
// include directive
|
// include directive
|
||||||
NewPos.X:=1;
|
NewPos.X:=1;
|
||||||
@ -965,7 +969,8 @@ begin
|
|||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
writeln('TFindDeclarationTool.FindDeclaration D CursorNode=',NodeDescriptionAsString(CursorNode.Desc));
|
writeln('TFindDeclarationTool.FindDeclaration D CursorNode=',NodeDescriptionAsString(CursorNode.Desc));
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if CursorNode.Desc=ctnUsesSection then begin
|
if (not IsDirtySrcValid)
|
||||||
|
and (CursorNode.Desc=ctnUsesSection) then begin
|
||||||
// in uses section
|
// in uses section
|
||||||
Result:=FindDeclarationInUsesSection(CursorNode,CleanCursorPos,
|
Result:=FindDeclarationInUsesSection(CursorNode,CleanCursorPos,
|
||||||
NewPos,NewTopLine);
|
NewPos,NewTopLine);
|
||||||
@ -980,20 +985,29 @@ begin
|
|||||||
CheckIfCursorInBeginNode;
|
CheckIfCursorInBeginNode;
|
||||||
CheckIfCursorInProcNode;
|
CheckIfCursorInProcNode;
|
||||||
CheckIfCursorInPropertyNode;
|
CheckIfCursorInPropertyNode;
|
||||||
// set cursor
|
// set cursor on identifier
|
||||||
MoveCursorToCleanPos(CleanCursorPos);
|
MoveCursorToCleanPos(CleanCursorPos);
|
||||||
GetIdentStartEndAtPosition(Src,CleanCursorPos,
|
if IsDirtySrcValid then begin
|
||||||
CurPos.StartPos,CurPos.EndPos);
|
DirtySrc.SetCursorToIdentStartEndAtPosition;
|
||||||
if (CurPos.StartPos<CurPos.EndPos) then begin
|
CursorAtIdentifier:=DirtySrc.CurPos.StartPos<DirtySrc.CurPos.EndPos;
|
||||||
|
IdentifierStart:=DirtySrc.GetCursorSrcPos;
|
||||||
|
end else begin
|
||||||
|
GetIdentStartEndAtPosition(Src,CleanCursorPos,
|
||||||
|
CurPos.StartPos,CurPos.EndPos);
|
||||||
|
CursorAtIdentifier:=CurPos.StartPos<CurPos.EndPos;
|
||||||
|
IdentifierStart:=@Src[CurPos.StartPos];
|
||||||
|
end;
|
||||||
|
if CursorAtIdentifier then begin
|
||||||
// find declaration of identifier
|
// find declaration of identifier
|
||||||
Params:=TFindDeclarationParams.Create;
|
Params:=TFindDeclarationParams.Create;
|
||||||
try
|
try
|
||||||
Params.ContextNode:=CursorNode;
|
Params.ContextNode:=CursorNode;
|
||||||
Params.SetIdentifier(Self,@Src[CurPos.StartPos],@CheckSrcIdentifier);
|
Params.SetIdentifier(Self,IdentifierStart,@CheckSrcIdentifier);
|
||||||
Params.Flags:=[fdfSearchInParentNodes,fdfExceptionOnNotFound,
|
Params.Flags:=[fdfSearchInParentNodes,fdfExceptionOnNotFound,
|
||||||
fdfExceptionOnPredefinedIdent,
|
fdfExceptionOnPredefinedIdent,
|
||||||
fdfTopLvlResolving,fdfSearchInAncestors];
|
fdfTopLvlResolving,fdfSearchInAncestors];
|
||||||
if not DirectSearch then begin
|
if not DirectSearch then begin
|
||||||
|
// ToDo: DirtySrc
|
||||||
Result:=FindDeclarationOfIdentAtCursor(Params);
|
Result:=FindDeclarationOfIdentAtCursor(Params);
|
||||||
end else begin
|
end else begin
|
||||||
Include(Params.Flags,fdfIgnoreCurContextNode);
|
Include(Params.Flags,fdfIgnoreCurContextNode);
|
||||||
@ -1021,7 +1035,9 @@ begin
|
|||||||
NewTopLine:=Params.NewTopLine;
|
NewTopLine:=Params.NewTopLine;
|
||||||
if NewPos.Code=nil then begin
|
if NewPos.Code=nil then begin
|
||||||
if Params.IdentifierTool.IsPCharInSrc(Params.Identifier) then
|
if Params.IdentifierTool.IsPCharInSrc(Params.Identifier) then
|
||||||
Params.IdentifierTool.MoveCursorToCleanPos(Params.Identifier);
|
Params.IdentifierTool.MoveCursorToCleanPos(Params.Identifier)
|
||||||
|
else
|
||||||
|
MoveCursorToCleanPos(CleanCursorPos);
|
||||||
Params.IdentifierTool.RaiseExceptionFmt(ctsIdentifierNotFound,
|
Params.IdentifierTool.RaiseExceptionFmt(ctsIdentifierNotFound,
|
||||||
[GetIdentifier(Params.Identifier)]);
|
[GetIdentifier(Params.Identifier)]);
|
||||||
end;
|
end;
|
||||||
@ -1030,7 +1046,7 @@ begin
|
|||||||
Params.Free;
|
Params.Free;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
// find declaration of not identifier, e.g. numeric label
|
// find declaration of non identifier, e.g. numeric label
|
||||||
|
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
@ -1530,8 +1546,9 @@ function TFindDeclarationTool.FindDeclarationOfIdentAtCursor(
|
|||||||
Result:
|
Result:
|
||||||
true, if NewPos+NewTopLine valid
|
true, if NewPos+NewTopLine valid
|
||||||
|
|
||||||
For example:
|
Examples:
|
||||||
A^.B().C[].Identifier
|
A^.B().C[].Identifier
|
||||||
|
inherited Identifier(p1,p2)
|
||||||
}
|
}
|
||||||
var
|
var
|
||||||
StartPos, EndPos: integer;
|
StartPos, EndPos: integer;
|
||||||
@ -1544,9 +1561,12 @@ begin
|
|||||||
' "',copy(Src,Params.ContextNode.StartPos,20),'"');
|
' "',copy(Src,Params.ContextNode.StartPos,20),'"');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
// search in cleaned source
|
||||||
MoveCursorToCleanPos(Params.Identifier);
|
MoveCursorToCleanPos(Params.Identifier);
|
||||||
StartPos:=CurPos.StartPos;
|
if Params.ContextNode.Desc<>ctnIdentifier then
|
||||||
if Params.ContextNode.Desc<>ctnIdentifier then StartPos:=-1;
|
StartPos:=-1
|
||||||
|
else
|
||||||
|
StartPos:=GetHybridCursorStart;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
EndPos:=CurPos.EndPos;
|
EndPos:=CurPos.EndPos;
|
||||||
ReadNextAtom;
|
ReadNextAtom;
|
||||||
|
@ -813,7 +813,7 @@ begin
|
|||||||
writeln('TIdentCompletionTool.GatherIdentifiers A CursorPos=',CursorPos.X,',',CursorPos.Y);
|
writeln('TIdentCompletionTool.GatherIdentifiers A CursorPos=',CursorPos.X,',',CursorPos.Y);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
||||||
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}],true);
|
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos,{$ENDIF}]);
|
||||||
|
|
||||||
// find node at position
|
// find node at position
|
||||||
CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true);
|
CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true);
|
||||||
|
@ -663,12 +663,12 @@ begin
|
|||||||
if LinkIndex>=0 then begin
|
if LinkIndex>=0 then begin
|
||||||
LastIndex:=LinkIndex;
|
LastIndex:=LinkIndex;
|
||||||
while (Result>=0) do begin
|
while (Result>=0) do begin
|
||||||
if Links[Result].Code=Links[LinkIndex].Code then begin
|
if FLinks[Result].Code=FLinks[LinkIndex].Code then begin
|
||||||
if Links[Result].SrcPos>Links[LastIndex].SrcPos then begin
|
if Links[Result].SrcPos>FLinks[LastIndex].SrcPos then begin
|
||||||
// the include file was (in-)directly included by itself
|
// the include file was (in-)directly included by itself
|
||||||
// -> skip
|
// -> skip
|
||||||
Result:=FindParentLink(Result);
|
Result:=FindParentLink(Result);
|
||||||
end else if Links[Result].SrcPos=1 then begin
|
end else if FLinks[Result].SrcPos=1 then begin
|
||||||
// start found
|
// start found
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
@ -741,16 +741,16 @@ begin
|
|||||||
while l<=r do begin
|
while l<=r do begin
|
||||||
m:=(l+r) div 2;
|
m:=(l+r) div 2;
|
||||||
if m<LinkCount-1 then begin
|
if m<LinkCount-1 then begin
|
||||||
if ACleanPos<Links[m].CleanedPos then
|
if ACleanPos<FLinks[m].CleanedPos then
|
||||||
r:=m-1
|
r:=m-1
|
||||||
else if ACleanPos>=Links[m+1].CleanedPos then
|
else if ACleanPos>=FLinks[m+1].CleanedPos then
|
||||||
l:=m+1
|
l:=m+1
|
||||||
else begin
|
else begin
|
||||||
Result:=m;
|
Result:=m;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if ACleanPos>=Links[m].CleanedPos then begin
|
if ACleanPos>=FLinks[m].CleanedPos then begin
|
||||||
Result:=m;
|
Result:=m;
|
||||||
exit;
|
exit;
|
||||||
end else
|
end else
|
||||||
@ -1326,9 +1326,9 @@ begin
|
|||||||
// links
|
// links
|
||||||
for i:=0 to LinkCount-1 do begin
|
for i:=0 to LinkCount-1 do begin
|
||||||
writeln(' Link ',i,':'
|
writeln(' Link ',i,':'
|
||||||
,' CleanedPos=',Links[i].CleanedPos
|
,' CleanedPos=',FLinks[i].CleanedPos
|
||||||
,' SrcPos=',Links[i].SrcPos
|
,' SrcPos=',FLinks[i].SrcPos
|
||||||
,' Code=',HexStr(Cardinal(Links[i].Code),8)
|
,' Code=',HexStr(Cardinal(FLinks[i].Code),8)
|
||||||
);
|
);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -1859,7 +1859,6 @@ function TLinkScanner.GuessMisplacedIfdefEndif(StartCursorPos: integer;
|
|||||||
|
|
||||||
var
|
var
|
||||||
LinkID, i, BestSrcPos: integer;
|
LinkID, i, BestSrcPos: integer;
|
||||||
CurLink: TSourceLink;
|
|
||||||
LastCode: Pointer;
|
LastCode: Pointer;
|
||||||
SearchedCodes: TList;
|
SearchedCodes: TList;
|
||||||
begin
|
begin
|
||||||
@ -1870,9 +1869,8 @@ begin
|
|||||||
BestSrcPos:=0;
|
BestSrcPos:=0;
|
||||||
i:=0;
|
i:=0;
|
||||||
while i<LinkCount do begin
|
while i<LinkCount do begin
|
||||||
CurLink:=Links[i];
|
if (StartCode=FLinks[i].Code) and (StartCursorPos>=FLinks[i].SrcPos) then begin
|
||||||
if (StartCode=CurLink.Code) and (StartCursorPos>=CurLink.SrcPos) then begin
|
if (LinkID<0) or (BestSrcPos<FLinks[i].SrcPos) then
|
||||||
if (LinkID<0) or (BestSrcPos<CurLink.SrcPos) then
|
|
||||||
LinkID:=i;
|
LinkID:=i;
|
||||||
end;
|
end;
|
||||||
inc(i);
|
inc(i);
|
||||||
@ -1883,17 +1881,17 @@ begin
|
|||||||
SearchedCodes:=TList.Create;
|
SearchedCodes:=TList.Create;
|
||||||
try
|
try
|
||||||
while LinkId<LinkCount do begin
|
while LinkId<LinkCount do begin
|
||||||
Result:=GuessMisplacedIfdefEndifInCode(Links[LinkID].Code,
|
Result:=GuessMisplacedIfdefEndifInCode(FLinks[LinkID].Code,
|
||||||
StartCursorPos,StartCode,EndCursorPos,EndCode);
|
StartCursorPos,StartCode,EndCursorPos,EndCode);
|
||||||
if Result then exit;
|
if Result then exit;
|
||||||
// search next code
|
// search next code
|
||||||
LastCode:=Links[LinkID].Code;
|
LastCode:=FLinks[LinkID].Code;
|
||||||
SearchedCodes.Add(LastCode);
|
SearchedCodes.Add(LastCode);
|
||||||
repeat
|
repeat
|
||||||
inc(LinkID);
|
inc(LinkID);
|
||||||
if LinkID>=LinkCount then exit;
|
if LinkID>=LinkCount then exit;
|
||||||
until (Links[LinkID].Code<>LastCode)
|
until (FLinks[LinkID].Code<>LastCode)
|
||||||
and (SearchedCodes.IndexOf(Links[LinkID].Code)<0);
|
and (SearchedCodes.IndexOf(FLinks[LinkID].Code)<0);
|
||||||
end;
|
end;
|
||||||
finally
|
finally
|
||||||
SearchedCodes.Free;
|
SearchedCodes.Free;
|
||||||
@ -2627,21 +2625,30 @@ begin
|
|||||||
SkippedCleanPos:=-1;
|
SkippedCleanPos:=-1;
|
||||||
while i<LinkCount do begin
|
while i<LinkCount do begin
|
||||||
//writeln('[TLinkScanner.CursorToCleanPos] A ACursorPos=',ACursorPos,', Code=',Links[i].Code=ACode,', Links[i].SrcPos=',Links[i].SrcPos,', Links[i].CleanedPos=',Links[i].CleanedPos);
|
//writeln('[TLinkScanner.CursorToCleanPos] A ACursorPos=',ACursorPos,', Code=',Links[i].Code=ACode,', Links[i].SrcPos=',Links[i].SrcPos,', Links[i].CleanedPos=',Links[i].CleanedPos);
|
||||||
if (Links[i].Code=ACode) and (Links[i].SrcPos<=ACursorPos) then begin
|
if (FLinks[i].Code=ACode) and (FLinks[i].SrcPos<=ACursorPos) then begin
|
||||||
ACleanPos:=ACursorPos-Links[i].SrcPos+Links[i].CleanedPos;
|
// link in same code found
|
||||||
|
ACleanPos:=ACursorPos-FLinks[i].SrcPos+FLinks[i].CleanedPos;
|
||||||
//writeln('[TLinkScanner.CursorToCleanPos] B ACleanPos=',ACleanPos);
|
//writeln('[TLinkScanner.CursorToCleanPos] B ACleanPos=',ACleanPos);
|
||||||
if i+1<LinkCount then begin
|
if i+1<LinkCount then begin
|
||||||
|
// link has successor
|
||||||
//writeln('[TLinkScanner.CursorToCleanPos] C Links[i+1].CleanedPos=',Links[i+1].CleanedPos);
|
//writeln('[TLinkScanner.CursorToCleanPos] C Links[i+1].CleanedPos=',Links[i+1].CleanedPos);
|
||||||
if ACleanPos<Links[i+1].CleanedPos then begin
|
if ACleanPos<FLinks[i+1].CleanedPos then begin
|
||||||
|
// link covers the cursor position
|
||||||
Result:=0; // valid position
|
Result:=0; // valid position
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
// set found cleanpos to end of link
|
||||||
|
ACleanPos:=FLinks[i].CleanedPos+LinkSize(i);
|
||||||
|
// link does not cover the cursor position
|
||||||
|
// find the next link in the same code
|
||||||
j:=i+1;
|
j:=i+1;
|
||||||
while (j<LinkCount) and (Links[j].Code<>ACode) do inc(j);
|
while (j<LinkCount) and (FLinks[j].Code<>ACode) do inc(j);
|
||||||
//writeln('[TLinkScanner.CursorToCleanPos] D j=',j);
|
//writeln('[TLinkScanner.CursorToCleanPos] D j=',j);
|
||||||
if (j<LinkCount) and (Links[j].SrcPos>ACursorPos) then begin
|
if (j<LinkCount) and (FLinks[j].SrcPos>ACursorPos) then begin
|
||||||
if not SkippedPos then begin
|
if not SkippedPos then begin
|
||||||
// CursorPos was skipped, CleanPos is between two links
|
// CursorPos was skipped, CleanPos is between two links
|
||||||
|
// but because include files can be parsed multiple times,
|
||||||
|
// search must continue
|
||||||
SkippedPos:=true;
|
SkippedPos:=true;
|
||||||
SkippedCleanPos:=ACleanPos;
|
SkippedCleanPos:=ACleanPos;
|
||||||
end;
|
end;
|
||||||
@ -2653,25 +2660,20 @@ begin
|
|||||||
end else begin
|
end else begin
|
||||||
// in last link
|
// in last link
|
||||||
//writeln('[TLinkScanner.CursorToCleanPos] E length(FCleanedSrc)=',length(FCleanedSrc));
|
//writeln('[TLinkScanner.CursorToCleanPos] E length(FCleanedSrc)=',length(FCleanedSrc));
|
||||||
if ACleanPos<=length(FCleanedSrc) then
|
if ACleanPos<=length(FCleanedSrc) then begin
|
||||||
Result:=0 // valid position
|
Result:=0; // valid position
|
||||||
else begin
|
exit;
|
||||||
if SkippedPos then begin
|
|
||||||
Result:=-1;
|
|
||||||
ACleanPos:=SkippedCleanPos;
|
|
||||||
end else
|
|
||||||
Result:=1; // cursor beyond scanned code
|
|
||||||
end;
|
end;
|
||||||
exit;
|
break;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
inc(i);
|
inc(i);
|
||||||
end;
|
end;
|
||||||
if SkippedPos then begin
|
if SkippedPos then begin
|
||||||
Result:=-1;
|
Result:=-1;
|
||||||
ACLeanPos:=SkippedCleanPos;
|
ACleanPos:=SkippedCleanPos;
|
||||||
end else
|
end else
|
||||||
Result:=1;
|
Result:=1; // default: CursorPos beyond/outside scanned code
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TLinkScanner.CleanedPosToCursor(ACleanedPos: integer;
|
function TLinkScanner.CleanedPosToCursor(ACleanedPos: integer;
|
||||||
@ -2693,19 +2695,19 @@ begin
|
|||||||
while l<=r do begin
|
while l<=r do begin
|
||||||
m:=(l+r) div 2;
|
m:=(l+r) div 2;
|
||||||
if m<LinkCount-1 then begin
|
if m<LinkCount-1 then begin
|
||||||
if ACleanedPos<Links[m].CleanedPos then
|
if ACleanedPos<FLinks[m].CleanedPos then
|
||||||
r:=m-1
|
r:=m-1
|
||||||
else if ACleanedPos>=Links[m+1].CleanedPos then
|
else if ACleanedPos>=FLinks[m+1].CleanedPos then
|
||||||
l:=m+1
|
l:=m+1
|
||||||
else begin
|
else begin
|
||||||
ACode:=Links[m].Code;
|
ACode:=FLinks[m].Code;
|
||||||
ACursorPos:=ACleanedPos-Links[m].CleanedPos+Links[m].SrcPos;
|
ACursorPos:=ACleanedPos-FLinks[m].CleanedPos+FLinks[m].SrcPos;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
end else begin
|
end else begin
|
||||||
if ACleanedPos>=Links[m].CleanedPos then begin
|
if ACleanedPos>=FLinks[m].CleanedPos then begin
|
||||||
ACode:=Links[m].Code;
|
ACode:=FLinks[m].Code;
|
||||||
ACursorPos:=ACleanedPos-Links[m].CleanedPos+Links[m].SrcPos;
|
ACursorPos:=ACleanedPos-FLinks[m].CleanedPos+FLinks[m].SrcPos;
|
||||||
exit;
|
exit;
|
||||||
end else
|
end else
|
||||||
ConsistencyCheckI(2);
|
ConsistencyCheckI(2);
|
||||||
@ -2726,18 +2728,18 @@ begin
|
|||||||
or (CleanEndPos>CleanedLen+1) or (not Assigned(FOnGetSourceStatus)) then exit;
|
or (CleanEndPos>CleanedLen+1) or (not Assigned(FOnGetSourceStatus)) then exit;
|
||||||
LinkIndex:=LinkIndexAtCleanPos(CleanStartPos);
|
LinkIndex:=LinkIndexAtCleanPos(CleanStartPos);
|
||||||
if LinkIndex<0 then exit;
|
if LinkIndex<0 then exit;
|
||||||
ACode:=Links[LinkIndex].Code;
|
ACode:=FLinks[LinkIndex].Code;
|
||||||
FOnGetSourceStatus(Self,ACode,CodeIsReadOnly);
|
FOnGetSourceStatus(Self,ACode,CodeIsReadOnly);
|
||||||
if CodeIsReadOnly then exit;
|
if CodeIsReadOnly then exit;
|
||||||
repeat
|
repeat
|
||||||
inc(LinkIndex);
|
inc(LinkIndex);
|
||||||
if (LinkIndex>=LinkCount) or (Links[LinkIndex].CleanedPos>CleanEndPos) then
|
if (LinkIndex>=LinkCount) or (FLinks[LinkIndex].CleanedPos>CleanEndPos) then
|
||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if ACode<>Links[LinkIndex].Code then begin
|
if ACode<>FLinks[LinkIndex].Code then begin
|
||||||
ACode:=Links[LinkIndex].Code;
|
ACode:=FLinks[LinkIndex].Code;
|
||||||
FOnGetSourceStatus(Self,ACode,CodeIsReadOnly);
|
FOnGetSourceStatus(Self,ACode,CodeIsReadOnly);
|
||||||
if CodeIsReadOnly then exit;
|
if CodeIsReadOnly then exit;
|
||||||
end;
|
end;
|
||||||
@ -2753,14 +2755,14 @@ begin
|
|||||||
or (CleanEndPos>CleanedLen+1) or (UniqueSortedCodeList=nil) then exit;
|
or (CleanEndPos>CleanedLen+1) or (UniqueSortedCodeList=nil) then exit;
|
||||||
LinkIndex:=LinkIndexAtCleanPos(CleanStartPos);
|
LinkIndex:=LinkIndexAtCleanPos(CleanStartPos);
|
||||||
if LinkIndex<0 then exit;
|
if LinkIndex<0 then exit;
|
||||||
ACode:=Links[LinkIndex].Code;
|
ACode:=FLinks[LinkIndex].Code;
|
||||||
AddCodeToUniqueList(ACode,UniqueSortedCodeList);
|
AddCodeToUniqueList(ACode,UniqueSortedCodeList);
|
||||||
repeat
|
repeat
|
||||||
inc(LinkIndex);
|
inc(LinkIndex);
|
||||||
if (LinkIndex>=LinkCount) or (Links[LinkIndex].CleanedPos>CleanEndPos) then
|
if (LinkIndex>=LinkCount) or (FLinks[LinkIndex].CleanedPos>CleanEndPos) then
|
||||||
exit;
|
exit;
|
||||||
if ACode<>Links[LinkIndex].Code then begin
|
if ACode<>FLinks[LinkIndex].Code then begin
|
||||||
ACode:=Links[LinkIndex].Code;
|
ACode:=FLinks[LinkIndex].Code;
|
||||||
AddCodeToUniqueList(ACode,UniqueSortedCodeList);
|
AddCodeToUniqueList(ACode,UniqueSortedCodeList);
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
@ -2777,23 +2779,21 @@ procedure TLinkScanner.DeleteRange(CleanStartPos,CleanEndPos: integer);
|
|||||||
ToDo: keep include directives
|
ToDo: keep include directives
|
||||||
}
|
}
|
||||||
var LinkIndex, StartPos, Len, aLinkSize: integer;
|
var LinkIndex, StartPos, Len, aLinkSize: integer;
|
||||||
Link: TSourceLink;
|
|
||||||
begin
|
begin
|
||||||
if (CleanStartPos<1) or (CleanStartPos>=CleanEndPos)
|
if (CleanStartPos<1) or (CleanStartPos>=CleanEndPos)
|
||||||
or (CleanEndPos>CleanedLen+1) or (not Assigned(FOnDeleteSource)) then exit;
|
or (CleanEndPos>CleanedLen+1) or (not Assigned(FOnDeleteSource)) then exit;
|
||||||
LinkIndex:=LinkIndexAtCleanPos(CleanEndPos-1);
|
LinkIndex:=LinkIndexAtCleanPos(CleanEndPos-1);
|
||||||
while LinkIndex>=0 do begin
|
while LinkIndex>=0 do begin
|
||||||
Link:=Links[LinkIndex];
|
StartPos:=CleanStartPos-FLinks[LinkIndex].CleanedPos;
|
||||||
StartPos:=CleanStartPos-Link.CleanedPos;
|
if StartPos<0 then StartPos:=0;
|
||||||
if Startpos<0 then StartPos:=0;
|
|
||||||
aLinkSize:=LinkSize(LinkIndex);
|
aLinkSize:=LinkSize(LinkIndex);
|
||||||
if CleanEndPos<Link.CleanedPos+aLinkSize then
|
if CleanEndPos<FLinks[LinkIndex].CleanedPos+aLinkSize then
|
||||||
Len:=CleanEndPos-Link.CleanedPos-StartPos
|
Len:=CleanEndPos-FLinks[LinkIndex].CleanedPos-StartPos
|
||||||
else
|
else
|
||||||
Len:=aLinkSize-StartPos;
|
Len:=aLinkSize-StartPos;
|
||||||
inc(StartPos,Link.SrcPos);
|
inc(StartPos,FLinks[LinkIndex].SrcPos);
|
||||||
FOnDeleteSource(Self,Links[LinkIndex].Code,StartPos,Len);
|
FOnDeleteSource(Self,FLinks[LinkIndex].Code,StartPos,Len);
|
||||||
if Link.CleanedPos<=CleanStartPos then break;
|
if FLinks[LinkIndex].CleanedPos<=CleanStartPos then break;
|
||||||
dec(LinkIndex);
|
dec(LinkIndex);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -325,7 +325,7 @@ begin
|
|||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
writeln('TMethodJumpingCodeTool.FindJumpPoint A CursorPos=',CursorPos.X,',',CursorPos.Y);
|
writeln('TMethodJumpingCodeTool.FindJumpPoint A CursorPos=',CursorPos.X,',',CursorPos.Y);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
|
||||||
GetLineInfo(CleanCursorPos,LineStart,LineEnd,FirstAtomStart,LastAtomEnd);
|
GetLineInfo(CleanCursorPos,LineStart,LineEnd,FirstAtomStart,LastAtomEnd);
|
||||||
if CleanCursorPos<FirstAtomStart then CleanCursorPos:=FirstAtomStart;
|
if CleanCursorPos<FirstAtomStart then CleanCursorPos:=FirstAtomStart;
|
||||||
if CleanCursorPos>=LastAtomEnd then CleanCursorPos:=LastAtomEnd-1;
|
if CleanCursorPos>=LastAtomEnd then CleanCursorPos:=LastAtomEnd-1;
|
||||||
|
@ -91,7 +91,8 @@ type
|
|||||||
TBuildTreeFlag = (
|
TBuildTreeFlag = (
|
||||||
btSetIgnoreErrorPos,
|
btSetIgnoreErrorPos,
|
||||||
btKeepIgnoreErrorPos,
|
btKeepIgnoreErrorPos,
|
||||||
btLoadDirtySource
|
btLoadDirtySource,
|
||||||
|
btCursorPosOutAllowed
|
||||||
);
|
);
|
||||||
TBuildTreeFlags = set of TBuildTreeFlag;
|
TBuildTreeFlags = set of TBuildTreeFlag;
|
||||||
|
|
||||||
@ -200,7 +201,7 @@ type
|
|||||||
procedure BuildTree(OnlyInterfaceNeeded: boolean); virtual;
|
procedure BuildTree(OnlyInterfaceNeeded: boolean); virtual;
|
||||||
procedure BuildTreeAndGetCleanPos(TreeRange: TTreeRange;
|
procedure BuildTreeAndGetCleanPos(TreeRange: TTreeRange;
|
||||||
const CursorPos: TCodeXYPosition; var CleanCursorPos: integer;
|
const CursorPos: TCodeXYPosition; var CleanCursorPos: integer;
|
||||||
BuildTreeFlags: TBuildTreeFlags; ExceptionOnCursorPosOut: boolean);
|
BuildTreeFlags: TBuildTreeFlags);
|
||||||
procedure BuildSubTreeForClass(ClassNode: TCodeTreeNode); virtual;
|
procedure BuildSubTreeForClass(ClassNode: TCodeTreeNode); virtual;
|
||||||
procedure BuildSubTreeForBeginBlock(BeginNode: TCodeTreeNode); virtual;
|
procedure BuildSubTreeForBeginBlock(BeginNode: TCodeTreeNode); virtual;
|
||||||
procedure BuildSubTreeForProcHead(ProcNode: TCodeTreeNode); virtual;
|
procedure BuildSubTreeForProcHead(ProcNode: TCodeTreeNode); virtual;
|
||||||
@ -3243,8 +3244,7 @@ end;
|
|||||||
|
|
||||||
procedure TPascalParserTool.BuildTreeAndGetCleanPos(
|
procedure TPascalParserTool.BuildTreeAndGetCleanPos(
|
||||||
TreeRange: TTreeRange; const CursorPos: TCodeXYPosition;
|
TreeRange: TTreeRange; const CursorPos: TCodeXYPosition;
|
||||||
var CleanCursorPos: integer; BuildTreeFlags: TBuildTreeFlags;
|
var CleanCursorPos: integer; BuildTreeFlags: TBuildTreeFlags);
|
||||||
ExceptionOnCursorPosOut: boolean);
|
|
||||||
var
|
var
|
||||||
CaretType: integer;
|
CaretType: integer;
|
||||||
IgnorePos: TCodePosition;
|
IgnorePos: TCodePosition;
|
||||||
@ -3297,7 +3297,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
if (CaretType=-2) or ExceptionOnCursorPosOut then
|
if (CaretType=-2) or (not (btCursorPosOutAllowed in BuildTreeFlags)) then
|
||||||
RaiseException(ctsCursorPosOutsideOfCode);
|
RaiseException(ctsCursorPosOutsideOfCode);
|
||||||
// cursor outside of clean code
|
// cursor outside of clean code
|
||||||
CleanCursorPos:=-1;
|
CleanCursorPos:=-1;
|
||||||
|
@ -1252,7 +1252,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
if IdentTree=nil then exit;
|
if IdentTree=nil then exit;
|
||||||
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,[]);
|
||||||
BestDiff:=SrcLen+1;
|
BestDiff:=SrcLen+1;
|
||||||
MoveCursorToCleanPos(1);
|
MoveCursorToCleanPos(1);
|
||||||
repeat
|
repeat
|
||||||
@ -1326,7 +1326,7 @@ begin
|
|||||||
StartPos:=CursorPos;
|
StartPos:=CursorPos;
|
||||||
EndPos:=CursorPos;
|
EndPos:=CursorPos;
|
||||||
Result:=true;
|
Result:=true;
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
|
||||||
{$IFDEF VerboseGetStringConstBounds}
|
{$IFDEF VerboseGetStringConstBounds}
|
||||||
writeln('TStandardCodeTool.GetStringConstBounds A ',CleanCursorPos,' "',copy(Src,CleanCursorPos-5,5),'" | "',copy(Src,CleanCursorPos,5),'"');
|
writeln('TStandardCodeTool.GetStringConstBounds A ',CleanCursorPos,' "',copy(Src,CleanCursorPos-5,5),'" | "',copy(Src,CleanCursorPos,5),'"');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -1518,7 +1518,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
//writeln('TStandardCodeTool.GatherResourceStringSections A ');
|
//writeln('TStandardCodeTool.GatherResourceStringSections A ');
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
|
||||||
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||||
PositionList.Clear;
|
PositionList.Clear;
|
||||||
ANode:=CursorNode;
|
ANode:=CursorNode;
|
||||||
@ -1558,7 +1558,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
if ResStrIdentifier='' then exit;
|
if ResStrIdentifier='' then exit;
|
||||||
// parse source and find clean positions
|
// parse source and find clean positions
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
|
||||||
// find resource string section
|
// find resource string section
|
||||||
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||||
if (ANode=nil) then exit;
|
if (ANode=nil) then exit;
|
||||||
@ -1587,7 +1587,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
if MaxLen<=0 then exit;
|
if MaxLen<=0 then exit;
|
||||||
// parse source and find clean positions
|
// parse source and find clean positions
|
||||||
BuildTreeAndGetCleanPos(trAll,StartCursorPos,StartPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,StartCursorPos,StartPos,[]);
|
||||||
Dummy:=CaretToCleanPos(EndCursorPos, EndPos);
|
Dummy:=CaretToCleanPos(EndCursorPos, EndPos);
|
||||||
if (Dummy<>0) and (Dummy<>-1) then exit;
|
if (Dummy<>0) and (Dummy<>-1) then exit;
|
||||||
// read string constants and extract identifier characters
|
// read string constants and extract identifier characters
|
||||||
@ -1723,7 +1723,7 @@ var
|
|||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
// parse source and find clean positions
|
// parse source and find clean positions
|
||||||
BuildTreeAndGetCleanPos(trAll,StartCursorPos,StartPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,StartCursorPos,StartPos,[]);
|
||||||
Dummy:=CaretToCleanPos(EndCursorPos, EndPos);
|
Dummy:=CaretToCleanPos(EndCursorPos, EndPos);
|
||||||
if (Dummy<>0) and (Dummy<>-1) then exit;
|
if (Dummy<>0) and (Dummy<>-1) then exit;
|
||||||
// read string constants and convert it
|
// read string constants and convert it
|
||||||
@ -1809,7 +1809,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
if PositionList=nil then exit;
|
if PositionList=nil then exit;
|
||||||
// parse source and find clean positions
|
// parse source and find clean positions
|
||||||
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]);
|
||||||
// find resource string section
|
// find resource string section
|
||||||
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||||
if (ANode=nil) then exit;
|
if (ANode=nil) then exit;
|
||||||
@ -1834,7 +1834,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
IdentTree:=nil;
|
IdentTree:=nil;
|
||||||
// parse source and find clean positions
|
// parse source and find clean positions
|
||||||
BuildTreeAndGetCleanPos(trAll,SectionPos,CleanCursorPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,SectionPos,CleanCursorPos,[]);
|
||||||
// find resource string section
|
// find resource string section
|
||||||
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
ANode:=FindDeepestNodeAtPos(CleanCursorPos,true);
|
||||||
if (ANode=nil) then exit;
|
if (ANode=nil) then exit;
|
||||||
@ -1906,7 +1906,7 @@ begin
|
|||||||
SourceChangeCache.MainScanner:=Scanner;
|
SourceChangeCache.MainScanner:=Scanner;
|
||||||
// parse source and find clean positions
|
// parse source and find clean positions
|
||||||
//writeln('TStandardCodeTool.AddResourcestring B');
|
//writeln('TStandardCodeTool.AddResourcestring B');
|
||||||
BuildTreeAndGetCleanPos(trAll,SectionPos,CleanSectionPos,[],true);
|
BuildTreeAndGetCleanPos(trAll,SectionPos,CleanSectionPos,[]);
|
||||||
//writeln('TStandardCodeTool.AddResourcestring C');
|
//writeln('TStandardCodeTool.AddResourcestring C');
|
||||||
// find resource string section
|
// find resource string section
|
||||||
SectionNode:=FindDeepestNodeAtPos(CleanSectionPos,true);
|
SectionNode:=FindDeepestNodeAtPos(CleanSectionPos,true);
|
||||||
@ -2312,7 +2312,7 @@ begin
|
|||||||
Result:=false;
|
Result:=false;
|
||||||
try
|
try
|
||||||
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
||||||
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}],true);
|
[{$IFDEF IgnoreErrorAfterCursor}btSetIgnoreErrorPos{$ENDIF}]);
|
||||||
LinkIndex:=Scanner.LinkIndexAtCleanPos(CleanCursorPos);
|
LinkIndex:=Scanner.LinkIndexAtCleanPos(CleanCursorPos);
|
||||||
LinkIndex:=Scanner.FindParentLink(LinkIndex);
|
LinkIndex:=Scanner.FindParentLink(LinkIndex);
|
||||||
if LinkIndex<0 then
|
if LinkIndex<0 then
|
||||||
|
@ -307,6 +307,9 @@ begin
|
|||||||
Tool.Title:=lisCleanLazarusSource;
|
Tool.Title:=lisCleanLazarusSource;
|
||||||
Tool.WorkingDirectory:='$(LazarusDir)';
|
Tool.WorkingDirectory:='$(LazarusDir)';
|
||||||
Tool.CmdLineParams:='cleanall';
|
Tool.CmdLineParams:='cleanall';
|
||||||
|
// append target OS
|
||||||
|
if Options.TargetOS<>'' then
|
||||||
|
Tool.CmdLineParams:=Tool.CmdLineParams+' OS_TARGET='+Options.TargetOS;
|
||||||
Result:=ExternalTools.Run(Tool,Macros);
|
Result:=ExternalTools.Run(Tool,Macros);
|
||||||
if Result<>mrOk then exit;
|
if Result<>mrOk then exit;
|
||||||
end;
|
end;
|
||||||
|
@ -2823,10 +2823,12 @@ end;
|
|||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
procedure TWinControl.CMShowingChanged(var Message: TLMessage);
|
procedure TWinControl.CMShowingChanged(var Message: TLMessage);
|
||||||
begin
|
begin
|
||||||
|
// ToDo: do not send this while loading, send it after loading.
|
||||||
if HandleAllocated then
|
if HandleAllocated then
|
||||||
CNSendMessage(LM_ShowHide, Self, nil);
|
CNSendMessage(LM_ShowHide, Self, nil);
|
||||||
// SetWindowPos(FHandle, 0, 0, 0, 0, 0, ShowFlags[FShowing]);
|
// SetWindowPos(FHandle, 0, 0, 0, 0, 0, ShowFlags[FShowing]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TWinControl.ShowControl
|
Method: TWinControl.ShowControl
|
||||||
Params: AControl: Control to show
|
Params: AControl: Control to show
|
||||||
@ -2847,6 +2849,9 @@ end;
|
|||||||
{ =============================================================================
|
{ =============================================================================
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.143 2003/06/27 22:07:39 mattias
|
||||||
|
fixed targetos for clean all
|
||||||
|
|
||||||
Revision 1.142 2002/08/17 23:41:34 mattias
|
Revision 1.142 2002/08/17 23:41:34 mattias
|
||||||
many clipping fixes
|
many clipping fixes
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user