本文整理汇总了C#中CompletionDataList.AddRange方法的典型用法代码示例。如果您正苦于以下问题:C# CompletionDataList.AddRange方法的具体用法?C# CompletionDataList.AddRange怎么用?C# CompletionDataList.AddRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CompletionDataList
的用法示例。
在下文中一共展示了CompletionDataList.AddRange方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleCodeCompletion
protected virtual async Task<ICompletionDataList> HandleCodeCompletion (
CodeCompletionContext completionContext, bool forced, CancellationToken token)
{
var buf = this.Editor;
// completionChar may be a space even if the current char isn't, when ctrl-space is fired t
var currentLocation = new DocumentLocation (completionContext.TriggerLine, completionContext.TriggerLineOffset);
char currentChar = completionContext.TriggerOffset < 1? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 1);
char previousChar = completionContext.TriggerOffset < 2? ' ' : buf.GetCharAt (completionContext.TriggerOffset - 2);
LoggingService.LogDebug ("Attempting completion for state '{0}'x{1}, previousChar='{2}',"
+ " currentChar='{3}', forced='{4}'", tracker.Engine.CurrentState,
tracker.Engine.CurrentStateLength, previousChar, currentChar, forced);
//closing tag completion
if (tracker.Engine.CurrentState is XmlRootState && currentChar == '>')
return ClosingTagCompletion (buf, currentLocation);
// Auto insert '>' when '/' is typed inside tag state (for quick tag closing)
//FIXME: avoid doing this when the next non-whitespace char is ">" or ignore the next ">" typed
if (XmlEditorOptions.AutoInsertFragments && tracker.Engine.CurrentState is XmlTagState && currentChar == '/') {
buf.InsertAtCaret (">");
return null;
}
//entity completion
if (currentChar == '&' && (tracker.Engine.CurrentState is XmlRootState ||
tracker.Engine.CurrentState is XmlAttributeValueState))
{
var list = new CompletionDataList ();
//TODO: need to tweak semicolon insertion
list.Add ("apos").Description = "'";
list.Add ("quot").Description = "\"";
list.Add ("lt").Description = "<";
list.Add ("gt").Description = ">";
list.Add ("amp").Description = "&";
//not sure about these "completions". they're more like
//shortcuts than completions but they're pretty useful
list.Add ("'").CompletionText = "apos;";
list.Add ("\"").CompletionText = "quot;";
list.Add ("<").CompletionText = "lt;";
list.Add (">").CompletionText = "gt;";
list.Add ("&").CompletionText = "amp;";
var ecList = await GetEntityCompletions (token);
list.AddRange (ecList);
return list;
}
//doctype completion
if (tracker.Engine.CurrentState is XmlDocTypeState) {
if (tracker.Engine.CurrentStateLength == 1) {
CompletionDataList list = await GetDocTypeCompletions (token);
if (list != null && list.Count > 0)
return list;
}
return null;
}
//attribute value completion
//determine whether to trigger completion within attribute values quotes
if ((Tracker.Engine.CurrentState is XmlAttributeValueState)
//trigger on the opening quote
&& ((Tracker.Engine.CurrentStateLength == 1 && (currentChar == '\'' || currentChar == '"'))
//or trigger on first letter of value, if unforced
|| (forced || Tracker.Engine.CurrentStateLength == 2))) {
var att = (XAttribute)Tracker.Engine.Nodes.Peek ();
if (att.IsNamed) {
var attributedOb = Tracker.Engine.Nodes.Peek (1) as IAttributedXObject;
if (attributedOb == null)
return null;
//if triggered by first letter of value or forced, grab those letters
var result = await GetAttributeValueCompletions (attributedOb, att, token);
if (result != null) {
result.TriggerWordLength = Tracker.Engine.CurrentStateLength - 1;
return result;
}
return null;
}
}
//attribute name completion
if ((forced && Tracker.Engine.Nodes.Peek () is IAttributedXObject && !tracker.Engine.Nodes.Peek ().IsEnded)
|| ((Tracker.Engine.CurrentState is XmlNameState
&& Tracker.Engine.CurrentState.Parent is XmlAttributeState) ||
Tracker.Engine.CurrentState is XmlTagState)
&& (Tracker.Engine.CurrentStateLength == 1 || forced)) {
IAttributedXObject attributedOb = (Tracker.Engine.Nodes.Peek () as IAttributedXObject) ??
Tracker.Engine.Nodes.Peek (1) as IAttributedXObject;
if (attributedOb == null)
return null;
//attributes
if (attributedOb.Name.IsValid && (forced ||
(char.IsWhiteSpace (previousChar) && char.IsLetter (currentChar))))
//.........这里部分代码省略.........
示例2: GetElementCompletions
protected override void GetElementCompletions (CompletionDataList list)
{
var path = GetElementPath ();
if (path.Elements.Count > 0) {
IXmlCompletionProvider schema = FindSchema (path);
if (schema == null)
schema = inferredCompletionData;
if (schema != null) {
var completionData = schema.GetChildElementCompletionData (path);
if (completionData != null)
list.AddRange (completionData);
}
} else if (defaultSchemaCompletionData != null) {
list.AddRange (defaultSchemaCompletionData.GetElementCompletionData (defaultNamespacePrefix));
} else if (inferredCompletionData != null) {
list.AddRange (inferredCompletionData.GetElementCompletionData ());
}
AddMiscBeginTags (list);
}
示例3: AddHtmlAttributeValueCompletionData
protected void AddHtmlAttributeValueCompletionData (CompletionDataList list, HtmlSchema schema,
XName tagName, XName attributeName)
{
list.AddRange (schema.CompletionProvider.GetAttributeValueCompletionData (tagName.FullName,
attributeName.FullName));
}
示例4: CreateListWindow
static CompletionListWindow CreateListWindow(CompletionListWindowTests.SimulationSettings settings)
{
CompletionDataList dataList = new CompletionDataList ();
dataList.AutoSelect = settings.AutoSelect;
dataList.AddRange (settings.CompletionData);
dataList.DefaultCompletionString = settings.DefaultCompletionString;
ListWindow.ClearHistory ();
CompletionListWindow listWindow = new CompletionListWindow () {
CompletionDataList = dataList,
CompletionWidget = new TestCompletionWidget (),
AutoSelect = settings.AutoSelect,
CodeCompletionContext = new CodeCompletionContext (),
AutoCompleteEmptyMatch = settings.AutoCompleteEmptyMatch,
DefaultCompletionString = settings.DefaultCompletionString
};
listWindow.List.FilterWords ();
listWindow.UpdateWordSelection ();
listWindow.ResetSizes ();
return listWindow;
}
示例5: AddHtmlAttributeValueCompletionData
protected async Task AddHtmlAttributeValueCompletionData (CompletionDataList list, HtmlSchema schema,
XName tagName, XName attributeName, CancellationToken token)
{
list.AddRange (await schema.CompletionProvider.GetAttributeValueCompletionData (tagName.FullName,
attributeName.FullName, token));
}
示例6: AddHtmlTagCompletionData
protected static void AddHtmlTagCompletionData (CompletionDataList list, HtmlSchema schema, XName parentName)
{
if (schema == null)
return;
if (parentName.IsValid) {
list.AddRange (schema.CompletionProvider.GetChildElementCompletionData (parentName.FullName));
} else {
list.AddRange (schema.CompletionProvider.GetElementCompletionData ());
}
}
示例7: HandleCodeCompletion
protected virtual ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, bool forced, ref int triggerWordLength)
{
CompletionDataList cdl = new CompletionDataList ();
string contents = null,
symbol = null;
switch (completionChar) {
case '.':
// Dot operator
contents = Editor.Text;
symbol = RubyCompletion.GetSymbol (contents, completionContext.TriggerOffset-1);
// Console.WriteLine ("RubyBinding: Completing {0}", symbol);
if (!string.IsNullOrEmpty (symbol)) {
CompletionData[] completions = RubyCompletion.Complete (BasePath, contents, symbol, completionContext.TriggerLine-1);
if (null != completions) {
// Console.WriteLine ("RubyBinding: Got {0} completions", completions.Length);
cdl.AddRange (completions);
}
}
break;
case ':':
// Scope operator
if (1 < completionContext.TriggerOffset && ':' == Editor.GetCharAt (completionContext.TriggerOffset-2)) {
contents = Editor.Text;
symbol = RubyCompletion.GetSymbol (contents, completionContext.TriggerOffset-2);
string[] tokens = symbol.Split (new string[]{"::"}, StringSplitOptions.None);
symbol = (1 < tokens.Length)? string.Join ("::", tokens, 0, tokens.Length-1): tokens[0];
// Console.WriteLine ("RubyBinding: Completing {0}", symbol);
if (RubyCompletion.IsConstant (symbol)) {
CompletionData[] completions = RubyCompletion.Complete (BasePath, contents, symbol, completionContext.TriggerLine-1);
if (null != completions) {
// Console.WriteLine ("RubyBinding: Got {0} completions", completions.Length);
cdl.AddRange (completions);
}
}
}
break;
case ' ':
case '\t':
string line = Editor.GetLineText (completionContext.TriggerLine);
if ((null == line || (string.IsNullOrEmpty (line.Trim ()))) && !forced) {
// Don't complete on spacing unless requested
break;
}
contents = Editor.Text;
symbol = RubyCompletion.GetSymbol (contents, completionContext.TriggerOffset-2);
if (0 > Array.IndexOf (RubyCompletion.declarors, symbol.Trim ())) {
CompletionData[] completions = RubyCompletion.CompleteGlobal (BasePath, contents, completionContext.TriggerLine-1);
if (null != completions) {
cdl.AddRange (completions);
}
}
break;
default:
// Aggressive completion
if (char.IsLetter (completionChar)) {
CompletionData[] completions = RubyCompletion.CompleteGlobal (BasePath, Editor.Text, completionContext.TriggerLine-1);
cdl.AddRange (completions);
triggerWordLength = ResetTriggerOffset (completionContext);
}
break;
}
// Zero-length list causes segfault
return (0 < cdl.Count)? cdl: null;
}
示例8: AddHtmlTagCompletionData
protected static async Task AddHtmlTagCompletionData (CompletionDataList list, HtmlSchema schema, XName parentName, CancellationToken token)
{
if (schema == null)
return;
if (parentName.IsValid) {
list.AddRange (await schema.CompletionProvider.GetChildElementCompletionData (parentName.FullName.ToLower (), token));
} else {
list.AddRange (await schema.CompletionProvider.GetElementCompletionData (token));
}
}
示例9: GetElementCompletions
protected override async Task<CompletionDataList> GetElementCompletions (CancellationToken token)
{
var list = new CompletionDataList ();
var path = GetElementPath ();
if (path.Elements.Count > 0) {
IXmlCompletionProvider schema = FindSchema (path);
if (schema == null)
schema = inferredCompletionData;
if (schema != null) {
var completionData = await schema.GetChildElementCompletionData (path, token);
if (completionData != null)
list.AddRange (completionData);
}
} else if (defaultSchemaCompletionData != null) {
list.AddRange (await defaultSchemaCompletionData.GetElementCompletionData (defaultNamespacePrefix, token));
} else if (inferredCompletionData != null) {
list.AddRange (await inferredCompletionData.GetElementCompletionData (token));
}
AddMiscBeginTags (list);
return list;
}
示例10: GetAttributes
public static CompletionDataList GetAttributes (AspNetAppProject project, string directiveName,
Dictionary<string, string> existingAtts)
{
var list = new CompletionDataList ();
bool net20 = project == null || project.TargetFramework.ClrVersion != ClrVersion.Net_1_1;
//FIXME: detect whether the page is VB
bool vb = false;
switch (directiveName.ToLowerInvariant ()) {
case "page":
ExclusiveAdd (list, existingAtts, page11Attributes);
if (net20)
ExclusiveAdd (list, existingAtts, page20Attributes);
if (vb)
ExclusiveAdd (list, existingAtts, pageVBAttributes);
MutexAdd (list, existingAtts, page11MutexAttributes);
break;
case "control":
ExclusiveAdd (list, existingAtts, userControlAttributes);
if (vb)
ExclusiveAdd (list, existingAtts, pageVBAttributes);
break;
case "master":
ExclusiveAdd (list, existingAtts, userControlAttributes);
ExclusiveAdd (list, existingAtts, masterControlAttributes);
if (vb)
ExclusiveAdd (list, existingAtts, pageVBAttributes);
break;
case "mastertype":
MutexAdd (list, existingAtts, mastertypeAttributes);
break;
case "assembly":
//the two assembly directive attributes are mutually exclusive
MutexAdd (list, existingAtts, assemblyAttributes);
break;
case "import":
ExclusiveAdd (list, existingAtts, importAttributes);
break;
case "reference":
MutexAdd (list, existingAtts, referenceAttributes);
break;
case "register":
ExclusiveAdd (list, existingAtts, registerAttributes);
if (existingAtts.Keys.Intersect (registerAssemblyAttributes, StringComparer.OrdinalIgnoreCase).Any ()) {
ExclusiveAdd (list, existingAtts, registerAssemblyAttributes);
} else if (existingAtts.Keys.Intersect (registerUserControlAttributes, StringComparer.OrdinalIgnoreCase).Any ()) {
ExclusiveAdd (list, existingAtts, registerUserControlAttributes);
} else {
list.AddRange (registerAssemblyAttributes);
list.AddRange (registerUserControlAttributes);
}
break;
case "outputcache":
ExclusiveAdd (list, existingAtts, outputcacheAttributes);
break;
case "previouspagetype":
MutexAdd (list, existingAtts, previousPageTypeAttributes);
break;
case "implements":
ExclusiveAdd (list, existingAtts, implementsAttributes);
break;
}
return list.Count > 0? list : null;
}
示例11: GetPageAttributeValues
static CompletionDataList GetPageAttributeValues (AspNetAppProject project, FilePath fromFile, string attribute)
{
var list = new CompletionDataList ();
switch (attribute.ToLowerInvariant ()) {
//
//boolean, default to false
//
case "async":
case "aspcompat":
case "explicit": // useful for VB only. set to true in machine.config
case "maintainscrollpositiononpostback":
case "linepragmas": //actually not sure if this defaults true or false
case "smartnavigation":
case "strict": //VB ONLY
case "trace":
SimpleList.AddBoolean (list, false);
break;
//
//boolean, default to true
//
case "autoeventwireup":
case "buffer":
case "enableeventvalidation":
case "enablesessionstate":
case "enabletheming":
case "enableviewstate":
case "enableviewstatemac":
case "validaterequest": //enabled in machine.config
case "debug":
SimpleList.AddBoolean (list, true);
break;
//
//specialised hard value list completions
//
case "codepage":
list.AddRange (from e in Encoding.GetEncodings () select e.CodePage.ToString ());
list.DefaultCompletionString = Encoding.UTF8.CodePage.ToString ();
break;
case "compilationmode":
SimpleList.AddEnum (list, System.Web.UI.CompilationMode.Always);
break;
case "culture":
list.AddRange (from c in CultureInfo.GetCultures (CultureTypes.AllCultures) select c.Name);
list.DefaultCompletionString = CultureInfo.CurrentCulture.Name;
break;
case "lcid":
// locale ID, MUTUALLY EXCLUSIVE with Culture
list.AddRange (from c in CultureInfo.GetCultures (CultureTypes.AllCultures)
select c.LCID.ToString ());
list.DefaultCompletionString = CultureInfo.CurrentCulture.LCID.ToString ();
break;
case "responseencoding":
list.AddRange (from e in Encoding.GetEncodings () select e.Name);
list.DefaultCompletionString = Encoding.UTF8.EncodingName;
break;
case "tracemode":
list.Add ("SortByTime");
list.Add ("SortByCategory");
list.DefaultCompletionString = "SortByTime";
break;
case "transaction":
list.Add ("Disabled");
list.Add ("NotSupported");
list.Add ("Required");
list.Add ("RequiresNew");
list.DefaultCompletionString = "Disabled";
break;
case "viewstateencryptionmode":
SimpleList.AddEnum (list, ViewStateEncryptionMode.Auto);
break;
case "warninglevel":
list.AddRange (new string[] {"0", "1", "2", "3", "4"});
list.DefaultCompletionString = "0";
break;
case "masterpagefile":
return project != null
? MonoDevelop.Html.PathCompletion.GetPathCompletion (project, "*.master", fromFile,
x => "~/" + x.ProjectVirtualPath.ToString ().Replace (System.IO.Path.PathSeparator, '/'))
: null;
//
//we can probably complete these using info from the project, but not yet
//
/*
case "CodeFile":
//source file to compile for codebehind on server
case "ContentType":
//string, HTTP MIME content-type
//.........这里部分代码省略.........
示例12: GlobalComplete
// just dummy test TODO: rewrite
private ICompletionDataList GlobalComplete()
{
CompletionDataList list = new CompletionDataList ();
list.AutoSelect = true;
list.AddRange (keywordslist);
return list;
}
示例13: GetCompletionData
/// <summary>
/// Vrati vsetky mozne autokompletion , do zoznamu prida aj slova zo samotneho dokumentu
/// </summary>
/// <returns>
/// Zoznam autoCompletion slov odpovesajuci baseWord a completiontype
/// </returns>
public static ICompletionDataList GetCompletionData(this TextEditor editor ,string baseWord,string fullWord ,CompletionTyp completiontype)
{
string codestring = editor.Document.Text;
string type = "";
string parent = "";
editor.ParseString(fullWord,out parent,out type);
Regex regex = new Regex(@"\W", RegexOptions.Compiled);
codestring = regex.Replace(codestring, " ");
string[] list = codestring.Split(' ');
CompletionDataList listComplete = new CompletionDataList();
listComplete.CompletionSelectionMode = CompletionSelectionMode.OwnTextField;
if(!String.IsNullOrEmpty(type)){
//List<CompletionData> lst = MainClass.CompletedCache.AllCompletionOnlyOne.FindAll(x=>x.Parent == type);
List<CompletionData> lst = MainClass.CompletedCache.AllCompletionRepeat.FindAll(x=>x.Parent == type);
foreach ( CompletionData cd in lst){
string expres =cd.Parent+".on";
if(cd.Signature.StartsWith(expres) ){
//expres = cd.Signature.Replace(cd.Parent+".", cd.DisplayText +" = function ");
expres = cd.Signature.Replace(cd.Parent+"."+ cd.DisplayText, cd.DisplayText +" = function ");
cd.DisplayDescription =expres+"{}";
cd.CompletionText =expres+"{"+Environment.NewLine+"}";
}
}
if (lst != null)
listComplete.AddRange(lst.ToArray());
if(listComplete != null && listComplete.Count>0){
return listComplete;
}
}
switch (completiontype) {
case CompletionTyp.allType:
{
listComplete.AddRange(MainClass.CompletedCache.AllCompletionOnlyOne);
break;
}
case CompletionTyp.newType:
{
listComplete.AddRange(MainClass.CompletedCache.NewCompletion);
break;
}
case CompletionTyp.dotType:
{
listComplete.AddRange(MainClass.CompletedCache.DotCompletion);
break;
}
}
int i = 0;
foreach (string s in list) {
if ( !String.IsNullOrEmpty(s.Trim()) ){
if (s==baseWord)
i++;
if ((listComplete.Find(s)== null) && (s.Length>2) && ( (s!= baseWord) || (i ==1) ) ){
CompletionData cd = new CompletionData(s, null, s, s);
if (completiontype == CompletionTyp.newType){
if(char.ToUpper(s[0]) == s[0] && !char.IsDigit(s[0]) && !char.IsSymbol(s[0]) &&char.IsLetter(s[0]) ){
CompletionData cdParent =listComplete.Find(cd.DisplayText);
if (cdParent== null){
listComplete.Add(cd);
} else {
if(!cdParent.Description.Contains(cd.Description))
cdParent.Description =cdParent.Description+Environment.NewLine+cd.Description;
}
}
} else{
CompletionData cdParent =listComplete.Find(cd.DisplayText);
if (cdParent== null){
listComplete.Add(cd);
} else {
if(!cdParent.Description.Contains(cd.Description))
cdParent.Description =cdParent.Description+Environment.NewLine+cd.Description;
}
}
}
}
}
return listComplete;
}