-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[feature request] apply quickfix to current file OR a range of text (more general) #7760
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
I'd rather we had an "organize imports" action than blindly apply every available quick fix. |
Looking for the same! |
And organize imports assist would sound a lot better. It's rare to want to apply a bunch of quickfixes at once while it also might introduce some bugs due to overlapping text edits resulting from them. Hence closing as an indirect dupe of #5131 |
I don't think this use-case is necessarily rare. Especially for changes like "convert to snake case", it's often useful to be able to bulk apply when you copy paste something from an external source. |
Why would that external source use the wrong naming convention? |
Because it's often not Rust. |
I just ran into this with a database that uses |
Then I am confused as to how you would even get these kinds of diagnostics if its not rust code. |
Well there's lots of things that you might want to interact with that are defined elsewhere. Often that just means copy pasting some structure / enum / etc from a C header or somewhere else. Then you have a whole bunch of things which don't match rust formatting style, and infinity little "quick fix" buttons to press if you decide to go that route. For example, you might have something like the following. typedef struct VkPhysicalDeviceFeatures {
VkBool32 robustBufferAccess;
VkBool32 fullDrawIndexUint32;
VkBool32 imageCubeArray;
VkBool32 independentBlend;
VkBool32 geometryShader;
VkBool32 tessellationShader;
VkBool32 sampleRateShading;
VkBool32 dualSrcBlend;
VkBool32 logicOp;
VkBool32 multiDrawIndirect;
VkBool32 drawIndirectFirstInstance;
VkBool32 depthClamp;
VkBool32 depthBiasClamp;
VkBool32 fillModeNonSolid;
VkBool32 depthBounds;
VkBool32 wideLines;
VkBool32 largePoints;
VkBool32 alphaToOne;
VkBool32 multiViewport;
VkBool32 samplerAnisotropy;
VkBool32 textureCompressionETC2;
VkBool32 textureCompressionASTC_LDR;
VkBool32 textureCompressionBC;
VkBool32 occlusionQueryPrecise;
VkBool32 pipelineStatisticsQuery;
VkBool32 vertexPipelineStoresAndAtomics;
VkBool32 fragmentStoresAndAtomics;
VkBool32 shaderTessellationAndGeometryPointSize;
VkBool32 shaderImageGatherExtended;
VkBool32 shaderStorageImageExtendedFormats;
VkBool32 shaderStorageImageMultisample;
VkBool32 shaderStorageImageReadWithoutFormat;
VkBool32 shaderStorageImageWriteWithoutFormat;
VkBool32 shaderUniformBufferArrayDynamicIndexing;
VkBool32 shaderSampledImageArrayDynamicIndexing;
VkBool32 shaderStorageBufferArrayDynamicIndexing;
VkBool32 shaderStorageImageArrayDynamicIndexing;
VkBool32 shaderClipDistance;
VkBool32 shaderCullDistance;
VkBool32 shaderFloat64;
VkBool32 shaderInt64;
VkBool32 shaderInt16;
VkBool32 shaderResourceResidency;
VkBool32 shaderResourceMinLod;
VkBool32 sparseBinding;
VkBool32 sparseResidencyBuffer;
VkBool32 sparseResidencyImage2D;
VkBool32 sparseResidencyImage3D;
VkBool32 sparseResidency2Samples;
VkBool32 sparseResidency4Samples;
VkBool32 sparseResidency8Samples;
VkBool32 sparseResidency16Samples;
VkBool32 sparseResidencyAliased;
VkBool32 variableMultisampleRate;
VkBool32 inheritedQueries;
} VkPhysicalDeviceFeatures; It's not a huge issue of course, but it does annoy me personally, I found this bug looking to see if there was a way to bulk apply suggestions. |
Hm, I mean in this case, bulk changing the case of something I personally would use my IDE's tooling for that(VSCode allows me to just that), but that is obviously client specific. |
I was using vscode, so I'm not really sure what you mean? You can't select a whole range and apply fixes. At least, unless I'm missing something? But you're right that it might be better handled by the editor rather than rust-analyzer itself. |
Ah I had no idea that was a built-in feature. That's a lot easier than what I was doing! :) |
The Dart analysis server usually has an "apply this fix to every instance in this file" action for most quickfixes, IIRC. We could do something similar. |
Can confirm that this would have saved me a lot of time worth of work. Especially when I am re-organizing the usage of creates in my project and I have to re-import all the content of the crates with new |
It looks like the original poster wanted to remove unused imports. You can use 'cargo machete' for this |
I have a similar use case in my codebase: by using sed-like refactoring tools I ended up with a bunch of A tool that would let me apply a given assist throughout a project would be super useful to me. |
sometimes we have many warnings and we would like to apply quick fix, currently it seems that we can only do this one by one. Is it possible to apply quick fix to a range?
like the above, it's not effecient at all to apply quick fix one by one
The text was updated successfully, but these errors were encountered: