void TextAreaTextEntering(object sender, TextCompositionEventArgs e) { // don't start new code completion if there is still a completion window open if (CompletionWindow != null) { return; } if (e.Handled) { return; } // disable all code completion bindings when CC is disabled if (!CodeCompletionOptions.EnableCodeCompletion) { return; } ITextEditor adapter = GetAdapterFromSender(sender); foreach (char c in e.Text) { foreach (ICodeCompletionBinding cc in CodeCompletionBindings) { CodeCompletionKeyPressResult result = cc.HandleKeyPress(adapter, c); if (result == CodeCompletionKeyPressResult.Completed) { if (CompletionWindow != null) { // a new CompletionWindow was shown, but does not eat the input // tell it to expect the text insertion CompletionWindow.ExpectInsertionBeforeStart = true; } if (InsightWindow != null) { InsightWindow.ExpectInsertionBeforeStart = true; } return; } else if (result == CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion) { if (CompletionWindow != null) { if (CompletionWindow.StartOffset == CompletionWindow.EndOffset) { CompletionWindow.CloseWhenCaretAtBeginning = true; } } return; } else if (result == CodeCompletionKeyPressResult.EatKey) { e.Handled = true; return; } } } }
public void SetUp() { textEditor = new MockTextEditor(); textEditor.Document.Text = programStart + "override" + programEnd; textEditor.Caret.Offset = programStart.Length + "override".Length; textEditor.CreateParseInformation(); CSharpCompletionBinding completion = new CSharpCompletionBinding(); keyPressResult = completion.HandleKeyPress(textEditor, ' '); }
public void SetUp() { textEditor = new MockTextEditor(); textEditor.Document.Text = programStart + "override" + programEnd; textEditor.Caret.Offset = programStart.Length + "override".Length; textEditor.CreateParseInformation(); CSharpCompletionBinding completion = new CSharpCompletionBinding(); keyPressResult = completion.HandleKeyPress(textEditor, ' '); }
protected void TestKeyPress(string fileHeader, string fileFooter, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action<ICompletionItemList> constraint) { SetUpWithCode(fileHeader + fileFooter, fileHeader.Length); CodeCompletionKeyPressResult result = new XamlCodeCompletionBinding().HandleKeyPress(textEditor, keyPressed); Assert.AreEqual(keyPressResult, result); ICompletionItemList list = this.textEditor.LastCompletionItemList; constraint(list); }
protected void TestKeyPress(string fileHeader, string fileFooter, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action<ICompletionItemList> constraint) { this.textEditor.Document.Text = fileHeader + fileFooter; this.textEditor.Caret.Offset = fileHeader.Length; this.textEditor.CreateParseInformation(); CodeCompletionKeyPressResult result = new VBNetCompletionBinding().HandleKeyPress(textEditor, keyPressed); Assert.AreEqual(keyPressResult, result); ICompletionItemList list = this.textEditor.LastCompletionItemList; constraint(list); }
public void Init() { schemas = new XmlSchemaCompletionCollection(); schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXhtmlStrictSchema())); XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas); associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xml", "http://www.w3.org/1999/xhtml")); textEditor = new MockTextEditor(); textEditor.Document.Text = String.Empty; textEditor.FileName = new FileName(@"c:\projects\test.xml"); textEditor.Caret.Offset = 0; XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(associations); keyPressResult = completionBinding.HandleKeyPress(textEditor, '<'); }
public void Init() { schemas = new XmlSchemaCompletionCollection(); schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXsdSchema())); XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas); associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs")); textEditor = new MockTextEditor(); textEditor.FileName = new FileName(@"c:\projects\test.xsd"); textEditor.Document.Text = "<xs:schema></xs:schema>"; // Put cursor after the first 'a' in "<xs:schema>" textEditor.Caret.Offset = 10; XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(associations); keyPressResult = completionBinding.HandleKeyPress(textEditor, ' '); }
protected void TestKeyPress(string file, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action<ICompletionItemList> constraint) { int insertionPoint = file.IndexOf('|'); if (insertionPoint < 0) Assert.Fail("insertionPoint not found in text!"); this.textEditor.Document.Text = file.Replace("|", ""); this.textEditor.Caret.Offset = insertionPoint; this.textEditor.CreateParseInformation(); CodeCompletionKeyPressResult result = new VBNetCompletionBinding().HandleKeyPress(textEditor, keyPressed); Assert.AreEqual(keyPressResult, result); ICompletionItemList list = this.textEditor.LastCompletionItemList; constraint(list); }
public void Init() { schemas = new XmlSchemaCompletionCollection(); schemas.Add(new XmlSchemaCompletion(ResourceManager.ReadXsdSchema())); XmlSchemaFileAssociations associations = new XmlSchemaFileAssociations(new Properties(), new DefaultXmlSchemaFileAssociations(new AddInTreeNode()), schemas); associations.SetSchemaFileAssociation(new XmlSchemaFileAssociation(".xsd", "http://www.w3.org/2001/XMLSchema", "xs")); textEditor = new MockTextEditor(); textEditor.FileName = new FileName(@"c:\projects\test.xsd"); textEditor.Document.Text = "<xs:schema></xs:schema>"; // Put cursor after the first 'a' in "<xs:schema>" textEditor.Caret.Offset = 10; XmlCodeCompletionBinding completionBinding = new XmlCodeCompletionBinding(associations); keyPressResult = completionBinding.HandleKeyPress(textEditor, ' '); }
protected void TestKeyPress(string file, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action <ICompletionItemList> constraint) { int insertionPoint = file.IndexOf('|'); if (insertionPoint < 0) { Assert.Fail("insertionPoint not found in text!"); } this.textEditor.Document.Text = file.Replace("|", ""); this.textEditor.Caret.Offset = insertionPoint; this.textEditor.CreateParseInformation(); CodeCompletionKeyPressResult result = new VBNetCompletionBinding().HandleKeyPress(textEditor, keyPressed); Assert.AreEqual(keyPressResult, result); ICompletionItemList list = this.textEditor.LastCompletionItemList; constraint(list); }
public void HandleKeyPress_LessThanKeyPressed_KeyPressResultIsCompletedAfterPressingLessThanSign() { keyPressResult = completionBinding.HandleKeyPress(textEditor, '<'); Assert.AreEqual(CodeCompletionKeyPressResult.EatKey, keyPressResult); }
public void HandleKeyPress_LessThanKeyPressed_KeyPressResultIsCompletedAfterPressingLessThanSign() { keyPressResult = completionBinding.HandleKeyPress(textEditor, '<'); Assert.AreEqual(CodeCompletionKeyPressResult.Completed, keyPressResult); }
protected void TestKeyPress(string fileHeader, string fileFooter, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action <ICompletionItemList> constraint) { this.textEditor.Document.Text = fileHeader + fileFooter; this.textEditor.Caret.Offset = fileHeader.Length; this.textEditor.CreateParseInformation(); CodeCompletionKeyPressResult result = new XamlCodeCompletionBinding().HandleKeyPress(textEditor, keyPressed); Assert.AreEqual(keyPressResult, result); ICompletionItemList list = this.textEditor.LastCompletionItemList; constraint(list); }
public void HandleKeyPress_AnyKey_ReturnsNone() { keyPressResult = completionBinding.HandleKeyPress(textEditor, 'a'); Assert.AreEqual(CodeCompletionKeyPressResult.None, keyPressResult); }
void TextAreaTextEntering(object sender, TextCompositionEventArgs e) { // don't start new code completion if there is still a completion window open if (completionWindow != null) { return; } if (e.Handled) { return; } // disable all code completion bindings when CC is disabled if (!CodeCompletionOptions.EnableCodeCompletion) { return; } TextArea textArea = TextArea; if (textArea.ActiveInputHandler != textArea.DefaultInputHandler) { return; // deactivate CC for non-default input handlers } ITextEditor adapter = Adapter; foreach (char c in e.Text) { { CodeCompletionKeyPressResult result = Binding.HandleKeyPress(adapter, c); if (result == CodeCompletionKeyPressResult.Completed) { if (completionWindow != null) { // a new CompletionWindow was shown, but does not eat the input // tell it to expect the text insertion completionWindow.ExpectInsertionBeforeStart = true; } if (insightWindow != null) { insightWindow.ExpectInsertionBeforeStart = true; } return; } else if (result == CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion) { if (completionWindow != null) { if (completionWindow.StartOffset == completionWindow.EndOffset) { completionWindow.CloseWhenCaretAtBeginning = true; } } return; } else if (result == CodeCompletionKeyPressResult.EatKey) { e.Handled = true; return; } } } }
public void HandleKeyPress_AnyKey_ReturnsNone() { keyPressResult = completionBinding.HandleKeyPress(textEditor, 'a'); Assert.AreEqual(CodeCompletionKeyPressResult.None, keyPressResult); }
protected void TestKeyPress(string fileHeader, string fileFooter, char keyPressed, CodeCompletionKeyPressResult keyPressResult, Action <ICompletionItemList> constraint) { SetUpWithCode(fileHeader + fileFooter, fileHeader.Length); CodeCompletionKeyPressResult result = new XamlCodeCompletionBinding().HandleKeyPress(textEditor, keyPressed); Assert.AreEqual(keyPressResult, result); ICompletionItemList list = this.textEditor.LastCompletionItemList; constraint(list); }