Ejemplo n.º 1
0
        private static List <IVsTaskItem> GetErrorListItems(IVsErrorList errorList, int expectedItems)
        {
            List <IVsTaskItem> allItems = new List <IVsTaskItem>();

            for (int i = 0; i < 10; i++)
            {
                allItems.Clear();
                IVsEnumTaskItems items;
                ErrorHandler.ThrowOnFailure(((IVsTaskList)errorList).EnumTaskItems(out items));

                IVsTaskItem[] taskItems = new IVsTaskItem[1];

                uint[] itemCnt = new uint[1];

                while (ErrorHandler.Succeeded(items.Next(1, taskItems, itemCnt)) && itemCnt[0] == 1)
                {
                    allItems.Add(taskItems[0]);
                }
                if (allItems.Count == expectedItems)
                {
                    break;
                }
                // give time for errors to process...
                System.Threading.Thread.Sleep(1000);
            }
            return(allItems);
        }
        // ------------------------------------------------------
        /// <summary>
        /// Brings the error list window to the front.
        /// </summary>
        public void BringErrorListToFront()
        {
            IVsErrorList errorList =
                (IVsErrorList)GetService(typeof(SVsErrorList));

            errorList.BringToFront();
        }
Ejemplo n.º 3
0
 public ErrorUnRegister(TaskProvider provider, IVsErrorList errorList, uint cookie, PythonProjectNode project, string filename)
 {
     _errorList = errorList;
     _cookie    = cookie;
     _project   = project;
     _filename  = filename;
     _provider  = provider;
 }
Ejemplo n.º 4
0
 public ErrorTaskProvider(IServiceProvider serviceProvider, IVsTaskList taskList, IErrorProviderFactory errorProvider)
     : base(serviceProvider, taskList, errorProvider)
 {
     if (taskList is IVsErrorList)
     {
         _errorList = taskList as IVsErrorList;
     }
 }
 protected virtual void AfterCodeGenerated(bool error)
 {
     if (error)
     {
         IVsErrorList errorList = ErrorList;
         if (errorList != null)
         {
             errorList.BringToFront();
             errorList.ForceShowErrors();
         }
     }
 }
Ejemplo n.º 6
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     try
     {
         _ivsSolution       = (IVsSolution)Package.GetGlobalService(typeof(IVsSolution));
         _ivsErrorList      = (IVsErrorList)Package.GetGlobalService(typeof(SVsErrorList));
         _errorListProvider = new ErrorListProvider(serviceProvider);
         _initialized       = true;
     }
     catch (Exception exception)
     {
         Log.Error($"Failed to initialize Error List. {exception.Message}");
     }
 }
Ejemplo n.º 7
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     try
     {
         _ivsSolution = (IVsSolution)Package.GetGlobalService(typeof (IVsSolution));
         _ivsErrorList = (IVsErrorList)Package.GetGlobalService(typeof (SVsErrorList));
         _errorListProvider = new ErrorListProvider(serviceProvider);
         _initialized = true;
     }
     catch (Exception exception)
     {
         Log.Error($"Failed to initialize Error List. {exception.Message}");
     }
 }
Ejemplo n.º 8
0
        /*
         * private void SetTargetNamespace()
         * {
         *  if (!string.IsNullOrEmpty(this.CodeFileNameSpace))
         *  {
         *      TargetNamespace = CodeFileNameSpace;
         *      return;
         *  }
         *
         *  DTE dte = Dte;
         *  if (dte == null)
         *      return;
         *  IEnumerable activeProjects = dte.ActiveSolutionProjects as IEnumerable;
         *  if (activeProjects == null)
         *      return;
         *  Project project = activeProjects.OfType<Project>().First();
         *  if (project == null)
         *      return;
         *  var defaultNamespace = project.Properties.Item("DefaultNamespace");
         *  if (defaultNamespace != null && defaultNamespace.Value is string)
         *  {
         *      string targetNamespace = (string)defaultNamespace.Value;
         *      string projectFolder = Path.GetDirectoryName(project.FullName);
         *      string sourceFileFolder = Path.GetDirectoryName(this.CodeFilePath);
         *      if (sourceFileFolder.StartsWith(sourceFileFolder, StringComparison.InvariantCultureIgnoreCase))
         *      {
         *          string extraFolders = sourceFileFolder.Substring(projectFolder.Length);
         *          if (extraFolders.Length > 0)
         *          {
         *              string[] parts = extraFolders.TrimStart('\\').Split('\\');
         *              targetNamespace += "." + string.Join(".",
         *                  parts.Select(p => p.ToIdentifier()).ToArray());
         *          }
         *          targetNamespace += extraFolders.Replace("\\", ".");
         *      }
         *      TargetNamespace = targetNamespace;
         *  }
         * }
         */

        protected override void AfterCodeGenerated(bool error)
        {
            base.AfterCodeGenerated(error);

            if (error)
            {
                IVsErrorList errorList = ErrorList;
                if (errorList != null)
                {
                    errorList.BringToFront();
                    errorList.ForceShowErrors();
                }
            }
        }
Ejemplo n.º 9
0
        public ProjectAnalyzer(IPythonInterpreter interpreter, IPythonInterpreterFactory factory, IErrorProviderFactory errorProvider, PythonProjectNode project = null)
        {
            _errorProvider = errorProvider;

            _queue         = new ParseQueue(this);
            _analysisQueue = new AnalysisQueue(this);

            _interpreterFactory = factory;
            _project            = project;

            _analysisState = new PythonAnalyzer(interpreter, factory.GetLanguageVersion());
            _projectFiles  = new Dictionary <string, IProjectEntry>(StringComparer.OrdinalIgnoreCase);

            if (PythonToolsPackage.Instance != null)
            {
                _errorList = (IVsErrorList)PythonToolsPackage.GetGlobalService(typeof(SVsErrorList));
            }
        }
Ejemplo n.º 10
0
 /// <include file='doc\TaskProvider.uex' path='docs/doc[@for="ErrorListProvider.Dispose1"]/*' />
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     this.errorList = null;
 }
Ejemplo n.º 11
0
 /// <include file='doc\TaskProvider.uex' path='docs/doc[@for="ErrorListProvider.Dispose1"]/*' />
 protected override void Dispose(bool disposing)
 {
     base.Dispose(disposing);
     this.errorList = null;
 }
Ejemplo n.º 12
0
        protected override byte[] GenerateCode(string inputFileName, string inputFileContent)
        {
            if (this.ShowWarningDialog())
            {
                return(new byte[0]);
            }
            base.SetWaitCursor();
            this.errors = false;
            this.encodingSetFromOutputDirective = false;
            this.outputEncoding = null;
            ITextTemplating textTemplating = this.TextTemplating;
            string          s = string.Empty;

            CallContext.LogicalSetData("NamespaceHint", base.FileNamespace);
            try
            {
                if (textTemplating == null)
                {
                    throw new InvalidOperationException(Resources.TextTemplatingUnavailable);
                }
                textTemplating.BeginErrorSession();
                IVsHierarchy service = base.GetService(typeof(IVsHierarchy)) as IVsHierarchy;
                s            = this.ProcessTemplate(inputFileName, inputFileContent, textTemplating, service);
                this.errors |= textTemplating.EndErrorSession();
                MarkProjectForTextTemplating(service);
            }
            finally
            {
                CallContext.FreeNamedDataSlot("NamespaceHint");
            }
            if (this.errors)
            {
                IVsErrorList errorList = base.ErrorList;
                if (errorList != null)
                {
                    try
                    {
                        errorList.BringToFront();
                        errorList.ForceShowErrors();
                    }
                    catch
                    {
                    }
                }
            }
            if (this.outputEncoding == null)
            {
                this.outputEncoding = EncodingHelper.GetEncoding(inputFileName);
            }
            if (this.outputEncoding == null)
            {
                this.outputEncoding = Encoding.UTF8;
            }
            byte[] bytes    = this.outputEncoding.GetBytes(s);
            byte[] preamble = this.outputEncoding.GetPreamble();
            if ((preamble != null) && (preamble.Length > 0))
            {
                bool flag2 = false;
                if (bytes.Length >= preamble.Length)
                {
                    flag2 = true;
                    for (int i = 0; i < preamble.Length; i++)
                    {
                        if (preamble[i] != bytes[i])
                        {
                            flag2 = false;
                            break;
                        }
                    }
                }
                if (!flag2)
                {
                    byte[] array = new byte[preamble.Length + bytes.Length];
                    preamble.CopyTo(array, 0);
                    bytes.CopyTo(array, preamble.Length);
                    bytes = array;
                }
            }
            return(bytes);
        }
Ejemplo n.º 13
0
        public object service()
        {
            IVsErrorList commandServices = Package.GetGlobalService((typeof(SVsErrorList))) as IVsErrorList;

            return(commandServices);
        }