Beispiel #1
0
 public FunctionResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file, string name, int lineDefined, int lastLineDefined)
     : base(plugin, file, lineDefined)
 {
     Name            = name;
     LineDefined     = lineDefined;
     LastLineDefined = lastLineDefined;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="language">Language error is in</param>
 /// <param name="file">File syntax error is in</param>
 /// <param name="line">Line number in file that syntax error is on</param>
 /// <param name="error">Syntax error description</param>
 public SledSyntaxCheckerEntry(ISledLanguagePlugin language, SledProjectFilesFileType file, int line, string error)
 {
     Language = language;
     File     = file;
     Line     = line;
     Error    = error;
 }
Beispiel #3
0
 public VariableResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file, string name, int line, int occurence, VariableResultType variableType)
     : base(plugin, file, line)
 {
     Name         = name;
     Occurence    = occurence;
     VariableType = variableType;
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="language">Language error is in</param>
 /// <param name="file">File syntax error is in</param>
 /// <param name="line">Line number in file that syntax error is on</param>
 /// <param name="error">Syntax error description</param>
 public SledSyntaxCheckerEntry(ISledLanguagePlugin language, SledProjectFilesFileType file, int line, string error)
 {
     Language = language;
     File = file;
     Line = line;
     Error = error;
 }
Beispiel #5
0
        /// <summary>
        /// Create a new project file or return a reference to one in the project if it already exists
        /// </summary>
        /// <param name="szAbsPath">Absolute path to file</param>
        /// <param name="bAlreadyInProject">Whether the project file already exists in the project</param>
        /// <param name="project">Project to aid in file creation</param>
        /// <returns>Project file</returns>
        public SledProjectFilesFileType CreateFrom(string szAbsPath, SledProjectFilesType project, out bool bAlreadyInProject)
        {
            // Check for existing
            var file = m_projectFilesFinderService.Get.Find(szAbsPath);

            if (file != null)
            {
                bAlreadyInProject = true;
                return(file);
            }

            // Create new
            file = SledProjectFilesFileType.Create(szAbsPath, project);
            SetupFile(file);

            // Check if matching open document
            ISledDocument sd;

            if (m_documentService.Get.IsOpen(new Uri(szAbsPath), out sd))
            {
                // Set references
                SetReferences(file, sd);
            }

            bAlreadyInProject = false;
            return(file);
        }
Beispiel #6
0
        private void SetupCompileAttribute(SledProjectFilesFileType file)
        {
            if (file == null)
            {
                return;
            }

            // Look for a SledLuaCompileAttributeType attribute in file.Attributes
            var iface = SledDomUtil.GetFirstAs <SledLuaCompileAttributeType, SledAttributeBaseType>(file.Attributes);

            // Files' attribute is already set up
            if (iface != null)
            {
                return;
            }

            var domNode = new DomNode(SledLuaSchema.SledLuaCompileAttributeType.Type);

            // Create new attribute
            var attr = domNode.As <SledLuaCompileAttributeType>();

            // Default values
            attr.Name    = m_luaLanguagePlugin.LanguageName;
            attr.Compile = true;

            // Add new attribute to file
            file.Attributes.Add(attr);
        }
 public SyntaxCheckerWorkItem(SledProjectFilesFileType file, SledSyntaxCheckerVerbosity verbosity, object userData, SledUtil.BoolWrapper shouldCancel)
 {
     m_file         = file;
     m_verbosity    = verbosity;
     m_userData     = userData;
     m_shouldCancel = shouldCancel;
     Errors         = new List <SledSyntaxCheckerEntry>();
 }
Beispiel #8
0
 public ParserWorkItem(SledProjectFilesFileType file, SledLanguageParserVerbosity verbosity, object userData, SledUtil.BoolWrapper shouldCancel)
 {
     m_file         = file;
     m_verbosity    = verbosity;
     m_userData     = userData;
     m_shouldCancel = shouldCancel;
     Results        = new List <SledLanguageParserResult>();
 }
        public IEnumerable<int> ValidBreakpointLineNumbers(SledProjectFilesFileType file)
        {
            List<int> lines;
            if (!m_validBreakpoints.TryGetValue(file, out lines))
                yield break;

            foreach (var line in lines)
                yield return line;
        }
Beispiel #10
0
        private void OpenProjectFile(SledProjectFilesFileType file)
        {
            var doc = m_project[file.Uri];

            if (doc != null)
            {
                ((DocumentAdapter)doc).SledDocument = file.SledDocument;
            }

            m_broker.DocumentOpened(doc);
        }
Beispiel #11
0
        private void SetupFile(SledProjectFilesFileType file)
        {
            // Assign language plugin (if any)
            file.LanguagePlugin = m_languagePluginService.Get.GetPluginForExtension(Path.GetExtension(file.Path));

            var project = file.Project ?? m_projectService.Get.ActiveProject;

            // Set Uri
            var absPath = SledUtil.GetAbsolutePath(file.Path, project.AssetDirectory);

            file.Uri = new Uri(absPath);
        }
Beispiel #12
0
        public IEnumerable <int> ValidBreakpointLineNumbers(SledProjectFilesFileType file)
        {
            List <int> lines;

            if (!m_validBreakpoints.TryGetValue(file, out lines))
            {
                yield break;
            }

            foreach (var line in lines)
            {
                yield return(line);
            }
        }
Beispiel #13
0
        private static DateTime GetDateTime(SledProjectFilesFileType file)
        {
            try
            {
                var dateTime = File.GetLastWriteTime(file.AbsolutePath);
                return(dateTime);
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "[SledProjectOpenFile] Exception " +
                    "obtaining file info for \"{0}\": {1}",
                    file.AbsolutePath, ex.Message);

                return(DateTime.Now);
            }
        }
Beispiel #14
0
        /// <summary>
        /// Create a new project file or return a reference to one in the project if it already exists
        /// </summary>
        /// <param name="sd">Open document</param>
        /// <param name="bAlreadyInProject">Whether the project file already exists in the project</param>
        /// <param name="project">Project to aid in file creation</param>
        /// <returns>Project file</returns>
        public SledProjectFilesFileType CreateFrom(ISledDocument sd, SledProjectFilesType project, out bool bAlreadyInProject)
        {
            // Check for existing
            var file = m_projectFilesFinderService.Get.Find(sd);

            if (file != null)
            {
                bAlreadyInProject = true;
                return(file);
            }

            // Create new
            file = SledProjectFilesFileType.Create(sd.Uri.LocalPath, project);
            SetupFile(file);

            // Set references
            SetReferences(file, sd);

            bAlreadyInProject = false;
            return(file);
        }
Beispiel #15
0
 public SledLuaVariableParserServiceEventArgs(SledProjectFilesFileType file, IEnumerable <SledLuaVariableParserService.Result> results)
 {
     File    = file;
     Results = new List <SledLuaVariableParserService.Result>(results);
 }
Beispiel #16
0
        /// <summary>
        /// Add file to project with specified folder
        /// </summary>
        /// <param name="absPath">Absolute path to file</param>
        /// <param name="folder">Folder to add the file to</param>
        /// <param name="file">Handle to file in project</param>
        /// <returns>True if file added (or already in the project) or false if not</returns>
        public bool AddFile(string absPath, SledProjectFilesFolderType folder, out SledProjectFilesFileType file)
        {
            file = m_projectFileFinderService.Get.Find(absPath);
            if (file != null)
                return true;

            var project = ActiveProject;

            // Create new project file (if possible)
            bool bAlreadyInProject;
            file = m_projectFilesUtilityService.Get.CreateFrom(absPath, project, out bAlreadyInProject);
            if (file == null)
                return false;

            if (bAlreadyInProject)
                return true;

            // Add to project (DOM will handle firing the event)
            if (folder == null)
                project.Files.Add(file);
            else
                folder.Files.Add(file);

            return true;
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="plugin">Language plugin</param>
 /// <param name="file">Project file</param>
 protected SledLanguageParserResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file)
 {
     Plugin = plugin;
     File = file;
 }
Beispiel #18
0
        private void OpenProjectFile(SledProjectFilesFileType file)
        {
            var doc = m_project[file.Uri];
            if (doc != null)
                ((DocumentAdapter)doc).SledDocument = file.SledDocument;

            m_broker.DocumentOpened(doc);
        }
 public ParserWorkItem(SledProjectFilesFileType file, SledLanguageParserVerbosity verbosity, object userData, SledUtil.BoolWrapper shouldCancel)
 {
     m_file = file;
     m_verbosity = verbosity;
     m_userData = userData;
     m_shouldCancel = shouldCancel;
     Results = new List<SledLanguageParserResult>();
 }
 public BreakpointResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file, int line)
     : base(plugin, file, line)
 {
 }
 public FunctionResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file, string name, int lineDefined, int lastLineDefined)
     : base(plugin, file, lineDefined)
 {
     Name = name;
     LineDefined = lineDefined;
     LastLineDefined = lastLineDefined;
 }
 public VariableResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file, string name, int line, int occurence, VariableResultType variableType)
     : base(plugin, file, line)
 {
     Name = name;
     Occurence = occurence;
     VariableType = variableType;
 }
 protected Result(ISledLanguagePlugin plugin, SledProjectFilesFileType file, int line)
     : base(plugin, file)
 {
     Line = line;
 }
Beispiel #24
0
 protected Result(ISledLanguagePlugin plugin, SledProjectFilesFileType file, int line)
     : base(plugin, file)
 {
     Line = line;
 }
 public SledLuaFunctionCursorWatcherServiceEventArgs(SledProjectFilesFileType file, SledLuaFunctionType function)
 {
     File     = file;
     Function = function;
 }
Beispiel #26
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="project">Project</param>
 /// <param name="file">File</param>
 /// <param name="oldPath">Old path (used when file path is changing)</param>
 /// <param name="newPath">New path (used when file path is changing)</param>
 public SledProjectServiceFileEventArgs(SledProjectFilesType project, SledProjectFilesFileType file, string oldPath, string newPath)
     : base(project)
 {
     File = file;
     OldPath = oldPath;
     NewPath = newPath;
 }
 public SledLuaVariableParserServiceEventArgs(SledProjectFilesFileType file, IEnumerable<SledLuaVariableParserService.Result> results)
 {
     File = file;
     Results = new List<SledLuaVariableParserService.Result>(results);
 }
Beispiel #28
0
 private static int CompareFiles(SledProjectFilesFileType file1, SledProjectFilesFileType file2)
 {
     return(string.Compare(file1.Name, file2.Name, StringComparison.CurrentCultureIgnoreCase));
 }
Beispiel #29
0
 private void CloseProjectFile(SledProjectFilesFileType file)
 {
     m_broker.DocumentClosed(m_project[file.Uri]);
 }
Beispiel #30
0
 private void CloseProjectFile(SledProjectFilesFileType file)
 {
     m_broker.DocumentClosed(m_project[file.Uri]);
 }
Beispiel #31
0
        private void RemoveBreakpoints(SledProjectFilesFileType file)
        {
            // Remove breakpoints in the file from the project
            // but leave the open document (if any) alone

            var needsSaving = file.Breakpoints.Count > 0;

            while (file.Breakpoints.Count > 0)
            {
                // Remove breakpoint from GUI (will fire event through Collection_Removing)
                file.Breakpoints.RemoveAt(0);
            }

            if (needsSaving)
                m_projectService.SaveSettings();
        }
Beispiel #32
0
 private static void SetReferences(SledProjectFilesFileType file, ISledDocument sd)
 {
     file.SledDocument  = sd;
     sd.SledProjectFile = file;
 }
Beispiel #33
0
 private static bool IsDuplicate(SledProjectFilesFileType file, int lineNumber)
 {
     return file.Breakpoints.Any(bp => bp.Line == lineNumber);
 }
Beispiel #34
0
 /// <summary>
 /// Add a breakpoint to a file
 /// </summary>
 /// <param name="file">File to add breakpoint to</param>
 /// <param name="lineNumber">Line number</param>
 public void AddBreakpoint(SledProjectFilesFileType file, int lineNumber)
 {
     AddBreakpoint(file, lineNumber, null, true, false);
 }
Beispiel #35
0
 /// <summary>
 /// Add a breakpoint to a file supplying a condition
 /// </summary>
 /// <param name="file">File to add breakpoint to</param>
 /// <param name="lineNumber">Line number</param>
 /// <param name="condition">Condition</param>
 /// <param name="bConditionResult">Whether condition evaluates to true or false</param>
 /// <param name="bUseFunctionEnvironment">Whether to use the current function's environment or _G when checking the breakpoint condition (if any)</param>
 public void AddBreakpoint(SledProjectFilesFileType file, int lineNumber, string condition, bool bConditionResult, bool bUseFunctionEnvironment)
 {
     SledProjectFilesBreakpointType breakpoint;
     AddBreakpoint(file, lineNumber, condition, bConditionResult, true, bUseFunctionEnvironment, out breakpoint);
 }
Beispiel #36
0
 /// <summary>
 /// Add file to project
 /// </summary>
 /// <param name="absPath">Absolute path to file</param>
 /// <param name="file">Handle to file in project</param>
 /// <returns>True if file added (or already in the project) or false if not</returns>
 public bool AddFile(string absPath, out SledProjectFilesFileType file)
 {
     return AddFile(absPath, null, out file);
 }
Beispiel #37
0
        /// <summary>
        /// Remove a breakpoint from a file
        /// </summary>
        /// <param name="file">File to remove breakpoint from</param>
        /// <param name="lineNumber">Line number</param>
        public void RemoveBreakpoint(SledProjectFilesFileType file, int lineNumber)
        {
            if (file == null)
                return;

            if (lineNumber < 0)
                return;

            var breakpoint = file.Breakpoints.FirstOrDefault(bp => bp.Line == lineNumber);
            if (breakpoint == null)
                return;

            file.Breakpoints.Remove(breakpoint);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="project">Project</param>
 /// <param name="file">File</param>
 public SledProjectServiceFileEventArgs(SledProjectFilesType project, SledProjectFilesFileType file)
     : this(project, file, string.Empty, string.Empty)
 {
 }
Beispiel #39
0
 public BreakpointResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file, int line)
     : base(plugin, file, line)
 {
 }
Beispiel #40
0
        private void AddBreakpoints(SledProjectFilesFileType file)
        {
            // Silently add breakpoints from the project to
            // the newly opened document

            if (m_bAddingOrRemoving)
                return;

            try
            {
                m_bAddingOrRemoving = true;

                var sd = file.SledDocument;
                if (sd == null)
                    return;

                var bpInvalids = new List<SledProjectFilesBreakpointType>();

                foreach (var bp in file.Breakpoints)
                {
                    if (sd.IsBreakpointSet(bp.Line))
                        continue;

                    if (!sd.IsValidLine(bp.Line))
                    {
                        bpInvalids.Add(bp);
                        continue;
                    }

                    sd.Editor.Breakpoint(bp.Line, true);
                    if (!sd.IsBreakpointSet(bp.Line))
                    {
                        bpInvalids.Add(bp);
                        continue;
                    }

                    var ibp = sd.Editor.GetBreakpoint(bp.Line);
                    ibp.Enabled = bp.Enabled;
                    ibp.Marker = bp.ConditionEnabled;
                    bp.Breakpoint = ibp;
                    bp.Refresh();

                    // Fire event
                    OnBreakpointSilentAdded(new SledBreakpointServiceBreakpointEventArgs(bp));
                }

                foreach (var bp in bpInvalids)
                {
                    bp.File.Breakpoints.Remove(bp);
                }

                sd.Control.Refresh();
            }
            finally
            {
                m_bAddingOrRemoving = false;
            }
        }
Beispiel #41
0
        private static DateTime GetDateTime(SledProjectFilesFileType file)
        {
            try
            {
                var dateTime = File.GetLastWriteTime(file.AbsolutePath);
                return dateTime;
            }
            catch (Exception ex)
            {
                SledOutDevice.OutLine(
                    SledMessageType.Error,
                    "[SledProjectOpenFile] Exception " + 
                    "obtaining file info for \"{0}\": {1}",
                    file.AbsolutePath, ex.Message);

                return DateTime.Now;
            }
        }
Beispiel #42
0
 private static SledProjectFilesBreakpointType FindBreakpointInFile(SledProjectFilesFileType file, IBreakpoint ibp)
 {
     return file.Breakpoints.FirstOrDefault(bp => bp.Breakpoint == ibp);
 }
Beispiel #43
0
 private static int CompareFiles(SledProjectFilesFileType file1, SledProjectFilesFileType file2)
 {
     return string.Compare(file1.Name, file2.Name, StringComparison.CurrentCultureIgnoreCase);
 }
Beispiel #44
0
 public TempBpDetails(SledProjectFilesFileType file, int line, string condition, bool conditionResult, bool conditionEnabled, bool useFunctionEnvironment)
 {
     File = file;
     Line = line;
     Condition = condition;
     ConditionResult = conditionResult;
     ConditionEnabled = conditionEnabled;
     UseFunctionEnvironment = useFunctionEnvironment;
 }
 public SledLuaFunctionCursorWatcherServiceEventArgs(SledProjectFilesFileType file, SledLuaFunctionType function)
 {
     File = file;
     Function = function;
 }
Beispiel #46
0
 /// <summary>
 /// Add a breakpoint to a file supplying a condition
 /// </summary>
 /// <param name="file">File to add breakpoint to</param>
 /// <param name="lineNumber">Line number</param>
 /// <param name="condition">Condition</param>
 /// <param name="bConditionResult">Whether condition evaluates to true or false</param>
 public void AddBreakpoint(SledProjectFilesFileType file, int lineNumber, string condition, bool bConditionResult)
 {
     AddBreakpoint(file, lineNumber, condition, bConditionResult, false);
 }
Beispiel #47
0
        private void SetupCompileAttribute(SledProjectFilesFileType file)
        {
            if (file == null)
                return;

            // Look for a SledLuaCompileAttributeType attribute in file.Attributes
            var iface = SledDomUtil.GetFirstAs<SledLuaCompileAttributeType, SledAttributeBaseType>(file.Attributes);

            // Files' attribute is already set up
            if (iface != null)
                return;

            var domNode = new DomNode(SledLuaSchema.SledLuaCompileAttributeType.Type);

            // Create new attribute
            var attr = domNode.As<SledLuaCompileAttributeType>();

            // Default values
            attr.Name = m_luaLanguagePlugin.LanguageName;
            attr.Compile = true;

            // Add new attribute to file
            file.Attributes.Add(attr);
        }
Beispiel #48
0
        /// <summary>
        /// Add a breakpoint to a file supplying a condition
        /// </summary>
        /// <param name="file">File to add breakpoint to</param>
        /// <param name="lineNumber">Line number</param>
        /// <param name="condition">Condition</param>
        /// <param name="conditionResult">Whether condition evaluates to true or false</param>
        /// <param name="conditionEnabled">Whether the condition is enabled or not</param>
        /// <param name="useFunctionEnvironment">Whether to use the current function's environment or _G when checking the breakpoint condition (if any)</param>
        /// <param name="breakpoint">The breakpoint if it was added otherwise null</param>
        /// <returns>Whether the breakpoint was added or not</returns>
        public bool AddBreakpoint(SledProjectFilesFileType file, int lineNumber, string condition, bool conditionResult, bool conditionEnabled, bool useFunctionEnvironment, out SledProjectFilesBreakpointType breakpoint)
        {
            breakpoint = null;

            if (file == null)
                return false;

            // Can't add more than one breakpoint per line
            if (IsDuplicate(file, lineNumber))
                return false;

            // Breakpoint in the document (or none if document not open)
            IBreakpoint ibp = null;

            var sd = file.SledDocument;
            if (sd != null)
            {
                m_bAddingOrRemoving = true;

                // Add breakpoint to open document
                sd.Editor.Breakpoint(lineNumber, true);
                ibp = sd.Editor.GetBreakpoint(lineNumber);

                m_bAddingOrRemoving = false;
            }

            // Create project style breakpoint
            breakpoint = SledProjectFilesBreakpointType.Create(ibp);

            // set some properties in case the document isn't open and we don't have a real IBreakpoint yet
            if (ibp == null)
            {
                breakpoint.Line = lineNumber;
                breakpoint.Enabled = true;
            }

            // Setup condition if any
            if (!string.IsNullOrEmpty(condition))
            {
                breakpoint.Condition = condition;
                breakpoint.ConditionResult = conditionResult;
                breakpoint.ConditionEnabled = conditionEnabled;
                breakpoint.UseFunctionEnvironment = useFunctionEnvironment;

                // Draw breakpoint indicator in open document breakpoint
                if (ibp != null)
                    ibp.Marker = true;
            }

            // Add breakpoint to file finally
            file.Breakpoints.Add(breakpoint);
            
            return breakpoint != null;
        }
Beispiel #49
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="project">Project</param>
 /// <param name="file">File</param>
 public SledProjectServiceFileEventArgs(SledProjectFilesType project, SledProjectFilesFileType file)
     : this(project, file, string.Empty, string.Empty)
 {
 }
 public SyntaxCheckerWorkItem(SledProjectFilesFileType file, SledSyntaxCheckerVerbosity verbosity, object userData, SledUtil.BoolWrapper shouldCancel)
 {
     m_file = file;
     m_verbosity = verbosity;
     m_userData = userData;
     m_shouldCancel = shouldCancel;
     Errors = new List<SledSyntaxCheckerEntry>();
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="plugin">Language plugin</param>
 /// <param name="file">Project file</param>
 protected SledLanguageParserResult(ISledLanguagePlugin plugin, SledProjectFilesFileType file)
 {
     Plugin = plugin;
     File   = file;
 }