diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 25de4ece07..36460a2840 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -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; diff --git a/components/codetools/identcompletiontool.pas b/components/codetools/identcompletiontool.pas index 76f27d51db..c57b87a1ca 100644 --- a/components/codetools/identcompletiontool.pas +++ b/components/codetools/identcompletiontool.pas @@ -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; diff --git a/components/codetools/pascalparsertool.pas b/components/codetools/pascalparsertool.pas index e0e1cb8ab8..197fccd969 100644 --- a/components/codetools/pascalparsertool.pas +++ b/components/codetools/pascalparsertool.pas @@ -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; diff --git a/ideintf/menuintf.pas b/ideintf/menuintf.pas index 399a33810f..cf199570a0 100644 --- a/ideintf/menuintf.pas +++ b/ideintf/menuintf.pas @@ -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