Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Source Editor Extensionと SwiftSyntaxでコード自動生成ツール を作る

6500a96a5f0786d7ff0c53429d691ae6?s=47 kazuhiro4949
September 18, 2021

Source Editor Extensionと SwiftSyntaxでコード自動生成ツール を作る

6500a96a5f0786d7ff0c53429d691ae6?s=128

kazuhiro4949

September 18, 2021
Tweet

Transcript

  1. ྛ࿨߂ !LB[VIJSP 4PVSDF&EJUPS&YUFOTJPOͱ 4XJGU4ZOUBYͰίʔυࣗಈੜ੒πʔϧ Λ࡞Δ J04%$+BQBO

  2. w ֓ཁ w ࣄྫ%*)FMQFSGPS4XJGU w ࣄྫ"DDFTT-FWFM$IBOHFSGPS9DPEF w ٕज़ղઆ w ଞͷख๏ͱͷൺֱ

    w ·ͱΊ
  3. w ֓ཁ w ࣄྫ%*)FMQFSGPS4XJGU w ࣄྫ"DDFTT-FWFM$IBOHFSGPS9DPEF w ٕज़ղઆ w ଞͷख๏ͱͷൺֱ

    w ·ͱΊ
  4. ֓ཁ w ίʔυࣗಈੜ੒ख๏ͱͯ͠4PVSDF&EJUPS&YUFOTJPO 4XJGU4ZOUBYΛఏҊ w ࣮ࡍʹ։ൃͰ׆༻͍ͯ͠Δ w ϝϦοτɾσϝϦοτ͕͋ΔͷͰଞͷํ๏ͱซ༻͢Δͷ͕ྑ͍

  5. w ֓ཁ w ࣄྫ%*)FMQFSGPS4XJGU w ࣄྫ"DDFTT-FWFM$IBOHFSGPS9DPEF w ٕज़ղઆ w ଞͷख๏ͱͷൺֱ

    w ·ͱΊ
  6. എܠͱͳΔ՝୊ w ػೳ࣮૷ͨ͠ޙͰϦϑΝΫλϦϯά ͠ͳ͕ΒςετΛॻ͖͍ͨ w %*ͷͨΊʹϓϩτίϧ࡞੒ɾϞοΫ ࡞੒͢Δͷ͕໘౗ ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷

    ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  7. എܠͱͳΔ՝୊ w ػೳ࣮૷ͨ͠ޙͰϦϑΝΫλϦϯά ͠ͳ͕ΒςετΛॻ͖͍ͨ w %*ͷͨΊʹϓϩτίϧ࡞੒ɾϞοΫ ࡞੒͢Δͷ͕໘౗ ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷

    ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  8. എܠͱͳΔ՝୊ w ػೳ࣮૷ͨ͠ޙͰϦϑΝΫλϦϯά ͠ͳ͕ΒςετΛॻ͖͍ͨ w %*ͷͨΊʹϓϩτίϧ࡞੒ɾϞοΫ ࡞੒͢Δͷ͕໘౗ ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷

    ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  9. %*)FMQFSGPS4XJGU w 4XJGUͷϦϑΝΫλϦϯάπʔϧ w Ϋϥε͔Βϓϩτίϧͷநग़ w ϓϩτίϧ͔ΒϞοΫͷੜ੒ IUUQTBQQTBQQMFDPNKQBQQEJIFMQFSGPSTXJGUJE

  10. %*)FMQFSGPS4XJGU w 4XJGUͷϦϑΝΫλϦϯάπʔϧ w Ϋϥε͔Βϓϩτίϧͷநग़ w ϓϩτίϧ͔ΒϞοΫͷੜ੒ IUUQTBQQTBQQMFDPNKQBQQEJIFMQFSGPSTXJGUJE

  11. %*)FMQFSGPS4XJGU w 4XJGUͷϦϑΝΫλϦϯάπʔϧ w Ϋϥε͔Βϓϩτίϧͷநग़ w ϓϩτίϧ͔ΒϞοΫͷੜ੒ Ϋϥε ϓϩτίϧ

  12. %*)FMQFSGPS4XJGU w 4XJGUͷϦϑΝΫλϦϯάπʔϧ w Ϋϥε͔Βϓϩτίϧͷநग़ w ϓϩτίϧ͔ΒϞοΫͷੜ੒ Ϋϥε ϓϩτίϧ ϞοΫ

  13. σϞ

  14. %*)FMQFSGPS4XJGUͷಛ௃ w 9DPEF্Ͱ࣮૷தίʔυʹର͠ ͯϦϑΝΫλϦϯάՄೳ w ϦϑΝΫλϦϯάͷεςοϓΛ Ұ෦লུͰ͖Δ w લड़ͷϦζϜΛ่ͣ͞ʹίʔυ ੜ੒͢Δ

    ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷ ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  15. %*)FMQFSGPS4XJGUͷಛ௃ w ϦϑΝΫλϦϯάͷεςοϓΛ Ұ෦লུͰ͖Δ w લड़ͷϦζϜΛ่ͣ͞ʹίʔυ ੜ੒͢Δ w 9DPEF্Ͱ࣮૷தίʔυʹର͠ ͯϦϑΝΫλϦϯάՄೳ

    ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷ ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  16. %*)FMQFSGPS4XJGUͷಛ௃ w ϦϑΝΫλϦϯάͷεςοϓΛ Ұ෦লུͰ͖Δ w લड़ͷϦζϜΛ่ͣ͞ʹίʔυ ੜ੒͢Δ w 9DPEF্Ͱ࣮૷தίʔυʹର͠ ͯϦϑΝΫλϦϯάՄೳ

    ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷ ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  17. %*)FMQFSGPS4XJGUͷಛ௃ w ϦϑΝΫλϦϯάͷεςοϓΛ Ұ෦লུͰ͖Δ w લड़ͷϦζϜΛ่ͣ͞ʹίʔυ ੜ੒͢Δ w 9DPEF্Ͱ࣮૷தίʔυʹର͠ ͯϦϑΝΫλϦϯάՄೳ

    ᶃػೳ࣮૷ ᶅґଘΫϥεΛϓϩτίϧԽ ᶄςετ࣮૷ ᶆϞοΫ࡞੒ ᶇ%*Ͱ͖ΔΑ͏ʹͯ͠ςετΛ௨͢
  18. w ֓ཁ w ࣄྫ%*)FMQFSGPS4XJGU w ࣄྫ"DDFTT-FWFM$IBOHFSGPS9DPEF w ٕज़ղઆ w ଞͷख๏ͱͷൺֱ

    w ·ͱΊ
  19. എܠͱͳΔ՝୊ w طଘίʔυΛ'8Խ͢Δ࣌ʹ*'ެ։ ͢Δͷ͕໘౗ w ͦ͏͍͏͜ͱ͕͍ͨ͠ϓϩδΣΫτ ͸େମΫϥεͷίʔυྔ͕Ͱ͔͍

  20. എܠͱͳΔ՝୊ w طଘίʔυΛ'8Խ͢Δ࣌ʹ*'ެ։ ͢Δඞཁ͕͋Δ w ඞཁʹͳΔ࣌ʹ͸େମϓϩδΣΫτ ͷίʔυྔ͕Ͱ͔͍ ϞϊϦγοΫͳ ϓϩδΣΫτ ϓϩδΣΫτ

    ϑϨʔϜ ϫʔΫ ϑϨʔϜ ϫʔΫ ϑϨʔϜ ϫʔΫ ϑϨʔϜ ϫʔΫ ϑϨʔϜ ϫʔΫ
  21. എܠͱͳΔ՝୊ w طଘίʔυΛ'8Խ͢Δ࣌ʹ*'ެ։ ͢Δඞཁ͕͋Δ w ඞཁʹͳΔ࣌ʹ͸େମϓϩδΣΫτ ͷίʔυྔ͕Ͱ͔͘ͳ͍ͬͯͯᶅͷ ࡞ۀ͕େม ᶃϑϨʔϜϫʔΫͷശΛ࡞੒ ᶅඞཁͳ*'Λެ։

    ᶄ4XJGUϑΝΠϧͷλʔήοτมߋ ᶆϏϧυΛ௨͢
  22. "DDFTT-FWFM$IBOHFSGPS9DPEF w 4XJGUͷϦϑΝΫλϦϯάπʔϧ w JOUFSOBMΛҰׅͰQVCMJDʹม׵Ͱ ͖Δ IUUQTBQQTBQQMFDPNKQBQQBDDFTTMFWFMDIBOHFSGPSYDPEFJE

  23. "DDFTT-FWFM$I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Y 4PVSDF&EJUPS &YUFOTJPO 8SBQQFS$MBTT
  31. ߏ੒ 4XJGU4ZOUBY w 4XJGUͷ4XJGUʹΑΔύʔαʔ w IUUQTHJUIVCDPNBQQMF TXJGUTZOUBY w NBD04"QQͱ&YUFOTJPOͰڞ༗͢ ΔϥούʔΛ࡞Δ

    w NBD಺ͷEZMJCΛΞϓϦʹ૊ΈࠐΉ ඞཁ͕͋Δ NBD04"QQ MJC@*OUFSOBM4XJGU4ZOUBY1BSTFSEZMJC 4XJGU4ZOUBY 4PVSDF&EJUPS &YUFOTJPO 8SBQQFS$MBTT
  32. σϞ

  33. %*)FMQFSGPS4XJGUͷॲཧͷྲྀΕ 9DPEF NBD04BQQ 8SBQQFS 'SBNFXPSL 4PVSDF&EJUPS &YUFOTJPO 4XJGU4ZOUBY ᶃTXJGUϑΝΠϧΛ &YUFOTJPOʹ౉͢

    ᶄΧʔιϧબ୒ൣғΛ4USJOHͱͯͭ͠ͳ͍Ͱ 4XJGU4ZOUBYͷܕͱͯ͠ॲཧ ᶅύʔε݁Ռ͔ΒϓϩτίϧΛੜ੒ͯ͠ 4USJOHʹͯ͠ฦ͢ ᶆಉ͡TXJGUϑΝΠϧΛ্ॻ͖
  34. 9DPEF্Ͱͷ࢖͍ํ

  35. ࡞ͬͨNBD04ΞϓϦʹؔͯ͠ w MJC@*OUFSOBM4XJGU4ZOUBY1BSTFS Λ૊ΈࠐΜͩঢ়ଶͰ"QQ4UPSF΁ ެ։Մೳ w &YUFOTJPOΛ࢖͍ͬͯΔͱ৹ࠪͰ αϯϓϧϓϩδΣΫτ΋ཁٻ͞Ε ͨ IUUQTBQQTBQQMFDPNKQBQQEJIFMQFSGPSTXJGUJE

  36. w ֓ཁ w ࣄྫ%*)FMQFSGPS4XJGU w ࣄྫ"DDFTT-FWFM$IBOHFSGPS9DPEF w ٕज़ղઆ w ଞͷख๏ͱͷൺֱ

    w ·ͱΊ
  37. ίʔυࣗಈੜ੒ͷ୅දతͳख๏ͱͷൺֱ ํ๏ ಛ௕ σϝϦοτ 4PVSDF&EJUPS&YUFOTJPO w ίʔυฤू͠ͳ͕Β࣮ߦՄೳ w NBD04BQQͱͯ͠഑෍ w

    4XJGUϑΝΠϧ୯ମͷΈೖྗͰ͖Δ 9DPEF5FNQMBUF w ੩తϑΝΠϧΛ༻ҙ͢Δ͚ͩͰखܰ w ϑΝΠϧ࡞੒࣌ʹ࢖͑Δ w ίʔυʹΑΔෳࡶͳग़͠෼͚͕೉͍͠ 3VO4DSJQUFUD w Ϗϧυ࣌ʹࣗಈੜ੒ w ԿͰ΋ΠϯϓοτɾΞ΢τϓοτͰ͖Δ w ౎౓ϏϧυΛ௨͢ඞཁ͕͋Δ
  38. w ֓ཁ w ࣄྫ%*)FMQFSGPS4XJGU w ࣄྫ"DDFTT-FWFM$IBOHFSGPS9DPEF w ٕज़ղઆ w ଞͷख๏ͱͷൺֱ

    w ·ͱΊ
  39. ࠓ೔ͷ࿩ w ίʔυࣗಈੜ੒ख๏ͱͯ͠4PVSDF&EJUPS&YUFOTJPO 4XJGU4ZOUBYΛఏҊ w ͜ͷख๏ʹΑΔͭͷϢʔεέʔεΛ঺հ w ଞͷख๏ͱൺֱͯ͠ఏҊ಺༰ͷϝϦοτɾσϝϦοτΛղઆ

  40. 4PVSDF&EJUPS&YUFOTJPO 4XJGU4ZOUBY w ίʔυΛॻ͍͍ͯΔ࠷தʹɺͦΕΛ࢖ͬͯίʔυࣗಈੜ੒͕Ͱ͖Δ w ύʔαʔ΋༻ҙ͞Ε͍ͯΔͷͰɺࣗ෼ͷཁ݅ͷͨΊʹखܰʹಋೖͰ͖Δ w ίʔυࣗಈੜ੒ͷखஈͷҰͭͱͯ͠৭ʑ࢖͑ͦ͏

  41. ϦϑΝϨϯε w$SFBUJOHB4PVSDF&EJUPS&YUFOTJPO w IUUQTEFWFMPQFSBQQMFDPNEPDVNFOUBUJPOYDPEFLJUDSFBUJOH@B@TPVSDF@FEJUPS@FYUFOTJPO wBQQMFTXJGUTZOUBY w IUUQTHJUIVCDPNBQQMFTXJGUTZOUBY wLB[VIJSP%*)FMQFS'PS4XJGU w IUUQTHJUIVCDPNLB[VIJSP%*)FMQFS'PS4XJGU

    wLB[VIJSP"DDFTT-FWFM$IBOHFS w IUUQTHJUIVCDPNLB[VIJSP"DDFTT-FWFM$IBOHFS