Editor code completion for MATLAB Handle classes?

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.

 채택된 답변

per isakson
per isakson 2014년 12월 20일
편집: per isakson 2014년 12월 20일

1 개 추천

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
&nbsp
&nbsp

댓글 수: 4

Matt J
Matt J 2014년 12월 20일
편집: Matt J 2014년 12월 20일
Doesn't work for me in R2013b. Maybe it requires a preference setting of some sort? Also, I don't understand the 3rd example involving foo() and what distinguishes it from the 1st example, also involving foo(). And how was break mode reached in the 3rd example?
John
John 2014년 12월 20일
Matt J, in the 3rd example, code is not being debugged. I am able to get this working in 2014a.
John
John 2014년 12월 20일
I'll keep this thread open for a little while and let other suggestions be posted. If I see no better suggestions than the one by per isakson , I will accept his answer. It seems to be a good solution.
  • 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"&nbsp

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt J
Matt J 2014년 12월 20일
편집: Matt J 2014년 12월 20일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 Entering Commands에 대해 자세히 알아보기

질문:

2014년 12월 20일

댓글:

2014년 12월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by