æ¬è¨äºã®ã³ã¡ã³ãã«ã¦ããã¨ãããã³ã¡ã³ãããã¦ããããã«
ctagsã¯VBã«å¯¾å¿ãã¦ããã¨ã®äºã§ãããã¨ãããããã¨ããããã¾ãï¼ m(_ _)m
以ä¸ããã¨ããã®ã³ã¡ã³ãã§ãã
>ç§ã¨åããããã«ãã©ãçãã人ã®ããã«ã
>ctagsã¯ï¼¶ï¼¢ã«å¯¾å¿ãã¦ãã¾ãã
>ï¼ãã®ã¸ãã®èª¬æãå°ãªãã¦æ°ã¥ãã«ããã§ããï¼
>
>ctags -f xxx.tags --excmd=number -R --languages=Basic --langmap=Basic:.frm.bas.cls --Basic-types=-l -L srcList.txt
vimã§ã½ã¼ã¹ãè¦ããæ¸ããããããã¨ãå¤ãã®ã§ããããã®éã«ã¿ã°ãã¡ã¤ã«ã
ä½æãã¦ã¸ã£ã³ãããããããã¨ãããããã¾ãã
æåãªã®ãctagsã§ããã
ã§ããã®ãã¼ã«ã¯VBã«å¯¾å¿ãã¦ããªãã®ã§VBã®ã½ã¼ã¹ãè¦ããããã¨ãã«
é¢åãªã®ã§ãããã¤ã§ããä½ã£ã¦ã¿ã¾ããã
(対å¿ãã¦ããã¨ã®äºã§ããï¼
ãã¼ã¿ãããããããéã®æ£è¦è¡¨ç¾ã¯ä»¥ä¸ãåèã«ããã¦ããã ãã¾ããã
æè¬m(_ _)m
http://homepage1.nifty.com/markey/memo/200406.html#061601
以ä¸ãã½ã¼ã¹ã§ãã
åãã¦è¼ããã®ãé¢åãªã®ã§ä¸ãã¡ã¤ã«ã¨ãã¦è²¼ãä»ãã¦ã¾ãã
// vim:set ts=4 sw=4 et ws is nowrap ft=cs: using System; using System.Collections.Generic; using System.IO; using System.Text.RegularExpressions; namespace VBTags{ /// <summary> /// ã¢ããªã±ã¼ã·ã§ã³ã¡ã¤ã³ã¨ã³ããªãã¤ã³ãã表ãã¾ãã /// </summary> public class EntryPoint { /// <summary> /// ã¨ã³ããªãã¤ã³ãã¡ã½ããã§ãã /// </summary> /// <param name="args">èµ·åæå¼æ°</param> static void Main(string[] args) { new TagCreatorFactory(args).CreateCreator().Create(); } } /// <summary> /// ä½ããä½æããã¨ããã¤ã³ã¿ã¼ãã§ã¼ã¹ãå®ç¾©ãã¦ãã¾ãã /// </summary> public interface ICreator{ /// <summary> /// ä½æãã¾ãã /// </summary> void Create(); } /// <summary> /// ICreatorã¤ã³ã¿ãã§ã¼ã¹ã®å®è£ ãªãã¸ã§ã¯ãã®çæãæ å½ãããã¡ã¯ããªã¯ã©ã¹ã§ãã /// </summary> public interface ICreatorFactory { /// <summary> /// ICreatorã¤ã³ã¹ã¿ã³ã¹ãçæãã¾ãã /// </summary> /// <returns>ICreatorã¤ã³ã¹ã¿ã³ã¹</returns> ICreator CreateCreator(); } /// <summary> /// ã¿ã°ãã¼ã¿ã®ä½æã¤ã³ã¿ãã§ã¼ã¹ãå®ç¾©ãã¦ãã¾ãã /// </summary> public interface ITagDataCreator : ICreator{ /// <summary> /// å¦ç対象ã«å«ããæ¡å¼µåãåå¾ã»è¨å®ãã¾ãã /// </summary> string[] IncludeSuffix { get; set; } /// <summary> /// å¦çåºåºãã£ã¬ã¯ããªãåå¾ã»è¨å®ãã¾ãã /// </summary> string BaseDirectory { get; set; } /// <summary> /// ã¿ã°ãã¿ã¼ã³ãåå¾ã»è¨å®ãã¾ãã /// </summary> string TagPattern { get; set; } /// <summary> /// åºåãã£ã¬ã¯ããªãåå¾ã»è¨å®ãã¾ãã /// </summary> string OutputDirectory { get; set; } } /// <summary> /// ICreatorã¤ã³ã¿ã¼ãã§ã¼ã¹ã®ããã©ã«ãå®è£ ã¯ã©ã¹ã§ãã /// </summary> /// <remarks> /// ã¿ã°ãã¼ã¿ã®ä½æãæ å½ãã¾ãã /// ãã®ã¯ã©ã¹ã¯ãå®è¡ã«éãã¦ITagDataCreatorã¤ã³ã¿ã¼ãã§ã¼ã¹ã®å®è£ ã /// è¦æ±ãã¾ãã /// å é¨ã§ã¯ãITagDataCreatorã®å®è£ ã«å¦çãå§è²ãã¦ããã ãã§ãã /// </remarks> public class DefaultTagCreator : ICreator { /// <summary> /// ã¿ã°çæå¦çãæ å½ããå¦çãªãã¸ã§ã¯ã /// </summary> ITagDataCreator _tagDataCreator; /// <summary> /// ã³ã³ã¹ãã©ã¯ã¿ /// </summary> /// <param name="tagDataCreator">ã¿ã°çæå¦çãã¸ãã¯ãªãã¸ã§ã¯ã</param> public DefaultTagCreator(ITagDataCreator tagDataCreator) { _tagDataCreator = tagDataCreator; } /// <summary> /// ã¿ã°ãã¼ã¿ã®çæãè¡ãã¾ãã /// </summary> public void Create() { _tagDataCreator.Create(); } } /// <summary> /// ITagDataCreatorã¤ã³ã¿ã¼ãã§ã¼ã¹ã®ããã©ã«ãå®è£ ã¯ã©ã¹ã§ãã /// </summary> /// <remarks> /// ããã©ã«ãã§ããã®ã¯ã©ã¹ã¯vimç¨ã®ã¿ã°ãã¼ã¿ãçæãã¾ãã /// ä»ã®ã¿ã°ãã¼ã¿ãåºåããå ´åã¯å¥éå®è£ ã¯ã©ã¹ãä½æãã¾ãã /// ãã®éã«ãã®ã¯ã©ã¹ããã¼ã¹ã¯ã©ã¹ã¨ãã¦ä½æããã¨ä¾¿å©ã§ãã /// </remarks> public class DefaultTagDataCreator : ITagDataCreator { /// <summary> /// å¦ç対象ã«å«ããæ¡å¼µå /// </summary> string[] _includeSuffix; /// <summary> /// å¦çåºåºãã£ã¬ã¯ã㪠/// </summary> string _baseDirectory; /// <summary> /// ã¿ã°ãã¿ã¼ã³ /// </summary> string _tagPattern; /// <summary> /// åºåãã£ã¬ã¯ã㪠/// </summary> string _outputDirectory; /// <seealso cref="ITagDataCreator.IncludeSuffix"/> public string[] IncludeSuffix { get { return _includeSuffix; } set { _includeSuffix = value; } } /// <seealso cref="ITagDataCreator.BaseDirectory"/> public string BaseDirectory { get { return _baseDirectory; } set { _baseDirectory = value; } } /// <seealso cref="ITagDataCreator.TagPattern"/> public string TagPattern { get { return _tagPattern; } set { _tagPattern = value; } } /// <seealso cref="ITagDataCreator.OutputDirectory"/> public string OutputDirectory { get { return _outputDirectory; } set { _outputDirectory = value; } } /// <summary> /// æå®ããããã¡ã¤ã«ãã¹ã®æ¡å¼µåã妥å½ãªãã®ãã©ãããå¤æãã¾ãã /// </summary> /// <param name="filePath">ãã¡ã¤ã«ãã¹</param> /// <returns>妥å½ãªæ¡å¼µåã®å ´åtrue, ãã以å¤ã¯false</returns> protected virtual bool IsValidSuffix(string filePath) { foreach(string suffix in _includeSuffix) { if(filePath.EndsWith(suffix)) { return true; } } return false; } /// <summary> /// æå®ããããã¡ã¤ã«ãã¹ããã¿ã°ãã¼ã¿ãåå¾ãã¾ãã /// </summary> /// <param name="filePath">ãã¡ã¤ã«ãã¹</param> /// <returns>ã¿ã°ãã¼ã¿ã®ãªã¹ã</returns> protected virtual List<string> GetTagData(string filePath) { List<string> result = new List<string>(); Regex regex = new Regex(_tagPattern); using(StreamReader sr = new StreamReader(filePath)) { int count = 0; for(string line = sr.ReadLine(); line != null; line = sr.ReadLine(), count++) { Match m = regex.Match(line); if(m.Success) { result.Add(GetFormatString(m, filePath, line, count)); } } } return result; } /// <summary> /// æå®ããããã¼ã¿ããé©åãªã¿ã°ãã¼ã¿ãçæããè¿ãã¾ãã /// </summary> /// <param name="m">æ£è¦è¡¨ç¾ããããªãã¸ã§ã¯ã</param> /// <param name="filePath">ãã¡ã¤ã«ãã¹</param> /// <param name="line">è¡ãã¼ã¿</param> /// <param name="lineCount">è¡æ°</param> /// <returns>ãã©ã¼ãããæ¸ã¿ã®ã¿ã°ãã¼ã¿</returns> protected virtual string GetFormatString(Match m, string filePath, string line, int lineCount) { return string.Format("{0}\t{1}\t/^{2}$/;\"\tf", m.Groups[2], filePath, line); } /// <summary> /// ã¿ã°ãã¼ã¿ãçæãã¾ãã /// </summary> public virtual void Create() { if(_baseDirectory == null || _baseDirectory.Length == 0) { _baseDirectory = "."; } _baseDirectory = Path.GetFullPath(_baseDirectory); Console.WriteLine("[å¦çéå§] 対象åºåºãã£ã¬ã¯ããªï¼{0}", _baseDirectory); List<string> result = new List<string>(); foreach(string f in Directory.GetFiles(_baseDirectory)) { if(!IsValidSuffix(f)) { continue; } result.AddRange(GetTagData(f)); } foreach(string subDirectory in Directory.GetDirectories(_baseDirectory, "*", SearchOption.AllDirectories)) { foreach(string f in Directory.GetFiles(subDirectory)) { if(!IsValidSuffix(f)) { continue; } result.AddRange(GetTagData(f)); } } result.Sort(); using(StreamWriter writer = new StreamWriter(Path.Combine(_outputDirectory, "tags"))) { foreach(string element in result) { writer.WriteLine(element); } } } } /// <summary> /// Sakuraã¨ãã£ã¿ç¨ã®ã¿ã°ãã¼ã¿ãçæããã¿ã°ãã¼ã¿çæã¯ã©ã¹ã§ãã /// </summary> public class SakuraTagDataCreator : DefaultTagDataCreator { /// <summary> /// ãã¼ã¿ãé©åãªæ¸å¼ã«ãã©ã¼ããããã¦è¿ãã¾ãã /// </summary> /// <param name="m">æ£è¦è¡¨ç¾ããããªãã¸ã§ã¯ã</param> /// <param name="filePath">ãã¡ã¤ã«ãã¹</param> /// <param name="line">è¡ãã¼ã¿</param> /// <param name="lineCount">è¡æ°</param> /// <returns>ãã©ã¼ãããæ¸ã¿ã®ãã¼ã¿</returns> protected override string GetFormatString(Match m, string filePath, string line, int lineCount) { return string.Format("{0}\t{1}\t{2};\"\tf", m.Groups[2], filePath, lineCount); } } /// <summary> /// ã¿ã°ãã¼ã¿çæã¯ã©ã¹ã®çæãæ å½ãããã¡ã¯ããªã¯ã©ã¹ã§ãã /// </summary> public class TagCreatorFactory : ICreatorFactory{ /// <summary> /// èµ·åæå¼æ° /// </summary> string[] _args; /// <summary> /// ã³ã³ã¹ãã©ã¯ã¿ /// </summary> /// <param name="args">èµ·åæå¼æ°</param> public TagCreatorFactory(string[] args) { _args = args; } #region ICreatorFactory ã¡ã³ã /// <summary> /// æå®ããããã¼ã¿ã«åºã¥ãã¦å¦çãè¡ãã¿ã°ãã¼ã¿çæã¯ã©ã¹ãç¹å®ããè¿ãã¾ãã /// </summary> /// <returns>ã¿ã°ãã¼ã¿çæãªãã¸ã§ã¯ã</returns> public ICreator CreateCreator() { ICreator creator = null; ITagDataCreator tagDataCreator = null; tagDataCreator = new DefaultTagDataCreator(); if(_args.Length == 2) { tagDataCreator = new SakuraTagDataCreator(); } string directory = string.IsNullOrEmpty(_args[0]) ? "." : _args[0]; tagDataCreator.IncludeSuffix = new string[]{ "frm" ,"bas" ,"cls" }; tagDataCreator.BaseDirectory = directory; tagDataCreator.TagPattern = "(Sub|Function|Const)\\s+([^\\s]+)\\s*(\\(|=)"; tagDataCreator.OutputDirectory = directory; creator = new DefaultTagCreator(tagDataCreator); return creator; } #endregion } }
ä»ã®ã©ã¤ãã©ãªã使ç¨ãã¦ããªãã®ã§ã
ä¸ã®ã½ã¼ã¹ã
csc ã½ã¼ã¹ãã¡ã¤ã«
ã¨ããã°ãã³ã³ãã¤ã«ã§ãã¾ãã
.net framework 2.0ãå¿
è¦ã«ãªãã¾ãã
ç¾ç¶ãvimã¨sakuraã¨ãã£ã¿ã®å½¢å¼ã«å¯¾å¿ãã¦ãã¾ãã
VBTags c:\tmp
ã¨ããã°vimç¨ã§ã
VBTags c:\tmp -sakura
ã¨ããã°sakuraç¨ã®ã¿ã°ãã¡ã¤ã«ãåºæ¥ä¸ããã¾ãã
[追è¨]
GUIçã¤ãã£ã¦ã¿ã¾ããã
以ä¸ã®è¨äºãåç
§ãããã¾ãã
http://d.hatena.ne.jp/gsf_zero1/20070409/p1
ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼ï¼
éå»ã®è¨äºã«ã¤ãã¦ã¯ã以ä¸ã®ãã¼ã¸ãããåç
§ä¸ããã
- ããããåå¿é²æ¥è¨ã¾ã¨ã