2017-04-08 8 views
0

X ++ 편집기에서 구현 후 인터페이스를 자동 추출 할 수있는 기능이 있습니까?AX2012 X ++ 코드 편집기의 자동 추출 인터페이스

마찬가지로 Visual Studio에는 인터페이스를 구현하는 데 필요한 모든 메서드에 대한 메서드 스텁을 제공하여 구현 된 인터페이스를 자동으로 추출하는 기능이 있습니다.

답변

1

아니요, 이러한 기능은 없습니다.

하지만 글을 쓸 수 있습니다. 아래 샘플 코드를 참조하십시오. Action menu item\Menus\SysContextMenu에 추가하십시오.

는 다른 방법이 \Classes\EditorScripts

public static void main(Args _args) 
{ 
    #macrolib.AOT 

    SysContextMenuAOT menuAot; 
    TreeNode tn; 
    DictClass dc; 
    DictMethod dm; 
    int i, j; 
    str dmName; 
    str intSrc, intParams; 

    TreeNode itnRoot, itnChild; 

    if (!SysContextMenu::startedFrom(_args)) 
    { 
     throw error(Error::wrongUseOfFunction(funcName())); 
    } 

    menuAot = _args.parmObject(); 
    tn = menuAot.getFirstNode(); 

    dc = new DictClass(className2Id(tn.AOTname())); 
    if (!dc) 
    { 
     throw error(Error::wrongUseOfFunction(funcName())); 
    } 

    for (i = 1; i <= dc.objectMethodCnt(); i++) 
    { 
     dm = dc.objectMethodObject(i); 
     dmName = dm.name(); 
     if (dm.isStatic() 
      || dm.isDelegate() 
      || dm.accessSpecifier() != AccessSpecifier::public 
      || dm.name() == identifierStr(classDeclaration) 
     ) 
     { 
      continue; 
     } 

     if (!itnRoot) 
     { 
      itnRoot = TreeNode::findNode(#ClassesPath).AOTadd("I" + dc.name()); 
      itnRoot.AOTsave(); 

      itnChild = itnRoot.AOTfirstChild(); 
      itnChild.AOTsetSource(strFmt('public interface I%1\n{\n}', dc.name())); 
     } 

     itnChild = itnRoot.AOTadd(dm.name()); 
     intParams = ''; 
     for (j = 1; j <= dm.parameterCnt(); j++) 
     { 
      if (j > 1) 
      { 
       intParams+= ', '; 
      } 
      intParams+= strFmt('%1 %2', extendedTypeId2DisplayName(dm.parameterType(j), dm.parameterId(j)), dm.parameterName(j)); 
     } 
     intSrc = strFmt('public %1 %2(%3)\n{\n}', extendedTypeId2DisplayName(dm.returnType(), dm.returnId()), dm.name(), intParams); 
     itnChild.AOTsetSource(intSrc); 
    } 

    if (itnRoot) 
    { 
     itnRoot.AOTcompile(); 
     itnRoot.AOTrestore(); 
     itnRoot.AOTnewWindow(); 
     itnRoot.AOTedit(); 
    } 
} 
+0

에 우수함 방법을 추가 할 수 있습니다, 그 예를 들어 주셔서 감사합니다! – Stef