Private/protected properties not suggested by methods in class folder

7 ビュー (過去 30 日間)
Benjamin
Benjamin 2024 年 12 月 27 日
編集済み: Matt J 2024 年 12 月 28 日
I've included pictures rather than text in order to show the suggestion windows that open while you're typing.
As a minimal example, I've created a folder, @MyClass, with two files, MyClass.m and Func2.m, the latter of which is a method of MyClass prescribed in the methods block of the class definition, as outlined here.
First picture: The contents of MyClass.m. Note that as I define Func1(), I have suggestions for all 4 properties, including one that is protected and one that is private. The other function, Func2(), is declared here as well.
Second picture: The contents of Func2.m. Note that as I define it, I have suggestions only for the 2 public properties.
While there are no errors or warnings if I use the protected or private property, having the peace of mind with automatic suggestions for those properties is sorely missed. If this is a bug or oversight, I hope it's resolved soon (or perhaps already is in a release later than 2023b). Otherwise, is there a way to annotate Func2() (or the methods block it's declared in) to have full visibility of the private/protected properties when modified in the editor?
  3 件のコメント
Benjamin
Benjamin 2024 年 12 月 27 日
Oh right, it's only important to provide the signature in the classdef if the method attributes are something other than the defaults.
Nonetheless, I'm still hoping to find out how to give Func2() the same visibility of the properties that Func1() has.
Matt J
Matt J 2024 年 12 月 27 日
編集済み: Matt J 2024 年 12 月 28 日
If this is a bug or oversight, I hope it's resolved soon (or perhaps already is in a release later than 2023b)
But even if they do, it could never be a complete fix. For user-defined classes, there is no robust way to implement an autocomplete, because of course the dot-indexing functionality is subject to modification by the user via dotReference. Obviously, no autocompletion logic that TMW could implement can anticipate what a user might do to overload built-in dot indexing.

サインインしてコメントする。

回答 (1 件)

埃博拉酱
埃博拉酱 2024 年 12 月 28 日
編集済み: 埃博拉酱 2024 年 12 月 28 日
R2024b does not reproduce your issue - may have been fixed.
  2 件のコメント
Walter Roberson
Walter Roberson 2024 年 12 月 28 日
I think it might be important that Func2 is in its own .m file
埃博拉酱
埃博拉酱 2024 年 12 月 28 日
@Walter Roberson Yes it is exactly in my test. It just CAN find the private property in R2024b.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeCreating and Concatenating Matrices についてさらに検索

製品


リリース

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by