protected override Action <ITextControl> ExecutePsiTransaction(ISolution solution, IProgressIndicator progress) { if (!Highlighting.IsValid()) { return(null); } var node = Highlighting.Node; var badWordTextRange = Highlighting.Range.TextRange; var newText = StringUtil.ReplaceSection( node.GetText(), Suggestion, badWordTextRange.StartOffset - node.GetDocumentRange().TextRange.StartOffset, badWordTextRange.Length ); if (node is IIdentifier) { return(textControl => { var declaredIdentifier = TextControlToPsi.GetDeclaredElements(solution, textControl) .FirstOrDefault(); solution.GetComponent <RenameRefactoringExecutor>().Execute(declaredIdentifier, textControl, newText); }); } if (node is IComment) { var newElement = CreateNode(node, newText); ModificationUtil.ReplaceChild(node, newElement); return(null); } if (JavaScriptUtil.IsStringLiteral(node)) { var newElement = CreateNode(node, newText); ModificationUtil.ReplaceChild(node, newElement); return(null); } return(null); }
protected override bool IsIgnored(string text) { return(base.IsIgnored(text) || JavaScriptUtil.IsKeyword(text)); }