本文整理汇总了C#中ScintillaNet.WordStartPosition方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaNet.WordStartPosition方法的具体用法?C# ScintillaNet.WordStartPosition怎么用?C# ScintillaNet.WordStartPosition使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet
的用法示例。
在下文中一共展示了ScintillaNet.WordStartPosition方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GenerateDelegateMethods
//.........这里部分代码省略.........
if (m.Parameters != null && m.Parameters.Count > 0)
{
MemberModel mm = m.Parameters[m.Parameters.Count - 1];
if (mm.Name.StartsWith("..."))
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);
}
finally { Sci.EndUndoAction(); }
}
示例2: GenerateDefaultHandlerName
private static void GenerateDefaultHandlerName(ScintillaNet.ScintillaControl Sci, int position, int targetPos, string eventName, bool closeBrace)
{
string target = null;
int contextOwnerPos = GetContextOwnerEndPos(Sci, Sci.WordStartPosition(targetPos, true));
if (contextOwnerPos != -1)
{
ASResult contextOwnerResult = ASComplete.GetExpressionType(Sci, contextOwnerPos);
if (contextOwnerResult != null && !contextOwnerResult.IsNull()
&& contextOwnerResult.Member != null)
{
if (contextOwnerResult.Member.Name == "contentLoaderInfo" && Sci.CharAt(contextOwnerPos) == '.')
{
// we want to name the event from the loader var and not from the contentLoaderInfo parameter
contextOwnerPos = GetContextOwnerEndPos(Sci, Sci.WordStartPosition(contextOwnerPos - 1, true));
if (contextOwnerPos != -1)
{
contextOwnerResult = ASComplete.GetExpressionType(Sci, contextOwnerPos);
if (contextOwnerResult != null && !contextOwnerResult.IsNull()
&& contextOwnerResult.Member != null)
{
target = contextOwnerResult.Member.Name;
}
}
}
else
{
target = contextOwnerResult.Member.Name;
}
}
}
eventName = Camelize(eventName.Substring(eventName.LastIndexOf('.') + 1));
if (target != null) target = target.TrimStart(new char[] { '_' });
switch (ASContext.CommonSettings.HandlerNamingConvention)
{
case HandlerNamingConventions.handleTargetEventName:
if (target == null) contextToken = "handle" + Capitalize(eventName);
else contextToken = "handle" + Capitalize(target) + Capitalize(eventName);
break;
case HandlerNamingConventions.onTargetEventName:
if (target == null) contextToken = "on" + Capitalize(eventName);
else contextToken = "on" + Capitalize(target) + Capitalize(eventName);
break;
case HandlerNamingConventions.target_eventNameHandler:
if (target == null) contextToken = eventName + "Handler";
else contextToken = target + "_" + eventName + "Handler";
break;
default: //HandlerNamingConventions.target_eventName
if (target == null) contextToken = eventName;
else contextToken = target + "_" + eventName;
break;
}
char c = (char)Sci.CharAt(position - 1);
if (c == ',') InsertCode(position, "$(Boundary) " + contextToken + "$(Boundary)");
else InsertCode(position, contextToken);
position = Sci.WordEndPosition(position + 1, true);
Sci.SetSel(position, position);
c = (char)Sci.CharAt(position);
if (c <= 32) if (closeBrace) Sci.ReplaceSel(");"); else Sci.ReplaceSel(";");
Sci.SetSel(position, position);
}
示例3: GenerateFunctionJob
private static void GenerateFunctionJob(GeneratorJobType job, ScintillaNet.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();
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;
DockContent dc = 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);
}
}
//.........这里部分代码省略.........
示例4: GenerateVariableJob
private static void GenerateVariableJob(GeneratorJobType job, ScintillaNet.ScintillaControl Sci, MemberModel member,
bool detach, ClassModel inClass)
{
int position = 0;
MemberModel latest = null;
bool isOtherClass = false;
Visibility varVisi = job.Equals(GeneratorJobType.Variable) ? GetDefaultVisibility() : 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)
{
//.........这里部分代码省略.........
示例5: ConvertToConst
private static void ConvertToConst(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member, bool detach)
{
String suggestion = "NEW_CONST";
String label = TextHelper.GetString("ASCompletion.Label.ConstName");
String title = TextHelper.GetString("ASCompletion.Title.ConvertToConst");
Hashtable info = new Hashtable();
info["suggestion"] = suggestion;
info["label"] = label;
info["title"] = title;
DataEvent de = new DataEvent(EventType.Command, "ProjectManager.LineEntryDialog", info);
EventManager.DispatchEvent(null, de);
if (!de.Handled)
return;
suggestion = (string)info["suggestion"];
int position = Sci.CurrentPos;
MemberModel latest = null;
int wordPosEnd = Sci.WordEndPosition(position, true);
int wordPosStart = Sci.WordStartPosition(position, true);
char cr = (char)Sci.CharAt(wordPosEnd);
if (cr == '.')
{
wordPosEnd = Sci.WordEndPosition(wordPosEnd + 1, true);
}
else
{
cr = (char)Sci.CharAt(wordPosStart - 1);
if (cr == '.')
{
wordPosStart = Sci.WordStartPosition(wordPosStart - 1, true);
}
}
Sci.SetSel(wordPosStart, wordPosEnd);
string word = Sci.SelText;
Sci.ReplaceSel(suggestion);
if (member == null)
{
detach = false;
lookupPosition = -1;
position = Sci.WordStartPosition(Sci.CurrentPos, true);
Sci.SetSel(position, Sci.WordEndPosition(position, true));
}
else
{
latest = GetLatestMemberForVariable(GeneratorJobType.Constant, inClass,
Visibility.Private, new MemberModel("", "", FlagType.Static, 0));
if (latest != null)
{
position = FindNewVarPosition(Sci, inClass, latest);
}
else
{
position = GetBodyStart(inClass.LineFrom, inClass.LineTo, Sci);
detach = false;
}
if (position <= 0) return;
Sci.SetSel(position, position);
}
MemberModel m = NewMember(suggestion, member, FlagType.Variable | FlagType.Constant | FlagType.Static);
m.Type = ASContext.Context.Features.numberKey;
m.Value = word;
GenerateVariable(m, position, detach);
}
示例6: GenerateDelegateMethods
//.........这里部分代码省略.........
.Append(".")
.Append(m.Name)
.Append("(");
if (methodParams != null)
{
for (int i = 0; i < methodParams.Count; i++)
{
MemberModel param = methodParams[i];
sb.Append(param.Name);
if (i + 1 < methodParams.Count)
{
sb.Append(", ");
}
}
}
sb.Append(");");
}
else
{
sb.Append(member.Name)
.Append(".")
.Append(m.Name)
.Append(".apply(null, [");
for (int i = 0; i < methodParams.Count; i++)
{
MemberModel param = methodParams[i];
if (i + 1 < methodParams.Count)
{
sb.Append(param.Name);
if (i + 2 < methodParams.Count)
{
sb.Append(", ");
}
}
else
{
sb.Append("].concat(")
.Append(param.Name.Substring(3))
.Append(")");
}
}
sb.Append(");");
}
sb.Append("\n}");
if (methodParams != null)
{
for (int i = 0; i < methodParams.Count; i++)
{
MemberModel param = methodParams[i];
if (param.Type != null)
{
type = ASContext.Context.ResolveType(param.Type, selectedMembers[m].InFile);
importsList.Add(type.QualifiedName);
}
}
}
if (position < 0)
{
latest = FindLatest(FlagType.Function, inClass);
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, sb.ToString());
}
finally { Sci.EndUndoAction(); }
}
示例7: ConvertToConst
private static void ConvertToConst(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member, bool detach)
{
String suggestion = "NEW_CONST";
String label = TextHelper.GetString("ASCompletion.Label.ConstName");
String title = TextHelper.GetString("ASCompletion.Title.ConvertToConst");
Hashtable info = new Hashtable();
info["suggestion"] = suggestion;
info["label"] = label;
info["title"] = title;
DataEvent de = new DataEvent(EventType.Command, "LineEntryDialog", info);
EventManager.DispatchEvent(null, de);
if (!de.Handled)
{
return;
}
suggestion = (string)info["suggestion"];
int position = Sci.CurrentPos;
MemberModel latest = null;
int wordPosEnd = Sci.WordEndPosition(position, true);
int wordPosStart = Sci.WordStartPosition(position, true);
char cr = (char)Sci.CharAt(wordPosEnd);
if (cr == '.')
{
wordPosEnd = Sci.WordEndPosition(wordPosEnd + 1, true);
}
else
{
cr = (char)Sci.CharAt(wordPosStart - 1);
if (cr == '.')
{
wordPosStart = Sci.WordStartPosition(wordPosStart - 1, true);
}
}
Sci.SetSel(wordPosStart, wordPosEnd);
string word = Sci.SelText;
Sci.ReplaceSel(suggestion);
if (member == null)
{
detach = false;
lookupPosition = -1;
position = Sci.WordStartPosition(Sci.CurrentPos, true);
Sci.SetSel(position, Sci.WordEndPosition(position, true));
}
else
{
latest = FindLatest(FlagType.Constant, GetDefaultVisibility(), inClass)
?? FindLatest(FlagType.Variable, GetDefaultVisibility(), inClass);
if (latest != null)
{
position = FindNewVarPosition(Sci, inClass, latest);
}
else
{
position = GetBodyStart(inClass.LineFrom, inClass.LineTo, Sci);
detach = false;
}
if (position <= 0) return;
Sci.SetSel(position, position);
}
contextToken = suggestion + ":Number = " + word + "";
GenerateVariable(
NewMember(contextToken, member, FlagType.Variable | FlagType.Constant | FlagType.Static),
position, detach);
}