Esempio n. 1
0
        private string GetParameterNames(MethodDefinition method)
        {
            string parameters = method.Parameters.Trim();

            if (parameters == String.Empty)
            {
                return(String.Empty);
            }

            parameters = CSharpFormattingTools.
                         RemoveUnwantedBracketText(parameters);

            parameters = CSharpFormattingTools.
                         RemoveUnwantedAngleBracketText(parameters);

            StringBuilder sb = new StringBuilder();

            foreach (string s in parameters.Split(','))
            {
                string   p     = s.Trim();
                string[] split = p.Split();

                sb.Append(split[split.Length - 1]);
                sb.Append(", ");
            }

            return(sb.ToString().Trim().TrimEnd(','));
        }
        private void ColourizeVariablesAndTypes(
            QuickSharp.Editor.ScintillaEditForm document)
        {
            string source = document.GetContent() as string;

            source = CSharpFormattingTools.RemoveUnwantedText(source);
            source = CSharpFormattingTools.RemoveUnwantedBracketText(source);

            List <string> namespaces = GetNamespaceList(source);

            if (settingsManager.ColorizeTypes)
            {
                // Lexer WORD2 - types

                List <string> assemblies = new List <string>();

                foreach (string ns in namespaces)
                {
                    List <string> names =
                        referenceManager.GetNamespaceAssemblies(ns);

                    foreach (string name in names)
                    {
                        if (!assemblies.Contains(name))
                        {
                            assemblies.Add(name);
                        }
                    }
                }

                assemblies.AddRange(workspaceAssemblyList);

                document.Editor.Lexing.Keywords[1] =
                    "Array Boolean Date Enumerator Error Function Number Object RegExp String VBArray " +
                    CodeAssistTools.GetNamespaceTypesAsString(
                        namespaces, assemblies);
            }

            if (settingsManager.ColorizeVariables)
            {
                // Lexer GLOBALCLASS - variables
                DeclaredVariables declaredVariables =
                    new DeclaredVariables(source, fullNamespaceList, false);

                StringBuilder sb = new StringBuilder();

                foreach (Variable v in declaredVariables.Items)
                {
                    sb.Append(v.Name);
                    sb.Append(" ");
                }

                document.Editor.Lexing.Keywords[3] = sb.ToString();
            }

            document.Editor.Lexing.Colorize();
        }
Esempio n. 3
0
        public LookupContext(string fullSource, string preSource,
                             string line, int lineStartPos, int currentPos, bool insideClass)
        {
            _fullSource   = fullSource;
            _preSource    = preSource;
            _line         = line;
            _lineStartPos = lineStartPos;
            _currentPos   = currentPos;
            _beforeClass  = insideClass;

            /*
             * Cleanup the source code.
             */

            _preSource = CSharpFormattingTools.RemoveUnwantedText(_preSource);
            _preSource = CSharpFormattingTools.RemoveUnwantedBracketText(_preSource);
            _line      = CSharpFormattingTools.RemoveUnwantedText(_line);
            _line      = CSharpFormattingTools.RemoveUnwantedBracketText(_line);

            /*
             * Get rid of 'global::' - we don't do anything with them
             * so we might as well not have them.
             */

            _line = _line.Replace("global::", String.Empty);

            /*
             * We remove the content of any balanced brackets to
             * allow indexed variables to identified and classified.
             */

            _line = CSharpFormattingTools.RemoveUnwantedParentheses(Line);

            /*
             * Create the target.
             */

            _target = new LookupTarget(_line);

            /*
             * Find the visible methods and properties.
             */

            _localMethods    = new LocalMethods(_fullSource);
            _localProperties = new LocalProperties(_fullSource);
        }
        private void ColourizeVariablesAndTypes(ScintillaEditForm document)
        {
            string source = CSharpFormattingTools.
                            RemoveUnwantedText(document.GetContent() as string);

            source = CSharpFormattingTools.
                     RemoveUnwantedBracketText(source);

            List <string> namespaces = GetNamespaceList(source);

            if (settingsManager.ColorizeTypes)
            {
                /*
                 * Lexer WORD2 - types
                 */

                List <string> assemblies = new List <string>();

                foreach (string ns in namespaces)
                {
                    List <string> names =
                        referenceManager.GetNamespaceAssemblies(ns);

                    foreach (string name in names)
                    {
                        if (!assemblies.Contains(name))
                        {
                            assemblies.Add(name);
                        }
                    }
                }

                assemblies.AddRange(workspaceAssemblyList);

                document.Editor.Lexing.Keywords[1] =
                    CodeAssistTools.GetNamespaceTypesAsString(
                        namespaces, assemblies);
            }

            if (settingsManager.ColorizeVariables)
            {
                /*
                 * Lexer GLOBALCLASS - variables
                 */

                DeclaredVariables declaredVariables =
                    new DeclaredVariables(
                        source, namespaces, false,
                        DeclarationContext.All);

                InheritedVariablesBase inheritedVariables
                    = new InheritedVariablesCode(
                          source,
                          DeclarationContext.All,
                          workspaceAssemblyList,
                          fullNamespaceList,
                          rootNamespaceList,
                          configNamespaceList);

                StringBuilder sb = new StringBuilder();

                foreach (Variable v in declaredVariables.Items)
                {
                    sb.Append(v.Name);
                    sb.Append(" ");
                }

                foreach (Variable v in inheritedVariables.Items)
                {
                    sb.Append(v.Name);
                    sb.Append(" ");
                }

                document.Editor.Lexing.Keywords[3] = sb.ToString();
            }

            document.Editor.Lexing.Colorize();
        }