controlflow / resharper-postfix Goto Github PK
View Code? Open in Web Editor NEWReSharper Postfix Templates plugin
License: MIT License
ReSharper Postfix Templates plugin
License: MIT License
We have always used.
Thank you very much.
Type completion of argument is no longer performed at the time of the definition of the function in version 2.2-beta R#9.2
Scan for collections in context
switch (e) {
SomeEnum.SomeCase.case
}
=>
switch (e) {
case SomeEnum.SomeCase:
}
Thanks for a great extension!
Now when R# 9.1 is out I was hoping for some support for it.
It is really rare when somebody needs reflection over static type, let's hide it from auto
it's good plugins.
but
i want to add my own templates, how to add?
I have a variable named exitFileRecord of a POCO type. I write this code:
if (exitFileRecord._agentName.isnullor
I'm prompted with a popup for code completion that properly changes it to:
if (string.IsNullOrEmpty(exitFileRecord._agentName)
But when I continue and add this:
if (string.IsNullOrEmpty(exitFileRecord._agentName) && exitFileRecord._cert.issnullor
when I type that last "r", I have the pop up prompt with the suggested code change (which is correct in the popup), it changes it and ends up with this:
if (string.IsNullOrEmpty(exitFileRecord._agentName) && string.IsNullOrEmpty(String.IsNullOrEmptyd._cert))
That's not my typo on the Emptyd._cert. If leaves out my variable entirely and puts string.IsNullOrEmpty twice like you see here, followed by "d._cert".
I don't know how this would work, but I always end up using a generic parameter T
without having declared it in the method or class, and resharper's greedy code completion always adds a totally useless class name:
public void Foo(IEnumerable<ThreadStaticAttribute>
Can postfix do something to help? Add a 'create T' item in the code completion for IEnumerable<
above? Any better ideas?
Can add pls? :)
by now it points to webstorm blog post
Please add automatic braces added to blocks (.using, .if, .null/.notnull, etc), respecting the braces rules.
Currently the plugin always uses var
. For example, if I enter 10.for
, I get the following:
for (var i = 0; i < 10; i++)
However, ReSharper generates int
. Maybe it depends on ReSharper's settings (I've lowered severity of some inspections regarding usage of var
), I'm not sure. Either way, I'd prefer explicitly typed variables (or choosing type).
When I have a Task returning method like this:
public Task Foo()
{
SomethingAsync().await
}
The .await template produces noncompilable code. R# has a 'Make method 'Foo' async' quick fix for that, though.
Is that possible to invoke the quick fix automatically by default or at least have it as an option of choice?
Maybe allow:
using (Resource().var{caret}) { }
// =>
using (var resource = Resource(){caret}) { }
Hi,
as the current version of ReSharper 8 EAP already supports extension gallery it would be fine to find it there
Br, Daniel
It would be nice if some of the templates worked in .js files.
Task<string> empty = Task.FromResult(string.null);
// =>
Task<string> empty = Task.FromResult((string) null);
CancellationToken.default
// =>
default(CancellationToken);
When the awaited type is void
:
Task task = ...;
task.await
=>
Task task = ...;
await task;
Does not work in ReSharper 8.0.1 (EAP 8.0.1000.1886).
I'm getting this (related?):
Object reference not set to an instance of an object.
--- EXCEPTION #1/2 [NullReferenceException]
Message = “Object reference not set to an instance of an object.”
ExceptionPath = Root.InnerException
ClassName = System.NullReferenceException
HResult = COR_E_NULLREFERENCE=E_POINTER=80004003
Source = JetBrains.Platform.ReSharper.DocumentModel
StackTraceString = “
at JetBrains.DocumentModel.RangeMarkerExtentions.CreateRangeMarkerImpl(DocumentRange documentRange, Boolean mapToDocument)
at JetBrains.DocumentModel.RangeMarkerExtentions.CreateRangeMarker(DocumentRange documentRange)
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.LookupItems.PostfixLookupItem..ctor(String shortcut, PrefixExpressionContext context) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\LookupItems\PostfixLookupItem.cs:line 45
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.LookupItems.StatementPostfixLookupItem`1..ctor(String shortcut, PrefixExpressionContext context) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\LookupItems\StatementPostfixLookupItem.cs:line 23
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.LookupItems.KeywordStatementPostfixLookupItem`1..ctor(String shortcut, PrefixExpressionContext context) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\LookupItems\KeywordStatementPostfixLookupItem.cs:line 21
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.TemplateProviders.ForEachLoopTemplateProvider.LookupItem..ctor(PrefixExpressionContext context) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\TemplateProviders\ForEachLoopTemplateProvider.cs:line 62
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.TemplateProviders.ForEachLoopTemplateProvider.CreateItems(PostfixTemplateAcceptanceContext context, ICollection`1 consumer) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\TemplateProviders\ForEachLoopTemplateProvider.cs:line 56
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.PostfixTemplatesManager.CollectAvailableTemplates(ITreeNode reference, ICSharpExpression expression, DocumentRange replaceRange, ReparsedCodeCompletionContext context, Boolean forceMode, String templateName) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\PostfixTemplatesManager.cs:line 300
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.PostfixTemplatesManager.GetAvailableItems(ITreeNode node, Boolean forceMode, ReparsedCodeCompletionContext reparseContext, String templateName) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\PostfixTemplatesManager.cs:line 75
at JetBrains.ReSharper.ControlFlow.PostfixCompletion.CSharpPostfixItemProvider.AddLookupItems(CSharpCodeCompletionContext context, GroupedItemsCollector collector) in c:\BuildAgent\work\220ad833ac0a8d0d\PostfixCompletion\CSharpPostfixItemProvider.cs:line 59
at JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure.ItemsProviderOfSpecificContext`1.JetBrains.ReSharper.Feature.Services.CodeCompletion.Infrastructure.ICodeCompletionItemsProvider.AddLookupItems(ISpecificCodeCompletionContext context, GroupedItemsCollector collector, Object data)
at JetBrains.ReSharper.Feature.Services.CodeCompletion.IntellisenseManager.<>c__DisplayClass4e.<GetCompletionResult>b__33()
at JetBrains.Util.Logging.Logger.CatchIgnoreExceptions[TValue](Func`1 F, JetHashSet`1 exceptionTypesToIgnore)
”
--- Outer ---
--- EXCEPTION #2/2 [LoggerException]
Message = “Object reference not set to an instance of an object.”
ExceptionPath = Root
ClassName = JetBrains.Util.LoggerException
InnerException = “Exception #1 at Root.InnerException”
HResult = COR_E_APPLICATION=80131600
StackTraceString = “
at JetBrains.ReSharper.Feature.Services.CodeCompletion.IntellisenseManager.GetCompletionResult(CodeCompletionParameters parameters, ITextControl textControl, List`1 contexts)
at JetBrains.ReSharper.Feature.Services.CodeCompletion.AutomaticCodeCompletionSession.AsyncCompletionExecutor.Work()
at JetBrains.Application.InterruptableReadActivity.DoWork()
at JetBrains.Application.InterruptableReadActivity.WorkerThreadProc(ManualResetEvent nativeManualEvent)
at JetBrains.Application.InterruptableReadActivity.<>c__DisplayClass7.<DoStart>b__5()
at JetBrains.Threading.ThreadManager.PooledThread.ThreadProc()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
”
Including allowing choosing type name/var and generating variable name.
Would be great to have this kind of completion.
I often find myself typing a string (i.e. an error message) and then wanting to add some format arguments to it.
Thanks!
It would be cool if we could get a .safe
like .cast
item.safe[TAB]
var
ActionHandlers.myBoundActions ->
CompactMap<IActionDefWithId, IBoundAction>.myStorage.Values ->
ChunkList.myChunks ->
IBoundAction[][] at [0] ->
IBoundAction[] at [181] ->
BoundAction.myOtherHandlers ->
List._items ->
IAction[] at [0] ->
PostfixTemplatesTracker+ExpandPostfixTemplateHandler.myItemsOwnerFactory ->
LookupItemsOwnerFactory.Solution ->
SolutionElement
return x.array
=>
return new[] { x };
Only in double completion, I think.
ArgumentNullException.throw.value.nameof;
=>
throw new ArgumentNullException(nameof(value));
var agent = new SimpleDelegateAgent((index, cancellationToken) =>
{
if (index == 0) throw new InvalidOperationException("YO");
Task.FromResult(true).ret
});
Delegate is of type Func<Task>
:\
Suppose I have this assignment:
int myTmp, mySomeNumber;
...
myTmp = mySomeNumber;
I want to do mySomeNumber.arg
, and have:
myTmp = Method(mySomeNumber);
Currently, it's putting the entire expression inside: Method(myTmp = mySomeNumber)
(hope that's clear :P)
var baseType = (myTypeKind == AssemblyTypeKind.ValueType) ? typeof(ValueType) : typeof(object);
Here, do not suggest to parenthesize AssemblyTypeKind.ValueType
reference expression
Fresh VS install.
Postfix is not available in the R# Extension Manager.
I'm unable to install my favorite extension. :(
Enable only on simple int expressions - for example, only allow reference access chains without invocations.
persons.Select(it.__)
Should populate list of Person
members and produce lambda expression when completed:
persons.Select(p => p.Name)
Merge all possible qualifier types when outer overload is not bound yet.
Too many of them available now in auto-completion
Should behave like introduce variable suggestion, when some variable used multiple times in the same way:
var reference = expression.Reference;
DoSomething(reference.GetPsiModule());
if (reference.GetPsiModule()/*.push*/.IsValid) {
// ...
}
Should produce:
var psiModule = expression.Reference.GetPsiModule();
DoSomething(psiModule);
if (psiModule.IsValid) {
// ...
}
int.seq GetItems() {
// ...
}
=>
IEnumerable<int> GetItems() {
// ...
}
When enum case takes >1 bit, should emit
(value & Enum.Case) == Enum.Case
mail quote:
I wanted to ask you about a liiitle tweak though: could you please fix the “.arg” template
so when it gets unrolled the cursor is placed behind the right parenthesis, and not before. That way we don’t need to use -> key to continue writing the code.
Thanks!
The same for 'Source templates'
WebException.catch
=>
try {
// $END$
}
catch (WebException $name$) {
}
Pressing tab after mystring.IsNullOr
produces string.IsNullOrEmpty(mystring)
even if the namespace with IsNullOrEmpty()
extension method is in scope.
Currently x.P.EnumMember
generates x.P == Enum.EnumMember
.
Which is awesome btw.
However !x.P.EnumMember
generates !(x.P == Enum.EnumMember)
.
I think x.P != Enum.EnumMember
would be better for that case.
When .foreach
template is completed with .
suffix, do not populate foreach
statement iteration variable name hotspot, but produce it's usage inside foreach
body and populate next code completion:
items.foreach.M();
=>
foreach (var item in items) {
item.M();
}
No problems to report - just wanted to say that.
F# uses indexer of T this[int index]
signature to deduce element type of untyped collection, we may do the same. Check on ControlCollection
or MatchCollection
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.