Do a Find in Current Namespace in Visual Studio? - search

Want to be able to do a Find but contain my results to the current namespace the current opened file is in. Like "Current Project" but "Current Namespace". Is there a plugin or tool that can do this?

You can always use a regex :
namespace my_namespace(.*\n)*.*my_search
That's kind of an ugly solution, since it will select everything between namespace keyword and you search. But that's still useful.
You can adapt it and change capture groups in order to be able to use it for replacements.

Rather than parsing and inspecting every code file individually, Agent Mulder plugin utilizes ReSharper's Structural Search (sometimes known as Structural Search and Replace, or SSR) to look for patterns of code in the entire solution. This is both effective (since the solution structure already exists in ReSharper's caches), and makes it very easy to extend Agent Mulder to support additional containers.
Here is an overview of ReSharper's Structural Search API (based on ReSharper SDK v6.1)

Related

Sublime, altering behavior of highlighting definions upon mouse-hover

I have a project with several classes which partly share functions while at other times the functions are different in code, but use the same name.
When hovering over a function name, Sublime highlights every file and line where that definition is found.
In my opinion it would be better if it actually included which class the different highlights belong to.
Is it possible to edit this in some way ?
Assume systems.js contains 4 different classes (1 base, 3 children). I would like to append or prepend the shown strings by the class definition (fetchable via prototype).
The hover popup mentioned in your question is powered by Sublime's internal symbol index, which is created in combination with the syntax definition that's used to syntax highlight files that you're editing. The Sublime syntax system is fairly context free; it parses the structure of the code but it doesn't contain any real structural information about it.
So for example it can determine that getShots is a function or method because of the syntax that was used to define it, but it doesn't know what class it came from.
The code for the hover popup is available in Default/symbol.py (you can use PackageResourceViewer to examine it) and associates symbols under the cursor with other places that it's seen symbols with that name in other files in the project; it literally only knows the information that you see in the popup; places where things by that name are defined and places where things of that name are referenced.
So in one sense, the answer to your question is No; core sublime can't do that because it doesn't have enough code intelligence to be able to figure that sort of thing out; this is exacerbated by dynamic languages like JavaScript where things can theoretically change at runtime as well.
The primary reason for that is because Sublime is extensible enough to support literally every programming language instead of just focusing on one or two (as e.g. PhpStorm does), so it doesn't have the core code to determine the information required.
All that said, since Sublime is indeed extremely extensible, it's possible that external code that does specialize on a language could be leveraged by a package in order to provide the appropriate information.
Two examples of that are SublimeCodeIntel and LSP for example. I don't use either of them myself, so I don't know for sure how good a fit they might be in your workflow.
I highly recommend you shift to Visual Studio Code majorly because sublime is an editor whereas vs code is an IDE. Also, it has very great extension support for all languages. I would recommend you to use jshint which the most popular plugin for js code available for almost all popular editors and IDEs. But still if you want to go with Sublime I suggest you following plugins:
https://www.sitepoint.com/essential-sublime-text-javascript-plugins/

Android Studio / IntelliJ: Highlight custom strings in the log (or logcat)

Android and IntelliJ both have support for highlighting log messages based on the log level.
I'd like to go a step further and also highlight "my" classes, means classes from "my" packages - in a different way so that I can recognize them quickly in the log. So I'd like to see an option where I can define a custom string and then give lines which contain this string a custom highlighting. The "string" could be a package name, a debug string, or whatever.
Do you know if such a solution exists already? Maybe there's already a plugin for that?
I'm not aware of anything specifically targeting this use case, but I have workarounds for you.
Search
Focus the LogCat window by clicking into it and the press Ctrl+F, this brings up the local search bar and you can enter your package name:
Filter logs
This solution is from my question: How can I disable Android's internal logging for specific tags (e.g. AbsListView, GestureDetector, endeffect)
If you're having problems with spamming log lines you don't care about just filter them out, for example I have this configuration:
^(?!AbsListView|endeffect|GestureDetector|CustomFrequencyManager|ApplicationPackageManager|PersonaManager|ProgressBar|ViewRootImpl|MotionRecognitionManager)
^(?!Unable to resolve superclass of|Link of class|DexOpt: unable to opt direct call|Could not find class|Could not find method|VFY: )
This leaves only the most important/relevant log lines:
your app's logs
dalvikvm's Garbage Collections
StrictMode
and other unexpected things
High-level logging
I don't suggest you do this, included for completeness. Use only Log.wtf and Log.e for your own logging and set colors/LogCat view's level filter accordingly. This is not really useful if you want to have 5 levels of logging. There may be some sneak-in log lines, but less than normal.
What about the plugin https://plugins.jetbrains.com/plugin/7125-grep-console.
I use it and it is quite good.

Adding to ReSharper's 'Related Files' list

From version 5.0 onwards, ReSharper offers a "Go To Related Files" navigation which offers a list of files that R# thinks are related to the file currently being edited: for example, base types, derived types, .designer.cs to and from the relevant .cs, and so on.
I have looked in the R# Options and also online, but have not been able to find out:
Is there a way to add files to this list, either within R# natively or by an already-existing plug-in?
(My motivation is to be able to navigate at coding time between files containing classes that are connected by a run-time-only convention-over-configuration, er, convention)
I don't know about existing plugins, but this feature is extendable.
You need to implement IRelatedFilesProvider interface in your plugin and mark it by RelatedFilesProvider attribute. As far as I know, NHibernate plugin do it for analogous task.

Is there a way in Visual Studio to specify what a template class (new class) is going to look like?

I'm a long time Eclipse user trying to learn to Visual Studio. I know that Eclipse had Code Templates that would allow you to build classes with certain comments and formatting already added for a class.
For example:
Auto placing the copyright for the code at the top of the file
Who created the file
Predefined Comments,
etc...
Does Visual Studio 2005 have any functionality like this?
It depends. Visual Studio has a built-in code snippets manager that lets you do things like this to at least a degree (i.e., if you insert a code snippet, it'll be formatted as the snippet specifies, but if you write the same code manually, it won't). Also note that there are limitations on the languages with which you can use code snippets.
Outside of that, most of the major add-ins for VS (e.g., Visual Assist-X) provide their own ability to store and insert bits of code, formatted as you specify. Most of these provide at least some features missing from the built-in snippets manager such as working with other languages or being easier to access (along with quite a few other things -- IMO, VS borders on completely unusable without VA-X).
I would recommend looking at item and project templates in Visual Studio, which sound like what you're looking for. But, in your particular case (C++ development), it doesn't look like this is available to you.
The following MSDN article refers to VS templates, and mentions that for Visual C++ projects, that the template architecture isn't supported. Instead, there's information on creating custom wizards for your project and classes, which may give you the flexibility that you need. Sounds like it'll do what you want it to do, but it's much more work than it would be if you could use an item template for including basic comment structure for a default class file.
http://msdn.microsoft.com/en-us/library/6db0hwky%28VS.80%29.aspx

How to add custom code analysis in ReSharper

I'm new to ReSharper.
For those who uses Resharper, is there a way I can add custom code analysis rules?
For example I might have a rule say All private variables should start with letter "m". How can I add this to Resharper so if I violate this, it can shows as a warning or an error?
I know the question is old, but for all folks coming from google like me:
Resharper -> Options -> Code inspections -> Custom Patterns
There you can create your own rules for highlighting patterns or offering substitutions. This is for ReSharper 8. I'm not sure from which version this option is there.
Just to expand on what #AakashM notes above: this can be specified in ReSharper Options | Languages | (either Common or C# or whatever) | Naming Style.
If you click on Advanced Settings, and then double-click on one of the "entity descriptions", there is a far larger selection of possible entities (including events, namespaces etc) , together with access rights (private, protected, etc) and so on, for which you can define prefix, suffix and casing rules.
You can write your own plugins for ReSharper. Take a look at here:
http://stylecopforresharper.codeplex.com/
This is similar to what you're asking for. It might even do what you want. Not sure since I'm not a big StyleCop user.
Also take a look at the first in my series of blog posts coming on ReSharper plugins:
http://hadihariri.com/2010/01/12/writing-plug-ins-for-resharper-part-1-of-undefined/

Resources