mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 03:56:12 +02:00
codetools: directive parser now sets StartPos and EndPos of all nodes
git-svn-id: trunk@11780 -
This commit is contained in:
parent
ebac9fd99f
commit
2096f744ef
@ -324,6 +324,7 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
EndIFNode('EndIf without IfDef');
|
EndIFNode('EndIf without IfDef');
|
||||||
CreateChildNode(cdnEnd,cdnsEndif);
|
CreateChildNode(cdnEnd,cdnsEndif);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -333,6 +334,7 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
EndIFNode('EndC without IfC');
|
EndIFNode('EndC without IfC');
|
||||||
CreateChildNode(cdnEnd,cdnsEndC);
|
CreateChildNode(cdnEnd,cdnsEndC);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -342,6 +344,7 @@ begin
|
|||||||
Result:=true;
|
Result:=true;
|
||||||
EndIFNode('IfEnd without IfDef');
|
EndIFNode('IfEnd without IfDef');
|
||||||
CreateChildNode(cdnEnd,cdnsIfEnd);
|
CreateChildNode(cdnEnd,cdnsIfEnd);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -382,6 +385,7 @@ function TCompilerDirectivesTree.DefineDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsDefine);
|
CreateChildNode(cdnDefine,cdnsDefine);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -390,6 +394,7 @@ function TCompilerDirectivesTree.UndefDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsUndef);
|
CreateChildNode(cdnDefine,cdnsUndef);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -398,6 +403,7 @@ function TCompilerDirectivesTree.SetCDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsSetC);
|
CreateChildNode(cdnDefine,cdnsSetC);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -417,6 +423,7 @@ function TCompilerDirectivesTree.ShortSwitchDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsShortSwitch);
|
CreateChildNode(cdnDefine,cdnsShortSwitch);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -430,6 +437,7 @@ function TCompilerDirectivesTree.LongSwitchDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsLongSwitch);
|
CreateChildNode(cdnDefine,cdnsLongSwitch);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -438,6 +446,7 @@ function TCompilerDirectivesTree.ModeDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsMode);
|
CreateChildNode(cdnDefine,cdnsMode);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -446,6 +455,7 @@ function TCompilerDirectivesTree.ThreadingDirective: boolean;
|
|||||||
begin
|
begin
|
||||||
Result:=true;
|
Result:=true;
|
||||||
CreateChildNode(cdnDefine,cdnsThreading);
|
CreateChildNode(cdnDefine,cdnsThreading);
|
||||||
|
AtomStart:=SrcPos;
|
||||||
EndChildNode;
|
EndChildNode;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1108,6 +1118,9 @@ var
|
|||||||
dec(BlockLevel);
|
dec(BlockLevel);
|
||||||
if BlockLevel=0 then begin
|
if BlockLevel=0 then begin
|
||||||
BeginEnd:=SrcPos;
|
BeginEnd:=SrcPos;
|
||||||
|
ReadNextAtom;
|
||||||
|
if AtomIs(';') then
|
||||||
|
BeginEnd:=SrcPos;
|
||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
end else if UpAtomIs('BEGIN') or UpAtomIs('ASM') then
|
end else if UpAtomIs('BEGIN') or UpAtomIs('ASM') then
|
||||||
@ -1238,6 +1251,8 @@ var
|
|||||||
out NewNode: TCodeTreeNode): boolean;
|
out NewNode: TCodeTreeNode): boolean;
|
||||||
begin
|
begin
|
||||||
NewNode:=FindNodeAtPos(Position);
|
NewNode:=FindNodeAtPos(Position);
|
||||||
|
//if OldNode<>nil then DebugLn(['IsSameDirective OldNode=',OldNode.StartPos,' "',copy(Src,OldNode.StartPos,OldNode.EndPos-OldNode.StartPos),'"']);
|
||||||
|
//if NewNode<>nil then DebugLn(['IsSameDirective NewNode=',NewNode.StartPos,' "',copy(Src,NewNode.StartPos,NewNode.EndPos-NewNode.StartPos),'"']);
|
||||||
Result:=(NewNode<>nil) and (NewNode=OldNode);
|
Result:=(NewNode<>nil) and (NewNode=OldNode);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -1332,7 +1347,7 @@ begin
|
|||||||
LastDefNode:=nil;
|
LastDefNode:=nil;
|
||||||
for i:=0 to ListOfH2PasFunctions.Count-1 do begin
|
for i:=0 to ListOfH2PasFunctions.Count-1 do begin
|
||||||
BodyFunc:=TH2PasFunction(ListOfH2PasFunctions[i]);
|
BodyFunc:=TH2PasFunction(ListOfH2PasFunctions[i]);
|
||||||
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives DefNode=',(BodyFunc.DefNode<>nil),' Body="',copy(Src,BodyFunc.HeaderStart,BodyFunc.HeaderEnd-BodyFunc.HeaderStart),'"']);
|
//DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives DefNode=',(BodyFunc.DefNode<>nil),' Body="',copy(Src,BodyFunc.HeaderStart,BodyFunc.HeaderEnd-BodyFunc.HeaderStart),'"']);
|
||||||
if (BodyFunc.BeginStart<1) or (BodyFunc.DefNode=nil) then
|
if (BodyFunc.BeginStart<1) or (BodyFunc.DefNode=nil) then
|
||||||
continue;
|
continue;
|
||||||
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives Body="',copy(Src,BodyFunc.HeaderStart,BodyFunc.BeginEnd-BodyFunc.HeaderStart),'"']);
|
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives Body="',copy(Src,BodyFunc.HeaderStart,BodyFunc.BeginEnd-BodyFunc.HeaderStart),'"']);
|
||||||
@ -1341,6 +1356,7 @@ begin
|
|||||||
if (CurBodyBlock.LastBodyFunc<>nil)
|
if (CurBodyBlock.LastBodyFunc<>nil)
|
||||||
and HasCodeBetween(CurBodyBlock.LastBodyFunc.BeginEnd,BodyFunc.HeaderStart)
|
and HasCodeBetween(CurBodyBlock.LastBodyFunc.BeginEnd,BodyFunc.HeaderStart)
|
||||||
then begin
|
then begin
|
||||||
|
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives there is code between bodies']);
|
||||||
// there is code between last function body and current function body
|
// there is code between last function body and current function body
|
||||||
// end last block
|
// end last block
|
||||||
EndBodyBlock;
|
EndBodyBlock;
|
||||||
@ -1349,19 +1365,23 @@ begin
|
|||||||
if not IsSameDirective(LastDefNode,
|
if not IsSameDirective(LastDefNode,
|
||||||
BodyFunc.DefNode.HeaderStart,LastDefNode)
|
BodyFunc.DefNode.HeaderStart,LastDefNode)
|
||||||
then begin
|
then begin
|
||||||
|
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives other directive block']);
|
||||||
// another directive block => end last block
|
// another directive block => end last block
|
||||||
EndBodyBlock;
|
EndBodyBlock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if (CurBodyBlock.Definition=nil) then begin
|
if (CurBodyBlock.Definition=nil) then begin
|
||||||
// a new block
|
// a new block
|
||||||
|
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives start new block']);
|
||||||
StartBodyBlock(BodyFunc, LastDefNode);
|
StartBodyBlock(BodyFunc, LastDefNode);
|
||||||
end else begin
|
end else begin
|
||||||
// continue current block
|
// continue current block
|
||||||
|
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives continue block']);
|
||||||
CurBodyBlock.LastBodyFunc:=BodyFunc;
|
CurBodyBlock.LastBodyFunc:=BodyFunc;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
// end last block
|
// end last block
|
||||||
|
DebugLn(['TCompilerDirectivesTree.FixMissingH2PasDirectives end last block']);
|
||||||
EndBodyBlock;
|
EndBodyBlock;
|
||||||
|
|
||||||
finally
|
finally
|
||||||
@ -1443,7 +1463,7 @@ begin
|
|||||||
Result:=Tree.Root;
|
Result:=Tree.Root;
|
||||||
while Result<>nil do begin
|
while Result<>nil do begin
|
||||||
if Result.StartPos>p then
|
if Result.StartPos>p then
|
||||||
exit(nil);
|
exit(Result.Parent);
|
||||||
if (Result.EndPos>p)
|
if (Result.EndPos>p)
|
||||||
or ((Result.EndPos=p) and (Result.NextBrother<>nil)
|
or ((Result.EndPos=p) and (Result.NextBrother<>nil)
|
||||||
and (Result.NextBrother.StartPos>p))
|
and (Result.NextBrother.StartPos>p))
|
||||||
@ -1455,7 +1475,10 @@ begin
|
|||||||
Result:=Result.FirstChild;
|
Result:=Result.FirstChild;
|
||||||
end else begin
|
end else begin
|
||||||
// p is behind => next
|
// p is behind => next
|
||||||
Result:=Result.NextSkipChilds;
|
if Result.NextBrother<>nil then
|
||||||
|
Result:=Result.NextBrother
|
||||||
|
else
|
||||||
|
exit(Result.Parent);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
@ -25,9 +25,9 @@ implementation
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ was #define dname def_expr }
|
{ was #define dname def_expr }
|
||||||
function MPI_UNSIGNED_CHAR : MPI_Datatype;
|
function MPI_SIGNED_CHAR : MPI_Datatype;
|
||||||
begin
|
begin
|
||||||
MPI_UNSIGNED_CHAR:=MPI_Datatype($4c000102);
|
MPI_SIGNED_CHAR:=MPI_Datatype($4c000118);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
Loading…
Reference in New Issue
Block a user