Editor code completion for MATLAB Handle classes?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
John
am 20 Dez. 2014
Kommentiert: per isakson
am 20 Dez. 2014
When working with the definition for a handle class. Can the code completion feature see the methods and properties of the class?
classdef A < handle
properties
a;
b;
end
methods
function obj = A()
obj.b = 1; %Code Editor does not see the property b when I type in the period after obj.
end
end
end
Code Editor does not see the property b when I type in the period after obj.
0 Kommentare
Akzeptierte Antwort
per isakson
am 20 Dez. 2014
Bearbeitet: per isakson
am 20 Dez. 2014
I'm not sure what's in the documentation. I use R2013a and the code below. I work in "break mode", similar to In-situ Coding.
In "break mode" code completion works both with constructors and ordinary methods.
classdef A < handle
properties
a
b
end
methods
function obj = A()
end
function foo( obj )
end
end
end
 
 
4 Kommentare
per isakson
am 20 Dez. 2014
- Yes, it requires a preference setting (see below).
- Yes, the "No Completion" in the third example is because not in "break mode"; no breakpoint and no little green arrow.
A problem to provide Tab Completion when the variables are not defined, i.e. based on the text, is that there are syntax errors most of the time when the code is being written.
I've problems with the words, that's why I use so few. In the documentation I find the terms
- Tab completion not "Code completion"
- Debugging session I wrote "break mode" 
Weitere Antworten (1)
Matt J
am 20 Dez. 2014
Bearbeitet: Matt J
am 20 Dez. 2014
Inside most class methods, the editor would have no way of knowing in advance that "obj" is intended to be an object of the class. The constructor is an exception, because a class member is the only legal output argument of class constructors. But I can imagine the editor developers simply not investing in special treatment for constructors, when it's a convenience that can't be given anywhere else.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Debugging and Analysis finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!