mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 14:29:36 +02:00
improved IgnoreErrorAfterCursor for begin blocks, class block and proc heads
git-svn-id: trunk@7523 -
This commit is contained in:
parent
612ad985f5
commit
e1c20a0c4d
@ -87,6 +87,10 @@ type
|
|||||||
ncpPublicProcs, ncpPublicVars,
|
ncpPublicProcs, ncpPublicVars,
|
||||||
ncpPublishedProcs, ncpPublishedVars);
|
ncpPublishedProcs, ncpPublishedVars);
|
||||||
|
|
||||||
|
TNewVarLocation = (
|
||||||
|
ncpvPrivate,ncpvProtected,ncpvPublic,ncpvPublished,ncpvLocal
|
||||||
|
);
|
||||||
|
|
||||||
const
|
const
|
||||||
NewClassPartVisibilty: array[TNewClassPart] of TPascalClassSection = (
|
NewClassPartVisibilty: array[TNewClassPart] of TPascalClassSection = (
|
||||||
pcsPrivate, pcsPrivate,
|
pcsPrivate, pcsPrivate,
|
||||||
@ -96,6 +100,15 @@ const
|
|||||||
);
|
);
|
||||||
|
|
||||||
type
|
type
|
||||||
|
TCodeCompletionCodeTool = class;
|
||||||
|
|
||||||
|
TOnGetNewVariableLocation = function(Tool: TCodeCompletionCodeTool;
|
||||||
|
const VariableName: string; var VariableType: string;
|
||||||
|
IsMethod: boolean; NewLocation: TNewVarLocation
|
||||||
|
): boolean;
|
||||||
|
|
||||||
|
{ TCodeCompletionCodeTool }
|
||||||
|
|
||||||
TCodeCompletionCodeTool = class(TMethodJumpingCodeTool)
|
TCodeCompletionCodeTool = class(TMethodJumpingCodeTool)
|
||||||
private
|
private
|
||||||
ASourceChangeCache: TSourceChangeCache;
|
ASourceChangeCache: TSourceChangeCache;
|
||||||
@ -104,6 +117,7 @@ type
|
|||||||
FAddInheritedCodeToOverrideMethod: boolean;
|
FAddInheritedCodeToOverrideMethod: boolean;
|
||||||
FCompleteProperties: boolean;
|
FCompleteProperties: boolean;
|
||||||
FirstInsert: TCodeTreeNodeExtension; // list of insert requests
|
FirstInsert: TCodeTreeNodeExtension; // list of insert requests
|
||||||
|
FOnGetNewVariableLocation: TOnGetNewVariableLocation;
|
||||||
FSetPropertyVariablename: string;
|
FSetPropertyVariablename: string;
|
||||||
JumpToProcName: string;
|
JumpToProcName: string;
|
||||||
NewClassSectionIndent: array[TPascalClassSection] of integer;
|
NewClassSectionIndent: array[TPascalClassSection] of integer;
|
||||||
@ -168,6 +182,8 @@ type
|
|||||||
property AddInheritedCodeToOverrideMethod: boolean
|
property AddInheritedCodeToOverrideMethod: boolean
|
||||||
read FAddInheritedCodeToOverrideMethod
|
read FAddInheritedCodeToOverrideMethod
|
||||||
write FAddInheritedCodeToOverrideMethod;
|
write FAddInheritedCodeToOverrideMethod;
|
||||||
|
property OnGetNewVariableLocation: TOnGetNewVariableLocation
|
||||||
|
read FOnGetNewVariableLocation write FOnGetNewVariableLocation;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -744,6 +760,9 @@ var
|
|||||||
VarNameAtom, AssignmentOperator, TermAtom: TAtomPosition;
|
VarNameAtom, AssignmentOperator, TermAtom: TAtomPosition;
|
||||||
NewType: string;
|
NewType: string;
|
||||||
Params: TFindDeclarationParams;
|
Params: TFindDeclarationParams;
|
||||||
|
VarLocation: TNewVarLocation;
|
||||||
|
IsMethod: Boolean;
|
||||||
|
VariableName: String;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
|
|
||||||
@ -793,6 +812,15 @@ begin
|
|||||||
Params.Free;
|
Params.Free;
|
||||||
DeactivateGlobalWriteLock;
|
DeactivateGlobalWriteLock;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// ask what for location of new variable
|
||||||
|
VarLocation:=ncpvLocal;
|
||||||
|
VariableName:=GetAtom(VarNameAtom);
|
||||||
|
if Assigned(OnGetNewVariableLocation) then begin
|
||||||
|
IsMethod:=NodeIsInAMethod(CursorNode);
|
||||||
|
if not OnGetNewVariableLocation(Self,VariableName,NewType,
|
||||||
|
IsMethod,VarLocation) then exit;
|
||||||
|
end;
|
||||||
|
|
||||||
// all needed parameters found
|
// all needed parameters found
|
||||||
Result:=true;
|
Result:=true;
|
||||||
|
@ -856,7 +856,7 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
||||||
[{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]);
|
[{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]);
|
||||||
|
|
||||||
// find node at position
|
// find node at position
|
||||||
CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true);
|
CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true);
|
||||||
CurrentIdentifierList.StartContext.Node:=CursorNode;
|
CurrentIdentifierList.StartContext.Node:=CursorNode;
|
||||||
|
@ -620,8 +620,18 @@ begin
|
|||||||
CurKeyWordFuncList:=DefaultKeyWordFuncList;
|
CurKeyWordFuncList:=DefaultKeyWordFuncList;
|
||||||
end;
|
end;
|
||||||
ClassNode.SubDesc:=ClassNode.SubDesc and (not ctnsNeedJITParsing);
|
ClassNode.SubDesc:=ClassNode.SubDesc and (not ctnsNeedJITParsing);
|
||||||
finally
|
|
||||||
CurrentPhase:=OldPhase;
|
CurrentPhase:=OldPhase;
|
||||||
|
except
|
||||||
|
CurrentPhase:=OldPhase;
|
||||||
|
{$IFDEF ShowIgnoreErrorAfter}
|
||||||
|
DebugLn('TPascalParserTool.BuildSubTreeForClass ',MainFilename,' ERROR: ',LastErrorMessage);
|
||||||
|
{$ENDIF}
|
||||||
|
if (not IgnoreErrorAfterValid)
|
||||||
|
or (not IgnoreErrAfterPositionIsInFrontOfLastErrMessage) then
|
||||||
|
raise;
|
||||||
|
{$IFDEF ShowIgnoreErrorAfter}
|
||||||
|
DebugLn('TPascalParserTool.BuildSubTreeForClass',MainFilename,' IGNORING ERROR: ',LastErrorMessage);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -670,8 +680,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
until (CurPos.StartPos>=MaxPos);
|
until (CurPos.StartPos>=MaxPos);
|
||||||
BeginNode.SubDesc:=ctnNone;
|
BeginNode.SubDesc:=ctnNone;
|
||||||
finally
|
|
||||||
CurrentPhase:=OldPhase;
|
CurrentPhase:=OldPhase;
|
||||||
|
except
|
||||||
|
CurrentPhase:=OldPhase;
|
||||||
|
{$IFDEF ShowIgnoreErrorAfter}
|
||||||
|
DebugLn('TPascalParserTool.BuildSubTreeForBeginBlock ',MainFilename,' ERROR: ',LastErrorMessage);
|
||||||
|
{$ENDIF}
|
||||||
|
if (not IgnoreErrorAfterValid)
|
||||||
|
or (not IgnoreErrAfterPositionIsInFrontOfLastErrMessage) then
|
||||||
|
raise;
|
||||||
|
{$IFDEF ShowIgnoreErrorAfter}
|
||||||
|
DebugLn('TPascalParserTool.BuildSubTreeForBeginBlock ',MainFilename,' IGNORING ERROR: ',LastErrorMessage);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3438,7 +3458,7 @@ begin
|
|||||||
IgnorePos.Code:=CursorPos.Code;
|
IgnorePos.Code:=CursorPos.Code;
|
||||||
IgnorePos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,IgnorePos.P);
|
IgnorePos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,IgnorePos.P);
|
||||||
if IgnorePos.P<1 then IgnorePos.Code:=nil;
|
if IgnorePos.P<1 then IgnorePos.Code:=nil;
|
||||||
debugln('TPascalParserTool.BuildTreeAndGetCleanPos IgnorePos=',dbgsCP(IgnorePos));
|
//debugln('TPascalParserTool.BuildTreeAndGetCleanPos IgnorePos=',dbgsCP(IgnorePos));
|
||||||
IgnoreErrorAfter:=IgnorePos;
|
IgnoreErrorAfter:=IgnorePos;
|
||||||
end else
|
end else
|
||||||
ClearIgnoreErrorAfter;
|
ClearIgnoreErrorAfter;
|
||||||
@ -3571,8 +3591,18 @@ begin
|
|||||||
if IsOperator then Include(ParseAttr,pphIsOperator);
|
if IsOperator then Include(ParseAttr,pphIsOperator);
|
||||||
ReadTilProcedureHeadEnd(ParseAttr,HasForwardModifier);
|
ReadTilProcedureHeadEnd(ParseAttr,HasForwardModifier);
|
||||||
ProcNode.FirstChild.SubDesc:=ctnsNone;
|
ProcNode.FirstChild.SubDesc:=ctnsNone;
|
||||||
finally
|
|
||||||
CurrentPhase:=OldPhase;
|
CurrentPhase:=OldPhase;
|
||||||
|
except
|
||||||
|
CurrentPhase:=OldPhase;
|
||||||
|
{$IFDEF ShowIgnoreErrorAfter}
|
||||||
|
DebugLn('TPascalParserTool.BuildSubTreeForProcHead ',MainFilename,' ERROR: ',LastErrorMessage);
|
||||||
|
{$ENDIF}
|
||||||
|
if (not IgnoreErrorAfterValid)
|
||||||
|
or (not IgnoreErrAfterPositionIsInFrontOfLastErrMessage) then
|
||||||
|
raise;
|
||||||
|
{$IFDEF ShowIgnoreErrorAfter}
|
||||||
|
DebugLn('TPascalParserTool.BuildSubTreeForProcHead ',MainFilename,' IGNORING ERROR: ',LastErrorMessage);
|
||||||
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -510,14 +510,14 @@ begin
|
|||||||
else
|
else
|
||||||
StartIndex:=GetContainerIndex(false);
|
StartIndex:=GetContainerIndex(false);
|
||||||
|
|
||||||
debugln('TIDEMenuSection.CreateChildMenuItems Name="',Name,'" Container="',ContainerMenuItem.Caption,'" ContainerMenuItem.Count=',dbgs(ContainerMenuItem.Count),' StartIndex=',dbgs(StartIndex),' Size=',dbgs(Size),' NeedTopSeparator=',dbgs(NeedTopSeparator),' NeedBottomSeparator=',dbgs(NeedBottomSeparator));
|
//debugln('TIDEMenuSection.CreateChildMenuItems Name="',Name,'" Container="',ContainerMenuItem.Caption,'" ContainerMenuItem.Count=',dbgs(ContainerMenuItem.Count),' StartIndex=',dbgs(StartIndex),' Size=',dbgs(Size),' NeedTopSeparator=',dbgs(NeedTopSeparator),' NeedBottomSeparator=',dbgs(NeedBottomSeparator));
|
||||||
|
|
||||||
if NeedTopSeparator then begin
|
if NeedTopSeparator then begin
|
||||||
if (TopSeparator=nil) then begin
|
if (TopSeparator=nil) then begin
|
||||||
// create TopSeparator
|
// create TopSeparator
|
||||||
FTopSeparator:=MenuItemClass.Create(nil);
|
FTopSeparator:=MenuItemClass.Create(nil);
|
||||||
FTopSeparator.Caption:='-';
|
FTopSeparator.Caption:='-';
|
||||||
debugln('TIDEMenuSection.CreateChildMenuItem Insert TopSeparator: Container="',ContainerMenuItem.Caption,'" ContainerMenuItem.Count=',dbgs(ContainerMenuItem.Count),' StartIndex=',dbgs(StartIndex));
|
//debugln('TIDEMenuSection.CreateChildMenuItem Insert TopSeparator: Container="',ContainerMenuItem.Caption,'" ContainerMenuItem.Count=',dbgs(ContainerMenuItem.Count),' StartIndex=',dbgs(StartIndex));
|
||||||
ContainerMenuItem.Insert(StartIndex,FTopSeparator);
|
ContainerMenuItem.Insert(StartIndex,FTopSeparator);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -599,7 +599,7 @@ begin
|
|||||||
Item.CreateMenuItem;
|
Item.CreateMenuItem;
|
||||||
if Item.MenuItem<>nil then begin
|
if Item.MenuItem<>nil then begin
|
||||||
MenuIndex:=GetChildContainerIndex(Index);
|
MenuIndex:=GetChildContainerIndex(Index);
|
||||||
debugln('TIDEMenuSection.CreateChildMenuItem Insert Item="',Item.Caption,'" ContainerMenuItem="',ContainerMenuItem.Caption,'" ContainerMenuItem.Count=',dbgs(ContainerMenuItem.Count),' MenuIndex=',dbgs(MenuIndex));
|
//debugln('TIDEMenuSection.CreateChildMenuItem Insert Item="',Item.Caption,'" ContainerMenuItem="',ContainerMenuItem.Caption,'" ContainerMenuItem.Count=',dbgs(ContainerMenuItem.Count),' MenuIndex=',dbgs(MenuIndex));
|
||||||
ContainerMenuItem.Insert(MenuIndex,Item.MenuItem);
|
ContainerMenuItem.Insert(MenuIndex,Item.MenuItem);
|
||||||
end;
|
end;
|
||||||
// create the subsections
|
// create the subsections
|
||||||
|
Loading…
Reference in New Issue
Block a user