codetools: replaced TIdentifierListItem.Identifier PChar with string

git-svn-id: trunk@12986 -
This commit is contained in:
mattias 2007-11-23 15:00:50 +00:00
parent 6f84b7fbd6
commit 6874d3b117
3 changed files with 174 additions and 69 deletions

View File

@ -79,24 +79,36 @@ type
iliIsFunctionValid, iliIsFunctionValid,
iliIsAbstractMethod, iliIsAbstractMethod,
iliIsAbstractMethodValid, iliIsAbstractMethodValid,
iliParamListValid iliParamListValid,
iliNodeValid
); );
TIdentListItemFlags = set of TIdentListItemFlag; TIdentListItemFlags = set of TIdentListItemFlag;
{ TIdentifierListSearchItem }
TIdentifierListSearchItem = class
public
Identifier: PChar;
ParamList: string;
end;
{ TIdentifierListItem } { TIdentifierListItem }
TIdentifierListItem = class TIdentifierListItem = class
private private
FNext: TIdentifierListItem; FNext: TIdentifierListItem;
FParamList: string; FParamList: string;
FNode: TCodeTreeNode;
FToolNodesDeletedStep: integer;// only valid if iliNodeValid
function GetNode: TCodeTreeNode;
function GetParamList: string; function GetParamList: string;
procedure SetNode(const AValue: TCodeTreeNode);
procedure SetParamList(const AValue: string); procedure SetParamList(const AValue: string);
public public
Compatibility: TIdentifierCompatibility; Compatibility: TIdentifierCompatibility;
HistoryIndex: integer; HistoryIndex: integer;
Identifier: PChar; Identifier: string;
Level: integer; Level: integer;
Node: TCodeTreeNode;
Tool: TFindDeclarationTool; Tool: TFindDeclarationTool;
DefaultDesc: TCodeTreeNodeDesc; DefaultDesc: TCodeTreeNodeDesc;
Flags: TIdentListItemFlags; Flags: TIdentListItemFlags;
@ -118,8 +130,10 @@ type
function IsAbstractMethod: boolean; function IsAbstractMethod: boolean;
procedure Clear; procedure Clear;
function CompareParamList(CompareItem: TIdentifierListItem): integer; function CompareParamList(CompareItem: TIdentifierListItem): integer;
function CompareParamList(CompareItem: TIdentifierListSearchItem): integer;
public public
property ParamList: string read GetParamList write SetParamList; property ParamList: string read GetParamList write SetParamList;
property Node: TCodeTreeNode read GetNode write SetNode;
end; end;
TIdentifierListFlag = (ilfFilteredListNeedsUpdate); TIdentifierListFlag = (ilfFilteredListNeedsUpdate);
@ -148,7 +162,7 @@ type
FHistory: TIdentifierHistoryList; FHistory: TIdentifierHistoryList;
FItems: TAVLTree; // tree of TIdentifierListItem (completely sorted) FItems: TAVLTree; // tree of TIdentifierListItem (completely sorted)
FIdentView: TAVLTree; // tree of TIdentHistListItem sorted for identifiers FIdentView: TAVLTree; // tree of TIdentHistListItem sorted for identifiers
FIdentSearchItem: TIdentifierListItem; FIdentSearchItem: TIdentifierListSearchItem;
FPrefix: string; FPrefix: string;
FStartContext: TFindContext; FStartContext: TFindContext;
procedure SetContextFlags(const AValue: TIdentifierListContextFlags); procedure SetContextFlags(const AValue: TIdentifierListContextFlags);
@ -335,7 +349,7 @@ begin
end; end;
// then sort alpabetically (lower is better) // then sort alpabetically (lower is better)
Result:=CompareIdentifiers(Item2.Identifier,Item1.Identifier); Result:=CompareIdentifierPtrs(Pointer(Item2.Identifier),Pointer(Item1.Identifier));
if Result<>0 then exit; if Result<>0 then exit;
// then sort for ParamList (lower is better) // then sort for ParamList (lower is better)
@ -351,13 +365,29 @@ begin
Item2:=TIdentifierListItem(Data2); Item2:=TIdentifierListItem(Data2);
// sort alpabetically (lower is better) // sort alpabetically (lower is better)
Result:=CompareIdentifiers(Item2.Identifier,Item1.Identifier); Result:=CompareIdentifierPtrs(Pointer(Item2.Identifier),Pointer(Item1.Identifier));
if Result<>0 then exit; if Result<>0 then exit;
// then sort for ParamList (lower is better) // then sort for ParamList (lower is better)
Result:=Item2.CompareParamList(Item1); Result:=Item2.CompareParamList(Item1);
end; end;
function CompareIdentListSearchWithItems(SearchItem, Item: Pointer): integer;
var
TheSearchItem: TIdentifierListSearchItem;
TheItem: TIdentifierListItem;
begin
TheSearchItem:=TIdentifierListSearchItem(SearchItem);
TheItem:=TIdentifierListItem(Item);
// sort alpabetically (lower is better)
Result:=CompareIdentifierPtrs(Pointer(TheItem.Identifier),TheSearchItem.Identifier);
if Result<>0 then exit;
// then sort for ParamList (lower is better)
Result:=TheItem.CompareParamList(TheSearchItem);
end;
function CompareIdentHistListItem(Data1, Data2: Pointer): integer; function CompareIdentHistListItem(Data1, Data2: Pointer): integer;
var var
Item1: TIdentHistListItem; Item1: TIdentHistListItem;
@ -383,8 +413,8 @@ begin
IdentItem:=TIdentifierListItem(Data1); IdentItem:=TIdentifierListItem(Data1);
HistItem:=TIdentHistListItem(Data2); HistItem:=TIdentHistListItem(Data2);
Result:=CompareIdentifiers(PChar(Pointer(HistItem.Identifier)), Result:=CompareIdentifierPtrs(Pointer(HistItem.Identifier),
IdentItem.Identifier); Pointer(IdentItem.Identifier));
if Result<>0 then exit; if Result<>0 then exit;
//debugln('CompareIdentItemWithHistListItem ',HistItem.Identifier,'=',GetIdentifier(IdentItem.Identifier)); //debugln('CompareIdentItemWithHistListItem ',HistItem.Identifier,'=',GetIdentifier(IdentItem.Identifier));
@ -487,12 +517,13 @@ begin
AnAVLNode:=FItems.FindLowest; AnAVLNode:=FItems.FindLowest;
while AnAVLNode<>nil do begin while AnAVLNode<>nil do begin
CurItem:=TIdentifierListItem(AnAVLNode.Data); CurItem:=TIdentifierListItem(AnAVLNode.Data);
if (CurItem.Identifier<>nil) if (CurItem.Identifier<>'')
and ComparePrefixIdent(PChar(Pointer(Prefix)),CurItem.Identifier) then begin and ComparePrefixIdent(PChar(Pointer(Prefix)),PChar(Pointer(CurItem.Identifier)))
then begin
{$IFDEF ShowFilteredIdents} {$IFDEF ShowFilteredIdents}
DebugLn('::: FILTERED ITEM ',FFilteredList.Count,' ',GetIdentifier(CurItem.Identifier)); DebugLn('::: FILTERED ITEM ',FFilteredList.Count,' ',CurItem.Identifier);
{$ENDIF} {$ENDIF}
if length(Prefix)=GetIdentLen(CurItem.Identifier) then if length(Prefix)=length(CurItem.Identifier) then
// put exact matches at the beginning // put exact matches at the beginning
FFilteredList.Insert(0,CurItem) FFilteredList.Insert(0,CurItem)
else else
@ -533,8 +564,7 @@ begin
FFlags:=[ilfFilteredListNeedsUpdate]; FFlags:=[ilfFilteredListNeedsUpdate];
FItems:=TAVLTree.Create(@CompareIdentListItems); FItems:=TAVLTree.Create(@CompareIdentListItems);
FIdentView:=TAVLTree.Create(@CompareIdentListItemsForIdents); FIdentView:=TAVLTree.Create(@CompareIdentListItemsForIdents);
FIdentSearchItem:=TIdentifierListItem.Create(icompUnknown, FIdentSearchItem:=TIdentifierListSearchItem.Create;
false,0,nil,0,nil,nil,ctnNone);
FCreatedIdentifiers:=TFPList.Create; FCreatedIdentifiers:=TFPList.Create;
end; end;
@ -606,7 +636,7 @@ begin
FIdentSearchItem.Identifier:=Identifier; FIdentSearchItem.Identifier:=Identifier;
FIdentSearchItem.ParamList:=''; FIdentSearchItem.ParamList:='';
Result:=FIdentView.FindKey(FIdentSearchItem, Result:=FIdentView.FindKey(FIdentSearchItem,
@CompareIdentListItemsForIdents)<>nil; @CompareIdentListSearchWithItems)<>nil;
end; end;
function TIdentifierList.FindCreatedIdentifier(const Ident: string): integer; function TIdentifierList.FindCreatedIdentifier(const Ident: string): integer;
@ -664,19 +694,20 @@ begin
AnAVLNode:=FItems.FindLowest; AnAVLNode:=FItems.FindLowest;
while AnAVLNode<>nil do begin while AnAVLNode<>nil do begin
CurItem:=TIdentifierListItem(AnAVLNode.Data); CurItem:=TIdentifierListItem(AnAVLNode.Data);
if (CurItem.Identifier<>nil) if (CurItem.Identifier<>'')
and ComparePrefixIdent(PChar(Pointer(Prefix)),CurItem.Identifier) then begin and ComparePrefixIdent(PChar(Pointer(Prefix)),PChar(Pointer(CurItem.Identifier)))
then begin
if not FoundFirst then begin if not FoundFirst then begin
Result:=GetIdentifier(CurItem.Identifier); Result:=CurItem.Identifier;
FoundFirst:=true; FoundFirst:=true;
end else begin end else begin
SamePos:=length(Prefix); SamePos:=length(Prefix)+1;
while (SamePos<length(Result)) while (SamePos<=length(Result))
and (UpChars[CurItem.Identifier[SamePos]]=UpChars[Result[SamePos+1]]) and (UpChars[CurItem.Identifier[SamePos]]=UpChars[Result[SamePos]])
do do
inc(SamePos); inc(SamePos);
if SamePos<length(Result) then begin if SamePos<=length(Result) then begin
Result:=copy(Result,1,SamePos); Result:=copy(Result,1,SamePos-1);
if length(Result)=length(Prefix) then exit; if length(Result)=length(Prefix) then exit;
end; end;
end; end;
@ -1575,15 +1606,18 @@ end;
{ TIdentifierListItem } { TIdentifierListItem }
function TIdentifierListItem.GetParamList: string; function TIdentifierListItem.GetParamList: string;
var
CurNode: TCodeTreeNode;
begin begin
if not (iliParamListValid in Flags) then begin if not (iliParamListValid in Flags) then begin
// Note: if you implement param lists for other than ctnProcedure, check // Note: if you implement param lists for other than ctnProcedure, check
// CompareParamList // CompareParamList
if (Node<>nil) and (Node.Desc=ctnProcedure) then begin CurNode:=Node;
FParamList:=Tool.ExtractProcHead(Node, if (CurNode<>nil) and (CurNode.Desc=ctnProcedure) then begin
FParamList:=Tool.ExtractProcHead(CurNode,
[phpWithoutClassKeyword,phpWithoutClassName, [phpWithoutClassKeyword,phpWithoutClassName,
phpWithoutName,phpInUpperCase]); phpWithoutName,phpInUpperCase]);
//debugln('TIdentifierListItem.GetParamList A ',GetIdentifier(Identifier),' ',Tool.MainFilename,' ',dbgs(Node.StartPos)); //debugln('TIdentifierListItem.GetParamList A ',GetIdentifier(Identifier),' ',Tool.MainFilename,' ',dbgs(CurNode.StartPos));
end else end else
FParamList:=''; FParamList:='';
Include(Flags,iliParamListValid); Include(Flags,iliParamListValid);
@ -1591,6 +1625,37 @@ begin
Result:=FParamList; Result:=FParamList;
end; end;
function TIdentifierListItem.GetNode: TCodeTreeNode;
begin
if (not (iliNodeValid in Flags)) or (Tool=nil) then begin
Result:=nil;
exit;
end else begin
if FToolNodesDeletedStep=Tool.NodesDeletedChangeStep then begin
Result:=FNode;
end else begin
DebugLn(['TIdentifierListItem.GetNode node is gone from ',Tool.MainFilename]);
FNode:=nil;
end;
end;
end;
procedure TIdentifierListItem.SetNode(const AValue: TCodeTreeNode);
procedure RaiseToolMissing;
begin
raise Exception.Create('TIdentifierListItem.SetNode Node without Tool');
end;
begin
FNode:=AValue;
Include(Flags,iliNodeValid);
if (FNode<>nil) and (Tool=nil) then
RaiseToolMissing;
if (Tool<>nil) then
FToolNodesDeletedStep:=Tool.NodesDeletedChangeStep;
end;
procedure TIdentifierListItem.SetParamList(const AValue: string); procedure TIdentifierListItem.SetParamList(const AValue: string);
begin begin
FParamList:=AValue; FParamList:=AValue;
@ -1598,6 +1663,8 @@ begin
end; end;
function TIdentifierListItem.AsString: string; function TIdentifierListItem.AsString: string;
var
CurNode: TCodeTreeNode;
begin begin
Result:=IdentifierCompatibilityNames[Compatibility]; Result:=IdentifierCompatibilityNames[Compatibility];
if HasChilds then if HasChilds then
@ -1605,19 +1672,23 @@ begin
else else
Result:=Result+' HasNoChilds'; Result:=Result+' HasNoChilds';
Result:=Result+' History='+IntToStr(HistoryIndex); Result:=Result+' History='+IntToStr(HistoryIndex);
Result:=Result+' Ident='+GetIdentifier(Identifier); Result:=Result+' Ident='+Identifier;
Result:=Result+' Lvl='+IntToStr(Level); Result:=Result+' Lvl='+IntToStr(Level);
if Tool<>nil then if Tool<>nil then
Result:=Result+' File='+Tool.MainFilename; Result:=Result+' File='+Tool.MainFilename;
if Node<>nil then CurNode:=Node;
Result:=Result+' Node='+Node.DescAsString if CurNode<>nil then
+' "'+StringToPascalConst(copy(Tool.Src,Node.StartPos,50))+'"'; Result:=Result+' Node='+CurNode.DescAsString
+' "'+StringToPascalConst(copy(Tool.Src,CurNode.StartPos,50))+'"';
end; end;
function TIdentifierListItem.GetDesc: TCodeTreeNodeDesc; function TIdentifierListItem.GetDesc: TCodeTreeNodeDesc;
var
CurNode: TCodeTreeNode;
begin begin
if Node<>nil then CurNode:=Node;
Result:=Node.Desc if CurNode<>nil then
Result:=CurNode.Desc
else else
Result:=DefaultDesc; Result:=DefaultDesc;
end; end;
@ -1631,33 +1702,42 @@ begin
Compatibility:=NewCompatibility; Compatibility:=NewCompatibility;
if NewHasChilds then Include(FLags,iliHasChilds); if NewHasChilds then Include(FLags,iliHasChilds);
HistoryIndex:=NewHistoryIndex; HistoryIndex:=NewHistoryIndex;
Identifier:=NewIdentifier; Identifier:=GetIdentifier(NewIdentifier);
Level:=NewLevel; Level:=NewLevel;
Node:=NewNode;
Tool:=NewTool; Tool:=NewTool;
Node:=NewNode;
DefaultDesc:=NewDefaultDesc; DefaultDesc:=NewDefaultDesc;
BaseExprType:=CleanExpressionType; BaseExprType:=CleanExpressionType;
end; end;
function TIdentifierListItem.IsProcNodeWithParams: boolean; function TIdentifierListItem.IsProcNodeWithParams: boolean;
var
CurNode: TCodeTreeNode;
begin begin
Result:=(Node<>nil) and Tool.ProcNodeHasParamList(Node); CurNode:=Node;
Result:=(CurNode<>nil) and Tool.ProcNodeHasParamList(CurNode);
end; end;
function TIdentifierListItem.IsPropertyWithParams: boolean; function TIdentifierListItem.IsPropertyWithParams: boolean;
var
CurNode: TCodeTreeNode;
begin begin
Result:=(Node<>nil) and Tool.PropertyNodeHasParamList(Node); CurNode:=Node;
Result:=(CurNode<>nil) and Tool.PropertyNodeHasParamList(CurNode);
end; end;
function TIdentifierListItem.CheckHasChilds: boolean; function TIdentifierListItem.CheckHasChilds: boolean;
// returns true if test was successful // returns true if test was successful
var
CurNode: TCodeTreeNode;
begin begin
Result:=false; Result:=false;
if GetDesc in [ctnClass,ctnRecordType,ctnClassInterface] then begin if GetDesc in [ctnClass,ctnRecordType,ctnClassInterface] then begin
Result:=true; Result:=true;
exit; exit;
end; end;
if Node=nil then exit; CurNode:=Node;
if CurNode=nil then exit;
UpdateBaseContext; UpdateBaseContext;
if (BaseExprType.Desc=xtContext) if (BaseExprType.Desc=xtContext)
and (BaseExprType.Context.Node<>nil) and (BaseExprType.Context.Node<>nil)
@ -1668,14 +1748,17 @@ begin
end; end;
function TIdentifierListItem.CanBeAssigned: boolean; function TIdentifierListItem.CanBeAssigned: boolean;
var
CurNode: TCodeTreeNode;
begin begin
Result:=false; Result:=false;
if (Node=nil) then exit; CurNode:=Node;
if (CurNode=nil) then exit;
if (GetDesc=ctnVarDefinition) then if (GetDesc=ctnVarDefinition) then
Result:=true; Result:=true;
if (Node.Desc in [ctnProperty,ctnGlobalProperty]) then begin if (CurNode.Desc in [ctnProperty,ctnGlobalProperty]) then begin
if Tool.PropertyHasSpecifier(Node,'write') then exit(true); if Tool.PropertyHasSpecifier(CurNode,'write') then exit(true);
if Tool.PropNodeIsTypeLess(Node) then begin if Tool.PropNodeIsTypeLess(CurNode) then begin
exit(true);// ToDo: search the real property definition exit(true);// ToDo: search the real property definition
end; end;
end; end;
@ -1684,15 +1767,17 @@ end;
procedure TIdentifierListItem.UpdateBaseContext; procedure TIdentifierListItem.UpdateBaseContext;
var var
Params: TFindDeclarationParams; Params: TFindDeclarationParams;
CurNode: TCodeTreeNode;
begin begin
if (iliBaseExprTypeValid in Flags) then exit; if (iliBaseExprTypeValid in Flags) then exit;
BaseExprType:=CleanExpressionType; BaseExprType:=CleanExpressionType;
BaseExprType.Desc:=xtNone; BaseExprType.Desc:=xtNone;
if (Node<>nil) and (Tool<>nil) then begin CurNode:=Node;
if (CurNode<>nil) and (Tool<>nil) then begin
Tool.ActivateGlobalWriteLock; Tool.ActivateGlobalWriteLock;
Params:=TFindDeclarationParams.Create; Params:=TFindDeclarationParams.Create;
try try
BaseExprType.Context:=Tool.FindBaseTypeOfNode(Params,Node); BaseExprType.Context:=Tool.FindBaseTypeOfNode(Params,CurNode);
if (BaseExprType.Context.Node<>nil) then if (BaseExprType.Context.Node<>nil) then
BaseExprType.Desc:=xtContext; BaseExprType.Desc:=xtContext;
finally finally
@ -1709,10 +1794,12 @@ begin
end; end;
function TIdentifierListItem.IsFunction: boolean; function TIdentifierListItem.IsFunction: boolean;
var
CurNode: TCodeTreeNode;
begin begin
if not (iliIsFunctionValid in Flags) then begin if not (iliIsFunctionValid in Flags) then begin
if (Node<>nil) CurNode:=Node;
and Tool.NodeIsFunction(Node) then if (CurNode<>nil) and Tool.NodeIsFunction(CurNode) then
Include(Flags,iliIsFunction); Include(Flags,iliIsFunction);
Include(Flags,iliIsFunctionValid); Include(Flags,iliIsFunctionValid);
end; end;
@ -1720,10 +1807,13 @@ begin
end; end;
function TIdentifierListItem.IsAbstractMethod: boolean; function TIdentifierListItem.IsAbstractMethod: boolean;
var
CurNode: TCodeTreeNode;
begin begin
if not (iliIsAbstractMethodValid in Flags) then begin if not (iliIsAbstractMethodValid in Flags) then begin
if (Node<>nil) CurNode:=Node;
and Tool.MoveCursorToProcSpecifier(Node,psABSTRACT) then if (CurNode<>nil)
and Tool.MoveCursorToProcSpecifier(CurNode,psABSTRACT) then
Include(Flags,iliIsAbstractMethod); Include(Flags,iliIsAbstractMethod);
Include(Flags,iliIsAbstractMethodValid); Include(Flags,iliIsAbstractMethodValid);
end; end;
@ -1735,9 +1825,9 @@ begin
FParamList:=''; FParamList:='';
Compatibility:=icompUnknown; Compatibility:=icompUnknown;
HistoryIndex:=0; HistoryIndex:=0;
Identifier:=nil; Identifier:='';
Level:=0; Level:=0;
Node:=nil; FNode:=nil;
Tool:=nil; Tool:=nil;
DefaultDesc:=ctnNone; DefaultDesc:=ctnNone;
Flags:=[]; Flags:=[];
@ -1746,12 +1836,17 @@ end;
function TIdentifierListItem.CompareParamList(CompareItem: TIdentifierListItem function TIdentifierListItem.CompareParamList(CompareItem: TIdentifierListItem
): integer; ): integer;
var
CurNode: TCodeTreeNode;
CmpNode: TCodeTreeNode;
begin begin
Result:=0; Result:=0;
if Self=CompareItem then exit; if Self=CompareItem then exit;
if (Node=CompareItem.Node) then exit; CurNode:=Node;
if (Node=nil) or (CompareItem.Node=nil) then exit; CmpNode:=CompareItem.Node;
if (Node.Desc<>ctnProcedure) or (CompareItem.Node.Desc<>ctnProcedure) then if (CurNode=CmpNode) then exit;
if (CurNode=nil) or (CmpNode=nil) then exit;
if (CurNode.Desc<>ctnProcedure) or (CmpNode.Desc<>ctnProcedure) then
exit; exit;
{DbgOut('TIdentifierListItem.CompareParamList ',GetIdentifier(Identifier),'=',GetIdentifier(CompareItem.Identifier)); {DbgOut('TIdentifierListItem.CompareParamList ',GetIdentifier(Identifier),'=',GetIdentifier(CompareItem.Identifier));
if Node<>nil then if Node<>nil then
@ -1759,7 +1854,15 @@ begin
if CompareItem.Node<>nil then if CompareItem.Node<>nil then
DbgOut(' Other=',CompareItem.Tool.MainFilename,' ',dbgs(CompareItem.Node.StartPos)); DbgOut(' Other=',CompareItem.Tool.MainFilename,' ',dbgs(CompareItem.Node.StartPos));
debugln('');} debugln('');}
Result:=SysUtils.CompareText(ParamList,CompareItem.ParamList); Result:=CompareTextIgnoringSpace(ParamList,CompareItem.ParamList,false);
end;
function TIdentifierListItem.CompareParamList(
CompareItem: TIdentifierListSearchItem): integer;
begin
if (ParamList='') and (CompareItem.ParamList='') then
exit(0);
Result:=CompareTextIgnoringSpace(ParamList,CompareItem.ParamList,false);
end; end;
{ TIdentifierHistoryList } { TIdentifierHistoryList }
@ -1824,7 +1927,7 @@ begin
end else begin end else begin
// create a new history item // create a new history item
NewHistItem:=TIdentHistListItem.Create; NewHistItem:=TIdentHistListItem.Create;
NewHistItem.Identifier:=GetIdentifier(NewItem.Identifier); NewHistItem.Identifier:=NewItem.Identifier;
NewHistItem.NodeDesc:=NewItem.GetDesc; NewHistItem.NodeDesc:=NewItem.GetDesc;
NewHistItem.ParamList:=NewItem.ParamList; NewHistItem.ParamList:=NewItem.ParamList;
AdjustIndex:=0; AdjustIndex:=0;

View File

@ -100,7 +100,7 @@ begin
if (Position<0) or (Position>=CodeToolBoss.IdentifierList.GetFilteredCount) then if (Position<0) or (Position>=CodeToolBoss.IdentifierList.GetFilteredCount) then
exit; exit;
Item:=CodeToolBoss.IdentifierList.FilteredItems[Position]; Item:=CodeToolBoss.IdentifierList.FilteredItems[Position];
DebugLn(['TLazDocHintProvider.ReadLazDocData Identifier=',GetIdentifier(Item.Identifier)]); DebugLn(['TLazDocHintProvider.ReadLazDocData Identifier=',Item.Identifier]);
Chain:=nil; Chain:=nil;
try try
if (Item.Node<>nil) then begin if (Item.Node<>nil) then begin

View File

@ -182,6 +182,7 @@ var
AColor: TColor; AColor: TColor;
ANode: TCodeTreeNode; ANode: TCodeTreeNode;
BackgroundColor: TColor; BackgroundColor: TColor;
ItemNode: TCodeTreeNode;
begin begin
Result.X := 0; Result.X := 0;
Result.Y := ACanvas.TextHeight('W'); Result.Y := ACanvas.TextHeight('W');
@ -266,7 +267,7 @@ begin
SetFontColor(clBlack); SetFontColor(clBlack);
ACanvas.Font.Style:=ACanvas.Font.Style+[fsBold]; ACanvas.Font.Style:=ACanvas.Font.Style+[fsBold];
s:=GetIdentifier(IdentItem.Identifier); s:=IdentItem.Identifier;
if MeasureOnly then if MeasureOnly then
Inc(Result.X, 1+ACanvas.TextWidth(s)) Inc(Result.X, 1+ACanvas.TextWidth(s))
else begin else begin
@ -278,12 +279,13 @@ begin
ACanvas.Font.Style:=ACanvas.Font.Style-[fsBold]; ACanvas.Font.Style:=ACanvas.Font.Style-[fsBold];
s:=''; s:='';
if IdentItem.Node<>nil then begin ItemNode:=IdentItem.Node;
case IdentItem.Node.Desc of if ItemNode<>nil then begin
case ItemNode.Desc of
ctnProcedure: ctnProcedure:
begin begin
s:=IdentItem.Tool.ExtractProcHead(IdentItem.Node, s:=IdentItem.Tool.ExtractProcHead(ItemNode,
[phpWithoutClassName,phpWithoutName,phpWithVarModifiers, [phpWithoutClassName,phpWithoutName,phpWithVarModifiers,
phpWithParameterNames,phpWithDefaultValues,phpWithResultType, phpWithParameterNames,phpWithDefaultValues,phpWithResultType,
phpWithOfObject]); phpWithOfObject]);
@ -291,38 +293,38 @@ begin
ctnProperty: ctnProperty:
begin begin
s:=IdentItem.Tool.ExtractProperty(IdentItem.Node, s:=IdentItem.Tool.ExtractProperty(ItemNode,
[phpWithoutName,phpWithVarModifiers, [phpWithoutName,phpWithVarModifiers,
phpWithParameterNames,phpWithDefaultValues,phpWithResultType]); phpWithParameterNames,phpWithDefaultValues,phpWithResultType]);
end; end;
ctnVarDefinition: ctnVarDefinition:
begin begin
ANode:=IdentItem.Tool.FindTypeNodeOfDefinition(IdentItem.Node); ANode:=IdentItem.Tool.FindTypeNodeOfDefinition(ItemNode);
s:=' : '+IdentItem.Tool.ExtractNode(ANode,[]); s:=' : '+IdentItem.Tool.ExtractNode(ANode,[]);
end; end;
ctnTypeDefinition: ctnTypeDefinition:
begin begin
ANode:=IdentItem.Tool.FindTypeNodeOfDefinition(IdentItem.Node); ANode:=IdentItem.Tool.FindTypeNodeOfDefinition(ItemNode);
s:=' = '+IdentItem.Tool.ExtractNode(ANode,[]); s:=' = '+IdentItem.Tool.ExtractNode(ANode,[]);
end; end;
ctnConstDefinition: ctnConstDefinition:
begin begin
ANode:=IdentItem.Tool.FindTypeNodeOfDefinition(IdentItem.Node); ANode:=IdentItem.Tool.FindTypeNodeOfDefinition(ItemNode);
if ANode<>nil then if ANode<>nil then
s:=' = '+IdentItem.Tool.ExtractNode(ANode,[]) s:=' = '+IdentItem.Tool.ExtractNode(ANode,[])
else begin else begin
s:=IdentItem.Tool.ExtractCode(IdentItem.Node.StartPos+length(s), s:=IdentItem.Tool.ExtractCode(ItemNode.StartPos+length(s),
IdentItem.Node.EndPos,[]); ItemNode.EndPos,[]);
end; end;
s:=copy(s,1,50); s:=copy(s,1,50);
end; end;
ctnRecordCase: ctnRecordCase:
begin begin
s:=' : '+IdentItem.Tool.ExtractRecordCaseType(IdentItem.Node); s:=' : '+IdentItem.Tool.ExtractRecordCaseType(ItemNode);
end; end;
end; end;
@ -390,12 +392,12 @@ function FindUnitName(IdentList: TIdentifierList;
var var
CodeBuf: TCodeBuffer; CodeBuf: TCodeBuffer;
begin begin
Result:=GetIdentifier(IdentItem.Identifier); Result:=IdentItem.Identifier;
CodeBuf:=CodeToolBoss.FindUnitSource(IdentList.StartContextPos.Code,Result,''); CodeBuf:=CodeToolBoss.FindUnitSource(IdentList.StartContextPos.Code,Result,'');
if CodeBuf=nil then exit; if CodeBuf=nil then exit;
Result:=CodeToolBoss.GetSourceName(CodeBuf,true); Result:=CodeToolBoss.GetSourceName(CodeBuf,true);
if Result='' then if Result='' then
Result:=GetIdentifier(IdentItem.Identifier); Result:=IdentItem.Identifier;
end; end;
function GetIdentCompletionValue(aCompletion : TSynCompletion; function GetIdentCompletionValue(aCompletion : TSynCompletion;
@ -424,7 +426,7 @@ begin
exit; exit;
end; end;
Result:=GetIdentifier(IdentItem.Identifier); Result:=IdentItem.Identifier;
//DebugLn(['GetIdentCompletionValue ',NodeDescriptionAsString(IdentItem.GetDesc)]); //DebugLn(['GetIdentCompletionValue ',NodeDescriptionAsString(IdentItem.GetDesc)]);
case IdentItem.GetDesc of case IdentItem.GetDesc of