本文整理汇总了C#中ScintillaNet类的典型用法代码示例。如果您正苦于以下问题:C# ScintillaNet类的具体用法?C# ScintillaNet怎么用?C# ScintillaNet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ScintillaNet类属于命名空间,在下文中一共展示了ScintillaNet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: HaXeCompletion
public HaXeCompletion(ScintillaNet.ScintillaControl sci, int position)
{
this.sci = sci;
this.position = position;
tips = new ArrayList();
nbErrors = 0;
}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:7,代码来源:HaXeCompletion.cs
示例2: HandleGeneratorCompletion
static public bool HandleGeneratorCompletion(ScintillaNet.ScintillaControl Sci, bool autoHide, string word)
{
ContextFeatures features = ASContext.Context.Features;
if (features.overrideKey != null && word == features.overrideKey)
return HandleOverrideCompletion(Sci, autoHide);
return false;
}
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:7,代码来源:ASGenerator.cs
示例3: ShowTips
public void ShowTips(ScintillaNet.ScintillaControl sciMonitor)
{
if (PluginCore.Controls.CompletionList.Active)
PluginCore.Controls.CompletionList.Hide();
PluginCore.Controls.UITools.CallTip.Hide();
if (textParameters.comments == null)
PluginCore.Controls.UITools.CallTip.CallTipShow(sciMonitor, textParameters.posParameters, textParameters.text);
else
PluginCore.Controls.UITools.CallTip.CallTipShow(sciMonitor, textParameters.posParameters, textParameters.text + textParameter);
PluginCore.Controls.UITools.CallTip.CallTipSetHlt(startToolTip, endToolTip);
}
开发者ID:fordream,项目名称:wanghe-project,代码行数:13,代码来源:WordRegionParameter.cs
示例4: 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);
}
}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:17,代码来源:SnippetHelper.cs
示例5: OnChar
static public bool OnChar(ScintillaNet.ScintillaControl Sci, int Value, int position, int style)
{
if (style == 3 || style == 124)
{
switch (Value)
{
// documentation tag
case '@':
return HandleDocTagCompletion(Sci);
// documentation bloc
case '*':
if ((position > 2) && (Sci.CharAt(position-3) == '/') && (Sci.CharAt(position-2) == '*')
&& ((position == 3) || (Sci.BaseStyleAt(position-4) != 3)))
HandleBoxCompletion(Sci, position);
break;
}
}
return false;
}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:20,代码来源:ASDocumentation.cs
示例6: InsertSnippetText
/// <summary>
/// Inserts the specified snippet to the document
/// </summary>
public static Int32 InsertSnippetText(ScintillaNet.ScintillaControl sci, Int32 currentPosition, String snippet)
{
sci.BeginUndoAction();
try
{
Int32 newIndent;
String text = snippet;
if (sci.SelTextSize > 0)
currentPosition -= sci.MBSafeTextLength(sci.SelText);
Int32 line = sci.LineFromPosition(currentPosition);
Int32 indent = sci.GetLineIndentation(line);
sci.ReplaceSel("");
Int32 lineMarker = LineEndDetector.DetectNewLineMarker(text, sci.EOLMode);
String newline = LineEndDetector.GetNewLineMarker(lineMarker);
if (newline != "\n") text = text.Replace(newline, "\n");
newline = LineEndDetector.GetNewLineMarker((Int32)PluginBase.MainForm.Settings.EOLMode);
text = PluginBase.MainForm.ProcessArgString(text).Replace(newline, "\n");
newline = LineEndDetector.GetNewLineMarker(sci.EOLMode);
String[] splitted = text.Trim().Split('\n');
for (Int32 j = 0; j < splitted.Length; j++)
{
if (j != splitted.Length - 1) sci.InsertText(sci.CurrentPos, splitted[j] + newline);
else sci.InsertText(sci.CurrentPos, splitted[j]);
sci.CurrentPos += sci.MBSafeTextLength(splitted[j]) + newline.Length;
if (j > 0)
{
line = sci.LineFromPosition(sci.CurrentPos - newline.Length);
newIndent = sci.GetLineIndentation(line) + indent;
sci.SetLineIndentation(line, newIndent);
}
}
Int32 length = sci.CurrentPos - currentPosition - newline.Length;
Int32 delta = PostProcessSnippets(sci, currentPosition);
return length + delta;
}
finally
{
sci.EndUndoAction();
}
}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:44,代码来源:SnippetHelper.cs
示例7: 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;
}
开发者ID:heon21st,项目名称:flashdevelop,代码行数:24,代码来源:SnippetHelper.cs
示例8: GenerateSnippets
/// <summary>
/// Generates the menu for the selected sci control
/// </summary>
public void GenerateSnippets(ScintillaNet.ScintillaControl sci)
{
String path;
String content;
PathWalker walker;
List<String> files;
items = new List<String>();
String surroundFolder = "surround";
path = Path.Combine(PathHelper.SnippetDir, surroundFolder);
if (Directory.Exists(path))
{
walker = new PathWalker(PathHelper.SnippetDir + surroundFolder, "*.fds", false);
files = walker.GetFiles();
foreach (String file in files)
{
items.Add(file);
}
}
path = Path.Combine(PathHelper.SnippetDir, sci.ConfigurationLanguage);
path = Path.Combine(path, surroundFolder);
if (Directory.Exists(path))
{
walker = new PathWalker(path, "*.fds", false);
files = walker.GetFiles();
foreach (String file in files)
{
items.Add(file);
}
}
if (items.Count > 0) items.Sort();
this.DropDownItems.Clear();
foreach (String itm in items)
{
content = File.ReadAllText(itm);
if (content.IndexOf("{0}") > -1)
{
this.DropDownItems.Insert(this.DropDownItems.Count, new ToolStripMenuItem(Path.GetFileNameWithoutExtension(itm)));
}
}
}
开发者ID:CamWiseOwl,项目名称:flashdevelop,代码行数:43,代码来源:SurroundMenu.cs
示例9: Styler
public Styler(ScintillaNet.Scintilla ScintillaCtrl)
{
STLControl = ScintillaCtrl;
InitStyleIndex();
LoadStyle(STLControl);
//ApplyStyle(@"(\$\w+)", styleIndex["Variable"], 1);
//ApplyStyle(@"(\$\w+?)\s*=[^>]", styleIndex["Variable (declare)"], 1);
//ApplyStyle(@"([=+&])", styleIndex["Operators"], 1);
//ApplyStyle(@"(VK_\w+)", styleIndex["Virtual-key"], 1);
//ApplyStyle(@"[Uu][0-9A-Fa-f]{4}", styleIndex["Hex Notation"], 0);
//ApplyStyle(@"(?:NULL)|(?:null)", styleIndex["NULL Value"], 0);
//ApplyStyle(@"(\[[*^]\])", styleIndex["Any Operator"], 1);
//ApplyStyle(@"(\[\$\w+\])", styleIndex["Reference"], 1);
//ApplyStyle(@"([><])", styleIndex["Virtual-key Start End Operator"], 1);
//ApplyStyle(@"(=>)", styleIndex["Out Operator"], 1);
//ApplyStyle(@"(\(\s*(?:['""])[^\1\n]+?\1\s*\))\B", styleIndex["Switch"], 1);
//ApplyStyle(@"(\\)\s+?$", styleIndex["Line Joiner"], 1);
//ApplyStyle(@"((['""])[^\1\n]+?\2\B)", styleIndex["String"], 1);
//ApplyStyle(@"(['""])[^\1\n]*(\\[Uu][0-9a-fA-F]{4})[^\1\n]*?\1\B", styleIndex["In-string Hex Notation"], 2);
}
开发者ID:khonsoe,项目名称:keymagic,代码行数:22,代码来源:Styler.cs
示例10: ConfigStyles
public ConfigStyles(ScintillaNet.Scintilla control, Dictionary<string, int> dict)
{
STLControl = control;
nameToIndex = dict;
originalStyles = new Dictionary<int, styleCopy>();
indexToName = new Dictionary<int, string>();
foreach (string name in dict.Keys)
{
ScintillaNet.Style thisSyle = STLControl.Styles[dict[name]];
styleCopy copy = new styleCopy();
copy.Font = thisSyle.Font;
copy.ForeColor = thisSyle.ForeColor;
copy.BackColor = thisSyle.BackColor;
originalStyles.Add(dict[name], copy);
indexToName.Add(dict[name], name);
}
InitializeComponent();
}
开发者ID:khonsoe,项目名称:keymagic,代码行数:23,代码来源:ConfigColor.cs
示例11: IsMatchTheTarget
/// <summary>
/// Checks if the given match actually is the declaration.
/// </summary>
public static bool IsMatchTheTarget(ScintillaNet.ScintillaControl Sci, SearchMatch match, ASResult target)
{
if (Sci == null || target == null || target.InFile == null || target.Member == null)
{
return false;
}
String originalFile = Sci.FileName;
// get type at match position
ASResult declaration = DeclarationLookupResult(Sci, Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value));
return (declaration.InFile != null && originalFile == declaration.InFile.FileName) && (Sci.CurrentPos == (Sci.MBSafePosition(match.Index) + Sci.MBSafeTextLength(match.Value)));
}
开发者ID:thecocce,项目名称:flashdevelop,代码行数:14,代码来源:RefactoringHelper.cs
示例12: 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
示例13: GenerateDelegateMethods
public static void GenerateDelegateMethods(ScintillaNet.ScintillaControl Sci, MemberModel member,
Dictionary<MemberModel, ClassModel> selectedMembers, ClassModel classModel, ClassModel inClass)
{
Sci.BeginUndoAction();
try
{
string result = TemplateUtils.ReplaceTemplateVariable(
TemplateUtils.GetTemplate("DelegateMethodsHeader"),
"Class",
classModel.Type);
int position = -1;
ClassModel type;
List<string> importsList = new List<string>();
bool isStaticMember = false;
if ((member.Flags & FlagType.Static) > 0)
isStaticMember = true;
inClass.ResolveExtends();
Dictionary<MemberModel, ClassModel>.KeyCollection selectedMemberKeys = selectedMembers.Keys;
foreach (MemberModel m in selectedMemberKeys)
{
MemberModel mCopy = (MemberModel) m.Clone();
string methodTemplate = NewLine;
bool overrideFound = false;
ClassModel baseClassType = inClass;
while (baseClassType != null && !baseClassType.IsVoid())
{
MemberList inClassMembers = baseClassType.Members;
foreach (MemberModel inClassMember in inClassMembers)
{
if ((inClassMember.Flags & FlagType.Function) > 0
&& m.Name.Equals(inClassMember.Name))
{
mCopy.Flags |= FlagType.Override;
overrideFound = true;
break;
}
}
if (overrideFound)
break;
baseClassType = baseClassType.Extends;
}
if (isStaticMember && (m.Flags & FlagType.Static) == 0)
mCopy.Flags |= FlagType.Static;
if ((m.Flags & FlagType.Setter) > 0)
{
methodTemplate += TemplateUtils.GetTemplate("Setter");
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Modifiers",
(TemplateUtils.GetStaticExternOverride(m) + TemplateUtils.GetModifiers(m)).Trim());
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Name", m.Name);
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "EntryPoint", "");
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Type", m.Parameters[0].Type);
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Member", member.Name + "." + m.Name);
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Void", ASContext.Context.Features.voidKey ?? "void");
}
else if ((m.Flags & FlagType.Getter) > 0)
{
methodTemplate += TemplateUtils.GetTemplate("Getter");
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Modifiers",
(TemplateUtils.GetStaticExternOverride(m) + TemplateUtils.GetModifiers(m)).Trim());
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Name", m.Name);
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "EntryPoint", "");
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Type", FormatType(m.Type));
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Member", member.Name + "." + m.Name);
}
else
{
methodTemplate += TemplateUtils.GetTemplate("Function");
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Body", "<<$(Return) >>$(Body)");
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "EntryPoint", null);
methodTemplate = TemplateUtils.ToDeclarationWithModifiersString(mCopy, methodTemplate);
if (m.Type != null && m.Type.ToLower() != "void")
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Return", "return");
else
methodTemplate = TemplateUtils.ReplaceTemplateVariable(methodTemplate, "Return", null);
// check for varargs
bool isVararg = false;
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));
//.........这里部分代码省略.........
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs
示例14: HandleOverrideCompletion
/// <summary>
/// List methods to override
/// </summary>
/// <param name="Sci">Scintilla control</param>
/// <param name="autoHide">Don't keep the list open if the word does not match</param>
/// <returns>Completion was handled</returns>
static private bool HandleOverrideCompletion(ScintillaNet.ScintillaControl Sci, bool autoHide)
{
// explore members
IASContext ctx = ASContext.Context;
ClassModel curClass = ctx.CurrentClass;
if (curClass.IsVoid()) return false;
List<MemberModel> members = new List<MemberModel>();
curClass.ResolveExtends(); // Resolve inheritance chain
// explore function or getters or setters
FlagType mask = FlagType.Function | FlagType.Getter | FlagType.Setter;
ClassModel tmpClass = curClass.Extends;
Visibility acc = ctx.TypesAffinity(curClass, tmpClass);
while (tmpClass != null && !tmpClass.IsVoid())
{
if (tmpClass.QualifiedName.StartsWith("flash.utils.Proxy"))
{
foreach (MemberModel member in tmpClass.Members)
{
member.Namespace = "flash_proxy";
members.Add(member);
}
break;
}
else
{
foreach (MemberModel member in tmpClass.Members)
if ((member.Flags & FlagType.Dynamic) > 0
&& (member.Flags & mask) > 0
&& (member.Access & acc) > 0) members.Add(member);
tmpClass = tmpClass.Extends;
// members visibility
acc = ctx.TypesAffinity(curClass, tmpClass);
}
}
members.Sort();
// build list
List<ICompletionListItem> known = new List<ICompletionListItem>();
MemberModel last = null;
foreach (MemberModel member in members)
{
if (last == null || last.Name != member.Name)
known.Add(new MemberItem(member));
last = member;
}
if (known.Count > 0) CompletionList.Show(known, autoHide);
return true;
}
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:58,代码来源:ASGenerator.cs
示例15: MakePrivate
public static bool MakePrivate(ScintillaNet.ScintillaControl Sci, MemberModel member)
{
ContextFeatures features = ASContext.Context.Features;
string visibility = GetPrivateKeyword();
if (features.publicKey == null || visibility == null) return false;
Regex rePublic = new Regex(String.Format(@"\s*({0})\s+", features.publicKey));
string line;
Match m;
int index, position;
for (int i = member.LineFrom; i <= member.LineTo; i++)
{
line = Sci.GetLine(i);
m = rePublic.Match(line);
if (m.Success)
{
index = Sci.MBSafeTextLength(line.Substring(0, m.Groups[1].Index));
position = Sci.PositionFromLine(i) + index;
Sci.SetSel(position, position + features.publicKey.Length);
Sci.ReplaceSel(visibility);
UpdateLookupPosition(position, features.publicKey.Length - visibility.Length);
return true;
}
}
return false;
}
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:26,代码来源:ASGenerator.cs
示例16: 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;
}
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:29,代码来源:ASGenerator.cs
示例17: 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);
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("String", inClass.InFile);
//.........这里部分代码省略.........
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs
示例18: ParseFunctionParameters
private static List<FunctionParameter> ParseFunctionParameters(ScintillaNet.ScintillaControl Sci, int p)
{
List<FunctionParameter> prms = new List<FunctionParameter>();
StringBuilder sb = new StringBuilder();
List<ASResult> types = new List<ASResult>();
bool isFuncStarted = false;
bool isDoubleQuote = false;
bool isSingleQuote = false;
bool wasEscapeChar = false;
bool doBreak = false;
bool writeParam = false;
int subClosuresCount = 0;
ASResult result = null;
IASContext ctx = ASContext.Context;
char[] charsToTrim = new char[] { ' ', '\t', '\r', '\n' };
int counter = Sci.TextLength; // max number of chars in parameters line (to avoid infinitive loop)
string characterClass = ScintillaNet.ScintillaControl.Configuration.GetLanguage(Sci.ConfigurationLanguage).characterclass.Characters;
int lastMemberPos = p;
// add [] and <>
while (p < counter && !doBreak)
{
char c = (char)Sci.CharAt(p++);
if (c == '(' && !isFuncStarted)
{
if (sb.ToString().Trim(charsToTrim).Length == 0)
{
isFuncStarted = true;
}
else
{
break;
}
}
else if (c == ';' && !isFuncStarted)
{
break;
}
else if (c == ')' && isFuncStarted && !wasEscapeChar && !isDoubleQuote && !isSingleQuote && subClosuresCount == 0)
{
isFuncStarted = false;
writeParam = true;
doBreak = true;
}
else if ((c == '(' || c == '[' || c == '<' || c == '{') && !wasEscapeChar && !isDoubleQuote && !isSingleQuote)
{
if (subClosuresCount == 0)
{
if (c == '{')
{
if (sb.ToString().TrimStart().Length > 0)
{
result = new ASResult();
result.Type = ctx.ResolveType("Function", null);
types.Insert(0, result);
}
else
{
result = new ASResult();
result.Type = ctx.ResolveType(ctx.Features.objectKey, null);
types.Insert(0, result);
}
}
else if (c == '(')
{
result = ASComplete.GetExpressionType(Sci, lastMemberPos + 1);
if (!result.IsNull())
{
types.Insert(0, result);
}
}
else if (c == '<')
{
if (sb.ToString().TrimStart().Length == 0)
{
result = new ASResult();
result.Type = ctx.ResolveType("XML", null);
types.Insert(0, result);
}
}
}
subClosuresCount++;
sb.Append(c);
wasEscapeChar = false;
}
else if ((c == ')' || c == ']' || c == '>' || c == '}') && !wasEscapeChar && !isDoubleQuote && !isSingleQuote)
{
if (c == ']')
{
result = ASComplete.GetExpressionType(Sci, p);
if (result.Type != null) result.Member = null;
else result.Type = ctx.ResolveType(ctx.Features.arrayKey, null);
types.Insert(0, result);
writeParam = true;
}
subClosuresCount--;
sb.Append(c);
wasEscapeChar = false;
}
else if (c == '\\')
//.........这里部分代码省略.........
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:101,代码来源:ASGenerator.cs
示例19: 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;
}
开发者ID:zaynyatyi,项目名称:flashdevelop,代码行数:33,代码来源:ASGenerator.cs
示例20: GenerateFunctionJob
private static void GenerateFunctionJob(GeneratorJobType job, ScintillaNet.ScintillaControl Sci, MemberModel member,
bool detach, ClassModel inClass)
{
int position = 0;
MemberModel la
|
请发表评论