mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 02:16:14 +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,
|
||||
ncpPublishedProcs, ncpPublishedVars);
|
||||
|
||||
TNewVarLocation = (
|
||||
ncpvPrivate,ncpvProtected,ncpvPublic,ncpvPublished,ncpvLocal
|
||||
);
|
||||
|
||||
const
|
||||
NewClassPartVisibilty: array[TNewClassPart] of TPascalClassSection = (
|
||||
pcsPrivate, pcsPrivate,
|
||||
@ -96,6 +100,15 @@ const
|
||||
);
|
||||
|
||||
type
|
||||
TCodeCompletionCodeTool = class;
|
||||
|
||||
TOnGetNewVariableLocation = function(Tool: TCodeCompletionCodeTool;
|
||||
const VariableName: string; var VariableType: string;
|
||||
IsMethod: boolean; NewLocation: TNewVarLocation
|
||||
): boolean;
|
||||
|
||||
{ TCodeCompletionCodeTool }
|
||||
|
||||
TCodeCompletionCodeTool = class(TMethodJumpingCodeTool)
|
||||
private
|
||||
ASourceChangeCache: TSourceChangeCache;
|
||||
@ -104,6 +117,7 @@ type
|
||||
FAddInheritedCodeToOverrideMethod: boolean;
|
||||
FCompleteProperties: boolean;
|
||||
FirstInsert: TCodeTreeNodeExtension; // list of insert requests
|
||||
FOnGetNewVariableLocation: TOnGetNewVariableLocation;
|
||||
FSetPropertyVariablename: string;
|
||||
JumpToProcName: string;
|
||||
NewClassSectionIndent: array[TPascalClassSection] of integer;
|
||||
@ -168,6 +182,8 @@ type
|
||||
property AddInheritedCodeToOverrideMethod: boolean
|
||||
read FAddInheritedCodeToOverrideMethod
|
||||
write FAddInheritedCodeToOverrideMethod;
|
||||
property OnGetNewVariableLocation: TOnGetNewVariableLocation
|
||||
read FOnGetNewVariableLocation write FOnGetNewVariableLocation;
|
||||
end;
|
||||
|
||||
|
||||
@ -744,6 +760,9 @@ var
|
||||
VarNameAtom, AssignmentOperator, TermAtom: TAtomPosition;
|
||||
NewType: string;
|
||||
Params: TFindDeclarationParams;
|
||||
VarLocation: TNewVarLocation;
|
||||
IsMethod: Boolean;
|
||||
VariableName: String;
|
||||
begin
|
||||
Result:=false;
|
||||
|
||||
@ -793,6 +812,15 @@ begin
|
||||
Params.Free;
|
||||
DeactivateGlobalWriteLock;
|
||||
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
|
||||
Result:=true;
|
||||
|
@ -856,7 +856,7 @@ begin
|
||||
{$ENDIF}
|
||||
BuildTreeAndGetCleanPos(trTillCursor,CursorPos,CleanCursorPos,
|
||||
[{$IFNDEF DisableIgnoreErrorAfter}btSetIgnoreErrorPos{$ENDIF}]);
|
||||
|
||||
|
||||
// find node at position
|
||||
CursorNode:=FindDeepestExpandedNodeAtPos(CleanCursorPos,true);
|
||||
CurrentIdentifierList.StartContext.Node:=CursorNode;
|
||||
|
@ -620,8 +620,18 @@ begin
|
||||
CurKeyWordFuncList:=DefaultKeyWordFuncList;
|
||||
end;
|
||||
ClassNode.SubDesc:=ClassNode.SubDesc and (not ctnsNeedJITParsing);
|
||||
finally
|
||||
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;
|
||||
|
||||
@ -670,8 +680,18 @@ begin
|
||||
end;
|
||||
until (CurPos.StartPos>=MaxPos);
|
||||
BeginNode.SubDesc:=ctnNone;
|
||||
finally
|
||||
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;
|
||||
|
||||
@ -3438,7 +3458,7 @@ begin
|
||||
IgnorePos.Code:=CursorPos.Code;
|
||||
IgnorePos.Code.LineColToPosition(CursorPos.Y,CursorPos.X,IgnorePos.P);
|
||||
if IgnorePos.P<1 then IgnorePos.Code:=nil;
|
||||
debugln('TPascalParserTool.BuildTreeAndGetCleanPos IgnorePos=',dbgsCP(IgnorePos));
|
||||
//debugln('TPascalParserTool.BuildTreeAndGetCleanPos IgnorePos=',dbgsCP(IgnorePos));
|
||||
IgnoreErrorAfter:=IgnorePos;
|
||||
end else
|
||||
ClearIgnoreErrorAfter;
|
||||
@ -3571,8 +3591,18 @@ begin
|
||||
if IsOperator then Include(ParseAttr,pphIsOperator);
|
||||
ReadTilProcedureHeadEnd(ParseAttr,HasForwardModifier);
|
||||
ProcNode.FirstChild.SubDesc:=ctnsNone;
|
||||
finally
|
||||
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;
|
||||
|
||||
|
@ -510,14 +510,14 @@ begin
|
||||
else
|
||||
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 (TopSeparator=nil) then begin
|
||||
// create TopSeparator
|
||||
FTopSeparator:=MenuItemClass.Create(nil);
|
||||
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);
|
||||
end;
|
||||
end;
|
||||
@ -599,7 +599,7 @@ begin
|
||||
Item.CreateMenuItem;
|
||||
if Item.MenuItem<>nil then begin
|
||||
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);
|
||||
end;
|
||||
// create the subsections
|
||||
|
Loading…
Reference in New Issue
Block a user