示例#1
0
        static public JadeCore.Workspace.IWorkspace Read(FilePath path, IFileService fileService)
        {
            WorkspaceType xml;
            XmlSerializer serializer = new XmlSerializer(typeof(WorkspaceType));
            TextReader tr = new StreamReader(path.Str);
            try
            {                
                xml = (WorkspaceType)serializer.Deserialize(tr);                
            }
            finally
            {
                tr.Close();
                tr.Dispose();
            }

            JadeCore.Workspace.IWorkspace result = new JadeCore.Workspace.Workspace(xml.Name, path);
            foreach (FolderType f in xml.Folders)
            {
                result.AddFolder(MakeFolder(result, result.Directory, f, fileService));
            }
            foreach (ProjectType p in xml.Projects)
            {
                result.AddProject(MakeProject(result.Directory, p, fileService));
            }

            return result;
        }
示例#2
0
        static private JadeCore.Project.IProject Read(string name, StreamReader reader, FilePath projectPath, IFileService fileService)
        {
            IProject project = new JadeCore.Project.Project(name, projectPath);

            while (!reader.EndOfStream)
            {
                string line = reader.ReadLine();
                Match match = Regex.Match(line, _compileLineRegex);
                if (match.Success)
                {
                    string itemPath = match.Groups[1].Value;
                    itemPath = JadeUtils.IO.PathUtils.CombinePaths(projectPath.Directory, itemPath);
                    project.AddItem(null, new JadeCore.Project.FileItem(fileService.MakeFileHandle(itemPath)));
                    continue;
                }
                match = Regex.Match(line, _includeLineRegex);
                if (match.Success)
                {
                    string itemPath = match.Groups[1].Value;
                    itemPath = JadeUtils.IO.PathUtils.CombinePaths(projectPath.Directory, itemPath);
                    project.AddItem(null, new JadeCore.Project.FileItem(fileService.MakeFileHandle(itemPath)));
                    continue;
                }
            }            
            return project;
        }
示例#3
0
文件: Workspace.cs 项目: JadeHub/Jade
 public NewWorkspace(string name, FilePath path)
 {
     Name = name;
     Path = path;
     _projects = new Collections.Observable.List<Project.IProject>();
     _groups = new Collections.Observable.List<string>();
 }
示例#4
0
文件: Workspace.cs 项目: JadeHub/Jade
 public Workspace(string name, FilePath path)
 {
     _name = name;
     _path = path;
     _rootFolder = new Folder(_name, this);
     _allProjects = new Collections.Observable.List<Project.IProject>();
 }
示例#5
0
 public UInt64 GetFileVersion(FilePath path)
 {
     ParseFile pf = null;
     if (_files.TryGetValue(path, out pf))
         return pf.Version;
     return 0;
 }
示例#6
0
文件: ParseJob.cs 项目: JadeHub/Jade
        private UInt64 _docVersion; //this is the version number at the time of job creation, when the job executes the version number may be greater

        public ParseJob(FilePath path, UInt64 version, string[] compilerArgs, CppCodeBrowser.IProjectIndex index)
        {
            _path = path;
            _docVersion = version;
            _compilerArgs = compilerArgs;
            _index = index;
        }
示例#7
0
 public FindAllReferences(DocumentViewModel vm, FilePath path, CppCodeBrowser.IProjectIndex index)
     : base(vm)
 {
     ViewModel.CaretOffsetChanged += ViewModelCaretOffsetChanged;
     _path = path;
     _index = index;            
 }
示例#8
0
 public InspectCursorCommand(DocumentViewModel vm, FilePath path, CppCodeBrowser.IProjectIndex index)
     : base(vm)
 {
     ViewModel.CaretOffsetChanged += ViewModelCaretOffsetChanged;
     _path = path;
     _index = index;
     RaiseCanExecuteChangedEvent();
 }
示例#9
0
 public TranslationUnit FindTranslationUnit(FilePath path)
 {
     lock (_lock)
     {
         if (_parseResults.ContainsKey(path))
             return _parseResults[path].TranslationUnit;
     }
     return null;
 }
示例#10
0
文件: Project.cs 项目: JadeHub/Jade
 public Project(string name, FilePath path)
 {
     _path = path;
     _name = name;            
     _items = new Dictionary<string, IItem>();
     _folders = new List<IFolder>();
     _allSourceFiles = new Collections.Observable.List<IFileItem>();
     _index = new CppCodeBrowser.ProjectIndex();
 }
示例#11
0
文件: IMap.cs 项目: JadeHub/Jade
 private IFileMap GetFileMap(FilePath path)
 {
     IFileMap result = null;
     if(_fileMappings.TryGetValue(path, out result) == false)
     {
         result = new FileMap(path);
         _fileMappings.Add(path, result);
     }
     return result;
 }
示例#12
0
文件: Folder.cs 项目: JadeHub/Jade
 public IFileItem FindFileItem(FilePath path)
 {
     foreach (IItem item in _items)
     {
         if(item is IFileItem && (item as IFileItem).Path == path)
         {
             return item as IFileItem;
         }
     }
     return null;
 }
示例#13
0
 public IFileHandle MakeFileHandle(FilePath path)
 {
     IFileHandle file = _handles.Get(path);
     if (file == null)
     {
         file = new FileHandle(this, path);
         _handles.Add(file);
         OnFileCreated(file);
     }
     return file;
 }
示例#14
0
 public ParseResult(IProjectIndex index, FilePath path, IEnumerable<ParseFile> files, LibClang.TranslationUnit tu)
 {
     _index = index;
     _path = path;
     _translationUnit = tu;
     _files = new Dictionary<FilePath, ParseFile>();
     foreach(ParseFile pf in files)
     {
         _files.Add(pf.Path, pf);
     }
 }
示例#15
0
        //private CppCodeBrowser.IProjectFile _indexItem;

        public SourceFileJumpToCommand(DocumentViewModel vm, FilePath path, CppCodeBrowser.IProjectIndex index)
            : base(vm)
        {
            ViewModel.CaretOffsetChanged += ViewModelCaretOffsetChanged;

            _path = path;
            _index = index;
            _jumpToBrowser = new CppCodeBrowser.JumpToBrowser(_index);
           // _indexItem = _index.FindProjectItem(_path);
            RaiseCanExecuteChangedEvent();
        }
示例#16
0
        public SearchHighlighter(FilePath path, Highlighting.Highlighter highlighter)
        {
            _highlighter = highlighter;
            _path = path;
            _searchController = JadeCore.Services.Provider.SearchController;

            ((INotifyCollectionChanged)_searchController.Searches).CollectionChanged += Searchs_CollectionChanged;
            _ranges = new HashSet<Highlighting.IHighlightedRange>();
            
            if(_searchController.Current != null)
            {
                OnNewSearch(_searchController.Current);
            }
        }
示例#17
0
        public static JadeCore.Project.IProject Read(string name, FilePath path, IFileService fileService)
        {
            FilePath filterFilePath = FilePath.Make(path.Str + ".filters");

            if(filterFilePath.Exists)
            {
                ProjectFiltersFileReader reader = new ProjectFiltersFileReader(name, filterFilePath, path, fileService);
                return reader.ReadFiltersFile();
            }
            else
            {
                using (StreamReader reader = CreateFileReader(path))
                {
                    return Read(name, reader, path, fileService);
                }
            }
        }
示例#18
0
文件: Parser.cs 项目: JadeHub/Jade
        public static ParseResult Parse(IProjectIndex index, FilePath path, string[] compilerArgs, IUnsavedFileProvider unsavedFiles)
        {
            TranslationUnit tu = new TranslationUnit(index.LibClangIndex, path.Str);

            //Take a snapshot of the source
            IEnumerable<ParseFile> files = unsavedFiles.UnsavedFiles;
            List<Tuple<string, string>> unsavedList = new List<Tuple<string, string>>();
            foreach (var i in files)
            {
                unsavedList.Add(new Tuple<string, string>(i.Path.Str, i.Content));
            }
            if (tu.Parse(compilerArgs, unsavedList) == false)
            {
                tu.Dispose();
                return null;
            }
            return new ParseResult(index, path, files, tu); ;
        }
示例#19
0
文件: Project.cs 项目: JadeHub/Jade
        private IFileItem FindFileItem(JadeCore.Project.IFolder folder, FilePath path)
        {
            foreach(IItem item in folder.Items)
            {
                if(item is FileItem)
                {
                    if ((item as FileItem).Path == path)
                        return item as FileItem;
                }
            }

            foreach(IFolder child in folder.Folders)
            {
                IFileItem result = FindFileItem(child, path);
                if (result != null)
                    return result;
            }

            return null;
        }
示例#20
0
文件: Project.cs 项目: JadeHub/Jade
 public IFileItem FindFileItem(FilePath path)
 {
     return FindFileItem(this, path);
 }
示例#21
0
 public bool Remove(FilePath path)
 {
     return _handles.Remove(path);
 }
示例#22
0
 public HeaderFile(FilePath path)
 {
     Path = path;
     _sourceFiles = new HashSet<ISourceFile>();
 }
示例#23
0
文件: Workspace.cs 项目: JadeHub/Jade
 public bool ContainsFile(FilePath path)
 {
     return FindProjectForFile(path) != null;
 }
示例#24
0
 public FileHandle(IFileService service, FilePath path)
 {
     _service = service;
     _path = path;
     _observers = new List<IFileObserver>();
 }
示例#25
0
文件: Workspace.cs 项目: JadeHub/Jade
 public JadeCore.Project.IProject FindProjectForFile(FilePath path)
 {
     return _rootFolder.FindProjectForFile(path);
 }
示例#26
0
 public IFileHandle Get(FilePath path)
 {
     IFileHandle handle;
     return _handles.TryGetValue(path, out handle) ? handle : null;
 }
示例#27
0
        public void OpenWorkspace(FilePath path)
        {
            if (CloseWorkspace() == false)
            {
                return;
            }

            try
            {
                if(path.Exists == false)
                {
                    return;
                }

                string extention = path.Extention.ToLower();
                if (extention == ".sln")
                {
                    _workspace = JadeCore.Persistence.Workspace.VisualStudioImport.Reader.Read(path, JadeCore.Services.Provider.FileService);
                }
                else if (extention == ".jws")
                {
                    _workspace = JadeCore.Persistence.Workspace.Reader.Read(path, JadeCore.Services.Provider.FileService);
                }
                _recentFiles.Add(path.Str);
                OnWorkspaceChanged(WorkspaceChangeOperation.Opened);
            }
            catch(Exception)
            {
                _workspace = null;
                throw;
            }
        }
示例#28
0
文件: Folder.cs 项目: JadeHub/Jade
        public JadeCore.Project.IProject FindProjectForFile(FilePath path)
        {
            JadeCore.Project.IProject result = null;
            foreach (IItem item in Items)
            {
                if (item is Project.IProject)
                {
                    if((item as Project.IProject).FindFileItem(path) != null)
                        return item as Project.IProject;
                }
            }

            foreach(IFolder folder in Folders)
            {
                result = folder.FindProjectForFile(path);
                if (result != null)
                    return result;
            }

            return result;
        }
示例#29
0
 public ResultProvider(FilePath sourceFile, CppCodeBrowser.IProjectIndex index, CppCodeBrowser.IUnsavedFileProvider unsavedFiles)
 {
     _index = index;
     _sourceFile = sourceFile;
     _unsavedFiles = unsavedFiles;
 }
示例#30
0
 public bool Contains(FilePath path)
 {
     return _handles.ContainsKey(path);
 }