mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-19 04:19:09 +02:00
codetools: implemented parsing jvm class external as no forrward, searching indirect a
git-svn-id: branches/fixes_1_4@48287 -
This commit is contained in:
parent
dd05e04624
commit
f15ba59e59
@ -821,7 +821,7 @@ type
|
||||
function FindDefaultAncestorOfClass(ClassNode: TCodeTreeNode;
|
||||
Params: TFindDeclarationParams; FindClassContext: boolean): boolean; // returns false for TObject, IInterface, IUnknown
|
||||
function FindAncestorOfClassInheritance(IdentifierNode: TCodeTreeNode;
|
||||
Params: TFindDeclarationParams; FindClassContext: boolean): boolean;
|
||||
ResultParams: TFindDeclarationParams; FindClassContext: boolean): boolean;
|
||||
function FindAncestorsOfClass(ClassNode: TCodeTreeNode;
|
||||
var ListOfPFindContext: TFPList;
|
||||
Params: TFindDeclarationParams; FindClassContext: boolean;
|
||||
@ -5781,13 +5781,14 @@ begin
|
||||
end;
|
||||
|
||||
function TFindDeclarationTool.FindAncestorOfClassInheritance(
|
||||
IdentifierNode: TCodeTreeNode;
|
||||
Params: TFindDeclarationParams; FindClassContext: boolean): boolean;
|
||||
IdentifierNode: TCodeTreeNode; ResultParams: TFindDeclarationParams;
|
||||
FindClassContext: boolean): boolean;
|
||||
var
|
||||
OldInput: TFindDeclarationInput;
|
||||
AncestorNode, ClassNode, ClassIdentNode: TCodeTreeNode;
|
||||
ClassNode: TCodeTreeNode;
|
||||
AncestorContext: TFindContext;
|
||||
AncestorStartPos: LongInt;
|
||||
ExprType: TExpressionType;
|
||||
Params: TFindDeclarationParams;
|
||||
begin
|
||||
{$IFDEF CheckNodeTool}CheckNodeTool(IdentifierNode);{$ENDIF}
|
||||
if (IdentifierNode=nil)
|
||||
@ -5800,7 +5801,6 @@ begin
|
||||
Result:=false;
|
||||
|
||||
ClassNode:=IdentifierNode.Parent.Parent;
|
||||
ClassIdentNode:=ClassNode.Parent;
|
||||
|
||||
if IdentifierNode.Desc=ctnSpecialize then begin
|
||||
if (IdentifierNode.FirstChild=nil) then begin
|
||||
@ -5812,33 +5812,46 @@ begin
|
||||
MoveCursorToCleanPos(IdentifierNode.FirstChild.StartPos);
|
||||
end else
|
||||
MoveCursorToCleanPos(IdentifierNode.StartPos);
|
||||
AncestorStartPos:=CurPos.StartPos;
|
||||
ReadNextAtom;
|
||||
AtomIsIdentifierE;
|
||||
AncestorStartPos:=CurPos.StartPos;
|
||||
ReadNextAtom;
|
||||
if CurPos.Flag=cafPoint then begin
|
||||
ReadNextAtom;
|
||||
AtomIsIdentifierE;
|
||||
AncestorStartPos:=CurPos.StartPos;
|
||||
end;
|
||||
{$IFDEF ShowTriedContexts}
|
||||
DebugLn('[TFindDeclarationTool.FindAncestorOfClass] ',
|
||||
' search ancestor class = ',GetIdentifier(@Src[AncestorStartPos]));
|
||||
{$ENDIF}
|
||||
|
||||
// search ancestor
|
||||
Params.Save(OldInput);
|
||||
Params.Flags:=[fdfSearchInParentNodes,fdfIgnoreCurContextNode,
|
||||
fdfExceptionOnNotFound,fdfSearchInAncestors]
|
||||
+(fdfGlobals*Params.Flags)
|
||||
-[fdfTopLvlResolving];
|
||||
Params.SetIdentifier(Self,@Src[AncestorStartPos],nil);
|
||||
Params.ContextNode:=ClassIdentNode;
|
||||
if not FindIdentifierInContext(Params) then
|
||||
exit;
|
||||
Params:=TFindDeclarationParams.Create;
|
||||
try
|
||||
Params.Flags:=fdfDefaultForExpressions-[fdfSearchInAncestors];
|
||||
Params.ContextNode:=ClassNode;
|
||||
if CurPos.Flag in [cafRoundBracketClose,cafComma] then begin
|
||||
// simple identifier
|
||||
{$IFDEF ShowTriedContexts}
|
||||
DebugLn('[TFindDeclarationTool.FindAncestorOfClass] ',
|
||||
' search ancestor class="',GetIdentifier(@Src[AncestorStartPos]),'" for class "',ExtractClassName(ClassNode,false),'"');
|
||||
{$ENDIF}
|
||||
Params.SetIdentifier(Self,@Src[AncestorStartPos],nil);
|
||||
if not FindIdentifierInContext(Params) then
|
||||
exit;
|
||||
AncestorContext.Tool:=Params.NewCodeTool;
|
||||
AncestorContext.Node:=Params.NewNode;
|
||||
end else begin
|
||||
// complex identifier
|
||||
{$IFDEF ShowTriedContexts}
|
||||
DebugLn(['[TFindDeclarationTool.FindAncestorOfClass] ',
|
||||
' search complex ancestor class = "',ExtractNode(IdentifierNode,[]),'"']);
|
||||
{$ENDIF}
|
||||
Params.Flags:=fdfDefaultForExpressions-[fdfSearchInAncestors];
|
||||
ExprType:=FindExpressionTypeOfTerm(IdentifierNode.StartPos,IdentifierNode.EndPos,Params,false);
|
||||
if ExprType.Desc=xtContext then
|
||||
AncestorContext:=ExprType.Context
|
||||
else
|
||||
AncestorContext:=CleanFindContext;
|
||||
end;
|
||||
finally
|
||||
Params.Free;
|
||||
end;
|
||||
|
||||
// check result
|
||||
if not (Params.NewNode.Desc in [ctnTypeDefinition,ctnGenericType]) then
|
||||
if (AncestorContext.Node=nil)
|
||||
or (not (AncestorContext.Node.Desc in [ctnTypeDefinition,ctnGenericType])) then
|
||||
begin
|
||||
MoveCursorToCleanPos(AncestorStartPos);
|
||||
ReadNextAtom;
|
||||
@ -5847,21 +5860,29 @@ begin
|
||||
|
||||
// search ancestor class context
|
||||
if FindClassContext then begin
|
||||
AncestorNode:=Params.NewNode;
|
||||
Params.Flags:=Params.Flags+[fdfFindChildren];
|
||||
AncestorContext:=Params.NewCodeTool.FindBaseTypeOfNode(Params,AncestorNode);
|
||||
Params.SetResult(AncestorContext);
|
||||
Params:=TFindDeclarationParams.Create;
|
||||
try
|
||||
Params.Flags:=fdfDefaultForExpressions+[fdfFindChildren];
|
||||
AncestorContext:=AncestorContext.Tool.FindBaseTypeOfNode(Params,AncestorContext.Node);
|
||||
|
||||
// check result
|
||||
if not (Params.NewNode.Desc in AllClasses) then
|
||||
begin
|
||||
MoveCursorToCleanPos(AncestorStartPos);
|
||||
ReadNextAtom;
|
||||
RaiseExceptionFmt(ctsStrExpectedButAtomFound,['class',GetAtom]);
|
||||
// check result
|
||||
if not (AncestorContext.Node.Desc in AllClasses) then begin
|
||||
MoveCursorToCleanPos(AncestorStartPos);
|
||||
ReadNextAtom;
|
||||
RaiseExceptionFmt(ctsStrExpectedButAtomFound,['class',GetAtom]);
|
||||
end;
|
||||
if AncestorContext.Node=ClassNode then begin
|
||||
MoveCursorToCleanPos(AncestorStartPos);
|
||||
ReadNextAtom;
|
||||
RaiseException('cycle detected');
|
||||
end;
|
||||
finally
|
||||
Params.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
ResultParams.SetResult(AncestorContext);
|
||||
Result:=true;
|
||||
Params.Load(OldInput,true);
|
||||
end;
|
||||
|
||||
function TFindDeclarationTool.FindAncestorsOfClass(ClassNode: TCodeTreeNode;
|
||||
@ -6066,9 +6087,7 @@ begin
|
||||
Node:=InheritanceNode.FirstChild;
|
||||
while Node<>nil do begin
|
||||
if not FindAncestorOfClassInheritance(Node,Params,true) then exit;
|
||||
if (ClassNode.Desc in AllClassInterfaces)
|
||||
or (Params.NewNode.Desc in AllClassObjects) then
|
||||
SearchDefaultAncestor:=false;
|
||||
SearchDefaultAncestor:=false;
|
||||
if Search(Params.NewCodeTool,Params.NewNode) then exit(true);
|
||||
Node:=Node.NextBrother;
|
||||
end;
|
||||
|
@ -2183,7 +2183,7 @@ function TLinkScanner.UpdateNeeded(
|
||||
3. unit source changed
|
||||
4. one of its include files changed
|
||||
5. init values changed (e.g. initial compiler defines)
|
||||
7. a missing include file can now be found
|
||||
6. a missing include file can now be found
|
||||
}
|
||||
var i: integer;
|
||||
SrcLog: TSourceLog;
|
||||
@ -2235,6 +2235,8 @@ begin
|
||||
end;
|
||||
|
||||
// check initvalues
|
||||
//if ExtractFileNameOnly(MainFilename)='androidr14' then
|
||||
// debugln(['TLinkScanner.UpdateNeeded FGlobalInitValuesChangeStep=',FGlobalInitValuesChangeStep,' CurInitValuesChangeStep=',CurInitValuesChangeStep]);
|
||||
if FGlobalInitValuesChangeStep<>CurInitValuesChangeStep then begin
|
||||
FGlobalInitValuesChangeStep:=CurInitValuesChangeStep;
|
||||
if Assigned(FOnGetInitValues) then begin
|
||||
@ -2243,7 +2245,8 @@ begin
|
||||
and (NewInitValuesChangeStep<>FInitValuesChangeStep)
|
||||
and (not FInitValues.Equals(NewInitValues)) then begin
|
||||
{$IFDEF VerboseUpdateNeeded}
|
||||
DebugLn(['TLinkScanner.UpdateNeeded because InitValues changed ',MainFilename]);
|
||||
//if ExtractFileNameOnly(MainFilename)='androidr14' then
|
||||
DebugLn(['TLinkScanner.UpdateNeeded because InitValues changed ',MainFilename]);
|
||||
{$ENDIF}
|
||||
Include(FStates,lssInitValuesChanged);
|
||||
exit;
|
||||
|
@ -527,7 +527,8 @@ var
|
||||
begin
|
||||
{$IFDEF MEM_CHECK}CheckHeap('TPascalParserTool.BuildTree A '+IntToStr(MemCheck_GetMem_Cnt));{$ENDIF}
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TPascalParserTool.BuildTree START ',MainFilename,' Range=',dbgs(Range),' ScannedRange=',dbgs(ScannedRange));
|
||||
//if ExtractFileNameOnly(MainFilename)='androidr14' then
|
||||
DebugLn('TPascalParserTool.BuildTree START ',MainFilename,' Range=',dbgs(Range),' ScannedRange=',dbgs(ScannedRange));
|
||||
{$ENDIF}
|
||||
ValidateToolDependencies;
|
||||
if not UpdateNeeded(Range) then begin
|
||||
@ -566,7 +567,8 @@ begin
|
||||
// scan code
|
||||
BeginParsing(Range);
|
||||
{$IFDEF VerboseUpdateNeeded}
|
||||
DebugLn(['TPascalParserTool.BuildTree PARSING ... LastScannedRange=',dbgs(ScannedRange),' new Range=',dbgs(Range),' ',MainFilename]);
|
||||
//if ExtractFileNameOnly(MainFilename)='androidr14' then
|
||||
DebugLn(['TPascalParserTool.BuildTree PARSING ... LastScannedRange=',dbgs(ScannedRange),' new Range=',dbgs(Range),' ',MainFilename]);
|
||||
{$ENDIF}
|
||||
//debugln(['TPascalParserTool.BuildTree "',Src,'"']);
|
||||
|
||||
@ -4181,6 +4183,7 @@ begin
|
||||
end;
|
||||
CurNode.EndPos:=CurPos.StartPos;
|
||||
EndChildNode;
|
||||
IsForward:=false;
|
||||
end;
|
||||
end else if UpAtomIs('HELPER') then begin
|
||||
IsHelper:=true;
|
||||
@ -4266,7 +4269,7 @@ begin
|
||||
if CurPos.Flag=cafSemicolon then
|
||||
ReadNextAtom;
|
||||
// read post modifiers
|
||||
if UpAtomIs('EXTERNAL') then begin
|
||||
if IsForward and UpAtomIs('EXTERNAL') then begin
|
||||
ReadNextAtom;
|
||||
if UpAtomIs('NAME') then begin
|
||||
ReadNextAtom;
|
||||
|
Loading…
Reference in New Issue
Block a user