2013-10-07 7 views
0

나는
(예를 들어 trivalized)Resharper 템플릿의 전체 변수를 대문자로 변환하는 방법은 무엇입니까?

///AT+$COMMAND$ 

void At$COMMAND$() 
{ 
} 

그래서 나는 "어쩌구"같은 것을 입력 할 템플릿의 사용자가 원하는 것을 가져 내가 변수가 문서 등을 위해 대문자 할 상황이 메서드 이름에 사용되지만 문서 부분은 "BLAH"로 변경됩니다.

예를 들어 나는이 작업을 수행 할 수

///AT+BLAH 
void AtBlah() 
{ 
} 

? 매크로에서 첫 글자를 대문자로 볼 수는 있지만 전체 단어를 대문자로 표시하고 싶습니다. 사용자 지정 매크로를 만들 수 있습니까?

+0

HTTP ://stackoverflow.com/questions/15342501/captilizing-a-name-in-a-resarper-template – Eldar

답변

0

그들은 단지 업데이트 된 설명서 당신은 그것을 아주 쉽게 새로운 문서로 http://confluence.jetbrains.com/display/NETCOM/4.04+Live+Template+Macros+%28R8%29

에서 그것을 확인할 수 있습니다 ReSharper에서 8에서 매크로의 변화를 충족하기 위해, 내 구현은 간다 :

using System.Collections.Generic; 
using System.Linq; 
using System.Runtime.InteropServices; 
using JetBrains.DocumentModel; 
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Macros; 
using JetBrains.ReSharper.Feature.Services.LiveTemplates.Hotspots; 

namespace ReSharperPlugin 
{ 
    [MacroDefinition("LiveTemplatesMacro.CapitalizeVariable", // macro name should be unique among all other macros, it's recommended to prefix it with your plugin name to achieve that 
    ShortDescription = "Capitalizes variable {0:list}", // description of the macro to be shown in the list of macros 
    LongDescription = "Capitalize full name of variable" // long description of the macro to be shown in the area below the list 
    )] 
    public class CapitalizeVariableMacro : IMacroDefinition 
    { 
     public string GetPlaceholder(IDocument document, IEnumerable<IMacroParameterValue> parameters) 
     { 
      return "A"; 
     } 

     public ParameterInfo[] Parameters 
     { 
      get { return new[] {new ParameterInfo(ParameterType.VariableReference)}; } 
     } 
    } 

    [MacroImplementation(Definition = typeof(CapitalizeVariableMacro))] 
    public class CapitalizeVariableMacroImpl : SimpleMacroImplementation 
    { 
     private readonly IMacroParameterValueNew _parameter; 

     public CapitalizeVariableMacroImpl([Optional] MacroParameterValueCollection parameters) 
     { 
      _parameter = parameters.OptionalFirstOrDefault(); 
     } 

     public override string EvaluateQuickResult(IHotspotContext context) 
     { 
      return _parameter == null ? null : _parameter.GetValue().ToUpperInvariant(); 
     } 
    } 
}