/// <summary>
        /// Generates the final output from a set of intermediates.
        /// </summary>
        /// <param name="intermediates">Intermediates that provide data to be generated.</param>
        /// <param name="outputPath">Path for output file to be generated.</param>
        public override void Generate(IEnumerable <Intermediate> intermediates, string outputPath)
        {
            NugetManifest manifest = new NugetManifest(this);

            manifest.ProcessIntermediates(intermediates);
            if (this.EncounteredError)
            {
                return;
            }

            manifest.Validate(this.ValidationErrorHandler);
            if (this.EncounteredError)
            {
                string tempPath = Path.GetTempFileName();
                this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.SavedManifest(tempPath), null, 0, 0));

                this.SaveManifest(manifest, tempPath);
                return;
            }

            FileTransfer packageTransfer = FileTransfer.Create(null, Path.GetTempFileName(), outputPath, "NugetPackage", true);

            using (Package package = Package.Open(packageTransfer.Source, FileMode.Create))
            {
                // Add all the manifest files.
                foreach (PackageFile file in manifest.Files)
                {
                    this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.CompressFile(file.SourcePath), file.File.LineNumber));

                    using (Stream fileStream = File.Open(file.SourcePath, FileMode.Open, FileAccess.Read, FileShare.Read))
                    {
                        PackagePart part = package.CreatePart(new Uri(file.PartUri, UriKind.Relative), file.MimeType, CompressionOption.Maximum);
                        this.SaveStreamToPart(fileStream, part);
                    }
                }

                var manifestUri = new Uri(String.Concat("/", manifest.Name, ".nuspec"), UriKind.Relative);

                // Create the manifest relationship
                package.CreateRelationship(manifestUri, TargetMode.Internal, "http://schemas.microsoft.com/packaging/2010/07/manifest");

                // Save the manifest to the package.
                using (Stream manifestStream = manifest.GetStream())
                {
                    PackagePart part = package.CreatePart(manifestUri, "application/octet", CompressionOption.Maximum);
                    this.SaveStreamToPart(manifestStream, part);
                }

                package.PackageProperties.Creator        = manifest.Manufacturer;
                package.PackageProperties.Description    = manifest.Description;
                package.PackageProperties.Identifier     = manifest.Name;
                package.PackageProperties.Version        = manifest.Version;
                package.PackageProperties.Language       = manifest.Language;
                package.PackageProperties.Keywords       = manifest.Tags;
                package.PackageProperties.Title          = manifest.DisplayName;
                package.PackageProperties.LastModifiedBy = "WiX Toolset v#.#.#.#";
            }

            FileTransfer.ExecuteTransfer(this, packageTransfer);
        }
コード例 #2
0
            public static void PostProcess(ref CompilerMessage message)
            {
                if (!(message.message.Contains("CS1069") || message.message.Contains("CS1070")))
                {
                    return;
                }

                var match = messageRegex.Match(message.message);

                if (!match.Success)
                {
                    return;
                }

                var index = message.message.IndexOf("Consider adding a reference to that assembly.");

                if (index != -1)
                {
                    message.message = message.message.Substring(0, index);
                }

                var moduleName = match.Groups[1].Value;

                message.message += $"Enable the built in package '{GetNiceDisplayNameForModule(moduleName)}' in the Package Manager window to fix this error.";
            }
コード例 #3
0
        public MatrisBase <object> Head(MatrisBase <object> df,
                                        int n = 5)
        {
            if (!df.IsValid())
            {
                throw new Exception(CompilerMessage.DF_INVALID_SIZE);
            }

            n = Math.Min(n, df.Row);
            if (n <= 0 || df.Row < n)
            {
                throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("satır", 1, df.Row));
            }

            return(df.Row == n
                ? df is Dataframe ? ((Dataframe)df.Copy()) : df.Copy()
                : df is Dataframe dataframe
                    ? new Dataframe(dataframe[new Range(0, n)],
                                    dataframe.Delimiter,
                                    dataframe.NewLine,
                                    null,
                                    Dataframe.GetCopyOfLabels(dataframe.GetColLabels()),
                                    dataframe.GetRowSettings().Copy(),
                                    dataframe.GetColSettings().Copy())
                    : new MatrisBase <object>(df[new Range(0, n)]));
        }
コード例 #4
0
 public static void PostProcess(ref CompilerMessage message)
 {
     if (message.message.Contains("CS8357"))
     {
         message.message = $"Deterministic compilation failed. You can disable Deterministic builds in Player Settings\n{message.message}";
     }
 }
コード例 #5
0
 public MatrisBase <object> Get(MatrisBase <object> A,
                                int i,
                                int j,
                                int based = 0)
 {
     return(!A.IsValid()
         ? throw new Exception(CompilerMessage.MAT_INVALID_SIZE)
         : i - based < 0 || i - based >= A.Row
         ? throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("satır", based, A.Row - 1))
         : j - based < 0 || j - based >= A.Col
         ? throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("sütun", based, A.Col - 1))
         : A is Dataframe df
             ? new Dataframe(new List <List <object> >()
     {
         new List <object>()
         {
             A[r: i - based, c: j - based]
         }
     },
                             df.Delimiter,
                             df.NewLine,
                             null,
                             null,
                             df.GetRowSettings().Copy(),
                             df.GetColSettings().Copy())
             : new MatrisBase <object>(new List <List <object> >()
     {
         new List <object>()
         {
             A[r: i - based, c: j - based]
         }
     }));
 }
コード例 #6
0
        public MatrisBase <object> Set(MatrisBase <object> A,
                                       int i,
                                       int j,
                                       float value,
                                       int based = 0)
        {
            if (!A.IsValid())
            {
                throw new Exception(CompilerMessage.MAT_INVALID_SIZE);
            }
            if (i - based < 0 || i - based >= A.Row)
            {
                throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("satır", based, A.Row - 1));
            }
            if (j - based < 0 || j - based >= A.Col)
            {
                throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("sütun", based, A.Col - 1));
            }

            List <List <object> > newlis = A is Dataframe ? ((Dataframe)A.Copy()).GetValues() : A.Copy().GetValues();

            newlis[i - based][j - based] = (dynamic)value;

            return(A is Dataframe df
                ? new Dataframe(newlis,
                                df.Delimiter,
                                df.NewLine,
                                Dataframe.GetCopyOfLabels(df.GetRowLabels()),
                                Dataframe.GetCopyOfLabels(df.GetColLabels()),
                                df.GetRowSettings().Copy(),
                                df.GetColSettings().Copy())
                : new MatrisBase <object>(newlis));
        }
コード例 #7
0
        static SnapshotSpan ToSnapshotSpan(ITextSnapshot currentSnapshot, CompilerMessage msg, ITextSnapshot snapshot)
        {
            var nSpan = msg.Location.Span;
            var span  = new Span(nSpan.StartPos, nSpan.Length);

            return(new SnapshotSpan(snapshot, span).TranslateTo(currentSnapshot, SpanTrackingMode.EdgeExclusive));
        }
コード例 #8
0
ファイル: FileModel.cs プロジェクト: tralivali1234/nitra
        public FileModel(FileId id, ITextBuffer textBuffer, ServerModel server, Dispatcher dispatcher, IVsHierarchy hierarchy, string fullPath)
        {
            Hierarchy   = hierarchy;
            FullPath    = fullPath;
            Ext         = Path.GetExtension(fullPath).ToLowerInvariant();
            Id          = id;
            Server      = server;
            _textBuffer = textBuffer;

            var snapshot = textBuffer.CurrentSnapshot;
            var empty    = new CompilerMessage[0];

            CompilerMessages          = new CompilerMessage[KindCount][] { empty, empty, empty };
            CompilerMessagesSnapshots = new ITextSnapshot[KindCount] {
                snapshot, snapshot, snapshot
            };
            _errorListProviders = new ErrorListProvider[KindCount] {
                null, null, null
            };

            server.Client.ResponseMap[id] = msg => dispatcher.BeginInvoke(DispatcherPriority.Normal,
                                                                          new Action <AsyncServerMessage>(msg2 => Response(msg2)), msg);

            server.Add(this);

            textBuffer.Changed += TextBuffer_Changed;
        }
コード例 #9
0
 internal void Verify(FrontendCompiler context, PackageItem parentItem)
 {
     if (String.IsNullOrEmpty(this.Name))
     {
         context.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredAttribute(this.typeName, "Name"), parentItem));
     }
 }
コード例 #10
0
 internal void Verify(FrontendCompiler context, PackageItem parentItem)
 {
     if (this.Name == BackgroundTaskType.Invalid)
     {
         context.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredAttribute("AdditionalTask", "Name"), parentItem));
     }
 }
コード例 #11
0
        /// <summary>
        /// Removes the destination for a file transfer.
        /// </summary>
        /// <param name="backend">Compiler backend that generated the transfer.</param>
        /// <param name="transfers">File transfers destination to remove.</param>
        private static void RemoveDestination(BackendCompiler backend, FileTransfer transfer)
        {
            if (File.Exists(transfer.Destination))
            {
                backend.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RemovingDestinationFile(transfer.Destination), transfer.LineNumber));

                // try to ensure the file is not read-only
                FileAttributes attributes = File.GetAttributes(transfer.Destination);
                try
                {
                    File.SetAttributes(transfer.Destination, attributes & ~FileAttributes.ReadOnly);
                }
                catch (ArgumentException ae) // thrown for unauthorized access errors
                {
                    throw new CompilerException(new CompilerMessageEventArgs(CompilerMessage.CannotTransferFile(transfer.Source, transfer.Destination), transfer.LineNumber), ae);
                }

                // try to delete the file
                try
                {
                    File.Delete(transfer.Destination);
                }
                catch (IOException ioe)
                {
                    throw new CompilerException(new CompilerMessageEventArgs(CompilerMessage.CannotTransferFile(transfer.Source, transfer.Destination), transfer.LineNumber), ioe);
                }
            }
            else // no idea what just happened, bail
            {
                //throw;
            }
        }
コード例 #12
0
        /// <summary>
        /// Create and save a matrix from given special class with given arguments and name
        /// </summary>
        public async Task OnPostAddMatrixSpecial()
        {
            if (_frontService.CheckCmdDate(HttpContext.Session.Get <DateTime>(SessionLastCommandDate)))
            {
                DateTime LastCmdDate = DateTime.Now;

                Dictionary <string, string> reqdict = new Dictionary <string, string>();
                await _utils.ReadAndDecodeRequest(Request.Body, Encoding.Default, IgnoredParams, reqdict);

                if (reqdict.ContainsKey(MatrisNameParam) && reqdict.ContainsKey(MatrisSpecialFuncParam) && reqdict.ContainsKey(MatrisSpecialArgsParam))
                {
                    Dictionary <string, MatrisBase <dynamic> > _dict = HttpContext.Session.GetMatrixDict(SessionMatrisDict, SessionSeedDict);

                    if (_dict.ContainsKey(reqdict[MatrisNameParam]))
                    {
                        HttpContext.Session.Set(SessionLastCommandDate, LastCmdDate);
                        using CommandMessage msg = new CommandMessage(CompilerMessage.MAT_NAME_ALREADY_EXISTS(reqdict[MatrisNameParam]), CommandState.WARNING);
                        HttpContext.Session.SetLastMsg(
                            SessionLastMessage,
                            msg
                            );
                        return;
                    }
                    else if (HttpContext.Session.GetDfSettings(SessionDfSettings).ContainsKey(reqdict[MatrisNameParam]))
                    {
                        HttpContext.Session.Set(SessionLastCommandDate, LastCmdDate);
                        using CommandMessage msg = new CommandMessage(CompilerMessage.DF_NAME_ALREADY_EXISTS(reqdict[MatrisNameParam]), CommandState.WARNING);
                        HttpContext.Session.SetLastMsg(
                            SessionLastMessage,
                            msg
                            );
                        return;
                    }

                    string actualFuncName = reqdict[MatrisSpecialFuncParam][1..reqdict[MatrisSpecialFuncParam].IndexOf("(", StringComparison.CurrentCulture)];
コード例 #13
0
        private object Instantiate(List <object> items, string path, Dictionary <string, string> namespaces, StatementNode node)
        {
            object item = null;

            if (node.Statement.StatementType == StatementType.Use)
            {
                if (node.Statement.Tokens[1].TokenType != ParserTokenType.NamespacePrefixDeclaration)
                {
                    this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.ExpectedToken("namespace prefix declaration", node.Statement.Tokens[1].Value), path, node.Statement.Range));
                    return(null);
                }

                string prefix = node.Statement.Tokens[1].Value;
                string typeNamespace;
                if (!this.TypeCache.TryGetNamespaceByPrefix(prefix, out typeNamespace))
                {
                    this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.UnknownNamespacePrefix(prefix), path, node.Statement.Range));
                    return(null);
                }

                namespaces.Add(prefix, typeNamespace);
            }
            else if (node.Statement.StatementType == StatementType.Object || node.Statement.StatementType == StatementType.ObjectStart)
            {
                item = this.InstantiateObject(items, path, namespaces, node);
            }
            else // ignorable stuff.
            {
                Debug.Assert(node.Children.Count == 0);
            }

            return(item);
        }
コード例 #14
0
ファイル: File.cs プロジェクト: lukaswinzenried/WixCustBa
        protected override void OnResolveBegin(FrontendCompiler context)
        {
            if (String.IsNullOrEmpty(this.Name) && String.IsNullOrEmpty(this.Source))
            {
                context.OnMessage(new CompilerMessageEventArgs(CompilerMessage.FileMissingNameAndSource(), this));
            }
            else if (String.IsNullOrEmpty(this.Name) || this.Name.EndsWith("\\", StringComparison.Ordinal))
            {
                this.Name = IO.Path.Combine(this.Name ?? String.Empty, IO.Path.GetFileName(this.Source));
            }

            // TODO: error if name ends with "\".

            base.OnResolveBegin(context);

            // TODO: error if name is empty.

            if (String.IsNullOrEmpty(this.Source))
            {
                // TODO: walk the parent tree to see if a source is available.

                this.Source = IO.Path.Combine(this.ParentRelativePathFromName ?? String.Empty, this.Name);
            }
            else if (this.Source.EndsWith("\\", StringComparison.Ordinal))
            {
                this.Source = IO.Path.Combine(this.Source, this.ParentRelativePathFromName ?? String.Empty, this.Name);
            }
        }
コード例 #15
0
        public MatrisBase <object> MinorMatris(MatrisBase <object> A,
                                               int row,
                                               int col,
                                               int based = 0)
        {
            if (!A.IsSquare())
            {
                throw new Exception(CompilerMessage.MAT_NOT_SQUARE);
            }

            CompilerUtils.AssertMatrixValsAreNumbers(A);

            List <List <object> > newlis = new List <List <object> >();
            List <List <object> > vals   = A.GetValues();

            row -= based;
            col -= based;

            if (row < 0 || row >= A.Row)
            {
                throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("satır", based, A.Row - based));
            }

            if (col < 0 || col >= A.Col)
            {
                throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("sütun", based, A.Col - based));
            }

            int rowindex = 0;

            for (int i = 0; i < row; i++)
            {
                newlis.Add(new List <object>());
                for (int j = 0; j < col; j++)
                {
                    newlis[rowindex].Add(vals[i][j]);
                }
                for (int j = col + 1; j < A.Col; j++)
                {
                    newlis[rowindex].Add(vals[i][j]);
                }
                rowindex++;
            }

            for (int i = row + 1; i < A.Row; i++)
            {
                newlis.Add(new List <object>());
                for (int j = 0; j < col; j++)
                {
                    newlis[rowindex].Add(vals[i][j]);
                }
                for (int j = col + 1; j < A.Col; j++)
                {
                    newlis[rowindex].Add(vals[i][j]);
                }
                rowindex++;
            }

            return(new MatrisBase <object>(newlis));
        }
コード例 #16
0
        private Dictionary <string, string> GetObjectNamespaces(string path, Dictionary <string, string> namespaces, StatementNode node)
        {
            Dictionary <string, string> newNamespaces = null;

            for (int i = 0; i < node.Statement.Tokens.Count; ++i)
            {
                string declaredPrefix = String.Empty;
                if (node.Statement.Tokens[i].TokenType == ParserTokenType.NamespacePrefixDeclaration)
                {
                    declaredPrefix = node.Statement.Tokens[i].Value;
                    ++i;

                    if (node.Statement.Tokens[i].TokenType != ParserTokenType.NamespaceDeclaration)
                    {
                        this.OnMessage(new CompilerMessageEventArgs(CompilerMessage.ExpectedToken("namespace declaration", node.Statement.Tokens[i].Value), path, node.Statement.Range));
                        break;
                    }
                }

                if (node.Statement.Tokens[i].TokenType == ParserTokenType.NamespaceDeclaration)
                {
                    if (newNamespaces == null)
                    {
                        newNamespaces = new Dictionary <string, string>(namespaces);
                    }

                    newNamespaces[declaredPrefix] = node.Statement.Tokens[i].Value;
                }
            }

            return((newNamespaces == null) ? namespaces : newNamespaces);
        }
コード例 #17
0
        public NitraError(CompilerMessage compilerMessage)
        {
            _compilerMessage = compilerMessage;

            var loc       = _compilerMessage.Location;
            var nitraFile = (XXLanguageXXFile)loc.Source.File;
            var span      = loc.Span;

            NitraFile = nitraFile;
            var doc = nitraFile.Document;

            // ReSharper don't show message for empty span
            if (span.IsEmpty)
            {
                if (span.StartPos > 0)
                {
                    span = new NSpan(span.StartPos - 1, span.EndPos);
                }
                else if (span.EndPos < doc.GetTextLength())
                {
                    span = new NSpan(span.StartPos, span.EndPos + 1);
                }
            }
            DocumentRange = new DocumentRange(doc, new TextRange(span.StartPos, span.EndPos));
        }
コード例 #18
0
        private TagSpan <ErrorTag> TagSpanFromMessage(CompilerMessage msg, ITextSnapshot snapshot)
        {
            var span         = new Span(msg.Location.StartPos, msg.Location.Length);
            var snapshotSpan = new SnapshotSpan(snapshot, span);
            var errorTag     = new ErrorTag(TranslateErrorType(msg.Type), msg.Text);

            return(new TagSpan <ErrorTag>(snapshotSpan, errorTag));
        }
        protected static void AssertSourceGenerationFailure(CompilerMessage[] compilerMessages, string expectedErrorMessage)
        {
            Assert.IsTrue(compilerMessages.Length == 1);

            CompilerMessage compilerMessage = compilerMessages.Single();

            Assert.AreEqual(compilerMessage.type, CompilerMessageType.Error);
            Assert.IsTrue(compilerMessage.message.Contains(expectedErrorMessage));
        }
コード例 #20
0
ファイル: Group.cs プロジェクト: lukaswinzenried/WixCustBa
        protected override void OnResolveBegin(FrontendCompiler context)
        {
            base.OnResolveBegin(context);

            if (String.IsNullOrEmpty(this.Id))
            {
                context.OnMessage(new CompilerMessageEventArgs(CompilerMessage.GroupMissingId(), this));
            }
        }
コード例 #21
0
 public MatrisBase <object> Row(MatrisBase <object> A,
                                int i,
                                int based = 0)
 {
     return(!A.IsValid()
         ? throw new Exception(CompilerMessage.MAT_INVALID_SIZE)
         : i - based < 0 || i - based >= A.Row
         ? throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("satır", based, A.Row - 1))
         : A.RowMat(i, based));
 }
コード例 #22
0
        private PackageItem SetTarget(FrontendCompiler context, PackageItem item)
        {
            if (this.targetProperty.GetValue(this.targetItem, null) != null)
            {
                context.OnMessage(new CompilerMessageEventArgs(CompilerMessage.OverwritingImplicitProperty(this.targetProperty.Name, this.Lookup), this.targetItem));
            }

            this.targetProperty.SetValue(this.targetItem, item, null);
            return(item);
        }
        public void CanCreateLogEntryMessage()
        {
            var message = CompilerMessage.Create("Error", "message", "stacktrace", 123, "fileName");

            Assert.That(message["type"], Is.EqualTo(CompilerMessage.MessageType));
            Assert.That(message["severity"], Is.EqualTo("Error"));
            Assert.That(message["stacktrace"], Is.EqualTo("stacktrace"));
            Assert.That(message["line"], Is.EqualTo(123));
            Assert.That(message["file"], Is.EqualTo("fileName"));
        }
コード例 #24
0
 public MatrisBase <object> Col(MatrisBase <object> A,
                                int j,
                                int based = 0)
 {
     return(!A.IsValid()
         ? throw new Exception(CompilerMessage.MAT_INVALID_SIZE)
         : j - based < 0 || j - based >= A.Col
         ? throw new Exception(CompilerMessage.MAT_OUT_OF_RANGE_INDEX("sütun", based, A.Col - 1))
         : A.ColMat(j, based));
 }
コード例 #25
0
        internal static void RunManagedProgram(string exe, string args, string workingDirectory, CompilerOutputParserBase parser)
        {
            Program   program;
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            if (Application.platform == RuntimePlatform.WindowsEditor)
            {
                ProcessStartInfo si = new ProcessStartInfo {
                    Arguments      = args,
                    CreateNoWindow = true,
                    FileName       = exe
                };
                program = new Program(si);
            }
            else
            {
                program = new ManagedProgram(MonoInstallationFinder.GetMonoInstallation("MonoBleedingEdge"), "4.0", exe, args);
            }
            using (program)
            {
                program.GetProcessStartInfo().WorkingDirectory = workingDirectory;
                program.Start();
                program.WaitForExit();
                stopwatch.Stop();
                Console.WriteLine("{0} exited after {1} ms.", exe, stopwatch.ElapsedMilliseconds);
                if (program.ExitCode != 0)
                {
                    if (parser != null)
                    {
                        string[] errorOutput    = program.GetErrorOutput();
                        string[] standardOutput = program.GetStandardOutput();
                        IEnumerator <CompilerMessage> enumerator = parser.Parse(errorOutput, standardOutput, true).GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                CompilerMessage current = enumerator.Current;
                                Debug.LogPlayerBuildError(current.message, current.file, current.line, current.column);
                            }
                        }
                        finally
                        {
                            if (enumerator == null)
                            {
                            }
                            enumerator.Dispose();
                        }
                    }
                    Debug.LogError("Failed running " + exe + " " + args + "\n\n" + program.GetAllOutput());
                    throw new Exception(string.Format("{0} did not run properly!", exe));
                }
            }
        }
コード例 #26
0
 protected static void FailOnError(CompilerMessage message)
 {
     if (message.MessageLevel >= MessageLevel.Error)
     {
         Assert.Fail(message.ToString());
     }
     else
     {
         TestContext.WriteLine(message.ToString());
     }
 }
コード例 #27
0
ファイル: BaseCommand.cs プロジェクト: HarryMills-UL/Element
        private void Log(CompilerMessage message)
        {
            var msg = LogMessagesAsJson ? JsonConvert.SerializeObject(message) : message.ToString();

            if (message.MessageLevel >= MessageLevel.Error)
            {
                Console.Error.WriteLine(msg);
            }
            else
            {
                Console.WriteLine(msg);
            }
        }
コード例 #28
0
            private static CustomScriptAssembly CustomScriptAssemblyFor(CompilerMessage m, EditorCompilation editorCompilation)
            {
                if (editorCompilation == null)
                {
                    return(null);
                }

                var file = new NPath(m.file).MakeAbsolute(editorCompilation.projectDirectory);

                return(editorCompilation
                       .GetCustomScriptAssemblies()
                       .FirstOrDefault(c => file.IsChildOf(new NPath(c.PathPrefix).MakeAbsolute())));
            }
コード例 #29
0
        protected override void OnResolveBegin(FrontendCompiler context)
        {
            base.OnResolveBegin(context);

            if (this.SupportedFileExtensions.Count == 0)
            {
                context.OnMessage(new CompilerMessageEventArgs(CompilerMessage.RequiredElement("FileSavePicker", "FileExtension"), this));
            }
            else
            {
                this.SupportedFileExtensions.ForEach(df => df.Verify(context, this));
            }
        }
コード例 #30
0
        public MatrisBase <dynamic> Range(float start,
                                          float end,
                                          float interval = 1,
                                          int axis       = 0,
                                          int digits     = 6)
        {
            if (start > end)
            {
                throw new Exception(CompilerMessage.MAT_START_END_ORDER);
            }
            if (interval > end - start)
            {
                throw new Exception(CompilerMessage.MAT_INTERVAL_INVALID);
            }

            if (axis != 0 && axis != 1)
            {
                throw new Exception(CompilerMessage.ARG_INVALID_VALUE("axis", "Satır vektör için 0, sütun vekör için 1 olmalı."));
            }

            int amount = Math.Min((int)((end - start) / interval), axis == 0 ? (int)MatrisLimits.forRows : (int)MatrisLimits.forCols);

            if (Math.Abs(end - (start + (amount * interval))) > 1e-7)
            {
                throw new Exception(CompilerMessage.MAT_INTERVAL_EXCESS);
            }

            List <List <dynamic> > vals = new List <List <dynamic> >();

            if (axis == 0)
            {
                vals.Add(new List <dynamic>());

                for (int i = 0; i <= amount; i++)
                {
                    vals[0].Add(Math.Round(start + (interval * i), digits));
                }
            }
            else
            {
                for (int i = 0; i <= amount; i++)
                {
                    vals.Add(new List <dynamic>()
                    {
                        Math.Round(start + (interval * i), digits)
                    });
                }
            }

            return(new MatrisBase <dynamic>(vals));
        }
コード例 #31
0
ファイル: FileModel.cs プロジェクト: JetBrains/Nitra
    public FileModel(FileId id, ITextBuffer textBuffer, Server server, Dispatcher dispatcher, IVsHierarchy hierarchy, string fullPath)
    {
      Hierarchy   = hierarchy;
      FullPath    = fullPath;
      Id          = id;
      Server      = server;
      _textBuffer = textBuffer;

      var snapshot = textBuffer.CurrentSnapshot;
      var empty = new CompilerMessage[0];
      CompilerMessages          = new CompilerMessage[KindCount][] { empty,    empty,    empty };
      CompilerMessagesSnapshots = new ITextSnapshot[KindCount]     { snapshot, snapshot, snapshot };
      _errorListProviders       = new ErrorListProvider[KindCount] { null,     null,     null};


      server.Client.ResponseMap[id] = msg => dispatcher.BeginInvoke(DispatcherPriority.Normal,
        new Action<AsyncServerMessage>(msg2 => Response(msg2)), msg);

      server.Client.Send(new ClientMessage.FileActivated(id));
      textBuffer.Changed += TextBuffer_Changed;
    }
コード例 #32
0
ファイル: NemerleErrorTask.cs プロジェクト: vestild/nemerle
        public NemerleErrorTask(ProjectInfo projectInfo, CompilerMessage compilerMessage)
        {
            ErrorHelper.ThrowIsNull(projectInfo,     "projectInfo");
            ErrorHelper.ThrowIsNull(compilerMessage, "compilerMessage");

            ProjectInfo     = projectInfo;
            CompilerMessage = compilerMessage;

            var loc = compilerMessage.Location;

            if (loc.FileIndex != 0)
            {
                var span = Utils.SpanFromLocation(loc);
                Document = loc.File;
                Line     = span.iStartLine;
                Column   = span.iStartIndex;
            }

            Text = compilerMessage.Msg;

            switch (compilerMessage.Kind)
            {
                case MessageKind.Error:
                    Priority = TaskPriority.High;
                    ErrorCategory = TaskErrorCategory.Error;
                    break;
                case MessageKind.Warning:
                    Priority = TaskPriority.Normal;
                    ErrorCategory = TaskErrorCategory.Warning;
                    break;
                default:
                    Priority = TaskPriority.Low;
                    ErrorCategory = TaskErrorCategory.Message;
                    break;
            }

            Category = TaskCategory.BuildCompile;
            HierarchyItem = projectInfo.ProjectNode.InteropSafeHierarchy;
        }
コード例 #33
0
        /// <summary>
        /// Converts data reported by the compiler into a readable string.
        /// </summary>
        /// <param name="msg">Message data as reported by the compiler.</param>
        /// <returns>Readable message string.</returns>
        private string FormMessage(CompilerMessage msg)
        {
            StringBuilder sb = new StringBuilder();

            if (msg.type == CompilerMessageType.Error)
                sb.AppendLine("Compiler error: " + msg.message);
            else
                sb.AppendLine("Compiler warning: " + msg.message);

            sb.AppendLine("\tin " + msg.file + "[" + msg.line + ":" + msg.column + "]");

            return sb.ToString();
        }
コード例 #34
0
ファイル: FileModel.cs プロジェクト: JetBrains/Nitra
    private void UpdateCompilerMessages(int index, CompilerMessage[] messages, int version)
    {
      var snapshot = _textBuffer.CurrentSnapshot;

      if (snapshot.Version.VersionNumber != version + 1)
        return;

      CompilerMessages[index]          = messages;
      CompilerMessagesSnapshots[index] = snapshot;

      CompilerMessagesTagger tegger;
      if (_textBuffer.Properties.TryGetProperty<CompilerMessagesTagger>(Constants.CompilerMessagesTaggerKey, out tegger))
        tegger.Update();

      var errorListProvider = _errorListProviders[index];
      var noTasks = errorListProvider == null || errorListProvider.Tasks.Count == 0;
      if (!(messages.Length == 0 && noTasks))
      {
        if (errorListProvider == null)
          _errorListProviders[index] = errorListProvider = new ErrorListProvider(Server.ServiceProvider);
        errorListProvider.SuspendRefresh();
        try
        {
          var tasks = errorListProvider.Tasks;
          tasks.Clear();
          foreach (var msg in messages)
          {
            var startPos = msg.Location.Span.StartPos;
            if (startPos > snapshot.Length)
            {
              continue;
            }
            var line = snapshot.GetLineFromPosition(startPos);
            var col = startPos - line.Start.Position;
            var task = new ErrorTask()
            {
              Text = msg.Text,
              Category = TaskCategory.CodeSense,
              ErrorCategory = ConvertMessageType(msg.Type),
              Priority = TaskPriority.High,
              HierarchyItem = Hierarchy,
              Line = line.LineNumber,
              Column = col,
              Document = FullPath,
            };

            task.Navigate += Task_Navigate;

            errorListProvider.Tasks.Add(task);
          }
        }
        finally { errorListProvider.ResumeRefresh(); }
      }
    }
コード例 #35
0
ファイル: NemerleErrorTask.cs プロジェクト: vestild/nemerle
 public NemerleErrorTask(ProjectInfo projectInfo, CompilerMessage compilerMessage, EventHandler navigateHandler)
     : this(projectInfo, compilerMessage)
 {
     Navigate += navigateHandler;
 }
コード例 #36
0
ファイル: ErrorListPresenter.cs プロジェクト: derigel23/Nitra
    private static TaskErrorCategory TranslateErrorCategory(CompilerMessage error)
    {
      switch (error.Type)
      {
        case CompilerMessageType.FatalError:
        case CompilerMessageType.Error:
          return TaskErrorCategory.Error;
        case CompilerMessageType.Warning:
          return TaskErrorCategory.Warning;
        case CompilerMessageType.Hint:
          return TaskErrorCategory.Message;
      }

      return TaskErrorCategory.Error;
    }
コード例 #37
0
    public NitraError(CompilerMessage compilerMessage)
    {
      _compilerMessage = compilerMessage;
      
      var loc        = _compilerMessage.Location;
      var nitraFile = (XXLanguageXXFile)loc.Source.File;
      var span       = loc.Span;

      NitraFile = nitraFile;
      var doc = nitraFile.Document;
      // ReSharper don't show message for empty span
      if (span.IsEmpty)
      {
        if (span.StartPos > 0)
          span = new NSpan(span.StartPos - 1, span.EndPos);
        else if (span.EndPos < doc.GetTextLength())
          span = new NSpan(span.StartPos, span.EndPos + 1);
      }
      DocumentRange = new DocumentRange(doc, new TextRange(span.StartPos, span.EndPos));
    }