Просмотр исходного кода

Add autocompletion for class members. Not context aware but still very helpful. Not supported for calltips yet.

Martijn Laan 1 год назад
Родитель
Сommit
c35dbd77d7

+ 12 - 3
ISHelp/ISHelpGen/UIsxclassesParser.pas

@@ -6,7 +6,7 @@ uses
   Classes;
 
 type
-  TIsxclassesParserStoredString = (ssLine, ssType, ssEnumValue, ssConstant, ssMember);
+  TIsxclassesParserStoredString = (ssLine, ssType, ssEnumValue, ssConstant, ssMember, ssProperty);
   TIsxclassesParserStrings = array [TIsxclassesParserStoredString] of TStringList;
 
   TIsxclassesParser = class
@@ -42,6 +42,8 @@ begin
   { Sorted for ignoring duplicates }
   FStrings[ssMember].Duplicates := dupIgnore;
   FStrings[ssMember].Sorted := True;
+  FStrings[ssProperty].Duplicates := dupIgnore;
+  FStrings[ssProperty].Sorted := True;
 end;
 
 destructor TIsxclassesParser.Destroy;
@@ -110,16 +112,19 @@ begin
         Continue;
       end;
 
+      var Typ := ssMember;
       P := Pos('procedure ', S);
       if P = 0 then
         P := Pos('function ', S);
-      if P = 0 then
+      if P = 0 then begin
+        Typ := ssProperty;
         P := Pos('property ', S);
+      end;
       if P <> 0 then begin
         Delete(S, 1, P-1);
         P := Pos(' ', S);
         Delete(S, 1, P);
-        FStrings[ssMember].Add(ExtractScriptFuncWithoutHeaderName(S));
+        FStrings[Typ].Add(ExtractScriptFuncWithoutHeaderName(S));
         Continue;
       end;
     end;
@@ -310,6 +315,10 @@ begin
     WriteLn(F);
     WriteStringArray(F, 'PascalEnumValues_Isxclasses', Indent, FStrings[ssEnumValue], 0);
     WriteLn(F);
+    WriteStringArray(F, 'PascalMembers_Isxclasses', Indent, FStrings[ssMember], 80);
+    WriteLn(F);
+    WriteStringArray(F, 'PascalProperties_Isxclasses', Indent, FStrings[ssProperty], 80);
+    WriteLn(F);
     WriteLN(F, 'implementation');
     WriteLn(F);
     Write(F, 'end.');

+ 62 - 0
ISHelp/isxclasses_wordlists_generated.pas

@@ -68,6 +68,68 @@ var
     'taLeftJustify', 'taRightJustify', 'taCenter'
   ];
 
+  PascalMembers_Isxclasses: array of AnsiString = [
+    'Add', 'AddCheckBox', 'AddEx', 'AddGroup', 'AddRadioButton', 'AddStrings', 'AdjustHeight',
+    'AdjustLabelHeight', 'AdjustLinkLabelHeight', 'Animate', 'Append', 'Arc', 'Assign',
+    'BringToFront', 'CalculateButtonWidth', 'CanFocus', 'ChangeDirectory', 'CheckItem',
+    'Chord', 'Clear', 'ClearSelection', 'Close', 'CopyFrom', 'CreateNewDirectory', 'Delete',
+    'DestroyComponents', 'Destroying', 'Download', 'Draw', 'Ellipse', 'Find', 'FindComponent',
+    'FindNextPage', 'FlipSizeAndCenterIfNeeded', 'FloodFill', 'Focused', 'Free', 'FreeNotification',
+    'Hide', 'IncTopDecHeight', 'IndexOf', 'Insert', 'InsertComponent', 'Invalidate', 'LineTo',
+    'LoadFromFile', 'LoadFromStream', 'MoveTo', 'Pie', 'Read', 'ReadBuffer', 'Rectangle',
+    'Refresh', 'Release', 'RemoveComponent', 'Repaint', 'RoundRect', 'SaveToFile', 'SaveToStream',
+    'ScrollInView', 'Seek', 'SelectAll', 'SendToBack', 'SetBounds', 'SetPaths', 'SetProgress',
+    'SetText', 'ShouldSizeX', 'ShouldSizeY', 'Show', 'ShowAboutBox', 'ShowModal', 'Sort',
+    'TextHeight', 'TextOut', 'TextWidth', 'Update', 'Write', 'WriteBuffer'
+  ];
+
+  PascalProperties_Isxclasses: array of AnsiString = [
+    'AbortButton', 'AbortedByUser', 'Active', 'ActiveControl', 'ActivePage', 'Align', 'Alignment',
+    'AllowGrayed', 'AlphaFormat', 'Anchors', 'AutoScroll', 'AutoSelect', 'AutoSize', 'BackButton',
+    'BackColor', 'Bevel', 'Bevel1', 'BeveledLabel', 'BevelInner', 'BevelKind', 'BevelOuter',
+    'BevelWidth', 'Bitmap', 'BorderIcons', 'BorderStyle', 'BorderWidth', 'Brush', 'Buttons',
+    'Cancel', 'CancelButton', 'Canvas', 'Caption', 'Center', 'CharCase', 'Checked', 'CheckListBox',
+    'ClientHeight', 'ClientWidth', 'Color', 'CommaText', 'ComponentCount', 'ComponentIndex',
+    'Components', 'ComponentsDiskSpaceLabel', 'ComponentsList', 'ComponentState', 'Constraints',
+    'ControlCount', 'Controls', 'ControlsFlipped', 'CopyMode', 'Count', 'CurPageID', 'Cursor',
+    'Default', 'Description', 'DesignInfo', 'DirBrowseButton', 'DirEdit', 'DiskSpaceLabel',
+    'DropDownCount', 'DroppedDown', 'Duplicates', 'Edits', 'Empty', 'Enabled', 'FilenameLabel',
+    'FinishedHeadingLabel', 'FinishedLabel', 'FinishedPage', 'Flat', 'FlipControlsOnShow',
+    'FocusControl', 'Font', 'ForceLTRReading', 'FormStyle', 'GroupBrowseButton', 'GroupEdit',
+    'Handle', 'Height', 'HideSelection', 'Hint', 'ID', 'InfoAfterClickLabel', 'InfoAfterMemo',
+    'InfoAfterPage', 'InfoBeforeClickLabel', 'InfoBeforeMemo', 'InfoBeforePage', 'InnerNotebook',
+    'InnerPage', 'InstallingPage', 'IsSaveButton', 'ItemCaption', 'ItemEnabled', 'ItemFontStyle',
+    'ItemIndex', 'ItemLevel', 'ItemObject', 'Items', 'ItemSubItem', 'KeepSizeY', 'KeyPreview',
+    'Left', 'LicenseAcceptedRadio', 'LicenseLabel1', 'LicenseMemo', 'LicenseNotAcceptedRadio',
+    'LicensePage', 'Lines', 'MainPanel', 'Max', 'MaxHeight', 'MaxLength', 'MaxWidth', 'Min',
+    'MinHeight', 'MinItemHeight', 'MinWidth', 'ModalResult', 'Mode', 'Modified', 'Msg1Label',
+    'Msg2Label', 'MsgLabel', 'MultiSelect', 'Name', 'NextButton', 'NoIconsCheck', 'NoRadio',
+    'Notebook', 'Objects', 'Offset', 'OnActivate', 'OnBackButtonClick', 'OnCancelButtonClick',
+    'OnChange', 'OnChanging', 'OnClick', 'OnClickCheck', 'OnClose', 'OnCloseQuery', 'OnCreate',
+    'OnDblClick', 'OnDeactivate', 'OnDestroy', 'OnDropDown', 'OnHide', 'OnKeyDown', 'OnKeyPress',
+    'OnKeyUp', 'OnLinkClick', 'OnNextButtonClick', 'OnRename', 'OnResize', 'OnShouldSkipPage',
+    'OnShow', 'OuterNotebook', 'Owner', 'PageCount', 'PageDescriptionLabel', 'PageIndex',
+    'PageNameLabel', 'Pages', 'Parent', 'ParentBackground', 'Password', 'PasswordChar',
+    'PasswordEdit', 'PasswordEditLabel', 'PasswordLabel', 'PasswordPage', 'Pen', 'Pitch',
+    'Pixels', 'PixelsPerInch', 'Position', 'PreparingErrorBitmapImage', 'PreparingLabel',
+    'PreparingMemo', 'PreparingNoRadio', 'PreparingPage', 'PreparingYesRadio', 'PrevAppDir',
+    'ProgressBar', 'ProgressGauge', 'PromptLabels', 'ReadOnly', 'ReadyLabel', 'ReadyMemo',
+    'ReadyPage', 'ReplaceColor', 'ReplaceWithColor', 'RequireRadioSelection', 'RichEditViewer',
+    'RightToLeft', 'RTFText', 'RunList', 'ScrollBars', 'SelCount', 'SelectComponentsLabel',
+    'SelectComponentsPage', 'SelectDirBitmapImage', 'SelectDirBrowseLabel', 'SelectDirLabel',
+    'SelectDirPage', 'Selected', 'SelectedValueIndex', 'SelectGroupBitmapImage', 'SelectProgramGroupPage',
+    'SelectStartMenuFolderBrowseLabel', 'SelectStartMenuFolderLabel', 'SelectTasksLabel',
+    'SelectTasksPage', 'SelLength', 'SelStart', 'SelText', 'Shape', 'ShowAccelChar', 'ShowBaseNameInsteadOfUrl',
+    'ShowHint', 'Showing', 'ShowLines', 'Size', 'SizeAndCenterOnShow', 'Sorted', 'State',
+    'StatusLabel', 'Stretch', 'Strings', 'Style', 'SubCaptionLabel', 'SubItemFontStyle',
+    'Surface', 'SurfaceColor', 'SurfaceHeight', 'SurfaceWidth', 'TabOrder', 'TabStop',
+    'Tag', 'TasksList', 'Text', 'Top', 'TypesCombo', 'UseRichEdit', 'UserInfoNameEdit',
+    'UserInfoNameLabel', 'UserInfoOrgEdit', 'UserInfoOrgLabel', 'UserInfoPage', 'UserInfoSerialEdit',
+    'UserInfoSerialLabel', 'UseVisualStyle', 'Values', 'Visible', 'WantReturns', 'WantTabs',
+    'WelcomeLabel1', 'WelcomeLabel2', 'WelcomePage', 'Width', 'WizardBitmapImage', 'WizardBitmapImage2',
+    'WizardSmallBitmapImage', 'WordWrap', 'YesRadio'
+  ];
+
 implementation
 
 end.

+ 2 - 4
Projects/Src/Compil32/CompForm.pas

@@ -4957,10 +4957,8 @@ begin
             types, etc if the current word has no dot before it }
           if WordList = '' then begin
             var ClassOrRecordMember := (PositionBeforeWordStartPos >= LinePos) and (FActiveMemo.GetByteAtPosition(PositionBeforeWordStartPos) = '.');
-            if not ClassOrRecordMember then begin
-              WordList := FMemosStyler.ScriptWordList;
-              FActiveMemo.SetAutoCompleteFillupChars('(')
-            end;
+            WordList := FMemosStyler.ScriptWordList[ClassOrRecordMember];
+            FActiveMemo.SetAutoCompleteFillupChars('(')
           end;
 
           if WordList = '' then

+ 18 - 3
Projects/Src/Compil32/ScintStylerInnoSetup.pas

@@ -82,7 +82,7 @@ type
     FISPPDirectivesWordList, FConstantsWordList: AnsiString;
     FSectionsWordList: AnsiString;
     FScriptFunctionsByName: TFunctionDefinitionsByName; { Only has functions with at least 1 parameter }
-    FScriptWordList: AnsiString;
+    FScriptWordList: array[Boolean] of AnsiString;
     FISPPInstalled: Boolean;
     FTheme: TTheme;
     procedure AddWordToList(const SL: TStringList; const Word: AnsiString;
@@ -122,6 +122,7 @@ type
     procedure StyleConstsUntilChars(const Chars: TScintRawCharSet;
       const NonConstStyle: TInnoSetupStylerStyle; var BraceLevel: Integer);
     procedure SetISPPInstalled(const Value: Boolean);
+    function GetScriptWordList(ClassOrRecordMembers: Boolean): AnsiString;
   protected
     procedure CommitStyle(const Style: TInnoSetupStylerStyle);
     procedure GetFoldLevel(const LineState, PreviousLineState: TScintLineState;
@@ -144,7 +145,7 @@ type
     property ISPPInstalled: Boolean read FISPPInstalled write SetISPPInstalled;
     property KeywordsWordList[Section: TInnoSetupStylerSection]: AnsiString read GetKeywordsWordList;
     property ScriptFunctionDefinition[Name: String]: AnsiString read GetScriptFunctionDefinition;
-    property ScriptWordList: AnsiString read FScriptWordList;
+    property ScriptWordList[ClassOrRecordMembers: Boolean]: AnsiString read GetScriptWordList;
     property SectionsWordList: AnsiString read FSectionsWordList;
     property Theme: TTheme read FTheme write FTheme;
   end;
@@ -627,7 +628,15 @@ constructor TInnoSetupStyler.Create(AOwner: TComponent);
       for var S in PascalVariables do
         AddWordToList(SL, S, awtScriptVariable);
 
-      FScriptWordList := BuildWordList(SL);
+      FScriptWordList[False] := BuildWordList(SL);
+
+      SL.Clear;
+      for var S in PascalMembers_Isxclasses do
+        AddWordToList(SL, S, awtScriptFunction);
+      for var S in PascalProperties_Isxclasses do
+        AddWordToList(SL, S, awtScriptProperty);
+
+      FScriptWordList[True] := BuildWordList(SL);
     finally
       SL.Free;
     end;
@@ -874,6 +883,12 @@ begin
     Result := '';
 end;
 
+function TInnoSetupStyler.GetScriptWordList(
+  ClassOrRecordMembers: Boolean): AnsiString;
+begin
+  Result := FScriptWordList[ClassOrRecordMembers];
+end;
+
 class function TInnoSetupStyler.GetSectionFromLineState(
   const LineState: TScintLineState): TInnoSetupStylerSection;
 begin

+ 1 - 0
Projects/Src/ScriptFunc.pas

@@ -156,6 +156,7 @@ begin
     raise Exception.CreateFmt('Invalid FunctionDefinition: %s', [Result]);
 end;
 
+{ Also present in UIsxclassesParser.pas }
 function ExtractScriptFuncWithoutHeaderName(const ScriptFuncWithoutHeader: AnsiString): AnsiString;
 begin
   Result := ScriptFuncWithoutHeader;

+ 2 - 1
whatsnew.htm

@@ -54,7 +54,8 @@ For conditions of distribution and use, see <a href="files/is/license.txt">LICEN
   <li>Added support for Visual Studio Code-style editor shortcuts, like Ctrl+D to Add Next Occurrence, Ctrl+Shift+K to delete a line and Alt+Click to add an additional cursor.<br />To activate this use the <i>Options</i> menu item in the <i>Tools</i> menu to set the new <i>Keys</i> option in the <i>Editor</i> group to <i>Visual Studio Code</i>.<br />The updated <a href="https://jrsoftware.org/ishelp/index.php?topic=compformshortcuts">Compiler IDE Keyboard And Mouse Commands</a> help topic lists all differences with the classic keyboard and mouse shortcuts.</li>
   <li>Added new shortcuts only available if Visual Studio Code-style editor shortcuts have been activated: Shift+Alt+Down to copy line down and Ctrl+] and Ctrl+[ to ident or unindent lines.</li>
   <li>Implemented parameter hints for all Pascal Scripting support functions for quick reference to the function's parameter names, types, and order. Parameter hints can be invoked manually by pressing Ctrl+Shift+Space or automatically by using the new <i>Invoke parameter hints automatically</i> option which is enabled by default.</li>
-  <li>Added autocompletion support for all Pascal Scripting support functions, types, constants, etcetera. Existing option <i>Invoke autocompletion automatically</i> controls whether the autocompletion suggestions appear automatically or only when invoked manually by pressing Ctrl+Space or Ctrl+I. Does not support autocompletion of class or record members.</li>
+  <li>Added autocompletion support for all Pascal Scripting support functions, types, constants, etcetera. Existing option <i>Invoke autocompletion automatically</i> controls whether the autocompletion suggestions appear automatically or only when invoked manually by pressing Ctrl+Space or Ctrl+I.</li>
+  <li>Added autocompletion support for all Pascal Scripting support class members and properties. Is not intelligent: always shows members and properties of all classes instead of just those of the object's class.</li>
   <li>Added new <i>Enable section folding</i> option which allows you to temporarily hide sections while editing by clicking the new minus or plus icons in the editor's gutter or by using the new keyboard shortcuts (Ctrl+Shift+[ to fold and Ctrl+Shift+] to unfold) or menu items. Enabled by default.</li>
   <li>The editor's gutter now shows change history to keep track of saved and unsaved modifications. Always enabled.</li>
   <li>The editor's font now defaults to Consolas if available, consistent with most other modern editors.</li>