本文整理汇总了C#中ScintillaNet.SetSel方法的典型用法代码示例。如果您正苦于以下问题:C# ScintillaNet.SetSel方法的具体用法?C# ScintillaNet.SetSel怎么用?C# ScintillaNet.SetSel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ScintillaNet
的用法示例。
在下文中一共展示了ScintillaNet.SetSel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ExecuteActionPoint
/// <summary>
/// Selects the text specified in the action point
/// </summary>
public static void ExecuteActionPoint(ActionPoint point, ScintillaNet.ScintillaControl sci)
{
if (point.EntryPosition != -1 && point.ExitPosition != -1)
{
Int32 start = sci.MBSafePosition(point.EntryPosition);
Int32 end = sci.MBSafePosition(point.ExitPosition);
sci.SetSel(start, end);
}
else if (point.EntryPosition != -1 && point.ExitPosition == -1)
{
Int32 start = sci.MBSafePosition(point.EntryPosition);
sci.SetSel(start, start);
}
}
示例2: PostProcessSnippets
/// <summary>
/// Processes the snippet and template arguments
/// </summary>
public static Int32 PostProcessSnippets(ScintillaNet.ScintillaControl sci, Int32 currentPosition)
{
Int32 delta = 0;
while (sci.SelectText(BOUNDARY, 0) != -1) { sci.ReplaceSel(""); delta -= BOUNDARY.Length; }
String text = sci.Text; // Store text temporarily
Int32 entryPosition = sci.MBSafePosition(text.IndexOf(ENTRYPOINT));
Int32 exitPosition = sci.MBSafePosition(text.IndexOf(EXITPOINT));
if (entryPosition != -1 && exitPosition != -1)
{
sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
sci.SelectText(EXITPOINT, 0); sci.ReplaceSel(""); delta -= EXITPOINT.Length;
sci.SetSel(entryPosition, exitPosition - ENTRYPOINT.Length);
}
else if (entryPosition != -1 && exitPosition == -1)
{
sci.SelectText(ENTRYPOINT, 0); sci.ReplaceSel(""); delta -= ENTRYPOINT.Length;
sci.SetSel(entryPosition, entryPosition);
}
else sci.SetSel(currentPosition, currentPosition);
return delta;
}
示例3: 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(); }
}
示例4: RenameMember
public static bool RenameMember(ScintillaNet.ScintillaControl Sci, MemberModel member, string newName)
{
ContextFeatures features = ASContext.Context.Features;
string kind = features.varKey;
if ((member.Flags & FlagType.Getter) > 0)
kind = features.getKey;
else if ((member.Flags & FlagType.Setter) > 0)
kind = features.setKey;
else if (member.Flags == FlagType.Function)
kind = features.functionKey;
Regex reMember = new Regex(String.Format(@"{0}\s+({1})[\s:]", kind, member.Name));
string line;
Match m;
int index, position;
for (int i = member.LineFrom; i <= member.LineTo; i++)
{
line = Sci.GetLine(i);
m = reMember.Match(line);
if (m.Success)
{
index = Sci.MBSafeTextLength(line.Substring(0, m.Groups[1].Index));
position = Sci.PositionFromLine(i) + index;
Sci.SetSel(position, position + member.Name.Length);
Sci.ReplaceSel(newName);
UpdateLookupPosition(position, 1);
return true;
}
}
return false;
}
示例5: RemoveOneLocalDeclaration
private static bool RemoveOneLocalDeclaration(ScintillaNet.ScintillaControl Sci, MemberModel contextMember)
{
string type = "";
if (contextMember.Type != null && (contextMember.Flags & FlagType.Inferred) == 0)
{
type = FormatType(contextMember.Type);
if (type.IndexOf('*') > 0)
type = type.Replace("/*", @"/\*\s*").Replace("*/", @"\s*\*/");
type = @":\s*" + type;
}
Regex reDecl = new Regex(String.Format(@"[\s\(]((var|const)\s+{0}\s*{1})\s*", contextMember.Name, type));
for (int i = contextMember.LineFrom; i <= contextMember.LineTo + 10; i++)
{
string text = Sci.GetLine(i);
Match m = reDecl.Match(text);
if (m.Success)
{
int index = Sci.MBSafeTextLength(text.Substring(0, m.Groups[1].Index));
int position = Sci.PositionFromLine(i) + index;
int len = Sci.MBSafeTextLength(m.Groups[1].Value);
Sci.SetSel(position, position + len);
if (contextMember.Type == null || (contextMember.Flags & FlagType.Inferred) != 0) Sci.ReplaceSel(contextMember.Name + " ");
else Sci.ReplaceSel(contextMember.Name);
UpdateLookupPosition(position, contextMember.Name.Length - len);
return true;
}
}
return false;
}
示例6: 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);
}
示例7: 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)
{
//.........这里部分代码省略.........
示例8: GenerateFieldFromParameter
private static void GenerateFieldFromParameter(ScintillaNet.ScintillaControl Sci, MemberModel member, ClassModel inClass,
Visibility scope)
{
int funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, Sci);
Sci.SetSel(funcBodyStart, Sci.LineEndPosition(member.LineTo));
string body = Sci.SelText;
string trimmed = body.TrimStart();
Regex re = new Regex("^super\\s*[\\(|\\.]");
Match m = re.Match(trimmed);
if (m.Success)
{
if (m.Index == 0)
{
int p = funcBodyStart + (body.Length - trimmed.Length);
int l = Sci.LineFromPosition(p);
p = Sci.PositionFromLine(l + 1);
funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, Sci, p);
}
}
Sci.SetSel(funcBodyStart, funcBodyStart);
Sci.CurrentPos = funcBodyStart;
bool isVararg = false;
string paramName = contextMember.Name;
if (paramName.StartsWith("..."))
{
paramName = paramName.TrimStart(new char[] { ' ', '.' });
isVararg = true;
}
string varName = paramName;
string scopedVarName = varName;
if ((scope & Visibility.Public) > 0)
{
if ((member.Flags & FlagType.Static) > 0)
scopedVarName = inClass.Name + "." + varName;
else
scopedVarName = "this." + varName;
}
else
{
if (ASContext.CommonSettings.PrefixFields.Length > 0 && !paramName.StartsWith(ASContext.CommonSettings.PrefixFields))
{
scopedVarName = varName = ASContext.CommonSettings.PrefixFields + varName;
}
if (ASContext.CommonSettings.GenerateScope || ASContext.CommonSettings.PrefixFields == "")
{
if ((member.Flags & FlagType.Static) > 0)
scopedVarName = inClass.Name + "." + varName;
else
scopedVarName = "this." + varName;
}
}
string template = TemplateUtils.GetTemplate("FieldFromParameter");
template = TemplateUtils.ReplaceTemplateVariable(template, "Name", scopedVarName);
template = TemplateUtils.ReplaceTemplateVariable(template, "Value", paramName);
template += "\n$(Boundary)";
SnippetHelper.InsertSnippetText(Sci, funcBodyStart, template);
MemberList classMembers = inClass.Members;
foreach (MemberModel classMember in classMembers)
if (classMember.Name.Equals(varName))
return;
MemberModel latest = GetLatestMemberForVariable(GeneratorJobType.Variable, inClass, GetDefaultVisibility(), new MemberModel());
if (latest == null) return;
int position = FindNewVarPosition(Sci, inClass, latest);
if (position <= 0) return;
Sci.SetSel(position, position);
Sci.CurrentPos = position;
MemberModel mem = NewMember(varName, member, FlagType.Variable, scope);
if (isVararg) mem.Type = "Array";
else mem.Type = contextMember.Type;
GenerateVariable(mem, position, true);
ASContext.Panel.RestoreLastLookupPosition();
}
示例9: 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(); }
}
示例10: GenerateOverride
static public void GenerateOverride(ScintillaNet.ScintillaControl Sci, ClassModel ofClass, MemberModel member, int position)
{
ContextFeatures features = ASContext.Context.Features;
List<string> typesUsed = new List<string>();
bool isProxy = (member.Namespace == "flash_proxy");
if (isProxy) typesUsed.Add("flash.utils.flash_proxy");
bool isAS2Event = ASContext.Context.Settings.LanguageId == "AS2" && member.Name.StartsWith("on");
bool isObjectMethod = ofClass.QualifiedName == "Object";
int line = Sci.LineFromPosition(position);
string currentText = Sci.GetLine(line);
int startPos = currentText.Length;
GetStartPos(currentText, ref startPos, features.privateKey);
GetStartPos(currentText, ref startPos, features.protectedKey);
GetStartPos(currentText, ref startPos, features.internalKey);
GetStartPos(currentText, ref startPos, features.publicKey);
GetStartPos(currentText, ref startPos, features.staticKey);
GetStartPos(currentText, ref startPos, features.overrideKey);
startPos += Sci.PositionFromLine(line);
FlagType flags = member.Flags;
string acc = "";
string decl = "";
if (features.hasNamespaces && member.Namespace != null
&& member.Namespace.Length > 0 && member.Namespace != "internal")
acc = member.Namespace;
else if ((member.Access & Visibility.Public) > 0) acc = features.publicKey;
else if ((member.Access & Visibility.Internal) > 0) acc = features.internalKey;
else if ((member.Access & Visibility.Protected) > 0) acc = features.protectedKey;
else if ((member.Access & Visibility.Private) > 0) acc = features.privateKey;
bool isStatic = (flags & FlagType.Static) > 0;
if (isStatic) acc = features.staticKey + " " + acc;
if (!isAS2Event && !isObjectMethod)
acc = features.overrideKey + " " + acc;
if ((flags & (FlagType.Getter | FlagType.Setter)) > 0)
{
string type = member.Type;
string name = member.Name;
if (member.Parameters != null && member.Parameters.Count > 0)
type = member.Parameters[0].Type;
type = FormatType(type);
if (type == null)
{
string message = String.Format(TextHelper.GetString("Info.TypeDeclMissing"), member.Name);
ErrorManager.ShowInfo(message);
return;
}
if (ofClass.Members.Search(name, FlagType.Getter, 0) != null)
{
decl += String.Format(GetTemplate("Getter"),
acc, name, type, "super." + name);
}
if (ofClass.Members.Search(name, FlagType.Setter, 0) != null)
{
string tpl = GetTemplate("Setter");
if (decl.Length > 0)
{
decl += "\n\n";
tpl = tpl.Replace("$(EntryPoint)", "");
}
decl += String.Format(tpl,
acc, name, type, "super." + name, ASContext.Context.Features.voidKey ?? "void");
}
}
else
{
string type = FormatType(member.Type);
if (type == null)
{
string message = String.Format(TextHelper.GetString("Info.TypeDeclMissing"), member.Name);
ErrorManager.ShowInfo(message);
return;
}
if (acc.Length > 0) acc += " ";
decl = acc + features.functionKey + " ";
bool noRet = type.Equals("void", StringComparison.OrdinalIgnoreCase);
type = (noRet) ? ASContext.Context.Features.voidKey : type;
if (!noRet) typesUsed.Add(getQualifiedType(type, ofClass));
string action = (isProxy || isAS2Event) ? "" : GetSuperCall(member, typesUsed, ofClass);
decl += member.Name
+ String.Format(GetTemplate("MethodOverride"), member.ParametersString(true), type, action);
}
Sci.BeginUndoAction();
try
{
if (ASContext.Context.Settings.GenerateImports && typesUsed.Count > 0)
{
int offset = AddImportsByName(typesUsed, line);
position += offset;
startPos += offset;
}
Sci.SetSel(startPos, position + member.Name.Length);
InsertCode(startPos, decl);
}
//.........这里部分代码省略.........
示例11: GenerateFieldFromParameter
private static void GenerateFieldFromParameter(ScintillaNet.ScintillaControl Sci, MemberModel member, ClassModel inClass)
{
int funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, Sci);
Sci.SetSel(funcBodyStart, Sci.LineEndPosition(member.LineTo));
string body = Sci.SelText;
string trimmed = body.TrimStart();
Regex re = new Regex("^super\\s*[\\(|\\.]");
Match m = re.Match(trimmed);
if (m.Success)
{
if (m.Index == 0)
{
int p = funcBodyStart + (body.Length - trimmed.Length);
int l = Sci.LineFromPosition(p);
p = Sci.PositionFromLine(l + 1);
funcBodyStart = GetBodyStart(member.LineFrom, member.LineTo, Sci, p);
}
}
Sci.SetSel(funcBodyStart, funcBodyStart);
Sci.CurrentPos = funcBodyStart;
bool isVararg = false;
string paramName = contextMember.Name;
if (paramName.StartsWith("..."))
{
paramName = paramName.TrimStart(new char[] { ' ', '.' });
isVararg = true;
}
string varName = paramName;
bool addThis = true;
if (ASContext.CommonSettings.PrefixFields.Length > 0 && !paramName.StartsWith(ASContext.CommonSettings.PrefixFields))
{
varName = ASContext.CommonSettings.PrefixFields + varName;
addThis = ASContext.CommonSettings.GenerateScope;
}
StringBuilder sb = new StringBuilder();
if (addThis) sb.Append("this.");
sb.Append(varName)
.Append(" = ")
.Append(paramName)
.Append(";")
.Append(NewLine)
.Append("$(Boundary)");
SnippetHelper.InsertSnippetText(Sci, funcBodyStart, sb.ToString());
MemberList classMembers = inClass.Members;
foreach (MemberModel classMember in classMembers)
{
if (classMember.Name.Equals(varName))
{
return;
}
}
MemberModel latest = FindLatest(FlagType.Variable | FlagType.Constant, GetDefaultVisibility(), inClass);
if (latest == null) return;
int position = FindNewVarPosition(Sci, inClass, latest);
if (position <= 0) return;
Sci.SetSel(position, position);
Sci.CurrentPos = position;
MemberModel mem = NewMember(varName, member, FlagType.Variable, GetDefaultVisibility());
if (isVararg)
{
mem.Type = "Array";
}
else
{
mem.Type = contextMember.Type;
}
GenerateVariable(mem, position, true);
ASContext.Panel.RestoreLastLookupPosition();
}
示例12: AddInterfaceDefJob
private static void AddInterfaceDefJob(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member)
{
ClassModel aType = ASContext.Context.ResolveType(contextParam, ASContext.Context.CurrentModel);
if (aType.IsVoid()) return;
FileModel fileModel = ASFileParser.ParseFile(aType.InFile.FileName, ASContext.Context);
foreach (ClassModel cm in fileModel.Classes)
{
if (cm.QualifiedName.Equals(aType.QualifiedName))
{
aType = cm;
break;
}
}
StringBuilder snippet = new StringBuilder();
DockContent dc = ASContext.MainForm.OpenEditableDocument(aType.InFile.FileName, true);
Sci = ASContext.CurSciControl;
MemberModel latest = FindLatest(FlagType.Function, aType);
int position;
if (latest == null)
{
position = GetBodyStart(aType.LineFrom, aType.LineTo, Sci);
}
else
{
position = Sci.PositionFromLine(latest.LineTo + 1) - ((Sci.EOLMode == 0) ? 1 : 0);
snippet.Append(NewLine);
}
Sci.SetSel(position, position);
Sci.CurrentPos = position;
List<MemberModel> parms = member.Parameters;
snippet.Append("function ")
.Append(member.ToDeclarationString())
.Append(";");
List<string> importsList = new List<string>();
string t;
if (parms != null && parms.Count > 0)
{
for (int i = 0; i < parms.Count; i++)
{
if (parms[i].Type != null)
{
t = getQualifiedType(parms[i].Type, inClass);
importsList.Add(t);
}
}
}
if (member.Type != null)
{
t = getQualifiedType(member.Type, inClass);
importsList.Add(t);
}
if (importsList.Count > 0)
{
int o = AddImportsByName(importsList, Sci.LineFromPosition(position));
position += o;
Sci.SetSel(position, position);
}
InsertCode(position, snippet.ToString());
Sci.CurrentPos = position;
}
示例13: AddAsParameter
private static void AddAsParameter(ClassModel inClass, ScintillaNet.ScintillaControl Sci, MemberModel member, bool detach)
{
if (!RemoveLocalDeclaration(Sci, contextMember)) return;
StringBuilder sb = new StringBuilder();
int position = Sci.PositionFromLine(member.LineFrom);
Sci.SetSel(position, Sci.LineEndPosition(member.LineTo));
string body = Sci.SelText;
int bracePos = body.IndexOf(')') + position;
if (member.Parameters != null && member.Parameters.Count > 0)
{
sb.Append(", ");
}
sb.Append(contextMember.Name);
if (contextMember.Type != null)
{
sb.Append(":")
.Append(contextMember.Type);
}
Sci.SetSel(bracePos, bracePos);
Sci.CurrentPos = bracePos;
InsertCode(bracePos, sb.ToString());
Sci.SetSel(lookupPosition, lookupPosition);
}
示例14: ChangeMethodDecl
//.........这里部分代码省略.........
{
funcResult.Member = m;
}
}
bool paramsDiffer = false;
if (funcResult.Member.Parameters != null)
{
// check that parameters have one and the same type
if (funcResult.Member.Parameters.Count == functionParameters.Count)
{
if (functionParameters.Count > 0)
{
List<MemberModel> parameters = funcResult.Member.Parameters;
for (int i = 0; i < parameters.Count; i++)
{
MemberModel p = parameters[i];
if (p.Type != functionParameters[i].paramType)
{
paramsDiffer = true;
break;
}
}
}
}
else
{
paramsDiffer = true;
}
}
// check that parameters count differs
else if (functionParameters.Count != 0)
{
paramsDiffer = true;
}
if (paramsDiffer)
{
int app = 0;
List<MemberModel> newParameters = new List<MemberModel>();
List<MemberModel> existingParameters = funcResult.Member.Parameters;
for (int i = 0; i < functionParameters.Count; i++)
{
FunctionParameter p = functionParameters[i];
if (existingParameters != null
&& existingParameters.Count > (i - app)
&& existingParameters[i - app].Type == p.paramType)
{
newParameters.Add(existingParameters[i - app]);
}
else
{
if (existingParameters != null && existingParameters.Count < functionParameters.Count)
{
app++;
}
newParameters.Add(new MemberModel(p.param, p.paramType, FlagType.ParameterVar, 0));
}
}
funcResult.Member.Parameters = newParameters;
int posStart = Sci.PositionFromLine(funcResult.Member.LineFrom);
int posEnd = Sci.LineEndPosition(funcResult.Member.LineTo);
Sci.SetSel(posStart, posEnd);
string selectedText = Sci.SelText;
Regex rStart = new Regex(String.Format(@"\s+{0}\s*\(([^\)]*)\)(\s*:\s*([^({{|\n|\r|\s|;)]+))?", funcResult.Member.Name));
Match mStart = rStart.Match(selectedText);
if (!mStart.Success)
{
return;
}
int start = mStart.Index + posStart;
int end = start + mStart.Length;
Sci.SetSel(start, end);
string decl = funcResult.Member.ToDeclarationString();
Sci.ReplaceSel(" " + decl);
// add imports to function argument types
if (functionParameters.Count > 0)
{
List<string> l = new List<string>();
foreach (FunctionParameter fp in functionParameters)
{
try
{
l.Add(fp.paramQualType);
}
catch (Exception)
{
}
}
start += AddImportsByName(l, Sci.LineFromPosition(end));
}
Sci.SetSel(start, start);
}
}
示例15: 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);
}