mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 00:19:50 +02:00
MG: published variables are now added with code creation options
git-svn-id: trunk@1733 -
This commit is contained in:
parent
3efe784a25
commit
13926110d3
@ -94,6 +94,8 @@ type
|
||||
property CodeCompleteSrcChgCache: TSourceChangeCache
|
||||
read ASourceChangeCache write SetCodeCompleteSrcChgCache;
|
||||
public
|
||||
function AddPublishedVariable(const UpperClassName,VarName, VarType: string;
|
||||
SourceChangeCache: TSourceChangeCache): boolean; override;
|
||||
function CompleteCode(CursorPos: TCodeXYPosition;
|
||||
var NewPos: TCodeXYPosition; var NewTopLine: integer;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
@ -296,6 +298,34 @@ begin
|
||||
or (ANodeExt.Flags=ord(ncpPrivateProcs));
|
||||
end;
|
||||
|
||||
function TCodeCompletionCodeTool.AddPublishedVariable(const UpperClassName,
|
||||
VarName, VarType: string; SourceChangeCache: TSourceChangeCache): boolean;
|
||||
begin
|
||||
Result:=false;
|
||||
if (UpperClassName='') or (VarName='') or (VarType='')
|
||||
or (SourceChangeCache=nil) or (Scanner=nil) then exit;
|
||||
// find classnode
|
||||
BuildTree(false);
|
||||
if not EndOfSourceFound then exit;
|
||||
ClassNode:=FindClassNodeInInterface(UpperClassName,true,false);
|
||||
// initialize class for code completion
|
||||
CodeCompleteClassNode:=ClassNode;
|
||||
CodeCompleteSrcChgCache:=SourceChangeCache;
|
||||
// check if variable already exists
|
||||
if VarExistsInCodeCompleteClass(UpperCaseStr(VarName)) then begin
|
||||
|
||||
end else begin
|
||||
AddClassInsertion(nil,UpperCaseStr(VarName),
|
||||
VarName+':'+VarType+';',VarName,'',ncpPublishedVars);
|
||||
if not InsertAllNewClassParts then
|
||||
RaiseException(ctsErrorDuringInsertingNewClassParts);
|
||||
// apply the changes
|
||||
if not SourceChangeCache.Apply then
|
||||
RaiseException(ctsUnableToApplyChanges);
|
||||
end;
|
||||
Result:=true;
|
||||
end;
|
||||
|
||||
function TCodeCompletionCodeTool.CompleteProperty(
|
||||
PropNode: TCodeTreeNode): boolean;
|
||||
{
|
||||
|
@ -117,7 +117,7 @@ type
|
||||
function FindPublishedVariable(const UpperClassName,
|
||||
UpperVarName: string): TCodeTreeNode;
|
||||
function AddPublishedVariable(const UpperClassName,VarName, VarType: string;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
SourceChangeCache: TSourceChangeCache): boolean; virtual;
|
||||
function RemovePublishedVariable(const UpperClassName, UpperVarName: string;
|
||||
SourceChangeCache: TSourceChangeCache): boolean;
|
||||
function RenamePublishedVariable(const UpperClassName,
|
||||
|
Loading…
Reference in New Issue
Block a user