Surrounding Code With Regions???
Hey again,
I tend to ask many question as it seems but it's all from love :)
i want to know if there is any way to surround a group of method /
properties / members / etc...
with regions?
if so, i would be more than happy to know!
thank you very much,
Guy.
Please sign in to leave a comment.
The only way is to create #region/#endregion directives and insert them into
PSI-tree
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Ga" <t4m.productions@gmail.com> wrote in message
news:f9voac$7ul$1@is.intellij.net...
>
>
>
>
Are you trying to duplicate the Ctrl-Alt-J "Surround With" functionality?
"Ga" <t4m.productions@gmail.com> wrote in message
news:f9voac$7ul$1@is.intellij.net...
>
>
>
>
Can you show me how please?
"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:fa10up$es3$1@is.intellij.net...
>
>
>> Hey again,
>>
>> I tend to ask many question as it seems but it's all from love :)
>>
>> i want to know if there is any way to surround a group of method /
>> properties / members / etc...
>> with regions?
>>
>> if so, i would be more than happy to know!
>>
>> thank you very much,
>> Guy.
>>
>
no,
i'm trying to create a plugin which will take all the class:
- members / methods / properties / delegates /...
and wrap each group into its region, and reorganize
them into a defined order... cool isn't it ?
So I would be happy if you could give me an example :)
"Paul Bradshaw" <pbradshaw@advsol.com> wrote in message
news:fa1p5r$q0o$1@is.intellij.net...
>
>> Hey again,
>>
>> I tend to ask many question as it seems but it's all from love :)
>>
>> i want to know if there is any way to surround a group of method /
>> properties / members / etc...
>> with regions?
>>
>> if so, i would be more than happy to know!
>>
>> thank you very much,
>> Guy.
>>
public void EnRegion(IList declarations, string regionName) { ITreeNode firstNode = declarations[0].ToTreeNode(); if (firstNode is IMultipleDeclarationMemberNode) { MultipleDeclarationUtil.SplitDeclarationBefore((IMultipleDeclarationMemberNode)firstNode); firstNode = ((IMultipleDeclarationMemberNode)firstNode).MultipleDeclaration; } ITreeNode lastNode = declarations[declarations.Count - 1].ToTreeNode(); if (lastNode is IMultipleDeclarationMemberNode) { MultipleDeclarationUtil.SplitDeclarationAfter((IMultipleDeclarationMemberNode)lastNode); lastNode = ((IMultipleDeclarationMemberNode)lastNode).MultipleDeclaration; } // Add new region IStartRegionNode startRegion; IEndRegionNode endRegion; CreateRegionDirectives(String.IsNullOrEmpty(regionName) ? "..." : regionName, out startRegion, out endRegion); using (WriteLockCookie.Create()) { if (startRegion != null) startRegion = ModificationUtil.AddChildBefore(firstNode, startRegion); if (endRegion != null) endRegion = ModificationUtil.AddChildAfter(lastNode, endRegion); } } private void CreateRegionDirectives(string regionText, out IStartRegionNode startRegion, out IEndRegionNode endRegion) { CSharpElementFactory factory = CSharpElementFactory.GetInstance(myDeclaration.GetManager().Solution); ICSharpFile file = factory.CreateFile("#region " + regionText + "\n#endregion"); ITreeNode node = file.FindTokenAt(0) as ITreeNode; startRegion = null; endRegion = null; while (node != null) { startRegion = node as IStartRegionNode; if (startRegion != null) break; node = node.Parent; } if (startRegion != null) endRegion = startRegion.EndRegion; } -- Eugene Pasynkov Developer JetBrains, Inc http://www.jetbrains.com "Develop with pleasure!" "Ga" ]]> wrote in message
news:fa22qc$fc9$1@is.intellij.net...
>
>
>> The only way is to create #region/#endregion directives and insert them
>> into PSI-tree
>>
>>
>> --
>> Eugene Pasynkov
>> Developer
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>> "Ga" <t4m.productions@gmail.com> wrote in message
>> news:f9voac$7ul$1@is.intellij.net...
>>> Hey again,
>>>
>>> I tend to ask many question as it seems but it's all from love :)
>>>
>>> i want to know if there is any way to surround a group of method /
>>> properties / members / etc...
>>> with regions?
>>>
>>> if so, i would be more than happy to know!
>>>
>>> thank you very much,
>>> Guy.
>>>
>>
>>
>
Hello,
Looks like the R#'s “Reorder Type Members” functionality.
—
Serge Baltic
JetBrains, Inc — http://www.jetbrains.com
“Develop with pleasure!”
everythings goes out fine except that the modification util does not
actually change the file and adds the region...
when debugging i see all that the debugging data is good (in terms of where
to create the region).
what might be the problem ???
other than that... thank you very much for your patience to write that code
:)
Guy.
//ModificationUtil doesn't change anything :(
startRegion = ModificationUtil.AddChildBefore(firstNode, startRegion);
"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:fa46mh$4r0$1@is.intellij.net...
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>> Can you show me how please?
>>
>>
>> "Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
>> message news:fa10up$es3$1@is.intellij.net...
>>> The only way is to create #region/#endregion directives and insert them
>>> into PSI-tree
>>>
>>>
>>> --
>>> Eugene Pasynkov
>>> Developer
>>> JetBrains, Inc
>>> http://www.jetbrains.com
>>> "Develop with pleasure!"
>>> "Ga" <t4m.productions@gmail.com> wrote in message
>>> news:f9voac$7ul$1@is.intellij.net...
>>>> Hey again,
>>>>
>>>> I tend to ask many question as it seems but it's all from love :)
>>>>
>>>> i want to know if there is any way to surround a group of method /
>>>> properties / members / etc...
>>>> with regions?
>>>>
>>>> if so, i would be more than happy to know!
>>>>
>>>> thank you very much,
>>>> Guy.
>>>>
>>>
>>>
>>
>>
>
Hey... :)
"Serge Baltic" <baltic@intellij.net> wrote in message
news:dc0986bf6bece8c9af16b69bbe84@news.intellij.net...
>
>> i'm trying to create a plugin which will take all the class:
>> - members / methods / properties / delegates /...
>> and wrap each group into its region, and reorganize
>> them into a defined order... cool isn't it ?
>> So I would be happy if you could give me an example :)
>
>
>
Please could you minimize your code and send it to me?
it will be much easier for me to check what's going wrong looking into the
code, then trying to guess it from your words :)
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Ga" <t4m.productions@gmail.com> wrote in message
news:fa4iea$umk$1@is.intellij.net...
>
>
>
>> public void EnRegion(IList declarations, string regionName) >> >> { >> >> ITreeNode firstNode = declarations[0].ToTreeNode(); >> >> if (firstNode is IMultipleDeclarationMemberNode) >> >> { >> >> MultipleDeclarationUtil.SplitDeclarationBefore((IMultipleDeclarationMemberNode)firstNode); >> >> firstNode = >> ((IMultipleDeclarationMemberNode)firstNode).MultipleDeclaration; >> >> } >> >> ITreeNode lastNode = declarations[declarations.Count - 1].ToTreeNode(); >> >> if (lastNode is IMultipleDeclarationMemberNode) >> >> { >> >> MultipleDeclarationUtil.SplitDeclarationAfter((IMultipleDeclarationMemberNode)lastNode); >> >> lastNode = >> ((IMultipleDeclarationMemberNode)lastNode).MultipleDeclaration; >> >> } >> >> // Add new region >> >> IStartRegionNode startRegion; >> >> IEndRegionNode endRegion; >> >> CreateRegionDirectives(String.IsNullOrEmpty(regionName) ? "..." : >> regionName, out startRegion, out endRegion); >> >> using (WriteLockCookie.Create()) >> >> { >> >> if (startRegion != null) startRegion = >> ModificationUtil.AddChildBefore(firstNode, startRegion); >> >> if (endRegion != null) endRegion = >> ModificationUtil.AddChildAfter(lastNode, endRegion); >> >> } >> >> } >> >> private void CreateRegionDirectives(string regionText, out >> IStartRegionNode startRegion, out IEndRegionNode endRegion) >> >> { >> >> CSharpElementFactory factory = >> CSharpElementFactory.GetInstance(myDeclaration.GetManager().Solution); >> >> ICSharpFile file = factory.CreateFile("#region " + regionText + >> "\n#endregion"); >> >> ITreeNode node = file.FindTokenAt(0) as ITreeNode; >> >> startRegion = null; >> >> endRegion = null; >> >> while (node != null) >> >> { >> >> startRegion = node as IStartRegionNode; >> >> if (startRegion != null) >> >> break; >> >> node = node.Parent; >> >> } >> >> if (startRegion != null) >> >> endRegion = startRegion.EndRegion; >> >> } >> >> >> -- >> Eugene Pasynkov >> Developer >> JetBrains, Inc >> http://www.jetbrains.com >> "Develop with pleasure!" >> "Ga" wrote in message >> news:fa22qc$fc9$1@is.intellij.net... >>> Can you show me how please? >>> >>> >>> "Eugene Pasynkov (JetBrains)" wrote in >>> message news:fa10up$es3$1@is.intellij.net... >>>> The only way is to create #region/#endregion directives and insert them >>>> into PSI-tree >>>> >>>> >>>> -- >>>> Eugene Pasynkov >>>> Developer >>>> JetBrains, Inc >>>> http://www.jetbrains.com >>>> "Develop with pleasure!" >>>> "Ga" wrote in message >>>> news:f9voac$7ul$1@is.intellij.net... >>>>> Hey again, >>>>> >>>>>]]> I tend to ask many question as it seems but it's all from love :)
>>>>>
>>>>> i want to know if there is any way to surround a group of method /
>>>>> properties / members / etc...
>>>>> with regions?
>>>>>
>>>>> if so, i would be more than happy to know!
>>>>>
>>>>> thank you very much,
>>>>> Guy.
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
Here is my source code... Just the relavent parts...
Thanks!!!
===== Cotext Action Class =====
/// /// in case the plugin could be applied, and the user selected /// to apply it, this method is invocated by resharper core. /// /// /// public void Execute(ISolution solution, ITextControl textControl) { PsiManager.GetInstance(m_solution).UpdateCaches(); m_tokenAccessor = new TokenAccessor(solution, textControl); //default sanity check made by the api dev team. if (m_solution != solution || m_textControl != textControl) { throw new InvalidOperationException(); } //check that we can modify the current file. Shell.Instance.AssertReadAccessAllowed(); //creating a command cookie is ment for supporting undo later //by visual studio. this is why inside the command cookie //definition we have a transaction, in order to 'tell' visual studio //to reverse all the changes that we perform now as a single action using (CommandCookie.Create("GenerateClassSingleton")) { // Any changes to PSI should be under a transaction PsiManager.GetInstance(m_solution). DoTransaction( delegate { //make the actual change to the class ExecuteMakeClassSingleton(TokenAccessor.ClassDeclaration.DeclaredName); }); } } private List declarations; ///
message news:fabt1l$5do$1@is.intellij.net...
>
>> everythings goes out fine except that the modification util does not
>> actually change the file and adds the region...
>> when debugging i see all that the debugging data is good (in terms of
>> where to create the region).
>> what might be the problem ???
>> other than that... thank you very much for your patience to write that
>> code :)
>> Guy.
>>
>> //ModificationUtil doesn't change anything :(
>> startRegion = ModificationUtil.AddChildBefore(firstNode, startRegion);
>>
>>
>> "Eugene Pasynkov (JetBrains)" wrote in >> message news:fa46mh$4r0$1@is.intellij.net... >>> public void EnRegion(IList declarations, string >>> regionName) >>> >>> { >>> >>> ITreeNode firstNode = declarations[0].ToTreeNode(); >>> >>> if (firstNode is IMultipleDeclarationMemberNode) >>> >>> { >>> >>> MultipleDeclarationUtil.SplitDeclarationBefore((IMultipleDeclarationMemberNode)firstNode); >>> >>> firstNode = >>> ((IMultipleDeclarationMemberNode)firstNode).MultipleDeclaration; >>> >>> } >>> >>> ITreeNode lastNode = declarations[declarations.Count - 1].ToTreeNode(); >>> >>> if (lastNode is IMultipleDeclarationMemberNode) >>> >>> { >>> >>> MultipleDeclarationUtil.SplitDeclarationAfter((IMultipleDeclarationMemberNode)lastNode); >>> >>> lastNode = >>> ((IMultipleDeclarationMemberNode)lastNode).MultipleDeclaration; >>> >>> } >>> >>> // Add new region >>> >>> IStartRegionNode startRegion; >>> >>> IEndRegionNode endRegion; >>> >>> CreateRegionDirectives(String.IsNullOrEmpty(regionName) ? "..." : >>> regionName, out startRegion, out endRegion); >>> >>> using (WriteLockCookie.Create()) >>> >>> { >>> >>> if (startRegion != null) startRegion = >>> ModificationUtil.AddChildBefore(firstNode, startRegion); >>> >>> if (endRegion != null) endRegion = >>> ModificationUtil.AddChildAfter(lastNode, endRegion); >>> >>> } >>> >>> } >>> >>> private void CreateRegionDirectives(string regionText, out >>> IStartRegionNode startRegion, out IEndRegionNode endRegion) >>> >>> { >>> >>> CSharpElementFactory factory = >>> CSharpElementFactory.GetInstance(myDeclaration.GetManager().Solution); >>> >>> ICSharpFile file = factory.CreateFile("#region " + regionText + >>> "\n#endregion"); >>> >>> ITreeNode node = file.FindTokenAt(0) as ITreeNode; >>> >>> startRegion = null; >>> >>> endRegion = null; >>> >>> while (node != null) >>> >>> { >>> >>> startRegion = node as IStartRegionNode; >>> >>> if (startRegion != null) >>> >>> break; >>> >>> node = node.Parent; >>> >>> } >>> >>> if (startRegion != null) >>> >>> endRegion = startRegion.EndRegion; >>> >>> } >>> >>> >>> -- >>> Eugene Pasynkov >>> Developer >>> JetBrains, Inc >>> http://www.jetbrains.com >>> "Develop with pleasure!" >>> "Ga" wrote in message >>> news:fa22qc$fc9$1@is.intellij.net... >>>> Can you show me how please? >>>> >>>> >>>> "Eugene Pasynkov (JetBrains)" wrote in >>>> message news:fa10up$es3$1@is.intellij.net... >>>>> The only way is to create #region/#endregion directives and insert >>>>> them into PSI-tree >>>>> >>>>> >>>>> -- >>>>> Eugene Pasynkov >>>>> Developer >>>>> JetBrains, Inc >>>>> http://www.jetbrains.com >>>>> "Develop with pleasure!" >>>>> "Ga" wrote in message >>>>> news:f9voac$7ul$1@is.intellij.net... >>>>>> Hey again, >>>>>> >>>>>>]]> I tend to ask many question as it seems but it's all from love :)
>>>>>>
>>>>>> i want to know if there is any way to surround a group of method /
>>>>>> properties / members / etc...
>>>>>> with regions?
>>>>>>
>>>>>> if so, i would be more than happy to know!
>>>>>>
>>>>>> thank you very much,
>>>>>> Guy.
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
The problem is in these lines:
currentClass.AddClassMemberDeclarationAfter(propDeclaration, null);
currentClass.AddClassMemberDeclarationAfter(instanceDeclaration, null);
Adding members to class copies the given declarations, and returns the new
instances of AST sub-tree.
So you have to modify these lines:
propDeclaration =
currentClass.AddClassMemberDeclarationAfter(propDeclaration, null);
instanceDeclaration =
currentClass.AddClassMemberDeclarationAfter(instanceDeclaration, null);
--
Eugene Pasynkov
Developer
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"
"Ga" <t4m.productions@gmail.com> wrote in message
news:famjf0$rb9$1@is.intellij.net...
>
>
>
>
>
>
>
>
>
>
>
>
>
>> Please could you minimize your code and send it to me?
>> it will be much easier for me to check what's going wrong looking into
>> the code, then trying to guess it from your words :)
>>
>> --
>> Eugene Pasynkov
>> Developer
>> JetBrains, Inc
>> http://www.jetbrains.com
>> "Develop with pleasure!"
>> "Ga" <t4m.productions@gmail.com> wrote in message
>> news:fa4iea$umk$1@is.intellij.net...
>>> everythings goes out fine except that the modification util does not
>>> actually change the file and adds the region...
>>> when debugging i see all that the debugging data is good (in terms of
>>> where to create the region).
>>> what might be the problem ???
>>> other than that... thank you very much for your patience to write that
>>> code :)
>>> Guy.
>>>
>>> //ModificationUtil doesn't change anything :(
>>> startRegion = ModificationUtil.AddChildBefore(firstNode, startRegion);
>>>
>>>
>>> "Eugene Pasynkov (JetBrains)" wrote in >>> message news:fa46mh$4r0$1@is.intellij.net... >>>> public void EnRegion(IList declarations, string >>>> regionName) >>>> >>>> { >>>> >>>> ITreeNode firstNode = declarations[0].ToTreeNode(); >>>> >>>> if (firstNode is IMultipleDeclarationMemberNode) >>>> >>>> { >>>> >>>> MultipleDeclarationUtil.SplitDeclarationBefore((IMultipleDeclarationMemberNode)firstNode); >>>> >>>> firstNode = >>>> ((IMultipleDeclarationMemberNode)firstNode).MultipleDeclaration; >>>> >>>> } >>>> >>>> ITreeNode lastNode = declarations[declarations.Count - 1].ToTreeNode(); >>>> >>>> if (lastNode is IMultipleDeclarationMemberNode) >>>> >>>> { >>>> >>>> MultipleDeclarationUtil.SplitDeclarationAfter((IMultipleDeclarationMemberNode)lastNode); >>>> >>>> lastNode = >>>> ((IMultipleDeclarationMemberNode)lastNode).MultipleDeclaration; >>>> >>>> } >>>> >>>> // Add new region >>>> >>>> IStartRegionNode startRegion; >>>> >>>> IEndRegionNode endRegion; >>>> >>>> CreateRegionDirectives(String.IsNullOrEmpty(regionName) ? "..." : >>>> regionName, out startRegion, out endRegion); >>>> >>>> using (WriteLockCookie.Create()) >>>> >>>> { >>>> >>>> if (startRegion != null) startRegion = >>>> ModificationUtil.AddChildBefore(firstNode, startRegion); >>>> >>>> if (endRegion != null) endRegion = >>>> ModificationUtil.AddChildAfter(lastNode, endRegion); >>>> >>>> } >>>> >>>> } >>>> >>>> private void CreateRegionDirectives(string regionText, out >>>> IStartRegionNode startRegion, out IEndRegionNode endRegion) >>>> >>>> { >>>> >>>> CSharpElementFactory factory = >>>> CSharpElementFactory.GetInstance(myDeclaration.GetManager().Solution); >>>> >>>> ICSharpFile file = factory.CreateFile("#region " + regionText + >>>> "\n#endregion"); >>>> >>>> ITreeNode node = file.FindTokenAt(0) as ITreeNode; >>>> >>>> startRegion = null; >>>> >>>> endRegion = null; >>>> >>>> while (node != null) >>>> >>>> { >>>> >>>> startRegion = node as IStartRegionNode; >>>> >>>> if (startRegion != null) >>>> >>>> break; >>>> >>>> node = node.Parent; >>>> >>>> } >>>> >>>> if (startRegion != null) >>>> >>>> endRegion = startRegion.EndRegion; >>>> >>>> } >>>> >>>> >>>> -- >>>> Eugene Pasynkov >>>> Developer >>>> JetBrains, Inc >>>> http://www.jetbrains.com >>>> "Develop with pleasure!" >>>> "Ga" wrote in message >>>> news:fa22qc$fc9$1@is.intellij.net... >>>>> Can you show me how please? >>>>> >>>>> >>>>> "Eugene Pasynkov (JetBrains)" wrote in >>>>> message news:fa10up$es3$1@is.intellij.net... >>>>>> The only way is to create #region/#endregion directives and insert >>>>>> them into PSI-tree >>>>>> >>>>>> >>>>>> -- >>>>>> Eugene Pasynkov >>>>>> Developer >>>>>> JetBrains, Inc >>>>>> http://www.jetbrains.com >>>>>> "Develop with pleasure!" >>>>>> "Ga" wrote in message >>>>>> news:f9voac$7ul$1@is.intellij.net... >>>>>>> Hey again, >>>>>>> >>>>>>>]]> I tend to ask many question as it seems but it's all from love :)
>>>>>>>
>>>>>>> i want to know if there is any way to surround a group of method /
>>>>>>> properties / members / etc...
>>>>>>> with regions?
>>>>>>>
>>>>>>> if so, i would be more than happy to know!
>>>>>>>
>>>>>>> thank you very much,
>>>>>>> Guy.
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
Hey just wanted to say,
you are amazing,
this forum is amazing,
soon i will publish the plugins i created thanks to you,
thanks,
guy.
"Eugene Pasynkov (JetBrains)" <Eugene.Pasynkov@jetbrains.com> wrote in
message news:fau2h9$c6p$1@is.intellij.net...
>
>
>
>
>
>
>
>
>
>
>
>> Here is my source code... Just the relavent parts...
>> Thanks!!!
>>
>> ===== Cotext Action Class =====
>>
>> /// >> /// in case the plugin could be applied, and the user selected >> /// to apply it, this method is invocated by resharper core. >> /// >> /// >> /// >> public void Execute(ISolution solution, ITextControl textControl) >> { >> PsiManager.GetInstance(m_solution).UpdateCaches(); >> m_tokenAccessor = new TokenAccessor(solution, textControl); >> //default sanity check made by the api dev team. >> if (m_solution != solution || m_textControl != textControl) >> { >> throw new InvalidOperationException(); >> } >> //check that we can modify the current file. >> Shell.Instance.AssertReadAccessAllowed(); >> >> //creating a command cookie is ment for supporting undo later >> //by visual studio. this is why inside the command cookie >> //definition we have a transaction, in order to 'tell' visual studio >> //to reverse all the changes that we perform now as a single action >> using (CommandCookie.Create("GenerateClassSingleton")) >> { >> // Any changes to PSI should be under a transaction >> PsiManager.GetInstance(m_solution). >> DoTransaction( >> delegate >> { >> //make the actual change to the class >> ExecuteMakeClassSingleton(TokenAccessor.ClassDeclaration.DeclaredName); >> }); >> } >> } >> private List declarations; >> ///
>>>
>>> --
>>> Eugene Pasynkov
>>> Developer
>>> JetBrains, Inc
>>> http://www.jetbrains.com
>>> "Develop with pleasure!"
>>> "Ga" <t4m.productions@gmail.com> wrote in message
>>> news:fa4iea$umk$1@is.intellij.net...
>>>> everythings goes out fine except that the modification util does not
>>>> actually change the file and adds the region...
>>>> when debugging i see all that the debugging data is good (in terms of
>>>> where to create the region).
>>>> what might be the problem ???
>>>> other than that... thank you very much for your patience to write that
>>>> code :)
>>>> Guy.
>>>>
>>>> //ModificationUtil doesn't change anything :(
>>>> startRegion = ModificationUtil.AddChildBefore(firstNode, startRegion);
>>>>
>>>>
>>>> "Eugene Pasynkov (JetBrains)" wrote in >>>> message news:fa46mh$4r0$1@is.intellij.net... >>>>> public void EnRegion(IList declarations, string >>>>> regionName) >>>>> >>>>> { >>>>> >>>>> ITreeNode firstNode = declarations[0].ToTreeNode(); >>>>> >>>>> if (firstNode is IMultipleDeclarationMemberNode) >>>>> >>>>> { >>>>> >>>>> MultipleDeclarationUtil.SplitDeclarationBefore((IMultipleDeclarationMemberNode)firstNode); >>>>> >>>>> firstNode = >>>>> ((IMultipleDeclarationMemberNode)firstNode).MultipleDeclaration; >>>>> >>>>> } >>>>> >>>>> ITreeNode lastNode = declarations[declarations.Count - >>>>> 1].ToTreeNode(); >>>>> >>>>> if (lastNode is IMultipleDeclarationMemberNode) >>>>> >>>>> { >>>>> >>>>> MultipleDeclarationUtil.SplitDeclarationAfter((IMultipleDeclarationMemberNode)lastNode); >>>>> >>>>> lastNode = >>>>> ((IMultipleDeclarationMemberNode)lastNode).MultipleDeclaration; >>>>> >>>>> } >>>>> >>>>> // Add new region >>>>> >>>>> IStartRegionNode startRegion; >>>>> >>>>> IEndRegionNode endRegion; >>>>> >>>>> CreateRegionDirectives(String.IsNullOrEmpty(regionName) ? "..." : >>>>> regionName, out startRegion, out endRegion); >>>>> >>>>> using (WriteLockCookie.Create()) >>>>> >>>>> { >>>>> >>>>> if (startRegion != null) startRegion = >>>>> ModificationUtil.AddChildBefore(firstNode, startRegion); >>>>> >>>>> if (endRegion != null) endRegion = >>>>> ModificationUtil.AddChildAfter(lastNode, endRegion); >>>>> >>>>> } >>>>> >>>>> } >>>>> >>>>> private void CreateRegionDirectives(string regionText, out >>>>> IStartRegionNode startRegion, out IEndRegionNode endRegion) >>>>> >>>>> { >>>>> >>>>> CSharpElementFactory factory = >>>>> CSharpElementFactory.GetInstance(myDeclaration.GetManager().Solution); >>>>> >>>>> ICSharpFile file = factory.CreateFile("#region " + regionText + >>>>> "\n#endregion"); >>>>> >>>>> ITreeNode node = file.FindTokenAt(0) as ITreeNode; >>>>> >>>>> startRegion = null; >>>>> >>>>> endRegion = null; >>>>> >>>>> while (node != null) >>>>> >>>>> { >>>>> >>>>> startRegion = node as IStartRegionNode; >>>>> >>>>> if (startRegion != null) >>>>> >>>>> break; >>>>> >>>>> node = node.Parent; >>>>> >>>>> } >>>>> >>>>> if (startRegion != null) >>>>> >>>>> endRegion = startRegion.EndRegion; >>>>> >>>>> } >>>>> >>>>> >>>>> -- >>>>> Eugene Pasynkov >>>>> Developer >>>>> JetBrains, Inc >>>>> http://www.jetbrains.com >>>>> "Develop with pleasure!" >>>>> "Ga" wrote in message >>>>> news:fa22qc$fc9$1@is.intellij.net... >>>>>> Can you show me how please? >>>>>> >>>>>> >>>>>> "Eugene Pasynkov (JetBrains)" wrote >>>>>> in message news:fa10up$es3$1@is.intellij.net... >>>>>>> The only way is to create #region/#endregion directives and insert >>>>>>> them into PSI-tree >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> Eugene Pasynkov >>>>>>> Developer >>>>>>> JetBrains, Inc >>>>>>> http://www.jetbrains.com >>>>>>> "Develop with pleasure!" >>>>>>> "Ga" wrote in message >>>>>>> news:f9voac$7ul$1@is.intellij.net... >>>>>>>> Hey again, >>>>>>>> >>>>>>>>]]> I tend to ask many question as it seems but it's all from love :)
>>>>>>>>
>>>>>>>> i want to know if there is any way to surround a group of method /
>>>>>>>> properties / members / etc...
>>>>>>>> with regions?
>>>>>>>>
>>>>>>>> if so, i would be more than happy to know!
>>>>>>>>
>>>>>>>> thank you very much,
>>>>>>>> Guy.
>>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>