Esempio n. 1
0
		protected override IEnumerable<string> GetTags (FileInformation fileInfo)
		{
			string tagFileName = Path.GetFileName (fileInfo.FileName) + ".tag";
			string tagFullFileName = Path.Combine (SystemTagsDirectory, tagFileName);
			
			string ctags_options = string.Format ("-dtx '{0}'", fileInfo.FileName);
			string ctags_output = string.Empty;
			
			if (!File.Exists (tagFullFileName) || File.GetLastWriteTimeUtc (tagFullFileName) < File.GetLastWriteTimeUtc (fileInfo.FileName)) {
				ctags_output = GetOutputFromProcess (CTagsExecutable, ctags_options, Environment.CurrentDirectory);
				File.WriteAllText (tagFullFileName, ctags_output);
			}
			
			return ctags_output.Split (newlines, StringSplitOptions.RemoveEmptyEntries);
		}
Esempio n. 2
0
		public override void FillFileInformation (FileInformation fileInfo)
		{
			IEnumerable<string> ctags_output = GetTags (fileInfo);
			if (ctags_output == null) return;
			
			foreach (string tagEntry in ctags_output) {
				if (tagEntry.StartsWith ("!_")) continue;
				
				Tag tag = ParseTag (tagEntry);
				
				if (tag != null)
					AddInfo (fileInfo, tag, tagEntry);
			}
			
			fileInfo.IsFilled = true;
		}
		protected override IEnumerable<string> GetTags (FileInformation fileInfo)
		{
			string tagFileName = Path.GetFileName (fileInfo.FileName) + ".tag";
			string tagFullFileName = Path.Combine (SystemTagsDirectory, tagFileName);
			string ctags_kinds = "--C++-kinds=+px";
			string ctags_output = string.Empty;
			
			if (PropertyService.Get<bool> ("CBinding.ParseLocalVariables", true))
				ctags_kinds += "l";
			
			string ctags_options = ctags_kinds + " --fields=+aStisk-fz --language-force=C++ --excmd=number --line-directives=yes -f '" + tagFullFileName + "' '" + fileInfo.FileName + "'";
			
			if (!File.Exists (tagFullFileName) || File.GetLastWriteTimeUtc (tagFullFileName) < File.GetLastWriteTimeUtc (fileInfo.FileName)) {
				ctags_output = GetOutputFromProcess (CTagsExecutable, ctags_options, Environment.CurrentDirectory);
				File.WriteAllText (tagFullFileName, ctags_output);
			}
			
			return ctags_output.Split (newlines, StringSplitOptions.RemoveEmptyEntries);
		}
Esempio n. 4
0
		private void UpdateSystemTags (Project project, string filename, IEnumerable<string> includedFiles)
		{
			if (!DepsInstalled)
				return;
			ProjectInformation info = ProjectInformationManager.Instance.Get (project);
			List<FileInformation> files;
			
			lock (info) {
				if (!info.IncludedFiles.ContainsKey (filename)) {
					files = new List<FileInformation> ();
					info.IncludedFiles.Add (filename, files);
				} else {
					files = info.IncludedFiles[filename];
				}
				
				foreach (string includedFile in includedFiles) {
					bool contains = false;
					
					foreach (FileInformation fi in files) {
						if (fi.FileName == includedFile) {
							contains = true;
						}
					}
					
					if (!contains) {
						FileInformation newFileInfo = new FileInformation (project, includedFile);
						files.Add (newFileInfo);
						ctags.FillFileInformation (newFileInfo);
					}
					
					contains = false;
				}
			}
		}
		private void AddInfo (FileInformation info, Tag tag, string ctags_output)
		{
			switch (tag.Kind)
			{
			case TagKind.Class:
				Class c = new Class (tag, info.Project, ctags_output);
				if (!info.Classes.Contains (c))
					info.Classes.Add (c);
				break;
			case TagKind.Enumeration:
				Enumeration e = new Enumeration (tag, info.Project, ctags_output);
				if (!info.Enumerations.Contains (e))
					info.Enumerations.Add (e);
				break;
			case TagKind.Enumerator:
				Enumerator en= new Enumerator (tag, info.Project, ctags_output);
				if (!info.Enumerators.Contains (en))
					info.Enumerators.Add (en);
				break;
			case TagKind.ExternalVariable:
				break;
			case TagKind.Function:
				Function f = new Function (tag, info.Project, ctags_output);
				if (!info.Functions.Contains (f))
					info.Functions.Add (f);
				break;
			case TagKind.Local:
				Local lo = new Local (tag, info.Project, ctags_output);
				if(!info.Locals.Contains (lo))
					info.Locals.Add (lo);
				break;
			case TagKind.Macro:
				Macro m = new Macro (tag, info.Project);
				if (!info.Macros.Contains (m))
					info.Macros.Add (m);
				break;
			case TagKind.Member:
				Member me = new Member (tag, info.Project, ctags_output);
				if (!info.Members.Contains (me))
					info.Members.Add (me);
				break;
			case TagKind.Namespace:
				Namespace n = new Namespace (tag, info.Project, ctags_output);
				if (!info.Namespaces.Contains (n))
					info.Namespaces.Add (n);
				break;
			case TagKind.Prototype:
				Function fu = new Function (tag, info.Project, ctags_output);
				if (!info.Functions.Contains (fu))
					info.Functions.Add (fu);
				break;
			case TagKind.Structure:
				Structure s = new Structure (tag, info.Project, ctags_output);
				if (!info.Structures.Contains (s))
					info.Structures.Add (s);
				break;
			case TagKind.Typedef:
				Typedef t = new Typedef (tag, info.Project, ctags_output);
				if (!info.Typedefs.Contains (t))
					info.Typedefs.Add (t);
				break;
			case TagKind.Union:
				Union u = new Union (tag, info.Project, ctags_output);
				if (!info.Unions.Contains (u))
					info.Unions.Add (u);
				break;
			case TagKind.Variable:
				Variable v = new Variable (tag, info.Project);
				if (!info.Variables.Contains (v))
					info.Variables.Add (v);
				break;
			default:
				break;
			}
		}
		private void FillFileInformation (FileInformation fileInfo)
		{
			if (!DepsInstalled)
				return;
			
			string confdir = PropertyService.ConfigPath;
			string tagFileName = Path.GetFileName (fileInfo.FileName) + ".tag";
			string tagdir = Path.Combine (confdir, "system-tags");
			string tagFullFileName = Path.Combine (tagdir, tagFileName);
			string ctags_kinds = "--C++-kinds=+px";
			
			if (PropertyService.Get<bool> ("CBinding.ParseLocalVariables", true))
				ctags_kinds += "l";
			
			string ctags_options = ctags_kinds + " --fields=+aStisk-fz --language-force=C++ --excmd=number --line-directives=yes -f '" + tagFullFileName + "' '" + fileInfo.FileName + "'";
			
			if (!Directory.Exists (tagdir))
				Directory.CreateDirectory (tagdir);
			
			if (!File.Exists (tagFullFileName) || File.GetLastWriteTimeUtc (tagFullFileName) < File.GetLastWriteTimeUtc (fileInfo.FileName)) {
				ProcessWrapper p = null;
				System.IO.StringWriter output = null;
				try {
					output = new System.IO.StringWriter ();
					
					p = Runtime.ProcessService.StartProcess ("ctags", ctags_options, null, null, output, null);
					p.WaitForOutput (10000);
					if (p.ExitCode != 0 || !File.Exists (tagFullFileName)) {
						LoggingService.LogError ("Ctags did not successfully populate the tags database '{0}' within ten seconds.\nOutput: {1}", tagFullFileName, output.ToString ());
						return;
					}
				} catch (Exception ex) {
					throw new IOException ("Could not create tags database (You must have exuberant ctags installed).", ex);
				} finally {
					if (output != null)
						output.Dispose ();
					if (p != null)
						p.Dispose ();
				}
			}
			
			string ctags_output;
			string tagEntry;
			
			using (StreamReader reader = new StreamReader (tagFullFileName)) {
				ctags_output = reader.ReadToEnd ();
			}
			
			using (StringReader reader = new StringReader (ctags_output)) {
				while ((tagEntry = reader.ReadLine ()) != null) {
					if (tagEntry.StartsWith ("!_")) continue;
					
					Tag tag = ParseTag (tagEntry);
					
					if (tag != null)
						AddInfo (fileInfo, tag, ctags_output);
				}
			}
			
			fileInfo.IsFilled = true;
		}
Esempio n. 7
0
        protected virtual void AddInfo(FileInformation info, Tag tag, string ctags_output)
        {
            switch (tag.Kind)
            {
            case TagKind.Class:
                Class c = new Class(tag, info.Project, ctags_output);
                if (!info.Classes.Contains(c))
                {
                    info.Classes.Add(c);
                }
                break;

            case TagKind.Enumeration:
                Enumeration e = new Enumeration(tag, info.Project, ctags_output);
                if (!info.Enumerations.Contains(e))
                {
                    info.Enumerations.Add(e);
                }
                break;

            case TagKind.Enumerator:
                Enumerator en = new Enumerator(tag, info.Project, ctags_output);
                if (!info.Enumerators.Contains(en))
                {
                    info.Enumerators.Add(en);
                }
                break;

            case TagKind.ExternalVariable:
                break;

            case TagKind.Function:
                Function f = new Function(tag, info.Project, ctags_output);
                if (!info.Functions.Contains(f))
                {
                    info.Functions.Add(f);
                }
                break;

            case TagKind.Local:
                Local lo = new Local(tag, info.Project, ctags_output);
                if (!info.Locals.Contains(lo))
                {
                    info.Locals.Add(lo);
                }
                break;

            case TagKind.Macro:
                Macro m = new Macro(tag, info.Project);
                if (!info.Macros.Contains(m))
                {
                    info.Macros.Add(m);
                }
                break;

            case TagKind.Member:
                Member me = new Member(tag, info.Project, ctags_output);
                if (!info.Members.Contains(me))
                {
                    info.Members.Add(me);
                }
                break;

            case TagKind.Namespace:
                Namespace n = new Namespace(tag, info.Project, ctags_output);
                if (!info.Namespaces.Contains(n))
                {
                    info.Namespaces.Add(n);
                }
                break;

            case TagKind.Prototype:
                Function fu = new Function(tag, info.Project, ctags_output);
                if (!info.Functions.Contains(fu))
                {
                    info.Functions.Add(fu);
                }
                break;

            case TagKind.Structure:
                Structure s = new Structure(tag, info.Project, ctags_output);
                if (!info.Structures.Contains(s))
                {
                    info.Structures.Add(s);
                }
                break;

            case TagKind.Typedef:
                Typedef t = new Typedef(tag, info.Project, ctags_output);
                if (!info.Typedefs.Contains(t))
                {
                    info.Typedefs.Add(t);
                }
                break;

            case TagKind.Union:
                Union u = new Union(tag, info.Project, ctags_output);
                if (!info.Unions.Contains(u))
                {
                    info.Unions.Add(u);
                }
                break;

            case TagKind.Variable:
                Variable v = new Variable(tag, info.Project);
                if (!info.Variables.Contains(v))
                {
                    info.Variables.Add(v);
                }
                break;

            default:
                break;
            }
        }
Esempio n. 8
0
 protected abstract IEnumerable <string> GetTags(FileInformation fileInfo);
Esempio n. 9
0
		protected abstract IEnumerable<string> GetTags (FileInformation fileInfo);