How to filter members for basic completion?

Hello,

I am seeking to extend R# by filtering the basic and smart completion list
depending on the context of usage. More specifically, I believe I want to
create a R# plugin to change the visible public API of a class when I am
writing unit tests. All members of my team use R# so I believe a R# is the
best route at this time.

I prefer use TDD to create the majority of my production code. I also use
RhinoMocks for a mocking framework because I don't have to define expectations
with strings for member names and object arrays for signatures. When I use
R# to rename a member or change the signature, the RhinoMock expectation
changes with it and results in more immediate compile-time errors than runtime
exceptions (common in NMock) and my unit tests and mocks stay up to date.
The disadvantage of RhinoMock is that all mockable members MUST be public
or internal. I don't have a philosophical problem with making most members
public, or at least internal. However, the resulting API is not clear to
other members of my team. The class under test may have 5 times as many Test
API members as Production API members, if I may make the distinction.

My intent is to expose all public/internal members to test classes, but only
truly public/internal API members to production code. My concept is to attribute
the public/internal members with a well-known attribute to indicate the member
is part of the Test API as well as the Production API, where the Test API
is a super-set of the Production API. When using basic and smart completion
inside a test, I wish to show the Test API. One of may strategies to determine
"test code" would be to scan for a attribute. When in non-test
code, I wish to display only the Production API.

I spent several hours last night with Reflector trying to find where I might
start to write the classes necessary to insert a filter for the list of items
viewable in the basic and smart completion lists. While gaining yet more
respect for your product by scanning the code structure, I did not find the
place to start.

Can you help me? Most importantly, is this something I can accomplish in
R# 2.5 with the current OpenAPI? Which class/interface(s) would I need to
implement to provide the filtering service? Which interfaces will I need
to understand to determine if members are part of the Test API? Which interfaces
will I need to understand to determine the context when presenting the list
of members by examining the current class and method? Which classes must
I register the filter with?

Thank you in advance to the R# team and others who have swam the uncharted
waters of OpenAPI!

Ed Chapel


3 comments
Comment actions Permalink

Hello Ed,

Unfortunately, there is no API for filtering code completion. We are going
to improve several aspects of OpenAPI and will take your request into consideration.
Thanks for letting us know about your requirements!

Sincerely,
Ilya Ryzhenkov

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"


EC> Hello,
EC>
EC> I am seeking to extend R# by filtering the basic and smart
EC> completion list depending on the context of usage. More
EC> specifically, I believe I want to create a R# plugin to change the
EC> visible public API of a class when I am writing unit tests. All
EC> members of my team use R# so I believe a R# is the best route at
EC> this time.
EC>
EC> I prefer use TDD to create the majority of my production code. I
EC> also use RhinoMocks for a mocking framework because I don't have to
EC> define expectations with strings for member names and object arrays
EC> for signatures. When I use R# to rename a member or change the
EC> signature, the RhinoMock expectation changes with it and results in
EC> more immediate compile-time errors than runtime exceptions (common
EC> in NMock) and my unit tests and mocks stay up to date. The
EC> disadvantage of RhinoMock is that all mockable members MUST be
EC> public or internal. I don't have a philosophical problem with making
EC> most members public, or at least internal. However, the resulting
EC> API is not clear to other members of my team. The class under test
EC> may have 5 times as many Test API members as Production API members,
EC> if I may make the distinction.
EC>
EC> My intent is to expose all public/internal members to test classes,
EC> but only truly public/internal API members to production code. My
EC> concept is to attribute the public/internal members with a
EC> well-known attribute to indicate the member is part of the Test API
EC> as well as the Production API, where the Test API is a super-set of
EC> the Production API. When using basic and smart completion inside a
EC> test, I wish to show the Test API. One of may strategies to
EC> determine "test code" would be to scan for a
EC> attribute. When in non-test code, I wish to display only the
EC> Production API.
EC>
EC> I spent several hours last night with Reflector trying to find where
EC> I might start to write the classes necessary to insert a filter for
EC> the list of items viewable in the basic and smart completion lists.
EC> While gaining yet more respect for your product by scanning the code
EC> structure, I did not find the place to start.
EC>
EC> Can you help me? Most importantly, is this something I can
EC> accomplish in R# 2.5 with the current OpenAPI? Which
EC> class/interface(s) would I need to implement to provide the
EC> filtering service? Which interfaces will I need to understand to
EC> determine if members are part of the Test API? Which interfaces will
EC> I need to understand to determine the context when presenting the
EC> list of members by examining the current class and method? Which
EC> classes must I register the filter with?
EC>
EC> Thank you in advance to the R# team and others who have swam the
EC> uncharted waters of OpenAPI!
EC>
EC> Ed Chapel
EC>


0
Comment actions Permalink

Hello Ilya,

Thanks for getting back to me. I'll be waiting impatiently for the expanded
API.

Ed

Hello Ed,

Unfortunately, there is no API for filtering code completion. We are
going to improve several aspects of OpenAPI and will take your request
into consideration. Thanks for letting us know about your
requirements!

Sincerely,
Ilya Ryzhenkov
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"



0
Comment actions Permalink

Ilya, you're wrong.
Code completion list could be filtered by plugin

All you need is to create class, mark it with
JetBrains.ReSharper.CodeInsight.CodeCompletion.RuleAttribute attribute

and implement

JetBrains.ReSharper.CodeInsight.CodeCompletion.IRule interface




--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Ilya Ryzhenkov" <orangy@netix.ru> wrote in message
news:9f6b3e29130db08c9026238d0f4ae@news.intellij.net...

Hello Ed,

>

Unfortunately, there is no API for filtering code completion. We are going
to improve several aspects of OpenAPI and will take your request into
consideration. Thanks for letting us know about your requirements!

>

Sincerely,
Ilya Ryzhenkov

>

JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

>
>

EC> Hello,
EC> EC> I am seeking to extend R# by filtering the basic and smart
EC> completion list depending on the context of usage. More
EC> specifically, I believe I want to create a R# plugin to change the
EC> visible public API of a class when I am writing unit tests. All
EC> members of my team use R# so I believe a R# is the best route at
EC> this time.
EC> EC> I prefer use TDD to create the majority of my production code. I
EC> also use RhinoMocks for a mocking framework because I don't have to
EC> define expectations with strings for member names and object arrays
EC> for signatures. When I use R# to rename a member or change the
EC> signature, the RhinoMock expectation changes with it and results in
EC> more immediate compile-time errors than runtime exceptions (common
EC> in NMock) and my unit tests and mocks stay up to date. The
EC> disadvantage of RhinoMock is that all mockable members MUST be
EC> public or internal. I don't have a philosophical problem with making
EC> most members public, or at least internal. However, the resulting
EC> API is not clear to other members of my team. The class under test
EC> may have 5 times as many Test API members as Production API members,
EC> if I may make the distinction.
EC> EC> My intent is to expose all public/internal members to test
classes,
EC> but only truly public/internal API members to production code. My
EC> concept is to attribute the public/internal members with a
EC> well-known attribute to indicate the member is part of the Test API
EC> as well as the Production API, where the Test API is a super-set of
EC> the Production API. When using basic and smart completion inside a
EC> test, I wish to show the Test API. One of may strategies to
EC> determine "test code" would be to scan for a
EC> attribute. When in non-test code, I wish to display only the
EC> Production API.
EC> EC> I spent several hours last night with Reflector trying to find
where
EC> I might start to write the classes necessary to insert a filter for
EC> the list of items viewable in the basic and smart completion lists.
EC> While gaining yet more respect for your product by scanning the code
EC> structure, I did not find the place to start.
EC> EC> Can you help me? Most importantly, is this something I can
EC> accomplish in R# 2.5 with the current OpenAPI? Which
EC> class/interface(s) would I need to implement to provide the
EC> filtering service? Which interfaces will I need to understand to
EC> determine if members are part of the Test API? Which interfaces will
EC> I need to understand to determine the context when presenting the
EC> list of members by examining the current class and method? Which
EC> classes must I register the filter with?
EC> EC> Thank you in advance to the R# team and others who have swam the
EC> uncharted waters of OpenAPI!
EC> EC> Ed Chapel
EC>



0

Please sign in to leave a comment.