Beispiel #1
0
            /// <summary>
            /// Gets a list of tokens from the IVsTextLines.
            /// </summary>
            /// <param name="lines">The IVsTextLines of the lines of source to parse.</param>
            /// <param name="service">The language service.</param>
            /// <returns>A list of tokens.</returns>
            public static List <FactTokenInfo> GetTokens(IVsTextLines lines, FactEditorLanguageService service)
            {
                Source source   = service.GetOrCreateSource(lines);
                string lineText = source.GetLine(0);

                // Get the scanner from the language service.
                IScanner scanner = service.GetScanner(lines);

                scanner.SetSource(lineText, 0);

                // Now use the scanner to parse the first line and build the list of the tokens.
                List <FactTokenInfo> tokens       = new List <FactTokenInfo>();
                FactTokenInfo        lastToken    = null;
                FactTokenInfo        currentToken = new FactTokenInfo();
                int state = 0;

                while (scanner.ScanTokenAndProvideInfoAboutIt(currentToken, ref state))
                {
                    if ((null != lastToken) && (currentToken.StartIndex > lastToken.EndIndex + 1))
                    {
                        tokens.Clear();
                    }
                    tokens.Add(currentToken);
                    lastToken    = currentToken;
                    currentToken = new FactTokenInfo();
                }

                return(tokens);
            }
Beispiel #2
0
        /// <summary>
        /// This is called by the package base class when our package is loaded. When devenv is run
        /// with the "/setup" command line switch it is not able to do a lot of the normal things,
        /// such as creating output windows and tool windows. Under normal circumstances our package
        /// isn't loaded when run with this switch. However, our package will be loaded when items
        /// are added to the toolbox, even when run with "/setup". To be safe we'll check for "setup"
        /// and we don't do anything interesting in MgdSetSite if we find it.
        /// </summary>
        protected sealed override void Initialize()
        {
            base.Initialize();

            // register the class designer editor factory
            RegisterEditorFactory(new ORMDesignerEditorFactory(this));

            if (!SetupMode)
            {
                ((IServiceContainer)this).AddService(typeof(ORMDesignerFontsAndColors), myFontAndColorService = new ORMDesignerFontsAndColors(this), true);

                FactEditorLanguageService managedLanguageService = new FactEditorLanguageService();
                managedLanguageService.SetSite(this);
                ((IServiceContainer)this).AddService(typeof(FactEditorLanguageService), managedLanguageService, true);

                // setup commands
                (myCommandSet = ORMDesignerDocView.CreateCommandSet(this)).Initialize();

                // Create managed tool windows
                AddToolWindow(typeof(ORMModelBrowserToolWindow));
                AddToolWindow(typeof(ORMReadingEditorToolWindow));
                AddToolWindow(typeof(ORMReferenceModeEditorToolWindow));
                AddToolWindow(typeof(ORMSamplePopulationToolWindow));
                AddToolWindow(typeof(ORMVerbalizationToolWindow));
                AddToolWindow(typeof(ORMDescriptionToolWindow));
                AddToolWindow(typeof(ORMNotesToolWindow));
                AddToolWindow(typeof(ORMContextWindow));
                AddToolWindow(typeof(ORMDiagramSpyWindow));

                // Make sure our options are loaded from the registry
                GetDialogPage(typeof(OptionsPage));

                InitializeToolbox();
            }
        }
Beispiel #3
0
            /// <summary>
            /// Gets a list of tokens from the IVsTextView.
            /// </summary>
            /// <param name="view">The IVsTextLines of the lines of source to parse.</param>
            /// <param name="service">The language service.</param>
            /// <returns>A list of tokens.</returns>
            public static List <FactTokenInfo> GetTokens(IVsTextView view, FactEditorLanguageService service)
            {
                IVsTextLines lines;

                ErrorHandler.ThrowOnFailure(view.GetBuffer(out lines));

                return(GetTokens(lines, service));
            }
Beispiel #4
0
            /// <summary>
            /// Gets the specific token that resides at the given index.
            /// </summary>
            /// <param name="index">The index of the token to get.</param>
            /// <param name="view">The IVsTextView of the lines of source to parse.</param>
            /// <param name="service">The language service.</param>
            /// <returns>The <see cref="T:Microsoft.VisualStudio.Package.TokenInfo"/> at the index.</returns>
            public static FactTokenInfo GetTokenAtIndex(int index, IVsTextView view, FactEditorLanguageService service)
            {
                IVsTextLines lines;

                ErrorHandler.ThrowOnFailure(view.GetBuffer(out lines));

                return(GetTokenAtIndex(index, lines, service));
            }
Beispiel #5
0
			/// <summary>
			/// Gets a list of tokens from the IVsTextView.
			/// </summary>
			/// <param name="view">The IVsTextLines of the lines of source to parse.</param>
			/// <param name="service">The language service.</param>
			/// <returns>A list of tokens.</returns>
			public static List<FactTokenInfo> GetTokens(IVsTextView view, FactEditorLanguageService service)
			{
				IVsTextLines lines;

				ErrorHandler.ThrowOnFailure(view.GetBuffer(out lines));

				return GetTokens(lines, service);
			}
Beispiel #6
0
			/// <summary>
			/// Gets the specific token that resides at the given index.
			/// </summary>
			/// <param name="index">The index of the token to get.</param>
			/// <param name="view">The IVsTextView of the lines of source to parse.</param>
			/// <param name="service">The language service.</param>
			/// <returns>The <see cref="T:Microsoft.VisualStudio.Package.TokenInfo"/> at the index.</returns>
			public static FactTokenInfo GetTokenAtIndex(int index, IVsTextView view, FactEditorLanguageService service)
			{
				IVsTextLines lines;

				ErrorHandler.ThrowOnFailure(view.GetBuffer(out lines));

				return GetTokenAtIndex(index, lines, service);
			}
Beispiel #7
0
			/// <summary>
			/// Gets the specific token that resides at the given index.
			/// </summary>
			/// <param name="index">The index of the token to get.</param>
			/// <param name="lines">The IVsTextLines of the lines of source to parse.</param>
			/// <param name="service">The language service.</param>
			/// <returns>The <see cref="T:Microsoft.VisualStudio.Package.TokenInfo"/> at the index.</returns>
			public static FactTokenInfo GetTokenAtIndex(int index, IVsTextLines lines, FactEditorLanguageService service)
			{
				List<FactTokenInfo> tokens = GetTokens(lines, service);

				foreach (FactTokenInfo token in tokens)
				{
					if (index >= token.StartIndex & index <= token.EndIndex)
					{
						return token;
					}
				}

				return null;
			}
Beispiel #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FactEditorReferenceModeDeclarations"/> class.
 /// </summary>
 /// <param name="languageService">The language service.</param>
 public FactEditorReferenceModeDeclarations(FactEditorLanguageService languageService)
 {
     myFactLanguageService       = languageService;
     myReferenceModeDeclarations = new List <ReferenceModeDeclaration>();
     ReloadModelElements();
 }
Beispiel #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="FactEditorObjectTypeDeclarations"/> class.
 /// </summary>
 /// <param name="languageService">The language service.</param>
 public FactEditorObjectTypeDeclarations(FactEditorLanguageService languageService)
 {
     myFactLanguageService    = languageService;
     myObjectTypeDeclarations = new List <ObjectTypeDeclaration>();
     ReloadModelElements();
 }
Beispiel #10
0
            /// <summary>
            /// Gets the specific token that resides at the given index.
            /// </summary>
            /// <param name="index">The index of the token to get.</param>
            /// <param name="lines">The IVsTextLines of the lines of source to parse.</param>
            /// <param name="service">The language service.</param>
            /// <returns>The <see cref="T:Microsoft.VisualStudio.Package.TokenInfo"/> at the index.</returns>
            public static FactTokenInfo GetTokenAtIndex(int index, IVsTextLines lines, FactEditorLanguageService service)
            {
                List <FactTokenInfo> tokens = GetTokens(lines, service);

                foreach (FactTokenInfo token in tokens)
                {
                    if (index >= token.StartIndex & index <= token.EndIndex)
                    {
                        return(token);
                    }
                }

                return(null);
            }
 /// <summary>
 /// Initializes a new instance of the <see cref="FactEditorAuthoringScope"/> class.
 /// </summary>
 /// <param name="languageService">The language service.</param>
 /// <param name="parseRequest">The parse request.</param>
 public FactEditorAuthoringScope(FactEditorLanguageService languageService, ParseRequest parseRequest)
 {
     m_LanguageService = languageService;
     m_ParseRequest    = parseRequest;
 }
Beispiel #12
0
			/// <summary>
			/// Gets a list of tokens from the IVsTextLines.
			/// </summary>
			/// <param name="lines">The IVsTextLines of the lines of source to parse.</param>
			/// <param name="service">The language service.</param>
			/// <returns>A list of tokens.</returns>
			public static List<FactTokenInfo> GetTokens(IVsTextLines lines, FactEditorLanguageService service)
			{
				Source source = service.GetOrCreateSource(lines);
				string lineText = source.GetLine(0);

				// Get the scanner from the language service.
				IScanner scanner = service.GetScanner(lines);
				scanner.SetSource(lineText, 0);

				// Now use the scanner to parse the first line and build the list of the tokens.
				List<FactTokenInfo> tokens = new List<FactTokenInfo>();
				FactTokenInfo lastToken = null;
				FactTokenInfo currentToken = new FactTokenInfo();
				int state = 0;
				while (scanner.ScanTokenAndProvideInfoAboutIt(currentToken, ref state))
				{
					if ((null != lastToken) && (currentToken.StartIndex > lastToken.EndIndex + 1))
					{
						tokens.Clear();
					}
					tokens.Add(currentToken);
					lastToken = currentToken;
					currentToken = new FactTokenInfo();
				}

				return tokens;
			}
			/// <summary>
			/// Initializes a new instance of the <see cref="FactEditorAuthoringScope"/> class.
			/// </summary>
			/// <param name="languageService">The language service.</param>
			/// <param name="parseRequest">The parse request.</param>
			public FactEditorAuthoringScope(FactEditorLanguageService languageService, ParseRequest parseRequest)
			{
				m_LanguageService = languageService;
				m_ParseRequest = parseRequest;
			}
Beispiel #14
0
		/// <summary>
		/// This is called by the package base class when our package is loaded. When devenv is run
		/// with the "/setup" command line switch it is not able to do a lot of the normal things,
		/// such as creating output windows and tool windows. Under normal circumstances our package
		/// isn't loaded when run with this switch. However, our package will be loaded when items 
		/// are added to the toolbox, even when run with "/setup". To be safe we'll check for "setup"
		/// and we don't do anything interesting in MgdSetSite if we find it. 
		/// </summary>
		protected sealed override void Initialize()
		{
			base.Initialize();

			// register the class designer editor factory
			RegisterEditorFactory(new ORMDesignerEditorFactory(this));

			if (!SetupMode)
			{
				((IServiceContainer)this).AddService(typeof(ORMDesignerFontsAndColors), myFontAndColorService = new ORMDesignerFontsAndColors(this), true);

				FactEditorLanguageService managedLanguageService = new FactEditorLanguageService();
				managedLanguageService.SetSite(this);
				((IServiceContainer)this).AddService(typeof(FactEditorLanguageService), managedLanguageService, true);

				// setup commands
				(myCommandSet = ORMDesignerDocView.CreateCommandSet(this)).Initialize();

				// Create managed tool windows
				AddToolWindow(typeof(ORMModelBrowserToolWindow));
				AddToolWindow(typeof(ORMReadingEditorToolWindow));
				AddToolWindow(typeof(ORMReferenceModeEditorToolWindow));
				AddToolWindow(typeof(ORMSamplePopulationToolWindow));
				AddToolWindow(typeof(ORMVerbalizationToolWindow));
				AddToolWindow(typeof(ORMDescriptionToolWindow));
				AddToolWindow(typeof(ORMNotesToolWindow));
				AddToolWindow(typeof(ORMContextWindow));
				AddToolWindow(typeof(ORMDiagramSpyWindow));

				// Make sure our options are loaded from the registry
				GetDialogPage(typeof(OptionsPage));

				InitializeToolbox();
			}

		}