Example #1
0
        private void FetchSourceDetails()
        {
            var importId = ImportToolkit.SearchImportInfo(PartItem);

            if (importId == null || String.IsNullOrEmpty(importId.Distributor))
            {
                HasDistributor = false;
                return;
            }

            HasDistributor = true;
            Distributor    = importId.Distributor;

            if (!Config.Manager.EnableViewItemSource)
            {
                HasSource = false;
                return;
            }

            var source = SourceLocator.GetSourceByLocation(importId.SourceLocation);

            HasSource = SourceInvoker.IsInvokable(source, PartItem.SourceArgument);
            if (HasSource)
            {
                InvokeSource.ExecuteAction = () => SourceInvoker.Invoke(source, PartItem.SourceArgument);
            }
        }
Example #2
0
        /*
         * Create a new TransformerException from a message and a Locator.
         *
         * <p>This constructor is especially useful when an application is
         * creating its own exception from within a DocumentHandler
         * callback.</p>
         *
         * @param message The error or warning message.
         * @param locator The locator object for the error or warning.
         */
        public TransformerException(String message, SourceLocator locator) :

            base(message)
        {
            this.containedException = null;
            this.locator            = locator;
        }
Example #3
0
        /*
         * Create a new TransformerException wrapping an existing exception.
         *
         * @param e The exception to be wrapped.
         */
        public TransformerException(java.lang.Throwable e) :

            base(e.toString())
        {
            this.containedException = e;
            this.locator            = null;
        }
Example #4
0
        /*
         * Create a new TransformerException.
         *
         * @param message The error or warning message.
         */
        public TransformerException(String message) :

            base(message)
        {
            this.containedException = null;
            this.locator            = null;
        }
Example #5
0
        private static readonly String m_newline = Environment.NewLine;         //$NON-NLS-1$

        /// <param name="name">filename in "basepath;package;filename" format
        /// </param>
        public DModule(SourceLocator sourceLocator, int id, int bitmap, String name, String script)
        {
            // If the caller gave us the script text, then we will create m_script
            // now.  But if the caller gave us an empty string, then we won't bother
            // looking for a disk file until someone actually asks for it.
            if (script != null && script.Length > 0)
            {
                m_script        = new ScriptText(script);
                m_gotRealScript = true;
            }

            NameParser nameParser = new NameParser(name);

            m_sourceLocator  = sourceLocator;
            m_rawName        = name;
            m_basePath       = nameParser.BasePath;       // may be null
            m_bitmap         = bitmap;
            m_id             = id;
            m_shortName      = generateShortName(nameParser);
            m_path           = generatePath(nameParser);
            m_line2Offset    = new System.Collections.ArrayList();
            m_line2Func      = new System.Collections.ArrayList();
            m_func2FirstLine = new System.Collections.Hashtable();
            m_func2LastLine  = new System.Collections.Hashtable();
            m_packageName    = nameParser.Package;
            m_gotAllFncNames = false;
        }
Example #6
0
        /*
         * Wrap an existing exception in a TransformerException.
         *
         * @param message The error or warning message, or null to
         *                use the message from the embedded exception.
         * @param locator The locator object for the error or warning.
         * @param e Any exception
         */
        public TransformerException(String message, SourceLocator locator,
                                    java.lang.Throwable e) :

            base(message)
        {
            this.containedException = e;
            this.locator            = locator;
        }
Example #7
0
        /*
         * Wrap an existing exception in a TransformerException.
         *
         * <p>This is used for throwing processor exceptions before
         * the processing has started.</p>
         *
         * @param message The error or warning message, or null to
         *                use the message from the embedded exception.
         * @param e Any exception
         */
        public TransformerException(String message, java.lang.Throwable e) :

            base(((message == null) || (message.length() == 0))
              ? e.toString()
              : message)
        {
            this.containedException = e;
            this.locator            = null;
        }
        /// <summary>
        ///     Inspect the specified location in the XML.
        /// </summary>
        /// <param name="position">
        ///     The location's position.
        /// </param>
        /// <returns>
        ///     An <see cref="SourceLocation"/> representing the result of the inspection.
        /// </returns>
        public SourceLocation Inspect(Position position)
        {
            if (position == null)
            {
                throw new ArgumentNullException(nameof(position));
            }

            return(SourceLocator.Inspect(position));
        }
        /// <summary>
        ///     Update the project in-memory state.
        /// </summary>
        /// <param name="xml">
        ///     The project XML.
        /// </param>
        public virtual void Update(string xml)
        {
            if (xml == null)
            {
                throw new ArgumentNullException(nameof(xml));
            }

            ClearDiagnostics();

            SourcePositions = new TextPositions(xml);
            SourceLocator   = new SourceLocator(SourcePositions);
            IsDirty         = true;

            bool loaded = TryLoadProject();
        }
Example #10
0
        private string CreateTempFile()
        {
            var target     = SourceLocator.GetTargetLocation(Location);
            var fileEntity = Context.Default.EmbeddedBlobs.FirstOrDefault(f => f.Name == target);

            if (fileEntity == null)
            {
                throw new FileNotFoundException();
            }

            var tempFilePath = Path.GetTempFileName();

            System.IO.File.WriteAllBytes(tempFilePath, fileEntity.Data);

            return(tempFilePath);
        }
Example #11
0
        public bool IsInvokable(ISource source, string arguments)
        {
            var sourcePath = SourceLocator.GetTargetLocation(source.Location);

            if (SourceLocator.IsLocalPathLocation(source.Location))
            {
                return(File.Exists(sourcePath));
            }

            if (SourceLocator.IsFileEntityLocation(source.Location))
            {
                using (var context = new Context())
                {
                    return(context.EmbeddedBlobs.Any(b => b.Name == sourcePath));
                }
            }

            throw new NotImplementedException(@"Source location " + source.Location + " not implemented yet.");
        }
        /// <summary>
        ///     Load and parse the project.
        /// </summary>
        /// <param name="cancellationToken">
        ///     An optional <see cref="CancellationToken"/> that can be used to cancel the operation.
        /// </param>
        /// <returns>
        ///     A task representing the load operation.
        /// </returns>
        public virtual async Task Load(CancellationToken cancellationToken = default(CancellationToken))
        {
            ClearDiagnostics();

            SourcePositions = null;
            SourceLocator   = null;

            string xml;

            using (StreamReader reader = ProjectFile.OpenText())
            {
                xml = await reader.ReadToEndAsync();
            }
            SourcePositions = new TextPositions(xml);
            SourceLocator   = new SourceLocator(SourcePositions);

            IsDirty = false;

            bool loaded = TryLoadProject();
        }
Example #13
0
 public FetchedPackage Fetch(string source)
 {
     try {
         if (File.Exists(Path.GetFullPath(source)))
         {
             return(new FetchedPackage(Path.GetFullPath(source), false));
         }
         var package = new SourceLocator(_token, _sourcePrioritization).GetPackage(source);
         if (package != null)
         {
             source = Path.Combine(Path.GetTempPath(), DateTime.Now.Ticks.ToString() + Path.GetFileName(package.Package));
             if (download(package.Package, source))
             {
                 return(new FetchedPackage(source, true));
             }
         }
     } catch (Exception ex) {
         Logger.Write(ex);
     }
     return(null);
 }
		/// <summary>
		/// Wrap an existing exception in a TransformerException.
		/// </summary>
		public TransformerException(string @message, SourceLocator @locator, Throwable @e)
		{
		}
Example #15
0
 /*
  * Method setLocator sets an instance of a SourceLocator
  * object that specifies where an error occurred.
  *
  * @param location A SourceLocator object, or null to clear the location.
  */
 public void setLocator(SourceLocator location)
 {
     locator = location;
 }
Example #16
0
 /// <summary>
 /// Wrap an existing exception in a TransformerException.
 /// </summary>
 public TransformerException(string @message, SourceLocator @locator, Throwable @e)
 {
 }
Example #17
0
		private static readonly String m_newline = Environment.NewLine; //$NON-NLS-1$
		
		/// <param name="name">filename in "basepath;package;filename" format
		/// </param>
		public DModule(SourceLocator sourceLocator, int id, int bitmap, String name, String script)
		{
			// If the caller gave us the script text, then we will create m_script
			// now.  But if the caller gave us an empty string, then we won't bother
			// looking for a disk file until someone actually asks for it.
			if (script != null && script.Length > 0)
			{
				m_script = new ScriptText(script);
				m_gotRealScript = true;
			}
			
			NameParser nameParser = new NameParser(name);
			
			m_sourceLocator = sourceLocator;
			m_rawName = name;
			m_basePath = nameParser.BasePath; // may be null
			m_bitmap = bitmap;
			m_id = id;
			m_shortName = generateShortName(nameParser);
			m_path = generatePath(nameParser);
			m_line2Offset = new System.Collections.ArrayList();
			m_line2Func = new System.Collections.ArrayList();
			m_func2FirstLine = new System.Collections.Hashtable();
			m_func2LastLine = new System.Collections.Hashtable();
			m_packageName = nameParser.Package;
			m_gotAllFncNames = false;
		}
Example #18
0
 /// <summary>
 /// Create a new TransformerException from a message and a Locator.
 /// </summary>
 public TransformerException(string @message, SourceLocator @locator)
 {
 }
Example #19
0
 /**
  * Wrap an existing exception in a TransformerException.
  *
  * <p>This is used for throwing processor exceptions before
  * the processing has started.</p>
  *
  * @param message The error or warning message, or null to
  *                use the message from the embedded exception.
  * @param e Any exception
  */
 public TransformerException(String message, java.lang.Throwable e)
     : base(((message == null) || (message.length() == 0))
       ? e.toString()
       : message)
 {
     this.containedException = e;
     this.locator            = null;
 }
Example #20
0
		public const String SCOPE_CHAIN_MARKER = "$scopechain"; //$NON-NLS-1$
		
		public DManager()
		{
			m_parms = new System.Collections.Hashtable();
			m_source = new IntMap();
			m_breakpoints = new System.Collections.ArrayList();
			m_values = new IntMap();
			m_previousValues = new IntMap();
			m_frames = new System.Collections.ArrayList();
			m_previousFrames = new System.Collections.ArrayList();
			m_swfInfo = new System.Collections.ArrayList();
			m_watchpoints = new System.Collections.ArrayList();
			m_event = new System.Collections.ArrayList();
			m_suspendInfo = null;
			m_sourceLocator = null;
			
			m_lastInGetVariable = null;
			m_attachChildren = true;
			m_squelchEnabled = false;
			m_lastConstantPool = null;
			m_playerVersion = - 1; // -1 => unknown
		}
Example #21
0
 /**
  * Create a new TransformerException.
  *
  * @param message The error or warning message.
  */
 public TransformerException(String message)
     : base(message)
 {
     this.containedException = null;
     this.locator            = null;
 }
Example #22
0
 /**
  * Create a new TransformerException wrapping an existing exception.
  *
  * @param e The exception to be wrapped.
  */
 public TransformerException(java.lang.Throwable e)
     : base(e.toString())
 {
     this.containedException = e;
     this.locator            = null;
 }
		/// <summary>
		/// Method setLocator sets an instance of a SourceLocator
		/// object that specifies where an error occured.
		/// </summary>
		public void setLocator(SourceLocator @location)
		{
		}
Example #24
0
 private string LocationString(SourceLocator sourceLocator)
 {
     return(sourceLocator == null
         ? $"In '{this.StylesheetPath}'."
         : $"At line '{sourceLocator.getLineNumber()}', column '{sourceLocator.getColumnNumber()}' of '{sourceLocator.getSystemId()}'.");
 }
Example #25
0
 /**
  * Create a new TransformerException from a message and a Locator.
  *
  * <p>This constructor is especially useful when an application is
  * creating its own exception from within a DocumentHandler
  * callback.</p>
  *
  * @param message The error or warning message.
  * @param locator The locator object for the error or warning.
  */
 public TransformerException(String message, SourceLocator locator)
     : base(message)
 {
     this.containedException = null;
     this.locator            = locator;
 }
		/// <summary>
		/// Create a new TransformerException from a message and a Locator.
		/// </summary>
		public TransformerException(string @message, SourceLocator @locator)
		{
		}
Example #27
0
 /// <summary>
 /// Method setLocator sets an instance of a SourceLocator
 /// object that specifies where an error occured.
 /// </summary>
 public void setLocator(SourceLocator @location)
 {
 }
Example #28
0
 /**
  * Wrap an existing exception in a TransformerException.
  *
  * @param message The error or warning message, or null to
  *                use the message from the embedded exception.
  * @param locator The locator object for the error or warning.
  * @param e Any exception
  */
 public TransformerException(String message, SourceLocator locator,
                         java.lang.Throwable e)
     : base(message)
 {
     this.containedException = e;
     this.locator            = locator;
 }
Example #29
0
 public void Click()
 {
     BeforeClick?.Invoke(this, SourceLocator.ToString());
     SourceElement.Click();
     AfterClick?.Invoke(this, SourceLocator.ToString());
 }
Example #30
0
        private void sourceCommands(string[] args)
        {
            var locator = new SourceLocator(_token, _sourcePrioritization);

            if (args.Length == 1)
            {
                locator
                .GetSources().ToList()
                .ForEach(x =>
                         Console.WriteLine(x.Name + " - " + x.Origin));
                return;
            }
            var useGlobal = globalSpecified(ref args);
            var path      = locator.GetLocalDir();

            if (useGlobal)
            {
                path = locator.GetGlobalDir();
            }
            if (args.Length == 4 && args[1] == "add")
            {
                if (path == null)
                {
                    printError("Config point is not initialized");
                    return;
                }
                var name    = args[2];
                var sources = locator.GetSourcesFrom(path);
                if (sources.Any(x => x.Name == name))
                {
                    printError("There is already a source named " + name);
                    return;
                }
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }
                var destination = Path.Combine(path, name + ".source");
                download(args[3], destination);
                if (!File.Exists(destination))
                {
                    printError("Failed while downloading source file " + args[3]);
                }
                _dispatch(string.Format("event|builtin package src added \"{0}\" \"{1}\"", name, destination));
                return;
            }
            if (args.Length == 3 && args[1] == "rm")
            {
                var name   = args[2];
                var source =
                    locator
                    .GetSources()
                    .FirstOrDefault(x => x.Name == name);
                if (source == null)
                {
                    printError("There is no package source named " + name);
                    return;
                }
                File.Delete(source.Path);
                _dispatch(string.Format("event|builtin package src removed \"{0}\" \"{1}\"", name, source.Path));
                return;
            }
            if (args.Length > 1 && args[1] == "update")
            {
                string name = null;
                if (args.Length > 2)
                {
                    name = args[2];
                }
                var sources =
                    locator
                    .GetSources()
                    .Where(x => name == null || x.Name == name);
                if (sources.Count() == 0)
                {
                    printError("There are no package sources to update");
                    return;
                }
                foreach (var source in sources)
                {
                    _dispatch("downloading " + source.Origin);
                    if (!download(source.Origin, source.Path))
                    {
                        printError("Failed to download source file " + source.Origin);
                    }
                    else
                    {
                        _dispatch(string.Format("event|builtin package src updated \"{0}\" \"{1}\"", source.Name, source.Path));
                    }
                }
                return;
            }
            if (args.Length > 1 && args[1] == "list")
            {
                var    os   = getOS();
                string name = null;
                if (args.Length > 2)
                {
                    name = args[2];
                }
                var sources =
                    locator
                    .GetSources()
                    .Where(x => name == null || x.Name == name);
                foreach (var source in sources)
                {
                    _dispatch("Packages in " + source.Name);
                    var sourcePackages = source.Packages.Where(x => x.OS.Contains(os)).OrderBy(x => x.Name);
                    foreach (var package in sourcePackages)
                    {
                        _dispatch("    " + package.ToString());
                    }
                }
            }
        }
Example #31
0
 /**
  * Method setLocator sets an instance of a SourceLocator
  * object that specifies where an error occurred.
  *
  * @param location A SourceLocator object, or null to clear the location.
  */
 public void setLocator(SourceLocator location)
 {
     locator = location;
 }