本文整理汇总了C#中MonoDevelop.Ide.CodeCompletion.CodeCompletionContext类的典型用法代码示例。如果您正苦于以下问题:C# CodeCompletionContext类的具体用法?C# CodeCompletionContext怎么用?C# CodeCompletionContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeCompletionContext类属于MonoDevelop.Ide.CodeCompletion命名空间,在下文中一共展示了CodeCompletionContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateCompletionAndUpdate
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, UnderlyingDocumentInfo docInfo,
out CodeCompletionContext codeCompletionContext)
{
var completion = CreateCompletion (editor, context, docInfo, out codeCompletionContext);
completion.UpdateParsedDocument ();
return completion;
}
示例2: HandleCompletion
public ICompletionDataList HandleCompletion (Document realDocument, CodeCompletionContext completionContext,
UnderlyingDocumentInfo docInfo, char currentChar, ref int triggerWordLength)
{
CodeCompletionContext ccc;
var completion = CreateCompletionAndUpdate (realDocument, docInfo, out ccc);
return completion.HandleCodeCompletion (completionContext, currentChar, ref triggerWordLength);
}
示例3: ShowWindow
public static bool ShowWindow (char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext, System.Action closedDelegate)
{
try {
if (wnd == null) {
wnd = new CompletionListWindow ();
wnd.WordCompleted += HandleWndWordCompleted;
}
try {
if (!wnd.ShowListWindow (firstChar, list, completionWidget, completionContext, closedDelegate)) {
if (list is IDisposable)
((IDisposable)list).Dispose ();
DestroyWindow ();
return false;
}
if (ForceSuggestionMode)
wnd.AutoSelect = false;
OnWindowShown (EventArgs.Empty);
return true;
} catch (Exception ex) {
LoggingService.LogError (ex.ToString ());
return false;
}
} finally {
ParameterInformationWindowManager.UpdateWindow (completionWidget);
}
}
示例4: GetCurrentParameterIndex
// Returns the index of the parameter where the cursor is currently positioned.
// -1 means the cursor is outside the method parameter list
// 0 means no parameter entered
// > 0 is the index of the parameter (1-based)
public int GetCurrentParameterIndex (ICompletionWidget widget, CodeCompletionContext ctx)
{
int cursor = widget.CurrentCodeCompletionContext.TriggerOffset;
int i = ctx.TriggerOffset;
if (i < 0 || i >= editor.Length || editor.GetCharAt (i) == ')')
return -1;
if (i > cursor)
return -1;
else if (i == cursor)
return 0;
int parameterIndex = 1;
while (i++ < cursor) {
if (i >= widget.TextLength)
break;
char ch = widget.GetChar (i);
if (ch == ',')
parameterIndex++;
else if (ch == ')')
return -1;
}
return parameterIndex;
}
示例5: CreateCompletionAndUpdate
CSharpCompletionTextEditorExtension CreateCompletionAndUpdate (Document realDocument, UnderlyingDocumentInfo docInfo,
out CodeCompletionContext codeCompletionContext)
{
var completion = CreateCompletion (realDocument, docInfo, out codeCompletionContext);
completion.UpdateParsedDocument ();
return completion;
}
示例6: HandleCodeCompletion
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char triggerChar, ref int triggerWordLength)
{
var l = new CompletionDataList();
if (!(triggerChar==' ' ||
char.IsLetter(triggerChar) ||
triggerChar == '@' ||
triggerChar == '(' ||
triggerChar == '_' ||
triggerChar == '.' ||
triggerChar == '\0'))
return l;
triggerWordLength = (char.IsLetter(triggerChar) || triggerChar=='_' || triggerChar=='@') ? 1 : 0;
// Require a parsed D source
var dom = base.Document.ParsedDocument as ParsedDModule;
if (dom != null && dom.DDom!=null)
lock(dom.DDom)
DCodeCompletionSupport.BuildCompletionData(
Document,
dom.DDom,
completionContext,
l,
triggerChar);
return l;
}
示例7: HandleCompletion
public Task<ICompletionDataList> HandleCompletion (MonoDevelop.Ide.Editor.TextEditor editor, DocumentContext context, CodeCompletionContext completionContext,
UnderlyingDocumentInfo docInfo, char currentChar, CancellationToken token)
{
CodeCompletionContext ccc;
var completion = CreateCompletionAndUpdate (editor, context, docInfo, out ccc);
return completion.HandleCodeCompletionAsync (completionContext, currentChar, token);
}
示例8: Update
public void Update (CodeCompletionContext completionContext, XmlDocument data)
{
//showCompletion = true;
offset = completionContext.TriggerOffset;
signature = data.FirstChild.InnerText.Trim ();
//MonoDevelop.Ide.MessageService.ShowError (signature);
signature = signature.Replace (" ", "");
signature = signature.Replace ("<", "<");
signature = signature.Replace (">", ">");
string[] splitByOpenParen = signature.Split ('(');
signature = "";
for (int i = 0; i < splitByOpenParen.Length; i++) {
string[] splitByCloseParen = splitByOpenParen[i].Split (')');
for (int j = 0; j < splitByCloseParen.Length; j++) {
if (i > 0 && j == 0) {
signature += splitByCloseParen[0].Replace ("->", "->");
} else {
signature += splitByCloseParen[i];
}
}
}
//string[] splitByColon = signature.Split (':');
//if (splitByColon.Length > 1) {
//parameterName = splitByColon[0];
//signature = splitByColon[1];
//}
//MonoDevelop.Ide.MessageService.ShowError (parameterName);
//MonoDevelop.Ide.MessageService.ShowError (signature);
parameters = signature.Split (new string[] { "->" }, StringSplitOptions.None);
for (int i = 0; i < parameters.Length; i++) {
parameters[i] = parameters[i].Replace ("->", " -> ");
//MonoDevelop.Ide.MessageService.ShowError (parameters[i]);
}
//MonoDevelop.Ide.MessageService.ShowError (parameters.Length.ToString ());
//MonoDevelop.Ide.MessageService.ShowError (parameters.ToString ());
}
示例9: HandleParameterCompletion
public override IParameterDataProvider HandleParameterCompletion(CodeCompletionContext completionContext, char completionChar)
{
if (mCompletionEnabled)
{
// HandleCodeCompletion is always called first, so we don't need to fetch completion data
if (completionChar == ')' || completionContext.TriggerLine != mCacheTriggerLine)
{
// invalidate cached completion
mCacheXML = null;
}
if (!mCacheIsObject && mCacheXML != null)
{
if (parameterDataProvider == null)
{
parameterDataProvider = new HaxeParameterDataProvider ();
parameterDataProvider.Update (completionContext, mCacheXML);
return parameterDataProvider;
}
}
else
{
if (parameterDataProvider != null)
{
parameterDataProvider.Clear ();
parameterDataProvider = null;
}
}
}
return null;
}
示例10: ParameterDataProvider
public ParameterDataProvider(Document doc, CodeCompletionContext context)
{
this.doc = doc;
string basepath = (null == doc.Project)?
doc.FileName.FullPath.ParentDirectory:
doc.Project.BaseDirectory.FullPath;
string contents = doc.Editor.Text;
string line = doc.Editor.GetLineText (context.TriggerLine);
method = RubyCompletion.GetSymbol (contents, context.TriggerOffset-1);
int methodIndex = line.IndexOf (method, 0);
// Console.WriteLine ("HandleParameterCompletion ({0} {1})", line, methodIndex);
if (0 < methodIndex) {
int end = line.LastIndexOfAny (RubyCompletion.wordBreakChars, methodIndex);
int start = -1;
if (0 < end) {
start = line.LastIndexOfAny (RubyCompletion.wordBreakChars, end-1)+1;
if (0 <= start) {
owner = line.Substring (start, end-start);
}
}
// Console.WriteLine ("Owner: {0}-{1}", start, end);
}
if ("def".Equals (owner, StringComparison.Ordinal) || 0 <= Array.IndexOf (RubyCompletion.reservedWords, method)) {
method = owner = string.Empty;
methodParams = new string[0];
return;
}
methodParams = RubyCompletion.GetMethodArguments (basepath, contents, context.TriggerLine-1, owner, method);
Valid = (null != methodParams);
}
示例11: ShowWindow
// ext may be null, but then parameter completion don't work
public static bool ShowWindow (CompletionTextEditorExtension ext, char firstChar, ICompletionDataList list, ICompletionWidget completionWidget, CodeCompletionContext completionContext)
{
try {
if (ext != null) {
int inserted = ext.document.Editor.EnsureCaretIsNotVirtual ();
if (inserted > 0)
completionContext.TriggerOffset = ext.document.Editor.Caret.Offset;
}
if (wnd == null) {
wnd = new CompletionListWindow ();
wnd.WordCompleted += HandleWndWordCompleted;
}
wnd.Extension = ext;
try {
if (!wnd.ShowListWindow (firstChar, list, completionWidget, completionContext)) {
if (list is IDisposable)
((IDisposable)list).Dispose ();
HideWindow ();
return false;
}
if (ForceSuggestionMode)
wnd.AutoSelect = false;
wnd.Show ();
DesktopService.RemoveWindowShadow (wnd);
OnWindowShown (EventArgs.Empty);
return true;
} catch (Exception ex) {
LoggingService.LogError (ex.ToString ());
return false;
}
} finally {
ParameterInformationWindowManager.UpdateWindow (ext, completionWidget);
}
}
示例12: CreateEditorData
public static EditorData CreateEditorData(Document EditorDocument, DModule Ast, CodeCompletionContext ctx, char triggerChar = '\0')
{
bool removeChar = char.IsLetter(triggerChar) || triggerChar == '_';
var deltaOffset = 0;//removeChar ? 1 : 0;
var caretOffset = ctx.TriggerOffset - (removeChar ? 1 : 0);
var caretLocation = new CodeLocation(ctx.TriggerLineOffset - deltaOffset, ctx.TriggerLine);
var codeCache = CreateCacheList(EditorDocument);
var ed = new EditorData
{
CaretLocation = caretLocation,
CaretOffset = caretOffset,
ModuleCode = removeChar ? EditorDocument.Editor.Text.Remove(ctx.TriggerOffset - 1, 1) : EditorDocument.Editor.Text,
SyntaxTree = Ast,
ParseCache = codeCache
};
if (EditorDocument.HasProject)
{
var cfg = EditorDocument.Project.GetConfiguration(IdeApp.Workspace.ActiveConfiguration);
if (cfg is DProjectConfiguration)
{
var dcfg = cfg as DProjectConfiguration;
ed.GlobalDebugIds = dcfg.CustomDebugIdentifiers;
ed.IsDebug = dcfg.DebugMode;
ed.DebugLevel = dcfg.DebugLevel;
ed.GlobalVersionIds = dcfg.GlobalVersionIdentifiers;
double d;
ulong v;
if (Double.TryParse(EditorDocument.Project.Version, out d))
ed.VersionNumber = (ulong)d;
else if (UInt64.TryParse(EditorDocument.Project.Version, out v))
ed.VersionNumber = v;
}
else if (cfg is DubProjectConfiguration)
{
var versions = new List<string>(VersionIdEvaluation.GetOSAndCPUVersions());
var dcfg = cfg as DubProjectConfiguration;
ed.IsDebug = dcfg.DebugMode;
HandleDubSettingsConditionExtraction(versions, (dcfg.ParentItem as DubProject).CommonBuildSettings);
HandleDubSettingsConditionExtraction(versions, dcfg.BuildSettings);
ed.GlobalVersionIds = versions.ToArray();
}
}
if (ed.GlobalVersionIds == null)
{
ed.GlobalVersionIds = VersionIdEvaluation.GetOSAndCPUVersions();
}
return ed;
}
示例13: HandleCodeCompletion
public override ICompletionDataList HandleCodeCompletion (CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength)
{
var pathCompletion = HandlePathCompletion ();
if (pathCompletion != null) {
return pathCompletion;
}
return base.HandleCodeCompletion (completionContext, completionChar, ref triggerWordLength);
}
示例14: HandleCodeCompletion
public override ICompletionDataList HandleCodeCompletion(CodeCompletionContext completionContext, char completionChar, ref int triggerWordLength)
{
if (mCompletionEnabled && completionContext.TriggerOffset != mCacheTriggerOffset)
{
return GetCompletionList (completionContext);
}
return null;
}
示例15: GetCurrentParameterIndex
public int GetCurrentParameterIndex(ICompletionWidget widget, CodeCompletionContext ctx)
{
if (showCompletion)
{
return 0;
}
return -1;
}