line-numbers

Visual Studio Extension: How to get the line on which Context Menu was called?

会有一股神秘感。 提交于 2019-12-08 05:22:55
问题 I would like to create a VS extension in which I need to know the line number the menu was called on. I found a VisualBasic implementation with a macro that seems to do this, but I don't know how to start this in C#. The goal would be to know the exact number of the line the ContextMenu was called on to put a placeholder icon on it just like a break point. Useful links are appreciated since I couldn't find much on this topic. 回答1: You could create a VSIX project and add a Command item in your

Method name from line number

五迷三道 提交于 2019-12-07 10:46:45
问题 Given a line number of a particular class source code (Java/C#) - is there an easy way to get the name of the method it falls within? (If it falls within one) (Presumably using an Abstract Syntax Tree) (This would be useful in limiting the output of checkstyle to just the method touched). I'm assuming you'd have to use an Abstract Syntax Tree to do Line#->MethodName. 回答1: (Java-specific) If the class file was compiled with debug info then the line number table will contain a mapping of code<-

HTML/CSS/JS: How to make an illusion of a textarea with line numbers?

自古美人都是妖i 提交于 2019-12-07 04:42:39
问题 I want to have a textarea which displays line numbers on the left. Wrap should be set to "off" (so that horizontal scrolling is available). I want to have my page as a single self-contained .html file (there will be no graphics), so I'd like to avoid any 3rd party frameworks. Which way should I go? How would you do this? 回答1: I would start with two text-areas and synchronzation mechanism. Something like this, <script> window.sync = function(e){ var textarea = document.getElementById("lines");

Java JTextArea Line Numbers

非 Y 不嫁゛ 提交于 2019-12-06 07:34:22
I'm trying to add line numbers to a JTextArea and am having some difficulties. The line numbers appear, but they do not scroll properly. I have a linked-list of a custom class that stores a line of data (log message) and a line number associated with it as well as visibility on whether it should be shown in the text area or not. So what I did was create two JTextAreas... one to store the logs, and the other to store the line numbers. The layout works and the line numbers populate correctly with the logs. The problem is when I try to scroll up or down. The logs adjust properly as you scroll,

Line Numbers, Code Highlighting in TextView

吃可爱长大的小学妹 提交于 2019-12-06 00:09:22
I'm working on an 'IDE' for Android - it could be useful for editing short scripts / making quick adjustments to files. At the moment I'm just using a simple EditText, but I am wanting to add several features, for example Line Numbering down the left hand side of the EditText and Code Highlighting. Does anyone have any suggestions about how to approach this? For the code highlighting, I'm guessing I'll need to write my own subclass of EditText. For the line numbering, could I have a thin vertical TextView that has the same text size as the EditText?? Yes, I'm aware editing code on a mobile

PHP get line number from logging event

主宰稳场 提交于 2019-12-05 23:25:23
问题 Ok I have another question HERE for my Logging Class but I wanted to be able to add the line number of the calling script to the log file entry. I have seen __Line __ but this gives me the line number of the line where this is at. Example: a.php $log = new Logger(); $log->debug('hello'); // Say this is line #20 Now in my Logger.php class in the debug() I use the __Line __ Magic Constant on for example line #300. When I run the script I would like the log entry to read 'on line 20' but it read

Method name from line number

送分小仙女□ 提交于 2019-12-05 12:39:00
Given a line number of a particular class source code (Java/C#) - is there an easy way to get the name of the method it falls within? (If it falls within one) (Presumably using an Abstract Syntax Tree) (This would be useful in limiting the output of checkstyle to just the method touched). I'm assuming you'd have to use an Abstract Syntax Tree to do Line#->MethodName. (Java-specific) If the class file was compiled with debug info then the line number table will contain a mapping of code<->line number. I don't think there's a built-in API for getting at this at runtime though I'm sure you can

HTML/CSS/JS: How to make an illusion of a textarea with line numbers?

喜夏-厌秋 提交于 2019-12-05 10:28:48
I want to have a textarea which displays line numbers on the left. Wrap should be set to "off" (so that horizontal scrolling is available). I want to have my page as a single self-contained .html file (there will be no graphics), so I'd like to avoid any 3rd party frameworks. Which way should I go? How would you do this? I would start with two text-areas and synchronzation mechanism. Something like this, <script> window.sync = function(e){ var textarea = document.getElementById("lines"); var source = document.getElementById("some_text_area"); textarea.scrollTop = source.scrollTop; } window

How to access line numbers when wrapping Firebug (or similar) Console api

放肆的年华 提交于 2019-12-05 02:41:43
I have wrapped the console API to provide granular logging levels as well as few other sugar features. This works fine, the only problem is that firebug (or whatever other console) will always report the line number the log came from as the line the console API itself is invoked. How would you suggest I make the console log the line number at which I call my wrapper function? I would prefer a cross browser solution but failing that a firebug plugin could be a good start. fyi I call my loging function like so: db.log(db.LogLevel.WARN, "Blah Blah Blah"); Interesting problem... I may have a hack

Get line numbers of fields without using a c# parser

让人想犯罪 __ 提交于 2019-12-05 01:06:52
问题 I would like to get the line #s of a type's fields. To get the line #'s of the statements in a method it is simple enough: Type type = typeof(MyClass); MethodInfo methodInfo = type.GetMethod("SomeMethod"); int token = methodInfo.MetadataToken; ISymbolReader reader = SymUtil.GetSymbolReaderForFile(@"dllName", null); // from mike stall's pdb2xml ISymbolMethod methodSymbol = reader.GetMethod(new SymbolToken(token)); int count = methodSymbol.SequencePointCount; ISymbolDocument[] docs = new