本文整理汇总了C#中ScintillaNet.ScintillaControl.WordEndPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaControl.WordEndPosition方法的具体用法?C# ScintillaControl.WordEndPosition怎么用?C# ScintillaControl.WordEndPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet.ScintillaControl
的用法示例。
在下文中一共展示了ScintillaControl.WordEndPosition方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Manager_OnMouseHover
private void Manager_OnMouseHover(ScintillaControl sci, Int32 position)
{
DebuggerManager debugManager = PluginMain.debugManager;
FlashInterface flashInterface = debugManager.FlashInterface;
if (!PluginBase.MainForm.EditorMenu.Visible && flashInterface != null && flashInterface.isDebuggerStarted && flashInterface.isDebuggerSuspended)
{
if (debugManager.CurrentLocation != null && debugManager.CurrentLocation.File != null)
{
String localPath = debugManager.GetLocalPath(debugManager.CurrentLocation.File);
if (localPath == null || localPath != PluginBase.MainForm.CurrentDocument.FileName)
{
return;
}
}
else return;
Point dataTipPoint = Control.MousePosition;
Rectangle rect = new Rectangle(m_ToolTip.Location, m_ToolTip.Size);
if (m_ToolTip.Visible && rect.Contains(dataTipPoint))
{
return;
}
position = sci.WordEndPosition(position, true);
String leftword = GetWordAtPosition(sci, position);
if (leftword != String.Empty)
{
try
{
ASTBuilder builder = new ASTBuilder(true);
ValueExp exp = builder.parse(new System.IO.StringReader(leftword));
ExpressionContext context = new ExpressionContext(flashInterface.Session);
context.Depth = debugManager.CurrentFrame;
Object obj = exp.evaluate(context);
Show(dataTipPoint, (Variable)obj);
}
catch (Exception){}
}
}
}
示例2: GetStatementReturnType
private static StatementReturnType GetStatementReturnType(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;
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);
if (resolve.IsNull()) resolve = null;
word = sci.GetWordFromPosition(pos);
}
IASContext ctx = inClass.InFile.Context;
m = Regex.Match(line, "new\\s+([\\w\\d.<>,_$-]+)+(<[^]]+>)|(<[^]]+>)", RegexOptions.IgnoreCase);
if (m.Success)
{
string m1 = m.Groups[1].Value;
string m2 = m.Groups[2].Value;
string cname;
if (string.IsNullOrEmpty(m1) && string.IsNullOrEmpty(m2))
cname = m.Groups[0].Value;
else
cname = String.Concat(m1, m2);
if (cname.StartsWith('<'))
cname = "Vector." + cname; // literal vector
type = ctx.ResolveType(cname, inClass.InFile);
if (!type.IsVoid()) resolve = null;
}
else
{
char c = (char)sci.CharAt(pos);
if (c == '"' || c == '\'')
{
type = ctx.ResolveType(ctx.Features.stringKey, inClass.InFile);
}
//.........这里部分代码省略.........
示例3: GenerateClass
private static void GenerateClass(ScintillaControl sci, String className, ClassModel inClass)
{
AddLookupPosition(); // remember last cursor position for Shift+F4
List<FunctionParameter> parameters = ParseFunctionParameters(sci, sci.WordEndPosition(sci.CurrentPos, true));
List<MemberModel> constructorArgs = new List<MemberModel>();
List<String> constructorArgTypes = new List<String>();
MemberModel paramMember = new MemberModel();
for (int i = 0; i < parameters.Count; i++)
{
FunctionParameter p = parameters[i];
constructorArgs.Add(new MemberModel(p.paramName, p.paramType, FlagType.ParameterVar, 0));
constructorArgTypes.Add(CleanType(GetQualifiedType(p.paramQualType, inClass)));
}
paramMember.Parameters = constructorArgs;
IProject project = PluginBase.CurrentProject;
if (String.IsNullOrEmpty(className)) className = "Class";
string projFilesDir = Path.Combine(PathHelper.TemplateDir, "ProjectFiles");
string projTemplateDir = Path.Combine(projFilesDir, project.GetType().Name);
string paramsString = TemplateUtils.ParametersString(paramMember, true);
Hashtable info = new Hashtable();
info["className"] = className;
if (project.Language.StartsWithOrdinal("as")) info["templatePath"] = Path.Combine(projTemplateDir, "Class.as.fdt");
else if (project.Language.StartsWithOrdinal("haxe")) info["templatePath"] = Path.Combine(projTemplateDir, "Class.hx.fdt");
else if (project.Language.StartsWithOrdinal("loom")) info["templatePath"] = Path.Combine(projTemplateDir, "Class.ls.fdt");
info["inDirectory"] = Path.GetDirectoryName(inClass.InFile.FileName);
info["constructorArgs"] = paramsString.Length > 0 ? paramsString : null;
info["constructorArgTypes"] = constructorArgTypes;
DataEvent de = new DataEvent(EventType.Command, "ProjectManager.CreateNewFile", info);
EventManager.DispatchEvent(null, de);
if (de.Handled) return;
}
示例4: GenerateFunctionJob
private static void GenerateFunctionJob(GeneratorJobType job, ScintillaControl sci, MemberModel member,
bool detach, ClassModel inClass)
{
int position = 0;
MemberModel latest = null;
bool isOtherClass = false;
Visibility funcVisi = job.Equals(GeneratorJobType.FunctionPublic) ? Visibility.Public : GetDefaultVisibility(inClass);
int wordPos = sci.WordEndPosition(sci.CurrentPos, true);
List<FunctionParameter> functionParameters = ParseFunctionParameters(sci, wordPos);
// evaluate, if the function should be generated in other class
ASResult funcResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
int contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(sci.CurrentPos, true));
MemberModel isStatic = new MemberModel();
if (contextOwnerPos != -1)
{
ASResult contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
if (contextOwnerResult != null)
{
if (contextOwnerResult.Member == null && contextOwnerResult.Type != null)
{
isStatic.Flags |= FlagType.Static;
}
}
}
else if (member != null && (member.Flags & FlagType.Static) > 0)
{
isStatic.Flags |= FlagType.Static;
}
if (funcResult.RelClass != null && !funcResult.RelClass.IsVoid() && !funcResult.RelClass.Equals(inClass))
{
AddLookupPosition();
lookupPosition = -1;
ASContext.MainForm.OpenEditableDocument(funcResult.RelClass.InFile.FileName, true);
sci = ASContext.CurSciControl;
isOtherClass = true;
FileModel fileModel = new FileModel();
fileModel.Context = ASContext.Context;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(fileModel, sci.Text);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(funcResult.RelClass.QualifiedName))
{
funcResult.RelClass = cm;
break;
}
}
inClass = funcResult.RelClass;
ASContext.Context.UpdateContext(inClass.LineFrom);
}
string blockTmpl = null;
if ((isStatic.Flags & FlagType.Static) > 0)
{
blockTmpl = TemplateUtils.GetBoundary("StaticMethods");
}
else if ((funcVisi & Visibility.Public) > 0)
{
blockTmpl = TemplateUtils.GetBoundary("PublicMethods");
}
else
{
blockTmpl = TemplateUtils.GetBoundary("PrivateMethods");
}
latest = TemplateUtils.GetTemplateBlockMember(sci, blockTmpl);
if (latest == null || (!isOtherClass && member == null))
{
latest = GetLatestMemberForFunction(inClass, funcVisi, isStatic);
// if we generate function in current class..
if (!isOtherClass)
{
MethodsGenerationLocations location = ASContext.CommonSettings.MethodsGenerationLocations;
if (member == null)
{
detach = false;
lookupPosition = -1;
position = sci.WordStartPosition(sci.CurrentPos, true);
sci.SetSel(position, sci.WordEndPosition(position, true));
}
else if (latest != null && location == MethodsGenerationLocations.AfterSimilarAccessorMethod)
{
position = sci.PositionFromLine(latest.LineTo + 1) - ((sci.EOLMode == 0) ? 2 : 1);
sci.SetSel(position, position);
}
else
{
position = sci.PositionFromLine(member.LineTo + 1) - ((sci.EOLMode == 0) ? 2 : 1);
sci.SetSel(position, position);
}
}
//.........这里部分代码省略.........
示例5: GenerateVariableJob
private static void GenerateVariableJob(GeneratorJobType job, ScintillaControl sci, MemberModel member,
bool detach, ClassModel inClass)
{
int position = 0;
MemberModel latest = null;
bool isOtherClass = false;
Visibility varVisi = job.Equals(GeneratorJobType.Variable) ? GetDefaultVisibility(inClass) : Visibility.Public;
FlagType ft = job.Equals(GeneratorJobType.Constant) ? FlagType.Constant : FlagType.Variable;
// evaluate, if the variable (or constant) should be generated in other class
ASResult varResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
int contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(sci.CurrentPos, true));
MemberModel isStatic = new MemberModel();
if (contextOwnerPos != -1)
{
ASResult contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
if (contextOwnerResult != null)
{
if (contextOwnerResult.Member == null && contextOwnerResult.Type != null)
{
isStatic.Flags |= FlagType.Static;
}
}
}
else if (member != null && (member.Flags & FlagType.Static) > 0)
{
isStatic.Flags |= FlagType.Static;
}
ASResult returnType = null;
int lineNum = sci.CurrentLine;
string line = sci.GetLine(lineNum);
Match m = Regex.Match(line, "\\b" + Regex.Escape(contextToken) + "\\(");
if (m.Success)
{
returnType = new ASResult();
returnType.Type = ASContext.Context.ResolveType("Function", null);
}
else
{
m = Regex.Match(line, @"=\s*[^;\n\r}}]+");
if (m.Success)
{
int posLineStart = sci.PositionFromLine(lineNum);
if (posLineStart + m.Index >= sci.CurrentPos)
{
line = line.Substring(m.Index);
StatementReturnType rType = GetStatementReturnType(sci, inClass, line, posLineStart + m.Index);
if (rType != null)
{
returnType = rType.resolve;
}
}
}
}
if (varResult.RelClass != null && !varResult.RelClass.IsVoid() && !varResult.RelClass.Equals(inClass))
{
AddLookupPosition();
lookupPosition = -1;
ASContext.MainForm.OpenEditableDocument(varResult.RelClass.InFile.FileName, false);
sci = ASContext.CurSciControl;
isOtherClass = true;
FileModel fileModel = new FileModel();
fileModel.Context = ASContext.Context;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(fileModel, sci.Text);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(varResult.RelClass.QualifiedName))
{
varResult.RelClass = cm;
break;
}
}
inClass = varResult.RelClass;
ASContext.Context.UpdateContext(inClass.LineFrom);
}
latest = GetLatestMemberForVariable(job, inClass, varVisi, isStatic);
// if we generate variable in current class..
if (!isOtherClass && member == null)
{
detach = false;
lookupPosition = -1;
position = sci.WordStartPosition(sci.CurrentPos, true);
sci.SetSel(position, sci.WordEndPosition(position, true));
}
else // if we generate variable in another class
{
if (latest != null)
{
//.........这里部分代码省略.........
示例6: ChangeConstructorDecl
private static void ChangeConstructorDecl(ScintillaControl sci, MemberModel member, ClassModel inClass)
{
int wordPos = sci.WordEndPosition(sci.CurrentPos, true);
List<FunctionParameter> functionParameters = ParseFunctionParameters(sci, wordPos);
ASResult funcResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
if (funcResult == null || funcResult.Type == null) return;
if (funcResult.Type != null && !funcResult.Type.Equals(inClass))
{
AddLookupPosition();
lookupPosition = -1;
ASContext.MainForm.OpenEditableDocument(funcResult.Type.InFile.FileName, true);
sci = ASContext.CurSciControl;
FileModel fileModel = new FileModel(funcResult.Type.InFile.FileName);
fileModel.Context = ASContext.Context;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(fileModel, sci.Text);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(funcResult.Type.QualifiedName))
{
funcResult.Type = cm;
break;
}
}
inClass = funcResult.Type;
ASContext.Context.UpdateContext(inClass.LineFrom);
}
foreach (MemberModel m in inClass.Members)
{
if ((m.Flags & FlagType.Constructor) > 0)
{
funcResult.Member = m;
break;
}
}
if (funcResult.Member == null) return;
if (IsHaxe) funcResult.Member.Name = "new";
ChangeDecl(sci, funcResult.Member, functionParameters);
}
示例7: ChangeMethodDecl
private static void ChangeMethodDecl(ScintillaControl Sci, MemberModel member, ClassModel inClass)
{
int wordPos = Sci.WordEndPosition(Sci.CurrentPos, true);
List<FunctionParameter> functionParameters = ParseFunctionParameters(Sci, wordPos);
ASResult funcResult = ASComplete.GetExpressionType(Sci, Sci.WordEndPosition(Sci.CurrentPos, true));
if (funcResult == null || funcResult.Member == null) return;
if (funcResult.InClass != null && !funcResult.InClass.Equals(inClass))
{
AddLookupPosition();
lookupPosition = -1;
ASContext.MainForm.OpenEditableDocument(funcResult.InClass.InFile.FileName, true);
Sci = ASContext.CurSciControl;
FileModel fileModel = new FileModel();
fileModel.Context = ASContext.Context;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(fileModel, Sci.Text);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(funcResult.InClass.QualifiedName))
{
funcResult.InClass = cm;
break;
}
}
inClass = funcResult.InClass;
ASContext.Context.UpdateContext(inClass.LineFrom);
}
MemberList members = inClass.Members;
foreach (MemberModel m in members)
{
if (m.Equals(funcResult.Member))
{
funcResult.Member = m;
break;
}
}
ChangeDecl(Sci, funcResult.Member, functionParameters);
}
示例8: ContextualGenerator
public static void ContextualGenerator(ScintillaControl Sci, List<ICompletionListItem> options)
{
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;
int style = Sci.BaseStyleAt(position);
if (style == 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 && ASComplete.IsLiteralStyle(style))
{
ShowConvertToConst(found, options);
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, options);
return;
}
if (resolve.Member != null && !ASContext.Context.CurrentClass.IsVoid()
&& (resolve.Member.Flags & FlagType.LocalVar) > 0) // promote to class var
{
contextMember = resolve.Member;
ShowPromoteLocalAndAddParameter(found, options);
return;
}
}
if (contextToken != null && resolve.Member == null) // import declaration
{
if ((resolve.Type == null || resolve.Type.IsVoid() || !ASContext.Context.IsImported(resolve.Type, line)) && CheckAutoImport(found, options)) return;
if (resolve.Type == null)
{
suggestItemDeclaration = ASComplete.IsTextStyle(Sci.BaseStyleAt(position - 1));
}
}
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, options))
return;
}
ShowGetSetList(found, options);
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, options);
return;
}
m = Regex.Match(text, String.Format(patternAS2Delegate, contextToken), RegexOptions.IgnoreCase);
//.........这里部分代码省略.........
示例9: PositionInfos
public PositionInfos(ScintillaControl sci, Int32 position, String argString)
{
// Variables
String[] vars = argString.Split('¤');
this.ArgCurWord = vars[0];
this.ArgPackageName = vars[1];
this.ArgClassName = vars[2];
this.ArgClassType = vars[3];
this.ArgMemberName = vars[4];
this.ArgMemberType = vars[5];
// Selection
Int32 ss = sci.SelectionStart;
Int32 se = sci.SelectionEnd;
if (se != ss)
{
this.SelectionStart = ss;
this.SelectionEnd = se;
this.HasSelection = true;
if (sci.LineFromPosition(ss) != sci.LineFromPosition(se))
this.SelectionIsMultiline = true;
else SelectedText = sci.SelText;
}
// Current
this.CurrentPosition = position;
this.CurrentCharCode = sci.CharAt(position);
this.CurrentIsWhiteChar = (HelpTools.IsWhiteChar(this.CurrentCharCode));
this.CurrentIsDotChar = (this.CurrentCharCode == 46);
this.CurrentIsActionScriptChar = HelpTools.IsActionScriptChar(this.CurrentCharCode);
this.CurrentIsWordChar = HelpTools.IsWordChar((byte)this.CurrentCharCode);
Int32 s = sci.StyleAt(position);
this.CurrentIsInsideComment = (s == 1 || s == 2 || s == 3 || s == 17);
// Next
Int32 np = sci.PositionAfter(position);
if (np != position)
this.NextPosition = np;
else
this.CaretIsAtEndOfDocument = true;
// Word
this.CodePage = sci.CodePage; // (UTF-8|Big Endian|Little Endian : 65001) (8 Bits|UTF-7 : 0)
if (this.CurrentIsInsideComment == false && this.SelectionIsMultiline == false)
{
Int32 wsp = sci.WordStartPosition(position, true);
// Attention (WordEndPosition n'est pas estimé comme par defaut)
Int32 wep = sci.PositionBefore(sci.WordEndPosition(position, true));
if (this.CodePage != 65001)
{
wsp = HelpTools.GetWordStartPositionByWordChar(sci, position);
// Attention (WordEndPosition n'est pas estimé comme par defaut)
wep = sci.PositionBefore(HelpTools.GetWordEndPositionByWordChar(sci, position));
}
this.WordStartPosition = wsp;
this.WordEndPosition = wep;
if (this.CodePage == 65001)
this.WordFromPosition = this.ArgCurWord;
else
this.WordFromPosition = HelpTools.GetText(sci, wsp, sci.PositionAfter(wep));
if (position > wep)
this.CaretIsAfterLastLetter = true;
}
// Previous
if (this.CurrentPosition > 0)
{
this.PreviousPosition = sci.PositionBefore(position);
this.PreviousCharCode = sci.CharAt(this.PreviousPosition);
this.PreviousIsWhiteChar = HelpTools.IsWhiteChar(this.PreviousCharCode);
this.PreviousIsDotChar = (this.PreviousCharCode == 46);
this.PreviousIsActionScriptChar = HelpTools.IsActionScriptChar(this.PreviousCharCode);
}
// Line
this.CurrentLineIdx = sci.LineFromPosition(position);
if (this.CurrentPosition > 0)
this.PreviousLineIdx = sci.LineFromPosition(this.PreviousPosition);
this.LineIdxMax = sci.LineCount - 1;
this.LineStartPosition = HelpTools.LineStartPosition(sci, this.CurrentLineIdx);
this.LineEndPosition = sci.LineEndPosition(this.CurrentLineIdx);
this.NewLineMarker = LineEndDetector.GetNewLineMarker(sci.EOLMode);
// Previous / Next
if (this.WordStartPosition != -1)
{
this.PreviousNonWhiteCharPosition = HelpTools.PreviousNonWhiteCharPosition(sci, this.WordStartPosition);
this.PreviousWordIsFunction = (sci.GetWordFromPosition(this.PreviousNonWhiteCharPosition) == "function");
this.NextNonWhiteCharPosition = HelpTools.NextNonWhiteCharPosition(sci, this.WordEndPosition);
}
// Function
if (this.PreviousWordIsFunction)
{
//.........这里部分代码省略.........
示例10: UpdateHighlightUnderCursor
/// <summary>
///
/// </summary>
private void UpdateHighlightUnderCursor(ScintillaControl sci)
{
string file = PluginBase.MainForm.CurrentDocument.FileName;
if (!IsValidFile(file)) return;
int currentPos = sci.CurrentPos;
string newToken = sci.GetWordFromPosition(currentPos);
if (!string.IsNullOrEmpty(newToken)) newToken = newToken.Trim();
if (!string.IsNullOrEmpty(newToken))
{
if (prevResult == null && prevToken == newToken) return;
ASResult result = IsValidFile(file) ? ASComplete.GetExpressionType(sci, sci.WordEndPosition(currentPos, true)) : null;
if (result != null && !result.IsNull())
{
if (prevResult != null && (result.Member != prevResult.Member || result.Type != prevResult.Type || result.Path != prevResult.Path)) return;
RemoveHighlights(sci);
prevToken = newToken;
prevResult = result;
List<SearchMatch> matches = FilterResults(GetResults(sci, prevToken), result, sci);
if (matches == null || matches.Count == 0) return;
highlightUnderCursorTimer.Stop();
AddHighlights(sci, matches);
}
else RemoveHighlights(sci);
}
else RemoveHighlights(sci);
}
示例11: FilterResults
/// <summary>
/// TODO slavara: IMPLEMENT ME
/// </summary>
/// <param name="matches"></param>
/// <param name="exprType"></param>
/// <param name="sci"></param>
/// <returns></returns>
private List<SearchMatch> FilterResults(List<SearchMatch> matches, ASResult exprType, ScintillaControl sci)
{
if (matches == null || matches.Count == 0) return null;
MemberModel contextMember = null;
int lineFrom = 0;
int lineTo = sci.LineCount;
FlagType localVarMask = FlagType.LocalVar | FlagType.ParameterVar;
bool isLocalVar = false;
if (exprType.Member != null)
{
if ((exprType.Member.Flags & localVarMask) > 0)
{
contextMember = exprType.Context.ContextFunction;
lineFrom = contextMember.LineFrom;
lineTo = contextMember.LineTo;
isLocalVar = true;
}
}
List<SearchMatch> newMatches = new List<SearchMatch>();
foreach (SearchMatch m in matches)
{
if (m.Line < lineFrom || m.Line > lineTo) continue;
int pos = sci.MBSafePosition(m.Index);
exprType = ASComplete.GetExpressionType(sci, sci.WordEndPosition(pos, true));
if (exprType != null)
{
MemberModel member = exprType.Member;
if (!isLocalVar)
{
if ((exprType.Type != null && member == null) || (member != null && (member.Flags & localVarMask) == 0)) newMatches.Add(m);
}
else if (member != null && (member.Flags & localVarMask) > 0) newMatches.Add(m);
}
}
return newMatches;
}
示例12: GenerateFunctionJob
private static void GenerateFunctionJob(GeneratorJobType job, ScintillaControl sci, MemberModel member, bool detach, ClassModel inClass)
{
var position = 0;
bool isOtherClass = false;
Visibility visibility = job.Equals(GeneratorJobType.FunctionPublic) ? Visibility.Public : GetDefaultVisibility(inClass);
int wordPos = sci.WordEndPosition(sci.CurrentPos, true);
List<FunctionParameter> functionParameters = ParseFunctionParameters(sci, wordPos);
// evaluate, if the function should be generated in other class
ASResult funcResult = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
var memberIsStatic = member != null && (member.Flags & FlagType.Static) > 0;
var dot = ASContext.Context.Features.dot;
if (ASContext.CommonSettings.GenerateScope && !funcResult.Context.Value.Contains(dot))
{
position = sci.CurrentPos;
var start = sci.WordStartPosition(position, true);
var length = sci.MBSafeTextLength(contextToken);
sci.SetSel(start, start + length);
var scope = memberIsStatic ? inClass.QualifiedName : "this";
var text = scope + dot + contextToken;
sci.ReplaceSel(text);
UpdateLookupPosition(position, text.Length - length);
}
int contextOwnerPos = GetContextOwnerEndPos(sci, sci.WordStartPosition(sci.CurrentPos, true));
MemberModel isStatic = new MemberModel();
if (contextOwnerPos != -1)
{
ASResult contextOwnerResult = ASComplete.GetExpressionType(sci, contextOwnerPos);
if (contextOwnerResult != null
&& (contextOwnerResult.Member == null || (contextOwnerResult.Member.Flags & FlagType.Constructor) > 0)
&& contextOwnerResult.Type != null)
{
isStatic.Flags |= FlagType.Static;
}
}
else if (memberIsStatic)
{
isStatic.Flags |= FlagType.Static;
}
if (funcResult.RelClass != null && !funcResult.RelClass.IsVoid() && !funcResult.RelClass.Equals(inClass))
{
AddLookupPosition();
lookupPosition = -1;
ASContext.MainForm.OpenEditableDocument(funcResult.RelClass.InFile.FileName, true);
sci = ASContext.CurSciControl;
isOtherClass = true;
FileModel fileModel = new FileModel();
fileModel.Context = ASContext.Context;
ASFileParser parser = new ASFileParser();
parser.ParseSrc(fileModel, sci.Text);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(funcResult.RelClass.QualifiedName))
{
funcResult.RelClass = cm;
break;
}
}
inClass = funcResult.RelClass;
ASContext.Context.UpdateContext(inClass.LineFrom);
}
string blockTmpl;
if ((isStatic.Flags & FlagType.Static) > 0)
{
blockTmpl = TemplateUtils.GetBoundary("StaticMethods");
}
else if ((visibility & Visibility.Public) > 0)
{
blockTmpl = TemplateUtils.GetBoundary("PublicMethods");
}
else
{
blockTmpl = TemplateUtils.GetBoundary("PrivateMethods");
}
var latest = TemplateUtils.GetTemplateBlockMember(sci, blockTmpl);
if (latest == null || (!isOtherClass && member == null))
{
latest = GetLatestMemberForFunction(inClass, visibility, isStatic);
// if we generate function in current class..
if (!isOtherClass)
{
MethodsGenerationLocations location = ASContext.CommonSettings.MethodsGenerationLocations;
if (member == null)
{
detach = false;
lookupPosition = -1;
position = sci.WordStartPosition(sci.CurrentPos, true);
sci.SetSel(position, sci.WordEndPosition(position, true));
}
else if (latest != null && location == MethodsGenerationLocations.AfterSimilarAccessorMethod)
{
position = sci.PositionFromLine(latest.LineTo + 1) - (sci.EOLMode == 0 ? 2 : 1);
sci.SetSel(position, position);
}
else
{
//.........这里部分代码省略.........
示例13: GetWordFromPosition
/// <summary>
/// Gets a word from the specified position
/// </summary>
public static string GetWordFromPosition(ScintillaControl sci,int position, ref int start, ref int end)
{
try
{
//startPosition = sci.MBSafeCharPosition(sci.WordStartPosition(position, true));
//endPosition = sci.MBSafeCharPosition(sci.WordEndPosition(position, true));
//string keyword = sci.Text.Substring(startPosition, endPosition - startPosition);
start = sci.WordStartPosition(position, true);
end = sci.WordEndPosition(position, true);
int startPosition = sci.MBSafeCharPosition(start);
int endPosition = sci.MBSafeCharPosition(end);
string keyword = sci.Text.Substring(startPosition, endPosition - startPosition);
if (keyword.Length==0 || keyword.Equals(" ")) return null;
//startPosition = sci.WordStartPosition(position, true);
//endPosition = sci.WordEndPosition(position, true);
return keyword.Trim();
}
catch
{
return null;
}
}
示例14: GenerateDelegateMethods
//.........这里部分代码省略.........
if (m.Parameters != null && m.Parameters.Count > 0)
{
MemberModel mm = m.Parameters[m.Parameters.Count - 1];
if (mm.Name.StartsWithOrdinal("..."))
isVararg = true;
}
string callMethodTemplate = TemplateUtils.GetTemplate("CallFunction");
if (!isVararg)
{
callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Name", member.Name + "." + m.Name);
callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Arguments",
TemplateUtils.CallParametersString(m));
callMethodTemplate += ";";
}
else
{
List<MemberModel> pseudoParamsList = new List<MemberModel>();
pseudoParamsList.Add(new MemberModel("null", null, FlagType.ParameterVar, 0));
pseudoParamsList.Add(new MemberModel("[$(Subarguments)].concat($(Lastsubargument))", null, FlagType.ParameterVar, 0));
MemberModel pseudoParamsOwner = new MemberModel();
pseudoParamsOwner.Parameters = pseudoParamsList;
callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Name",
member.Name + "." + m.Name + ".apply");
callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Arguments",
TemplateUtils.CallParametersString(pseudoParamsOwner));
callMethodTemplate += ";";
List<MemberModel> arrayParamsList = new List<MemberModel>();
for (int i = 0; i < m.Parameters.Count - 1; i++)
{
MemberModel param = m.Parameters[i];
arrayParamsList.Add(param);
}
pseudoParamsOwner.Parameters = arrayParamsList;
callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Subarguments",
TemplateUtils.CallParametersString(pseudoParamsOwner));
callMethodTemplate = TemplateUtils.ReplaceTemplateVariable(callMethodTemplate, "Lastsubargument",
m.Parameters[m.Parameters.Count - 1].Name.TrimStart(new char[] { '.', ' '}));
}
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Body", callMethodTemplate);
}
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "BlankLine", NewLine);
result += methodTemplate;
if (m.Parameters != null)
{
for (int i = 0; i < m.Parameters.Count; i++)
{
MemberModel param = m.Parameters[i];
if (param.Type != null)
{
type = ASContext.Context.ResolveType(param.Type, selectedMembers[m].InFile);
importsList.Add(type.QualifiedName);
}
}
}
if (position < 0)
{
MemberModel latest = GetLatestMemberForFunction(inClass, mCopy.Access, mCopy);
if (latest == null)
{
position = Sci.WordStartPosition(Sci.CurrentPos, true);
Sci.SetSel(position, Sci.WordEndPosition(position, true));
}
else
{
position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 2 : 1);
Sci.SetSel(position, position);
}
}
else
{
position = Sci.CurrentPos;
}
if (m.Type != null)
{
type = ASContext.Context.ResolveType(m.Type, selectedMembers[m].InFile);
importsList.Add(type.QualifiedName);
}
}
if (importsList.Count > 0 && position > -1)
{
int o = AddImportsByName(importsList, Sci.LineFromPosition(position));
position += o;
Sci.SetSel(position, position);
}
InsertCode(position, result, Sci);
}
finally { Sci.EndUndoAction(); }
}
示例15: EventMetatag
private static void EventMetatag(ClassModel inClass, ScintillaControl sci, MemberModel member)
{
ASResult resolve = ASComplete.GetExpressionType(sci, sci.WordEndPosition(sci.CurrentPos, true));
string line = sci.GetLine(inClass.LineFrom);
int position = sci.PositionFromLine(inClass.LineFrom) + (line.Length - line.TrimStart().Length);
string value = resolve.Member.Value;
if (value != null)
{
if (value.StartsWith('\"'))
{
value = value.Trim(new char[] { '"' });
}
else if (value.StartsWith('\''))
{
value = value.Trim(new char[] { '\'' });
}
}
else value = resolve.Member.Type;
if (string.IsNullOrEmpty(value))
return;
Regex re1 = new Regex("'(?:[^'\\\\]|(?:\\\\\\\\)|(?:\\\\\\\\)*\\\\.{1})*'");
Regex re2 = new Regex("\"(?:[^\"\\\\]|(?:\\\\\\\\)|(?:\\\\\\\\)*\\\\.{1})*\"");
Match m1 = re1.Match(value);
Match m2 = re2.Match(value);
if (m1.Success || m2.Success)
{
Match m = null;
if (m1.Success && m2.Success) m = m1.Index > m2.Index ? m2 : m1;
else if (m1.Success) m = m1;
else m = m2;
value = value.Substring(m.Index + 1, m.Length - 2);
}
string template = TemplateUtils.GetTemplate("EventMetatag");
template = TemplateUtils.ReplaceTemplateVariable(template, "Name", value);
template = TemplateUtils.ReplaceTemplateVariable(template, "Type", contextParam);
template += "\n$(Boundary)";
AddLookupPosition();
sci.CurrentPos = position;
sci.SetSel(position, position);
InsertCode(position, template, sci);
}