accelerated identifier completion

git-svn-id: trunk@6877 -
This commit is contained in:
mattias 2005-03-02 15:59:53 +00:00
parent 80090ba2b3
commit 33f3ea4927
3 changed files with 39 additions and 9 deletions

View File

@ -79,6 +79,8 @@ type
); );
TIdentListItemFlags = set of TIdentListItemFlag; TIdentListItemFlags = set of TIdentListItemFlag;
{ TIdentifierListItem }
TIdentifierListItem = class TIdentifierListItem = class
private private
FNext: TIdentifierListItem; FNext: TIdentifierListItem;
@ -110,6 +112,7 @@ type
procedure UpdateBaseContext; procedure UpdateBaseContext;
function HasChilds: boolean; function HasChilds: boolean;
procedure Clear; procedure Clear;
function CompareParamList(CompareItem: TIdentifierListItem): integer;
public public
property ParamList: string read GetParamList write SetParamList; property ParamList: string read GetParamList write SetParamList;
end; end;
@ -277,7 +280,7 @@ begin
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:=AnsiCompareText(Item2.ParamList,Item1.ParamList); Result:=Item2.CompareParamList(Item1);
end; end;
function CompareIdentListItemsForIdents(Data1, Data2: Pointer): integer; function CompareIdentListItemsForIdents(Data1, Data2: Pointer): integer;
@ -293,7 +296,7 @@ begin
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:=AnsiCompareText(Item2.ParamList,Item1.ParamList); Result:=Item2.CompareParamList(Item1);
end; end;
function CompareIdentHistListItem(Data1, Data2: Pointer): integer; function CompareIdentHistListItem(Data1, Data2: Pointer): integer;
@ -307,6 +310,7 @@ begin
Result:=CompareIdentifiers(PChar(Item2.Identifier),PChar(Item1.Identifier)); Result:=CompareIdentifiers(PChar(Item2.Identifier),PChar(Item1.Identifier));
if Result<>0 then exit; if Result<>0 then exit;
//debugln('CompareIdentHistListItem ',Item2.Identifier,'=',Item1.Identifier);
Result:=CompareIdentifiers(PChar(Item2.ParamList),PChar(Item1.ParamList)); Result:=CompareIdentifiers(PChar(Item2.ParamList),PChar(Item1.ParamList));
end; end;
@ -321,7 +325,8 @@ begin
Result:=CompareIdentifiers(PChar(HistItem.Identifier),IdentItem.Identifier); Result:=CompareIdentifiers(PChar(HistItem.Identifier),IdentItem.Identifier);
if Result<>0 then exit; if Result<>0 then exit;
Result:=AnsiCompareText(HistItem.ParamList,IdentItem.ParamList); debugln('CompareIdentItemWithHistListItem ',HistItem.Identifier,'=',GetIdentifier(IdentItem.Identifier));
Result:=SysUtils.CompareText(HistItem.ParamList,IdentItem.ParamList);
end; end;
type type
@ -970,11 +975,14 @@ end;
function TIdentifierListItem.GetParamList: string; function TIdentifierListItem.GetParamList: string;
begin begin
if not FParamListValid then begin if not FParamListValid then begin
if (Node<>nil) and (Node.Desc=ctnProcedure) then // Note: if you implement param lists for other than ctnProcedure, check
// CompareParamList
if (Node<>nil) and (Node.Desc=ctnProcedure) then begin
FParamList:=Tool.ExtractProcHead(Node, FParamList:=Tool.ExtractProcHead(Node,
[phpWithoutClassKeyword,phpWithoutClassName, [phpWithoutClassKeyword,phpWithoutClassName,
phpWithoutName,phpInUpperCase]) phpWithoutName,phpInUpperCase]);
else //debugln('TIdentifierListItem.GetParamList A ',GetIdentifier(Identifier),' ',Tool.MainFilename,' ',dbgs(Node.StartPos));
end else
FParamList:=''; FParamList:='';
FParamListValid:=true; FParamListValid:=true;
end; end;
@ -1106,6 +1114,23 @@ begin
BaseExprType:=CleanExpressionType; BaseExprType:=CleanExpressionType;
end; end;
function TIdentifierListItem.CompareParamList(CompareItem: TIdentifierListItem
): integer;
begin
Result:=0;
if Self=CompareItem then exit;
if (Node=CompareItem.Node) then exit;
if (Node.Desc<>ctnProcedure) or (CompareItem.Node.Desc<>ctnProcedure) then
exit;
{DbgOut('TIdentifierListItem.CompareParamList ',GetIdentifier(Identifier),'=',GetIdentifier(CompareItem.Identifier));
if Node<>nil then
DbgOut(' Self=',Tool.MainFilename,' ',dbgs(Node.StartPos));
if CompareItem.Node<>nil then
DbgOut(' Other=',CompareItem.Tool.MainFilename,' ',dbgs(CompareItem.Node.StartPos));
debugln('');}
Result:=SysUtils.CompareText(ParamList,CompareItem.ParamList);
end;
{ TIdentifierHistoryList } { TIdentifierHistoryList }
procedure TIdentifierHistoryList.SetCapacity(const AValue: integer); procedure TIdentifierHistoryList.SetCapacity(const AValue: integer);

View File

@ -1922,12 +1922,12 @@ begin
InputHistories.ApplyFileDialogSettings(OpenDialog); InputHistories.ApplyFileDialogSettings(OpenDialog);
OpenDialog.Title:=lisOpenFile; OpenDialog.Title:=lisOpenFile;
OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect]; OpenDialog.Options:=OpenDialog.Options+[ofAllowMultiSelect];
OpenDialog.Filter:='Lazarus unit (*.pas;*.pp)|*.pas;*.pp' OpenDialog.Filter:='All files ('+GetAllFilesMask+')|'+GetAllFilesMask
+'|Lazarus unit (*.pas;*.pp)|*.pas;*.pp'
+'|Lazarus project (*.lpi)|*.lpi' +'|Lazarus project (*.lpi)|*.lpi'
+'|Lazarus form (*.lfm)|*.lfm' +'|Lazarus form (*.lfm)|*.lfm'
+'|Lazarus package (*.lpk)|*.lpk' +'|Lazarus package (*.lpk)|*.lpk'
+'|Lazarus project source (*.lpr)|*.lpr' +'|Lazarus project source (*.lpr)|*.lpr';
+'|All files ('+GetAllFilesMask+')|'+GetAllFilesMask;
if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin if OpenDialog.Execute and (OpenDialog.Files.Count>0) then begin
OpenFlags:=[ofAddToRecent]; OpenFlags:=[ofAddToRecent];
//debugln('TMainIDE.mnuOpenClicked OpenDialog.Files.Count=',dbgs(OpenDialog.Files.Count)); //debugln('TMainIDE.mnuOpenClicked OpenDialog.Files.Count=',dbgs(OpenDialog.Files.Count));
@ -11457,6 +11457,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.852 2005/03/02 15:59:53 mattias
accelerated identifier completion
Revision 1.851 2005/02/28 22:43:48 mattias Revision 1.851 2005/02/28 22:43:48 mattias
implemented updating lrs files from lfm files implemented updating lrs files from lfm files

View File

@ -1,3 +1,4 @@
{$IFDEF Gtk1}
const const
GDK_KEY_VoidSymbol = GDK_VoidSymbol; GDK_KEY_VoidSymbol = GDK_VoidSymbol;
GDK_KEY_BackSpace = GDK_BackSpace; GDK_KEY_BackSpace = GDK_BackSpace;
@ -1319,3 +1320,4 @@ const
GDK_KEY_Hangul_J_KkogjiDalrinIeung = GDK_Hangul_J_KkogjiDalrinIeung; GDK_KEY_Hangul_J_KkogjiDalrinIeung = GDK_Hangul_J_KkogjiDalrinIeung;
GDK_KEY_Hangul_J_YeorinHieuh = GDK_Hangul_J_YeorinHieuh; GDK_KEY_Hangul_J_YeorinHieuh = GDK_Hangul_J_YeorinHieuh;
GDK_KEY_Korean_Won = GDK_Korean_Won; GDK_KEY_Korean_Won = GDK_Korean_Won;
{$ENDIF}