private static void AssertExpectedFunctions(List <CompletionItem> completions, bool expectParamDefaultFunctions, IEnumerable <string>?fullyQualifiedFunctionNames = null) { fullyQualifiedFunctionNames ??= Enumerable.Empty <string>(); var fullyQualifiedFunctionParts = fullyQualifiedFunctionNames.Select(fqfn => { var parts = fqfn.Split('.', StringSplitOptions.None); return(@namespace: parts[0], function: parts[1]); }); var functionCompletions = completions.Where(c => c.Kind == CompletionItemKind.Function).OrderBy(c => c.Label).ToList(); var availableFunctionNames = new NamespaceSymbol[] { new AzNamespaceSymbol(ResourceScope.ResourceGroup), new SystemNamespaceSymbol() } .SelectMany(ns => ns.Type.MethodResolver.GetKnownFunctions().Values) .Where(symbol => expectParamDefaultFunctions || !symbol.FunctionFlags.HasFlag(FunctionFlags.ParamDefaultsOnly)) .Select(func => func.Name) .Except(fullyQualifiedFunctionParts.Select(p => p.function), LanguageConstants.IdentifierComparer) .Concat(fullyQualifiedFunctionNames) .OrderBy(s => s); functionCompletions.Select(c => c.Label).Should().BeEquivalentTo(availableFunctionNames); functionCompletions.Should().OnlyContain(c => c.TextEdit !.TextEdit !.NewText.StartsWith(c.Label + '(', StringComparison.Ordinal)); functionCompletions.Should().OnlyContain(c => string.Equals(c.Label + "()", c.Detail)); functionCompletions.Should().OnlyContain(c => c.InsertTextFormat == InsertTextFormat.Snippet); }
public void GetSql(DbTarget db_target, ref StringBuilder sql) { sql.Append("REPLACE("); if (!Text.IsLiteral) { sql.Append("("); } Text.GetSql(db_target, ref sql); if (!Text.IsLiteral) { sql.Append(")"); } sql.Append(","); if (!OldText.IsLiteral) { sql.Append("("); } OldText.GetSql(db_target, ref sql); if (!OldText.IsLiteral) { sql.Append(")"); } sql.Append(","); if (!NewText.IsLiteral) { sql.Append("("); } NewText.GetSql(db_target, ref sql); if (!NewText.IsLiteral) { sql.Append(")"); } sql.Append(")"); }
protected override void ExecuteCrmWorkFlowActivity(CodeActivityContext context, LocalWorkflowContext localContext) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (localContext == null) { throw new ArgumentNullException(nameof(localContext)); } EntityReference noteToUpdate = NoteToUpdate.Get(context); if (noteToUpdate == null) { throw new ArgumentNullException("Note cannot be null"); } string newText = NewText.Get(context); Entity note = new Entity("annotation") { Id = noteToUpdate.Id, ["notetext"] = newText }; localContext.OrganizationService.Update(note); UpdatedText.Set(context, newText); }
public override string ToString() { var displayText = NewText != null ? NewText.Replace("\r", @"\r").Replace("\n", @"\n").Replace("\t", @"\t") : "null"; return($"LinePositionSpanTextChange {{ StartLine={StartLine}, StartColumn={StartColumn}, EndLine={EndLine}, EndColumn={EndColumn}, NewText={displayText} }}"); }
public override string ToString() { var displayText = NewText != null ? NewText.Replace("\r", @"\r").Replace("\n", @"\n").Replace("\t", @"\t") : string.Empty; return($"StartLine={StartLine}, StartColumn={StartColumn}, EndLine={EndLine}, EndColumn={EndColumn}, NewText='{displayText}'"); }
public override int GetHashCode() { return(NewText.GetHashCode() * (23 + StartLine) * (29 + StartColumn) * (31 + EndLine) * (37 + EndColumn)); }
/// <summary> /// Returns a modified string with non-regular characters replaced by valid ones, or the same string if no replacement is needed. /// Optionally, an invalid-character-replacement can be specified. Use the null-character ('\0') to remove non-valid chars. /// </summary> public static string Regularize(this string OriginalText, char InvalidCharReplacement = '?', string ValidCharacters = STR_VALID_CHARACTERS) { /* For Testing... * * string Text = ""; * Text = "Almíbar y dulce néctar. Ándate y vuelve con Él."; * Console.WriteLine("Original=[{0}], Regularized=[{1}]", Text, Text.Regularize()); * Text = "Bernardo O'Higgins y Hernán Büchi."; * Console.WriteLine("Original=[{0}], Regularized=[{1}]", Text, Text.Regularize()); * Text = "Bernardo O'Higgins y Hernán Büchi."; * Console.WriteLine("Original=[{0}], Regularized=[{1}]", Text, Text.Regularize('\0')); * Text = "El Nº1 de las hûestes de O'Higgins conocía al almirante O'Brien."; * Console.WriteLine("Original=[{0}], Regularized=[{1}]", Text, Text.Regularize()); * Text = "El Nº1 de los Hûsares de O'Higgins conocía al almirante O'Brien."; * Console.WriteLine("Original=[{0}], Regularized=[{1}]", Text, Text.Regularize('\0')); */ if (String.IsNullOrEmpty(OriginalText)) { return(OriginalText); } StringBuilder NewText = null; int NewTextIndex = 0; for (int Index = 0; Index < OriginalText.Length; Index++) { var OriginalChar = OriginalText[Index]; if (!ValidCharacters.Contains(OriginalChar)) { if (NewText == null) { NewText = new StringBuilder(OriginalText); } var Replacer = (CharacterReplacements.ContainsKey(OriginalChar) ? CharacterReplacements[OriginalChar] : InvalidCharReplacement); if (Replacer == '\0') { NewText.Remove(NewTextIndex, 1); NewTextIndex--; } else { NewText[NewTextIndex] = Replacer; } } NewTextIndex++; } var Result = (NewText == null ? OriginalText : NewText.ToString()); return(Result); }
public void DeclaringSymbolWithFunctionNameShouldHideTheFunctionCompletion() { var grouping = SyntaxTreeGroupingFactory.CreateFromText(@" param concat string var resourceGroup = true resource base64 'Microsoft.Foo/foos@2020-09-01' = { name: 'foo' } output length int = "); var offset = grouping.EntryPoint.ProgramSyntax.Declarations.OfType <OutputDeclarationSyntax>().Single().Value.Span.Position; var compilation = new Compilation(TestTypeHelper.CreateEmptyProvider(), grouping); var provider = new BicepCompletionProvider(new FileResolver(), new SnippetsProvider(), new TelemetryProvider(Server)); var context = BicepCompletionContext.Create(compilation, offset); var completions = provider.GetFilteredCompletions(compilation, context).ToList(); AssertExpectedFunctions(completions, expectParamDefaultFunctions: false, new[] { "sys.concat", "az.resourceGroup", "sys.base64" }); // outputs can't be referenced so they should not show up in completions completions.Where(c => c.Kind == SymbolKind.Output.ToCompletionItemKind()).Should().BeEmpty(); const string expectedVariable = "resourceGroup"; var variableCompletion = completions.Single(c => c.Kind == SymbolKind.Variable.ToCompletionItemKind()); variableCompletion.Label.Should().Be(expectedVariable); variableCompletion.Kind.Should().Be(CompletionItemKind.Variable); variableCompletion.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); variableCompletion.TextEdit !.TextEdit !.NewText.Should().Be(expectedVariable); variableCompletion.CommitCharacters.Should().BeNull(); variableCompletion.Detail.Should().Be(expectedVariable); const string expectedResource = "base64"; var resourceCompletion = completions.Single(c => c.Kind == SymbolKind.Resource.ToCompletionItemKind()); resourceCompletion.Label.Should().Be(expectedResource); resourceCompletion.Kind.Should().Be(CompletionItemKind.Interface); resourceCompletion.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); resourceCompletion.TextEdit !.TextEdit !.NewText.Should().Be(expectedResource); resourceCompletion.CommitCharacters.Should().BeEquivalentTo(new [] { ":", }); resourceCompletion.Detail.Should().Be(expectedResource); const string expectedParam = "concat"; var paramCompletion = completions.Single(c => c.Kind == SymbolKind.Parameter.ToCompletionItemKind()); paramCompletion.Label.Should().Be(expectedParam); paramCompletion.Kind.Should().Be(CompletionItemKind.Field); paramCompletion.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); paramCompletion.TextEdit !.TextEdit !.NewText.Should().Be(expectedParam); paramCompletion.CommitCharacters.Should().BeNull(); paramCompletion.Detail.Should().Be(expectedParam); }
static void AssertExistingKeywordCompletion(CompletionItem item) { item.Label.Should().Be("existing"); item.Detail.Should().Be("existing"); item.Documentation.Should().BeNull(); item.Kind.Should().Be(CompletionItemKind.Keyword); item.Preselect.Should().BeFalse(); item.TextEdit !.NewText.Should().Be("existing"); // do not add = to the list of commit chars // it makes it difficult to type = without the "existing" keyword :) item.CommitCharacters.Should().BeNull(); }
/// <summary> /// Removes a common prefix from the edit to turn IntelliSense replacements into insertions where possible /// </summary> /// <returns>A normalized text change</returns> public TextChange Normalize() { if (OldBuffer != null && IsReplace && NewLength > OldLength && NewText.StartsWith(OldText, StringComparison.Ordinal) && NewPosition == OldPosition) { // Normalize the change into an insertion of the uncommon suffix (i.e. strip out the common prefix) return(new TextChange(oldPosition: OldPosition + OldLength, oldLength: 0, oldBuffer: OldBuffer, newPosition: OldPosition + OldLength, newLength: NewLength - OldLength, newBuffer: NewBuffer)); } return(this); }
private static void AssertExpectedDeclarationTypeCompletions(List <CompletionItem> completions) { completions.Should().SatisfyRespectively( c => { const string expected = "array"; c.Label.Should().Be(expected); c.Kind.Should().Be(CompletionItemKind.Class); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.TextEdit !.TextEdit !.NewText.Should().Be(expected); c.Detail.Should().Be(expected); }, c => { const string expected = "bool"; c.Label.Should().Be(expected); c.Kind.Should().Be(CompletionItemKind.Class); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.TextEdit !.TextEdit !.NewText.Should().Be(expected); c.Detail.Should().Be(expected); }, c => { const string expected = "int"; c.Label.Should().Be(expected); c.Kind.Should().Be(CompletionItemKind.Class); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.TextEdit !.TextEdit !.NewText.Should().Be(expected); c.Detail.Should().Be(expected); }, c => { const string expected = "object"; c.Label.Should().Be(expected); c.Kind.Should().Be(CompletionItemKind.Class); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.TextEdit !.TextEdit !.NewText.Should().Be(expected); c.Detail.Should().Be(expected); }, c => { const string expected = "string"; c.Label.Should().Be(expected); c.Kind.Should().Be(CompletionItemKind.Class); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.TextEdit !.TextEdit !.NewText.Should().Be(expected); c.Detail.Should().Be(expected); }); }
public void VerifyParameterTypeCompletionWithPrecedingComment() { var grouping = SyntaxTreeGroupingFactory.CreateFromText("/*test*/param foo "); var compilation = new Compilation(TestTypeHelper.CreateEmptyProvider(), grouping); var provider = new BicepCompletionProvider(new FileResolver(), new SnippetsProvider(), new TelemetryProvider(Server)); var offset = grouping.EntryPoint.ProgramSyntax.Declarations.OfType <ParameterDeclarationSyntax>().Single().Type.Span.Position; var completions = provider.GetFilteredCompletions(compilation, BicepCompletionContext.Create(compilation, offset)); var declarationTypeCompletions = completions.Where(c => c.Kind == CompletionItemKind.Class).ToList(); AssertExpectedDeclarationTypeCompletions(declarationTypeCompletions); completions.Where(c => c.Kind == CompletionItemKind.Snippet).Should().SatisfyRespectively( c => { c.Label.Should().Be("secureObject"); c.Kind.Should().Be(CompletionItemKind.Snippet); c.InsertTextFormat.Should().Be(InsertTextFormat.Snippet); c.TextEdit !.TextEdit !.NewText.Should().Be("object"); c.TextEdit.TextEdit.Range.Start.Line.Should().Be(0); c.TextEdit.TextEdit.Range.Start.Character.Should().Be(18); c.Detail.Should().Be("Secure object"); c.AdditionalTextEdits !.Count().Should().Be(1); c.AdditionalTextEdits !.ElementAt(0).NewText.Should().Be("@secure()\n"); c.AdditionalTextEdits !.ElementAt(0).Range.Start.Line.Should().Be(0); c.AdditionalTextEdits !.ElementAt(0).Range.Start.Character.Should().Be(8); c.AdditionalTextEdits !.ElementAt(0).Range.End.Line.Should().Be(0); c.AdditionalTextEdits !.ElementAt(0).Range.End.Character.Should().Be(8); }, c => { c.Label.Should().Be("secureString"); c.Kind.Should().Be(CompletionItemKind.Snippet); c.InsertTextFormat.Should().Be(InsertTextFormat.Snippet); c.TextEdit !.TextEdit !.NewText.Should().Be("string"); c.TextEdit.TextEdit.Range.Start.Line.Should().Be(0); c.TextEdit.TextEdit.Range.Start.Character.Should().Be(18); c.Detail.Should().Be("Secure string"); c.AdditionalTextEdits !.Count().Should().Be(1); c.AdditionalTextEdits !.ElementAt(0).NewText.Should().Be("@secure()\n"); c.AdditionalTextEdits !.ElementAt(0).Range.Start.Line.Should().Be(0); c.AdditionalTextEdits !.ElementAt(0).Range.Start.Character.Should().Be(8); c.AdditionalTextEdits !.ElementAt(0).Range.End.Line.Should().Be(0); c.AdditionalTextEdits !.ElementAt(0).Range.End.Character.Should().Be(8); }); }
/// <summary> /// This constructor for hide and if i choose edit will show the variable for types of question /// </summary> public QuestionsInformation(TypeOfChoice AddOrEdit) { try { InitializeComponent(); InitHide(); NewText.Focus(); AddOrEditChoice = AddOrEdit; switch (AddOrEdit) { case TypeOfChoice.Edit: //For Change Ttitle this.Text = Survey.Properties.Messages.TitleOfQuestionEdit; ShowDataForEdit(); if (ReturnNewQuestion != null) { switch (ReturnNewQuestion.TypeOfQuestion) { case TypeOfQuestion.Slider: ShowForSlider(); break; case TypeOfQuestion.Smily: ShowForSmiles(); break; case TypeOfQuestion.Stars: ShowForStars(); break; } } break; case TypeOfChoice.Add: this.Text = Survey.Properties.Messages.TitleOfQuestionAdd; GroupOfTypes.Visible = true; InitHide(); break; } } catch (Exception ex) { GenralVariables.Errors.Log(ex.Message); MessageBox.Show(Survey.Properties.Messages.MessageError); } }
public void NonDeclarationContextShouldIncludeDeclaredSymbols() { var grouping = SyntaxTreeGroupingFactory.CreateFromText(@" param p string var v = resource r 'Microsoft.Foo/foos@2020-09-01' = { name: 'foo' } output o int = 42 "); var offset = grouping.EntryPoint.ProgramSyntax.Declarations.OfType <VariableDeclarationSyntax>().Single().Value.Span.Position; var compilation = new Compilation(TestTypeHelper.CreateEmptyProvider(), grouping); var provider = new BicepCompletionProvider(new FileResolver(), new SnippetsProvider(), new TelemetryProvider(Server)); var context = BicepCompletionContext.Create(compilation, offset); var completions = provider.GetFilteredCompletions(compilation, context).ToList(); AssertExpectedFunctions(completions, expectParamDefaultFunctions: false); // outputs can't be referenced so they should not show up in completions completions.Where(c => c.Kind == SymbolKind.Output.ToCompletionItemKind()).Should().BeEmpty(); // the variable won't appear in completions because we are not suggesting cycles completions.Where(c => c.Kind == SymbolKind.Variable.ToCompletionItemKind()).Should().BeEmpty(); const string expectedResource = "r"; var resourceCompletion = completions.Single(c => c.Kind == SymbolKind.Resource.ToCompletionItemKind()); resourceCompletion.Label.Should().Be(expectedResource); resourceCompletion.Kind.Should().Be(CompletionItemKind.Interface); resourceCompletion.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); resourceCompletion.TextEdit !.TextEdit !.NewText.Should().Be(expectedResource); resourceCompletion.CommitCharacters.Should().BeEquivalentTo(new[] { ":", }); resourceCompletion.Detail.Should().Be(expectedResource); const string expectedParam = "p"; var paramCompletion = completions.Single(c => c.Kind == SymbolKind.Parameter.ToCompletionItemKind()); paramCompletion.Label.Should().Be(expectedParam); paramCompletion.Kind.Should().Be(CompletionItemKind.Field); paramCompletion.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); paramCompletion.TextEdit !.TextEdit !.NewText.Should().Be(expectedParam); paramCompletion.CommitCharacters.Should().BeNull(); paramCompletion.Detail.Should().Be(expectedParam); }
/// <summary> /// This constructor for hide and if i choose edit will show the variable for types of question /// </summary> public QuestionsInformation(Qustions QuestionWillDeleteOrEdit, string AddOrEdit) { InitializeComponent(); InitHide(); this.QuestionWillDeleteOrEdit = QuestionWillDeleteOrEdit; NewText.Focus(); AddOrEdirChoice = AddOrEdit; try { if (TypeOfChoice.Edit.ToString() == AddOrEdit) { this.Text = Survey.Properties.Resource1.TitleOfQuestionEdit; GroupOfTypes.Visible = false; ShowDataForEdit(); if (QuestionWillDeleteOrEdit != null) { if (TypeOfQuestion.Slider.ToString() == QuestionWillDeleteOrEdit.TypeOfQuestion) { ShowForSlider(); } else if (TypeOfQuestion.Smily.ToString() == QuestionWillDeleteOrEdit.TypeOfQuestion) { ShowForSmiles(); } else if (TypeOfQuestion.Stars.ToString() == QuestionWillDeleteOrEdit.TypeOfQuestion) { ShowForStars(); } } } else if (TypeOfChoice.Add.ToString() == AddOrEdit) { this.Text = Survey.Properties.Resource1.TitleOfQuestionAdd; GroupOfTypes.Visible = true; InitHide(); } } catch (Exception ex) { StaticObjects.Erros.Log(ex); MessageBox.Show(Survey.Properties.Resource1.MessageError); } }
/// <summary> /// Removes any 'Joker' characters from a Criteria TextBox /// </summary> /// <param name="AFindCriteriaDataTable"></param> /// <param name="ASplitButton"></param> /// <param name="AAssociatedTextBox"></param> /// <param name="ALastSelection"></param> public static void RemoveJokersFromTextBox(DataTable AFindCriteriaDataTable, SplitButton ASplitButton, TextBox AAssociatedTextBox, TMatches ALastSelection) { string NewText; try { if (AAssociatedTextBox != null) { // Remove * Joker character(s) NewText = AAssociatedTextBox.Text.Replace("*", String.Empty); // If an EXACT search is wanted, we need to remove the % Joker character(s) as well if (ALastSelection == TMatches.EXACT) { NewText = NewText.Replace("%", String.Empty); } // TLogging.Log( // "RemoveJokersFromTextBox: Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (1): " + AAssociatedTextBox.Text); // AFindCriteriaDataTable.Rows[0].BeginEdit(); // AAssociatedTextBox.Text = NewText; // AFindCriteriaDataTable.Rows[0].EndEdit(); string fieldname = ((TextBox)AAssociatedTextBox).DataBindings[0].BindingMemberInfo.BindingMember; AFindCriteriaDataTable.Rows[0][fieldname] = NewText; fieldname = ((SplitButton)ASplitButton).DataBindings[0].BindingMemberInfo.BindingMember; AFindCriteriaDataTable.Rows[0][fieldname] = Enum.GetName(typeof(TMatches), ALastSelection); // AFindCriteriaDataTable.Rows[0].EndEdit(); // // AAssociatedTextBox.Text = NewText; // // TLogging.Log( // "RemoveJokersFromTextBox: Associated TextBox's (" + AAssociatedTextBox.Name + ") Text (2): " + AAssociatedTextBox.Text); } } catch (Exception exp) { MessageBox.Show("Exception in RemoveJokersFromTextBox: " + exp.ToString()); } }
private void CheckBuffer(ReadStrategy strategy, Keys key) { switch (strategy) { case ReadStrategy.DependsOnLength: { if (_buffer.Length >= StringLength) { var text = _buffer.ToString(); _buffer.Clear(); NewText?.Invoke(this, new NewStringEventArgs(text)); } break; } case ReadStrategy.DependsOnSymbols: { char end; if (key.TryToChar(_shiftPressed, out end)) { if (end == EndSymbol) { var text = _buffer.ToString(); _buffer.Clear(); NewText?.Invoke(this, new NewStringEventArgs(text)); } } break; } case ReadStrategy.DependsOnEnter: { if (key == Keys.Return) { var text = _buffer.ToString(); _buffer.Clear(); NewText?.Invoke(this, new NewStringEventArgs(text)); } break; } } }
private void HealingCalc() { GameObject NewText; float PlayerHealingNSum = 0; float EnemyHealingNDSum = 0; foreach (MagicEffect effect in activeMagicEffects) { if (effect.Type == MagicEffectType.Healing) { switch (effect.TargetCharacter) { case TargetCharacter.Player: PlayerHealingNSum += effect.Value; break; case TargetCharacter.Enemy: EnemyHealingNDSum += effect.Value; break; } } } if (PlayerHealingNSum > 0) { NewText = GameObject.Instantiate(mainBScript.Text); NewText.GetComponent <TextScript>().SetPlayerPos(); NewText.GetComponent <TextScript>().SetColor(1); NewText.GetComponent <TextScript>().SetText("+" + System.Convert.ToString(Mathf.RoundToInt(PlayerHealingNSum))); /// mainBScript.PlayerScript.Healing(PlayerHealingNSum); } if (EnemyHealingNDSum > 0) { NewText = GameObject.Instantiate(mainBScript.Text); NewText.GetComponent <TextScript>().SetEnemyPos(); NewText.GetComponent <TextScript>().SetColor(1); NewText.GetComponent <TextScript>().SetText("+" + System.Convert.ToString(Mathf.RoundToInt(EnemyHealingNDSum))); /// mainBScript.EnemyScript.Healing(EnemyHealingNDSum); } }
private void FireDamageCalc() { GameObject NewText; float PlayerPassiveDSum = 0; float EnemyPassiveDSum = 0; foreach (MagicEffect effect in activeMagicEffects) { if (effect.Type == MagicEffectType.Fire) { switch (effect.TargetCharacter) { case TargetCharacter.Player: PlayerPassiveDSum += effect.Value; break; case TargetCharacter.Enemy: EnemyPassiveDSum += effect.Value; break; } } } if (PlayerPassiveDSum > 0) { NewText = GameObject.Instantiate(mainBScript.Text); NewText.GetComponent <TextScript>().SetPlayerUpperPos(); NewText.GetComponent <TextScript>().SetColor(4); NewText.GetComponent <TextScript>().SetText("-" + System.Convert.ToString(Mathf.RoundToInt(PlayerPassiveDSum))); /// mainBScript.PlayerScript.HealthPoint -= PlayerPassiveDSum; } if (EnemyPassiveDSum > 0) { NewText = GameObject.Instantiate(mainBScript.Text); NewText.GetComponent <TextScript>().SetEnemyUpperPos(); NewText.GetComponent <TextScript>().SetColor(4); NewText.GetComponent <TextScript>().SetText("-" + System.Convert.ToString(Mathf.RoundToInt(EnemyPassiveDSum))); /// mainBScript.EnemyScript.HealthPoint -= EnemyPassiveDSum; } }
public NewBaseControl CreateControl(String controlType, Point position) { NewBaseControl control = null; switch (controlType) { case "Text": control = new NewText(); break; case "ActiveText": control = new NewActiveText(); break; case "Image": control = new NewImage(); break; case "ActiveImage": control = new NewActiveImage(); break; case "BackGroundImage": control = new NewBackGroundImage(); break; case "Line": control = new NewLine(); break; case "Table": control = new NewTable(); break; } control.ControlNum = Config.ElementNodeStartNum; control.ControlType = controlType; control.ControlPosition = position; control.Create(); return(control); }
protected override void Execute(CodeActivityContext executionContext) { ITracingService tracer = executionContext.GetExtension <ITracingService>(); IWorkflowContext context = executionContext.GetExtension <IWorkflowContext>(); IOrganizationServiceFactory serviceFactory = executionContext.GetExtension <IOrganizationServiceFactory>(); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); try { EntityReference noteToUpdate = NoteToUpdate.Get(executionContext); string newText = NewText.Get(executionContext); Entity note = new Entity("annotation"); note.Id = noteToUpdate.Id; note["notetext"] = newText; service.Update(note); UpdatedText.Set(executionContext, newText); } catch (Exception e) { throw new InvalidPluginExecutionException(e.Message); } }
public override int GetLineNumberFromPosition(int position) { return(NewText.GetLineNumberFromPosition(position)); }
public void DeclarationContextShouldReturnKeywordCompletions() { var grouping = SyntaxTreeGroupingFactory.CreateFromText(string.Empty); var compilation = new Compilation(TestTypeHelper.CreateEmptyProvider(), grouping); compilation.GetEntrypointSemanticModel().GetAllDiagnostics().Should().BeEmpty(); var provider = new BicepCompletionProvider(new FileResolver(), new SnippetsProvider(), new TelemetryProvider(Server)); var completions = provider.GetFilteredCompletions(compilation, BicepCompletionContext.Create(compilation, 0)); var keywordCompletions = completions .Where(c => c.Kind == CompletionItemKind.Keyword) .OrderBy(c => c.Label) .ToList(); keywordCompletions.Should().SatisfyRespectively( c => { c.Label.Should().Be("module"); c.Kind.Should().Be(CompletionItemKind.Keyword); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.InsertText.Should().BeNull(); c.Detail.Should().Be("Module keyword"); c.TextEdit !.TextEdit !.NewText.Should().Be("module"); }, c => { c.Label.Should().Be("output"); c.Kind.Should().Be(CompletionItemKind.Keyword); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.InsertText.Should().BeNull(); c.Detail.Should().Be("Output keyword"); c.TextEdit !.TextEdit !.NewText.Should().Be("output"); }, c => { c.Label.Should().Be("param"); c.Kind.Should().Be(CompletionItemKind.Keyword); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.InsertText.Should().BeNull(); c.Detail.Should().Be("Parameter keyword"); c.TextEdit !.TextEdit !.NewText.Should().Be("param"); }, c => { c.Label.Should().Be("resource"); c.Kind.Should().Be(CompletionItemKind.Keyword); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.InsertText.Should().BeNull(); c.Detail.Should().Be("Resource keyword"); c.TextEdit !.TextEdit !.NewText.Should().Be("resource"); }, c => { c.Label.Should().Be("targetScope"); c.Kind.Should().Be(CompletionItemKind.Keyword); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.InsertText.Should().BeNull(); c.Detail.Should().Be("Target Scope keyword"); c.TextEdit !.TextEdit !.NewText.Should().Be("targetScope"); }, c => { c.Label.Should().Be("var"); c.Kind.Should().Be(CompletionItemKind.Keyword); c.InsertTextFormat.Should().Be(InsertTextFormat.PlainText); c.InsertText.Should().BeNull(); c.Detail.Should().Be("Variable keyword"); c.TextEdit !.TextEdit !.NewText.Should().Be("var"); }); }
public override string GetText(TextSpan textSpan) { return(NewText.GetText(textSpan)); }