当前位置: 首页>>代码示例>>C#>>正文


C# ScintillaNet.StyleAt方法代码示例

本文整理汇总了C#中ScintillaNet.StyleAt方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaNet.StyleAt方法的具体用法?C# ScintillaNet.StyleAt怎么用?C# ScintillaNet.StyleAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ScintillaNet的用法示例。


在下文中一共展示了ScintillaNet.StyleAt方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ContextualGenerator

        static public void ContextualGenerator(ScintillaNet.ScintillaControl Sci)
        {
            if (ASContext.Context is ASContext) (ASContext.Context as ASContext).UpdateCurrentFile(false); // update model
            if ((ASContext.Context.CurrentClass.Flags & (FlagType.Enum | FlagType.TypeDef)) > 0) return;

            lookupPosition = -1;
            int position = Sci.CurrentPos;
            if (Sci.BaseStyleAt(position) == 19) // on keyword
                return;
            bool isNotInterface = (ASContext.Context.CurrentClass.Flags & FlagType.Interface) == 0;
            int line = Sci.LineFromPosition(position);
            contextToken = Sci.GetWordFromPosition(position);
            contextMatch = null;

            FoundDeclaration found = GetDeclarationAtLine(Sci, line);
            string text = Sci.GetLine(line);
            bool suggestItemDeclaration = false;

            if (isNotInterface && !String.IsNullOrEmpty(contextToken) && Char.IsDigit(contextToken[0]))
            {
                ShowConvertToConst(found);
                return;
            }

            ASResult resolve = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(position, true));
            contextResolved = resolve;
            
            // ignore automatic vars (MovieClip members)
            if (isNotInterface
                && resolve.Member != null
                && (((resolve.Member.Flags & FlagType.AutomaticVar) > 0) || (resolve.InClass != null && resolve.InClass.QualifiedName == "Object")))
            {
                resolve.Member = null;
                resolve.Type = null;
            }

            if (isNotInterface && found.inClass != ClassModel.VoidClass && contextToken != null)
            {
                if (resolve.Member == null && resolve.Type != null
                    && (resolve.Type.Flags & FlagType.Interface) > 0) // implement interface
                {
                    contextParam = resolve.Type.Type;
                    ShowImplementInterface(found);
                    return;
                }

                if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
                    && (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
                {
                    contextMember = resolve.Member;
                    ShowPromoteLocalAndAddParameter(found);
                    return;
                }
            }
            
            if (contextToken != null && resolve.Member == null) // import declaration
            {
                if ((resolve.Type == null || resolve.Type.IsVoid() || !ASContext.Context.IsImported(resolve.Type, line)) && CheckAutoImport(found)) return;
                if (resolve.Type == null)
                {
                    int stylemask = (1 << Sci.StyleBits) - 1;
                    suggestItemDeclaration = ASComplete.IsTextStyle(Sci.StyleAt(position - 1) & stylemask);
                }
            }

            if (isNotInterface && found.member != null)
            {
                // private var -> property
                if ((found.member.Flags & FlagType.Variable) > 0 && (found.member.Flags & FlagType.LocalVar) == 0)
                {
                    // maybe we just want to import the member's non-imported type
                    Match m = Regex.Match(text, String.Format(patternVarDecl, found.member.Name, contextToken));
                    if (m.Success)
                    {
                        contextMatch = m;
                        ClassModel type = ASContext.Context.ResolveType(contextToken, ASContext.Context.CurrentModel);
                        if (type.IsVoid() && CheckAutoImport(found))
                            return;
                    }
                    ShowGetSetList(found);
                    return;
                }
                // inside a function
                else if ((found.member.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) > 0
                    && resolve.Member == null && resolve.Type == null)
                {
                    if (contextToken != null)
                    {
                        // "generate event handlers" suggestion
                        string re = String.Format(patternEvent, contextToken);
                        Match m = Regex.Match(text, re, RegexOptions.IgnoreCase);
                        if (m.Success)
                        {
                            contextMatch = m;
                            contextParam = CheckEventType(m.Groups["event"].Value);
                            ShowEventList(found);
                            return;
                        }
                        m = Regex.Match(text, String.Format(patternAS2Delegate, contextToken), RegexOptions.IgnoreCase);
                        if (m.Success)
//.........这里部分代码省略.........
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例2: ContextualGenerator

        static public void ContextualGenerator(ScintillaNet.ScintillaControl Sci)
        {
            if (ASContext.Context is ASContext)
                (ASContext.Context as ASContext).UpdateCurrentFile(false); // update model

            lookupPosition = -1;
            int position = Sci.CurrentPos;
            if (Sci.BaseStyleAt(position) == 19) // on keyword
                return;
            int line = Sci.LineFromPosition(position);
            contextToken = Sci.GetWordFromPosition(position);
            contextMatch = null;

            FoundDeclaration found = GetDeclarationAtLine(Sci, line);
            string text = Sci.GetLine(line);
            bool suggestItemDeclaration = false;

            if (!String.IsNullOrEmpty(contextToken) && Char.IsDigit(contextToken[0]))
            {
                ShowConvertToConst(found);
                return;
            }

            ASResult resolve = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(position, true));
            // ignore automatic vars (MovieClip members)
            if (resolve.Member != null &&
                (((resolve.Member.Flags & FlagType.AutomaticVar) > 0)
                 || (resolve.inClass != null && resolve.inClass.QualifiedName == "Object")))
            {
                resolve.Member = null;
                resolve.Type = null;
            }

            if (found.inClass != ClassModel.VoidClass && contextToken != null)
            {
                if (resolve.Member == null && resolve.Type != null
                    && (resolve.Type.Flags & FlagType.Interface) > 0) // implement interface
                {
                    contextParam = resolve.Type.Type;
                    ShowImplementInterface(found);
                    return;
                }

                if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
                    && (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
                {
                    contextMember = resolve.Member;
                    ShowPromoteLocalAndAddParameter(found);
                    return;
                }

                if (resolve.Member == null && resolve.Type == null) // import declaration
                {
                    if (CheckAutoImport(found))
                    {
                        return;
                    }
                    else
                    {
                        int stylemask = (1 << Sci.StyleBits) - 1;
                        if (ASComplete.IsTextStyle(Sci.StyleAt(position - 1) & stylemask))
                        {
                            suggestItemDeclaration = true;
                        }
                    }
                }
            }

            if (found.member != null)
            {
                // private var -> property
                if ((found.member.Flags & FlagType.Variable) > 0 && (found.member.Flags & FlagType.LocalVar) == 0)
                {
                    // maybe we just want to import the member's non-imported type
                    Match m = Regex.Match(text, String.Format(patternVarDecl, found.member.Name, contextToken));
                    if (m.Success)
                    {
                        contextMatch = m;
                        ClassModel type = ASContext.Context.ResolveType(contextToken, ASContext.Context.CurrentModel);
                        if (type.IsVoid() && CheckAutoImport(found))
                            return;
                    }
                    // create property
                    ShowGetSetList(found);
                    return;
                }
                // inside a function
                else if ((found.member.Flags & (FlagType.Function | FlagType.Getter | FlagType.Setter)) > 0
                    && resolve.Member == null && resolve.Type == null)
                {
                    if (contextToken != null)
                    {
                        // "generate event handlers" suggestion
                        Match m = Regex.Match(text, String.Format(patternEvent, contextToken), RegexOptions.IgnoreCase);
                        if (m.Success)
                        {
                            contextMatch = m;
                            contextParam = CheckEventType(m.Groups["event"].Value);
                            ShowEventList(found);
                            return;
//.........这里部分代码省略.........
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例3: GenerateExtractVariable

        public static void GenerateExtractVariable(ScintillaNet.ScintillaControl Sci, string NewName)
        {
            FileModel cFile;
            IASContext context = ASContext.Context;
            Int32 pos = Sci.CurrentPos;

            string expression = Sci.SelText.Trim(new char[] { '=', ' ', '\t', '\n', '\r', ';', '.' });
            expression = expression.TrimEnd(new char[] { '(', '[', '{', '<' });
            expression = expression.TrimStart(new char[] { ')', ']', '}', '>' });

            cFile = ASContext.Context.CurrentModel;
            ASFileParser parser = new ASFileParser();
            parser.ParseSrc(cFile, Sci.Text);

            MemberModel current = cFile.Context.CurrentMember;

            string characterClass = ScintillaNet.ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;

            int funcBodyStart = ASGenerator.GetBodyStart(current.LineFrom, current.LineTo, Sci);
            Sci.SetSel(funcBodyStart, Sci.LineEndPosition(current.LineTo));
            string currentMethodBody = Sci.SelText;

            bool isExprInSingleQuotes = (expression.StartsWith("'") && expression.EndsWith("'"));
            bool isExprInDoubleQuotes = (expression.StartsWith("\"") && expression.EndsWith("\""));
            int stylemask = (1 << Sci.StyleBits) - 1;
            int lastPos = -1;
            char prevOrNextChar;
            Sci.Colourise(0, -1);
            while (true)
            {
                lastPos = currentMethodBody.IndexOf(expression, lastPos + 1);
                if (lastPos > -1)
                {
                    if (lastPos > 0)
                    {
                        prevOrNextChar = currentMethodBody[lastPos - 1];
                        if (characterClass.IndexOf(prevOrNextChar) > -1)
                        {
                            continue;
                        }
                    }
                    if (lastPos + expression.Length < currentMethodBody.Length)
                    {
                        prevOrNextChar = currentMethodBody[lastPos + expression.Length];
                        if (characterClass.IndexOf(prevOrNextChar) > -1)
                        {
                            continue;
                        }
                    }

                    int style = Sci.StyleAt(funcBodyStart + lastPos) & stylemask;
                    if (ASComplete.IsCommentStyle(style))
                    {
                        continue;
                    }
                    else if ((isExprInDoubleQuotes && currentMethodBody[lastPos] == '"' && currentMethodBody[lastPos + expression.Length - 1] == '"')
                        || (isExprInSingleQuotes && currentMethodBody[lastPos] == '\'' && currentMethodBody[lastPos + expression.Length - 1] == '\''))
                    {

                    }
                    else if (!ASComplete.IsTextStyle(style))
                    {
                        continue;
                    }

                    Sci.SetSel(funcBodyStart + lastPos, funcBodyStart + lastPos + expression.Length);
                    Sci.ReplaceSel(NewName);
                    currentMethodBody = currentMethodBody.Substring(0, lastPos) + NewName + currentMethodBody.Substring(lastPos + expression.Length);
                    lastPos += NewName.Length;
                }
                else
                {
                    break;
                }
            }

            Sci.CurrentPos = funcBodyStart;
            Sci.SetSel(Sci.CurrentPos, Sci.CurrentPos);

            MemberModel m = new MemberModel(NewName, "", FlagType.LocalVar, 0);
            m.Value = expression;

            string snippet = TemplateUtils.GetTemplate("Variable");
            snippet = TemplateUtils.ReplaceTemplateVariable(snippet, "Modifiers", null);
            snippet = TemplateUtils.ToDeclarationString(m, snippet);
            snippet += NewLine + "$(Boundary)";
            SnippetHelper.InsertSnippetText(Sci, Sci.CurrentPos, snippet);
        }
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:88,代码来源:ASGenerator.cs

示例4: GetExpression

        /// <summary>
        /// Find Actionscript expression at cursor position
        /// </summary>
        /// <param name="sci">Scintilla Control</param>
        /// <param name="position">Cursor position</param>
        /// <param name="ignoreWhiteSpace">Skip whitespace at position</param>
        /// <returns></returns>
        private static ASExpr GetExpression(ScintillaNet.ScintillaControl Sci, int position, bool ignoreWhiteSpace)
        {
            ASExpr expression = new ASExpr();
            expression.Position = position;
            expression.Separator = ' ';

            // file's member declared at this position
            expression.ContextMember = ASContext.Context.CurrentMember;
            int minPos = 0;
            string body = null;
            if (expression.ContextMember != null)
            {
                minPos = Sci.PositionFromLine(expression.ContextMember.LineFrom);
                StringBuilder sbBody = new StringBuilder();
                for (int i = expression.ContextMember.LineFrom; i <= expression.ContextMember.LineTo; i++)
                    sbBody.Append(Sci.GetLine(i)).Append('\n');
                body = sbBody.ToString();
                //int tokPos = body.IndexOf(expression.ContextMember.Name);
                //if (tokPos >= 0) minPos += tokPos + expression.ContextMember.Name.Length;

                if ((expression.ContextMember.Flags & (FlagType.Function | FlagType.Constructor | FlagType.Getter | FlagType.Setter)) > 0)
                {
                    expression.ContextFunction = expression.ContextMember;
                    expression.FunctionOffset = expression.ContextMember.LineFrom;

                    Match mStart = Regex.Match(body, "(\\)|[a-z0-9*.,-<>])\\s*{", RegexOptions.IgnoreCase);
                    if (mStart.Success)
                    {
                        // cleanup function body & offset
                        int pos = mStart.Index + mStart.Length;
                        expression.BeforeBody = (position < Sci.PositionFromLine(expression.ContextMember.LineFrom) + pos);
                        string pre = body.Substring(0, pos);
                        for (int i = 0; i < pre.Length - 1; i++)
                            if (pre[i] == '\r') { expression.FunctionOffset++; if (pre[i + 1] == '\n') i++; }
                            else if (pre[i] == '\n') expression.FunctionOffset++;
                        body = body.Substring(pos);
                    }
                    expression.FunctionBody = body;
                }
                else
                {
                    int eqPos = body.IndexOf('=');
                    expression.BeforeBody = (eqPos < 0 || position < Sci.PositionFromLine(expression.ContextMember.LineFrom) + eqPos);
                }
            }

            // get the word characters from the syntax definition
            string characterClass = ScintillaNet.ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;

            // get expression before cursor
            ContextFeatures features = ASContext.Context.Features;
            int stylemask = (1 << Sci.StyleBits) - 1;
            int style = (position >= minPos) ? Sci.StyleAt(position) & stylemask : 0;
            StringBuilder sb = new StringBuilder();
            StringBuilder sbSub = new StringBuilder();
            int subCount = 0;
            char c = ' ';
            char c2;
            int startPos = position;
            int braceCount = 0;
            int sqCount = 0;
            int genCount = 0;
            bool hasGenerics = features.hasGenerics;
            bool hadWS = false;
            bool hadDot = ignoreWhiteSpace;
            bool inRegex = false;
            char dot = features.dot[features.dot.Length - 1];
            while (position > minPos)
            {
                position--;
                style = Sci.StyleAt(position) & stylemask;
                if (style == 14) // regex literal
                {
                    inRegex = true;
                }
                else if (!ASComplete.IsCommentStyle(style))
                {
                    c2 = c;
                    c = (char)Sci.CharAt(position);
                    // end of regex literal
                    if (inRegex)
                    {
                        inRegex = false;
                        if (expression.SubExpressions == null) expression.SubExpressions = new List<string>();
                        expression.SubExpressions.Add("");
                        sb.Insert(0, "RegExp.#" + (subCount++) + "~");
                    }
                    // array access
                    if (c == '[')
                    {
                        sqCount--;
                        if (sqCount == 0)
                        {
//.........这里部分代码省略.........
开发者ID:fordream,项目名称:wanghe-project,代码行数:101,代码来源:Envelop.cs

示例5: GetStatementReturnType

        private static StatementReturnType GetStatementReturnType(ScintillaNet.ScintillaControl Sci, ClassModel inClass, string line, int startPos)
        {
            Regex target = new Regex(@"[;\s\n\r]*", RegexOptions.RightToLeft);
            Match m = target.Match(line);
            if (!m.Success)
            {
                return null;
            }
            line = line.Substring(0, m.Index);

            if (line.Length == 0)
            {
                return null;
            }

            line = ReplaceAllStringContents(line);

            ASResult resolve = null;
            int pos = -1; 
            string word = null;
            int stylemask = (1 << Sci.StyleBits) - 1;
            ClassModel type = null;

            if (line[line.Length - 1] == ')')
            {
                pos = -1;
                int lastIndex = 0;
                int bracesBalance = 0;
                while (true)
                {
                    int pos1 = line.IndexOf("(", lastIndex);
                    int pos2 = line.IndexOf(")", lastIndex);
                    if (pos1 != -1 && pos2 != -1)
                    {
                        lastIndex = Math.Min(pos1, pos2);
                    }
                    else if (pos1 != -1 || pos2 != -1)
                    {
                        lastIndex = Math.Max(pos1, pos2);
                    }
                    else
                    {
                        break;
                    }
                    if (lastIndex == pos1)
                    {
                        bracesBalance++;
                        if (bracesBalance == 1)
                        {
                            pos = lastIndex;
                        }
                    }
                    else if (lastIndex == pos2)
                    {
                        bracesBalance--;
                    }
                    lastIndex++;
                }
            }
            else
            {
                pos = line.Length;
            }
            if (pos != -1)
            {
                line = line.Substring(0, pos);
                pos += startPos;
                pos -= line.Length - line.TrimEnd().Length + 1;
                pos = Sci.WordEndPosition(pos, true);
                resolve = ASComplete.GetExpressionType(Sci, pos);
                word = Sci.GetWordFromPosition(pos);
            }
            char c = (char)Sci.CharAt(pos);
            if (word != null && Char.IsDigit(word[0]))
            {
                type = inClass.InFile.Context.ResolveType("Number", inClass.InFile);
            }
            else if (word != null && (word == "true" || word == "false"))
            {
                type = inClass.InFile.Context.ResolveType("Boolean", inClass.InFile);
            }
            else if (!(ASComplete.IsTextStyle(Sci.StyleAt(pos - 1) & stylemask)))
            {
                type = inClass.InFile.Context.ResolveType("String", inClass.InFile);
            }
            else if (c == '}')
            {
                type = inClass.InFile.Context.ResolveType("Object", inClass.InFile);
            }
            else if (c == '>')
            {
                type = inClass.InFile.Context.ResolveType("XML", inClass.InFile);
            }
            else if (c == ']')
            {
                type = inClass.InFile.Context.ResolveType("Array", inClass.InFile);
            }

            if (resolve == null)
            {
//.........这里部分代码省略.........
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs

示例6: HandleColonCompletion

		static private bool HandleColonCompletion(ScintillaNet.ScintillaControl Sci, string tail, bool autoHide)
		{
			DebugConsole.Trace("** Complete: ':'<class>");
			// Context
			ASClass cClass = ASContext.CurrentClass;
			
			// Valid statement
			int position = Sci.CurrentPos-1;
			string keyword = null;
			int stylemask = (1 << Sci.StyleBits) -1;
			char c;
			while (position > 0) 
			{
				position--;
				c = (char)Sci.CharAt(position);
				if ((c == '{') || (c == '=')) return false;
				else if ((Sci.StyleAt(position) & stylemask) == 19)
				{
					keyword = GetWordLeft(Sci, ref position);
					DebugConsole.Trace("'"+keyword+"'");
					break;
				}
			}
			if (keyword != "var" && keyword != "function" && keyword != "get" && keyword != "set" && keyword != "const")
				return false;
			
			// Consolidate known classes
			ASMemberList known = new ASMemberList();
			known.Merge(cClass.ToASMember());
			known.Merge(cClass.Imports);
			known.Merge(ASContext.TopLevel.Imports);
			known.Merge(ASContext.GetBasePackages());
			
			// show
			ArrayList list = new ArrayList();
			foreach(ASMember member in known)
				list.Add(new MemberItem(member));
			CompletionList.Show(list, autoHide, tail);
			return true;
		}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:40,代码来源:ASComplete.cs

示例7: OnChar

		/// <summary>
		/// Character written in editor
		/// </summary>
		/// <param name="Value">Character inserted</param>
		static public bool OnChar(ScintillaNet.ScintillaControl Sci, int Value, bool autoHide)
		{
			if (autoHide && !ASContext.HelpersEnabled)
				return false;
			try
			{
				int eolMode = Sci.EOLMode;
				// code auto
				if (((Value == 10) && (eolMode != 1)) || ((Value == 13) && (eolMode == 1)))
				{
					DebugConsole.Trace("Struct");
					HandleStructureCompletion(Sci);
					return false;
				}
				
				// ignore repeated characters
				int position = Sci.CurrentPos;
				if ((Sci.CharAt(position-2) == Value) && (Sci.CharAt(position-1) == Value) && (Value != '*'))
					return false;
				
				// ignore text in comments & quoted text
				Sci.Colourise(0,-1);
				int stylemask = (1 << Sci.StyleBits) -1;
				int style = Sci.StyleAt(position-1) & stylemask;
				DebugConsole.Trace("style "+style);
				if (!IsTextStyle(style) && !IsTextStyle(Sci.StyleAt(position) & stylemask))
				{
					// documentation completion
					if (ASContext.DocumentationCompletionEnabled && IsCommentStyle(style))
						return ASDocumentation.OnChar(Sci, Value, position, style);
					else if (autoHide) return false;
				}
				
				// stop here if the class is not valid
				if (!ASContext.IsClassValid()) return false;
				
				// handle
				switch (Value)
				{
					case '.':
						return HandleDotCompletion(Sci, autoHide);
						
					case ' ':
						position--;
						string word = GetWordLeft(Sci, ref position);
						DebugConsole.Trace("Word? "+word);
						if (word.Length > 0)
						switch (word) 
						{
							case "new":
							case "extends":
							case "implements":
								return HandleNewCompletion(Sci, "", autoHide);
							case "import":
								return HandleImportCompletion(Sci, "", autoHide);
							case "public":
								return HandleDeclarationCompletion(Sci, "function static var", "", autoHide);
							case "private":
								return HandleDeclarationCompletion(Sci, "function static var", "", autoHide);
							case "static":
								return HandleDeclarationCompletion(Sci, "function private public var", "", autoHide);
						}
						break;
						
					case ':':
						ASContext.UnsetOutOfDate();
						bool result = HandleColonCompletion(Sci, "", autoHide);
						ASContext.SetOutOfDate();
						return result;
						
					case '(':
						return HandleFunctionCompletion(Sci);
					case ')':
						if (InfoTip.CallTipActive) InfoTip.Hide();
						return false;
					
					case '*':
						return CodeAutoOnChar(Sci, Value);
				}
			}
			catch (Exception ex) {
				ErrorHandler.ShowError("Completion error", ex);
			}
			
			// CodeAuto context
			if (!PluginCore.Controls.CompletionList.Active) LastExpression = null;
			return false;
		}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:92,代码来源:ASComplete.cs

示例8: HandleFunctionCompletion

		/// <summary>
		/// Display method signature
		/// </summary>
		/// <param name="Sci">Scintilla control</param>
		/// <returns>Auto-completion has been handled</returns>
		static public bool HandleFunctionCompletion(ScintillaNet.ScintillaControl Sci)
		{
			// find method
			int position = Sci.CurrentPos-1;
			int parCount = 0;
			int braCount = 0;
			int comaCount = 0;
			int arrCount = 0;
			int style = 0;
			int stylemask = (1 << Sci.StyleBits) -1;
			char c;
			while (position >= 0)
			{
				style = Sci.StyleAt(position) & stylemask;
				if (style == 19)
				{
					string keyword = GetWordLeft(Sci, ref position);
					DebugConsole.Trace("Keyword "+keyword);
					if (!"new".StartsWith(keyword))
					{
						position = -1;
						break;
					}
				}
				if (IsTextStyleEx(style))
				{
					c = (char)Sci.CharAt(position);
					if (c == ';') 
					{
						position = -1;
						break;
					}
					// skip {} () [] blocks
					if ( ((braCount > 0) && (c != '{')) 
					    || ((arrCount > 0) && (c != '[')) 
					    || ((parCount > 0) && (c != '(')))
					{
						position--;
						continue;
					}
					// new block
					if (c == '}') braCount++;
					else if (c == ']') arrCount++;
					else if (c == ')') parCount++;
					
					// block closed
					else if (c == '{') 
					{
						if (braCount == 0) comaCount = 0;
						else braCount--;
					}
					else if (c == '[') 
					{
						if (arrCount == 0) comaCount = 0;
						else arrCount--;
					}
					else if (c == '(') 
					{
						if (--parCount < 0)
							// function start found
							break;
					}
					
					// new parameter reached
					else if (c == ',' && parCount == 0 && Sci.BaseStyleAt(position) != 6)
						comaCount++;
				}
				position--;
			}
			// continuing calltip ?
			if (HasCalltip())
			{
				if (calltipPos == position)
				{
					ShowCalltip(Sci, comaCount);
					return true;
				}
				else InfoTip.Hide();
			}
			else if (position < 0) 
				return false;
			
			// get expression at cursor position
			ASExpr expr = GetExpression(Sci, position);
			DebugConsole.Trace("Expr: "+expr.Value);
			if (expr.Value == null || expr.Value.Length == 0 || expr.separator == ':'
			    || (expr.Keyword == "function" && expr.separator == ' '))
				return false;
			DebugConsole.Trace("** Display method parameters");
			DebugConsole.Trace(expr.Value);
			// Context
			expr.LocalVars = ParseLocalVars(expr);
			ASClass aClass = ASContext.CurrentClass; 
			// Expression before cursor
			ASResult result = EvalExpression(expr.Value, expr, aClass, true);
//.........这里部分代码省略.........
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:ASComplete.cs

示例9: GetWordLeft

		static public string GetWordLeft(ScintillaNet.ScintillaControl Sci, ref int position)
		{
			string word = "";
			string exclude = "(){};,+*/\\=:.%\"<>";
			bool skipWS = true;
			int style;
			int stylemask = (1 << Sci.StyleBits) -1;
			char c;
			while (position >= 0) 
			{
				style = Sci.StyleAt(position) & stylemask;
				if (IsTextStyleEx(style))
				{
					c = (char)Sci.CharAt(position);
					if (c <= ' ') 
					{
						if (!skipWS)
							break;
					}
					else if (exclude.IndexOf(c) >= 0) break;
					else if (style != 6)
					{
						word = c+word;
						skipWS = false;
					}
				}
				position--;
			}
			return word;
		}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:30,代码来源:ASComplete.cs

示例10: GetExpression

		/// <summary>
		/// Find Actionscript expression at cursor position
		/// TODO  Improve this method
		/// </summary>
		/// <param name="sci">Scintilla Control</param>
		/// <param name="position">Cursor position</param>
		/// <returns></returns>
		static private ASExpr GetExpression(ScintillaNet.ScintillaControl Sci, int position)
		{
			ASExpr expression = new ASExpr();
			int startPos = position;
			expression.Position = position;
			expression.separator = ' ';
			
			// get last expression (until ';') excluding comments
			int stylemask = (1 << Sci.StyleBits) -1;
			int style = (position > 0) ? Sci.StyleAt(position-1) & stylemask : 0;
			bool ignoreKey = false;
			if (style == 19)
			{
				DebugConsole.Trace("Ignore keyword");
				ignoreKey = true;
			}
			StringBuilder sb = new StringBuilder();
			char c;
			while ((position > 0) && (style != 19 || ignoreKey)) 
			{
				position--;
				style = Sci.StyleAt(position) & stylemask;
				if (IsTextStyle(style) || ignoreKey)
				{
					c = (char)Sci.CharAt(position);
					if (c == ';')
					{
						expression.separator = c;
						break;
					}
					else if (c == '\n' || c == '\r')
					{
						if (sb.ToString().Trim().Length == 0) 
							break;
					}
					sb.Insert(0,c);
					if (ignoreKey && IsTextStyle(style)) ignoreKey = false;
				}
				// we found a keyword
				else if (style == 19)
				{
					expression.separator = ' ';
					int keywordPos = position;
					string keyword = GetWordLeft(Sci, ref keywordPos);
					
					if ((keyword == "function") || (keyword == "get") || (keyword == "set"))
					{
						// we found a function declaration
						string test = sb.ToString().Trim();
						
						// ignore anonymous function
						if ((keyword == "function") && test.StartsWith("("))
						{
							keyword = null;
							break;
						}
						
						// guess context more precisely
						bool hasBraces = (test.IndexOf('{') >= 0);
						test = re_balancedBraces.Replace(test, ";");
						
						// is it inside the function?
						if (test.IndexOf('{') >= 0)
						{
							c = ' ';
							while ((position < startPos) && (sb.Length > 0))
							{
								position++;
								c = (char)Sci.CharAt(position);
								sb.Remove(0,1);
								if (c == '{') break;
							}
							expression.separator = c;
						}
						// is it NOT inside function parameters?
						else if (test.IndexOf(')') >= 0)
						{
							if (hasBraces)
							{
								expression.separator = '}';
								expression.Value = "";
								return expression;
							}
							else
							{
								// is it before the return type declaration?
								int colon = test.LastIndexOf(':');
								if ((colon < 0) || (colon < test.LastIndexOf(')')))
									// this is invalid
									return expression;
							}
						}
						// inside function parameters?
//.........这里部分代码省略.........
开发者ID:heon21st,项目名称:flashdevelop,代码行数:101,代码来源:ASComplete.cs


注:本文中的ScintillaNet.StyleAt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。