Beispiel #1
0
        /// <summary>
        /// Classpathes & classes cache initialisation
        /// </summary>
        public override void BuildClassPath()
        {
            ReleaseClasspath();
            started = true;
            if (loomSettings == null)
            {
                throw new Exception("BuildClassPath() must be overridden");
            }
            if (contextSetup == null)
            {
                contextSetup          = new ContextSetupInfos();
                contextSetup.Lang     = settings.LanguageId;
                contextSetup.Platform = "loom";
                contextSetup.Version  = "1.0";
            }

            // external version definition
            platform     = contextSetup.Platform;
            majorVersion = 1;
            minorVersion = 0;
            ParseVersion(contextSetup.Version, ref majorVersion, ref minorVersion);

            string cpCheck = contextSetup.Classpath != null?
                             String.Join(";", contextSetup.Classpath).Replace('\\', '/') : "";

            //
            // Class pathes
            //
            classPath = new List <PathModel>();

            // SDK
            string compiler = PluginBase.CurrentProject != null && PluginBase.CurrentProject.CurrentSDK != null
                ? PluginBase.CurrentProject.CurrentSDK
                : loomSettings.GetDefaultSDK().Path;

            char   S       = Path.DirectorySeparatorChar;
            string sdkLibs = compiler + S + "libs";

            if (majorVersion > 0 && !String.IsNullOrEmpty(sdkLibs) && Directory.Exists(sdkLibs))
            {
                foreach (string loomlib in Directory.GetFiles(sdkLibs, "*.loomlib"))
                {
                    AddPath(loomlib);
                }
            }

            // add external pathes
            List <PathModel> initCP = classPath;

            classPath = new List <PathModel>();
            if (contextSetup.Classpath != null)
            {
                foreach (string cpath in contextSetup.Classpath)
                {
                    AddPath(cpath.Trim());
                }
            }

            // add library
            AddPath(PathHelper.LibraryDir + S + "LOOM" + S + "classes");
            // add user pathes from settings
            if (settings.UserClasspath != null && settings.UserClasspath.Length > 0)
            {
                foreach (string cpath in settings.UserClasspath)
                {
                    AddPath(cpath.Trim());
                }
            }

            // add initial pathes
            foreach (PathModel mpath in initCP)
            {
                AddPath(mpath);
            }

            // parse top-level elements
            InitTopLevelElements();
            if (cFile != null)
            {
                UpdateTopLevelElements();
            }

            // add current temporaty path
            if (temporaryPath != null)
            {
                string tempPath = temporaryPath;
                temporaryPath = null;
                SetTemporaryPath(tempPath);
            }
            FinalizeClasspath();
        }