Vim - Show data type - c

I typically code most of my C projects in Vim. I am comfortable with navigation, search and replace, and indexing via Ctags/Cscope.
One feature I would like to have, if possible, is a keymapping that will show the datatype for a variable under the cursor on screen.
For example, if my cursor is on a variable, "test123" (ie: int test123 = 0) is there a way to have the type (int) and some other details about the variable shown in another tab within Vim?
Also, is there something similar that would do the same for a struct variable, and show a list of all its members in the descriptive tab as well as the type (ie: struct)?
I've also noticed that sometimes while coding, I have a tab titled "[Scratch][Preview]" at the top of Vim that appears to fulfill this requirement, but I have no idea what triggers it (searches and Ctag searches don't seem to trigger it). It looks like so:
name: myStruct::instanceOfStrct| 2 cmd: /^ int instanceOfStrct;$/
.. (up a dir) | 3 kind: m
</code/test/test.c | 4 struct: myStruct
|+config/ | 5 access: public
|+lib/ | 6 filename: /code/test/test.c
I think this is something that already exists in Vim to some extent, but I have not idea how to work with it.
Thank you.

I do not know of any plugin that does what you want, however it should be quite possible using libclang. There is a fork of clang_complete that adds 'go to definition' functionality which is close to what you want. However development on that plugin seems to have stagnated.
Also the scratch buffer appears when doing autocompletion to give more information about a specific completion. It can be enabled and disabled using the completeopt setting.

Related

MFC MDI CMFCPropertyGridProperty adding Array for dropdown list merging MP4 tag data

I need some guidance on how to add a drop down list from an array of data after the read info from the MP4 Tag data is parsed. The mechanism I'm using is 100% operational, this is a creature feature addition. The MP4 tag I'm working with is Genre using the ID3V1 standard. There are 191 choices. The way my app was inherited, there are 2 columns, property/value and multiple rows. All of that works. The Genre tag was setup willy nilly so you could basically type whatever and it would store it. I want to remove that and have the 191 elements in the array to choose from using the drop down list. Part of the loading process is that it will pull in whatever was in the MP4 file. So, I want the user to be able to leave as is (most likely tagged by something that supports ID3V2), or select from the populated 191 elements in the dropdown list.
The object looks like this information.h:
protected:
CMFCPropertyGridCtrl m_wndProperties;
The information.cpp looks like this:
void CInformationView::OnInitialUpdate()
{
// create property grid
VERIFY(m_wndProperties.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP| WS_BORDER, CRect(0,0,0,0), this, 0));
// get document
CMovieDoc *lpkDoc = GetDocument();
ASSERT_VALID_PTR(lpkDoc);
// add properties //Information ORDER Loading <<<<< List shortened Stack overflow question
m_wndProperties.AddProperty(lpkDoc->m_pkArtist);
m_wndProperties.AddProperty(lpkDoc->m_pkTempo);
m_wndProperties.AddProperty(lpkDoc->m_pkGenre);
CView::OnInitialUpdate();
}
The way it pulls the data in from mp4.cpp:
// Genre
m_pkGenre = new CMFCPropertyGridProperty(_T("Genre"),
COleVariant(AfxStringFromUtf8(lptTags->genre), VT_BSTR));
The pointers in mp4.h:
CMFCPropertyGridProperty *m_pkArtist;
CMFCPropertyGridProperty *m_pkTempo;
CMFCPropertyGridProperty *m_pkGenre;
Now I know that pull downs in the 2nd column (Values) can be done because other tags have simple TRUE/FALSE that can be selected, so that tells me it should be possible to create the drop down list I'm looking to do. An example of the TRUE/FALSE looks like this:
// Compilation
m_pkCompilation = new CMFCPropertyGridProperty(_T("Compilation"),
COleVariant((!VALID_PTR(lptTags->compilation)) ? (short)0 : (short)*lptTags->compilation, VT_BOOL));
I've done arrays in C for things like microcontrollers, but not entirely sure if it is the same in C++. I'm thinking it should look like this:
// Initialize Genre Array
const char *genre[4] = { "Rock", "Rap", "Soul", "House" };
The questions are:
How do I create an the array (or does my example above look correct?) to house fixed strings like "Rock", "Rap", "Soul", etc. etc?
How to modify the VALUE row to have the pull down that contains the parsed Genre tag present and then when opened, show the 191 Genre tags where one can be selected to choose from (and ultimately save which is already working).
Actual code, not references to the learn.microsoft.com, the few things I've tried crashes when I try to alter the AddProperties I assume because of the lpkDoc pointers being used.
You should not use a plain old C-style array if you do not have a strong reason to. Use a std::vector instead. You don't even need to indicate the [size].
The same goes for char *. Use a CString or astd::string instead.
const std::vector<CString> = { L"Rock", L"Rap", L"Soul", L"House" };
Don't make your life harder than it needs to be.
2.
for (size_t i= 0; i < genre.size(); i++)
{
auto gnr= genre[i];
lpkDoc->m_pkGenre->AddOption(gnr);
}
or even better
for (auto it : genre)
{
lpkDoc->m_pkGenre->AddOption(it);
}
Important note: You should not have code about properties in your doc object. You are mixing business logic with user interaction logic. Your code in the future will be a nightmare to maintain.
I do not see your lpkDoc->m_pk variable init'ed anywhere, and I bet those pointers are pointing to no man's land.

How to verify words one by one on a locator in Robot Framework?

I am still a bit new to the robot framework but please rest assured I am constantly reading its User Guide. I am a bit stuck now with one test case.
I do have a list of individual words, that I need to verify on a page, mostly German translations of field labels if they appear correctly or are found in an element at all.
I have created a list variable as follows:
#{GERMAN_WORDS} | Benutzer | Passwort | Sendung | Transaktionen | Notiz
I have the following locator that contains the text labels on the webpage, and the one I need to verify:
${GENERAL_GERMAN_BOARD} |
xpath=//*[#id="generalAndIncidents:generalAndIncidentsPanel"]
I would like to check every single word one by one from the list variable, whether they are present in the locator above.
I did create the following keyword for this purpose, however I might be missing something because it calls the entire content of my list variable, instead of checking the words from it one by one:
Block Text Verification
[Arguments] ${text_list_variable} ${locator_to_check}
Wait Until Element is Visible ${locator_to_check}
FOR ${label} IN ${text_list_variable}
${labelTostring} Convert to String ${label}
${isMatching} = Run Keyword and Return Status Element Should Contain ${locator_to_check} ${labelTostring}
Log ${label}
Log ${isMatching}
Exit For Loop If '${isMatching}' == 'False'
END
I am getting the following output for this:
Element
'xpath=//*[#id="generalAndIncidents:generalAndIncidentsPanel"]' should
have contained text '['Benutzer', 'Passwort', 'Sendung',
'Transaktionen', 'Notiz']' but its text was.... (and it lists all the
text from my locator)
So, it is basically not checking the words one by one.
Am I doing something wrong here? Is this a bad approach I am trying to do here?
I would be grateful if anyone could provide me some hint on what I should do here instead!
Thank you very much!
You've made one small but crucial mistake - the variable in this line here:
FOR ${label} IN ${text_list_variable}
, should be accessed with #:
FOR ${label} IN #{text_list_variable}
The for-in loops in RF expect 1 or more arguments of the looped over values, and the # expands a list variable to its members.

ZOS: Create first member of dataset

I'm using ZOS with ISPF 7.1
I have allocated a dataset with the following information:
I'm trying to create the first member of this dataset through the Edit Entry Panel (it's option 2 on the menu):
But I always end up with a "Member not found" message.
I know this panel can edit members that already exist, but what is the correct way to create the first member of a dataset (without copying)?
ISPF Edit does not like a RECFM of U (undefined). So you can't do what you are asking with the library.
The message isn't correct, but I don't suppose people see it that often. You can report that to IBM (ask your Technical Support to raise a PMR). Then at some point in the future you'll have a warm feeling when you do the same thing and it produces an accurate message.
If you put members into that dataset with a "copy" and then try to get a member-selection list for Edit, you'll see a message that "Browse was substituted". This is the source of your first message. Recfm U causes the switch to Browse, you can't have a "new" member in Browse, so it looks for an old one, which isn't found.
If you genuinely want RECFM U, you're not going to be able to edit with ISPF.
If instead, from the LRECL and BLOCKSIZE, you wanted RECFM F (fixed-length records) then you'll need to delete and reallocate the dataset with F.
A good way to allocate a new library is to use 3.2 and firstly just list a similar existing library (leave the command area blank is how you do that, and enter the library name in the obvious place).
Then when you A for Allocate, it will "fill in" the parameters of the library you have just listed, and you can make any necessary changes.
Option 0 In ISPF Primary Option Menu is for PDF Environment settings.for example:
__ Allow empty member list
__ Allow empty member list (nomatch)
__ Empty member list for edit only
change them and test.
Got me 5 years to answer this one :D
Actually it's a very normal behavior. You created a PDS but there are any members inside. Simplest is to go to ISPF edit and in the dataset name type name of your dataset and in brackets the new member name - hlq.data.set.name(member01).

Eclipse - How do I view java arrays / collections better in debugger

Viewing/Searching java arrays and collections in the Eclipse Java debugger is tedious and time-consuming.
I tried this promising plugin (in alpha as of Aug 2012)
http://www.cvast.tuwien.ac.at/projects/visualdebugging/ArrayExplorer
But it freezes Eclipse for simple arrays beyond a few hundred elements.
I do use Detail formatters, but that still needs clicking on each element to see the values.
Are there any better ways to view this array/collection data?
Use the 'Expressions' tab.
There you can type in any number of expressions and have them evaluated in the current scope.
ie: collection.size(), collection.getValueAt(i), ect...
Eclipse > Preferences > Java > Debug >Detail Formatter
This may be close to what you are looking for. It is another tedious work to setup but once done you can see the value of objects in Expressions window.
Here is link to start
override toString method of your class and you will be able to see what you want to see. i'm attaching example to show you exactly that.
Even though i could not find a way to see them in nice table/array, i found a halfway workaround.
The solution is to define a static method in a throwaway class that takes the array as input and returns a string of concatenated values that one wants to quickly glance at. it could include the array index and newlines to view results formatted nicely. It can be fine tuned to print out only certain array indices to reduce clutter.
This static method can then be used in the watch area.

Selenium IDE - Typing values stored in an array into a textbox?

There's a webpage I'm trying to test that has multiple textboxes. I've gotten to the point where I can retrieve all the values in every textbox and store them into an array, but I'm stuck on how to type those same values into the textboxes again.
Here's what I have so far in Selenium:
Larger view: http://i.stack.imgur.com/rb93k.png
The stored variable 'count' is simply the number of rows in the table, and isn't causing a problem. The part I've circled in red is where the problem comes in.
When I run this test, instead of typing the value stored in the array at that index, it simply types:
This continues all the way until the end.
The variable 'i' is properly inserted, but for some reason instead of grabbing that value, it simply types it into the textbox.
Does anyone know how I can get the correct value in the array?
Below is the problematic line:
type | javascript{this.browserbot.getUserWindow().getTestingHooks('TextBoxValue_' + storedVars['i'])} | ${textBoxArray[${i}]} |
i'm using Selenium library through Robot Tests Framework. I'm not using any IDE, just using HTML to make test cases and defining new keywords.
When ever i want to access a list variable item, i just use the following sintaxe
#{list_variable_name}[0]
note that ${variable_name} is to access a single value variable or the reference to the list variable. If we want to access a list item we need to use # instead of $.
If i understand your situation right,
#{textBoxArray}[${i}] should work for you.
Try also
${textBoxArray}[${i}] because it seems that your are simply misplaycing the last }.
More details at
http://robotframework.googlecode.com/svn/tags/robotframework-2.5.4/doc/userguide/RobotFrameworkUserGuide.html#list-variables
I think you need to replace your circled reference to ${textBoxArray[${i}] with
javascript{storedVars['textBoxArray['+storedVars['j']+']']}
Read this blog post for more information, especially the section about 'Setting and getting variables'.
Quoting from the article, consider
store | 10 | x
This obviously sets x=10. There are a couple of ways to reference it:
${x} or storedVars['x']. They're not the same.
In particular
You can't assign anything to ${x}.
You can insert one more command before your problematic line:
getEval | storedVars['text'] = storedVars['textBoxArray'][storedVars['i']];
And change problematic line to:
type | javascript{this.browserbot.getUserWindow().getTestingHooks('TextBoxValue_' + storedVars['i'])} | ${text}
Also it will be probably helpful to declare your array in the beginning of the test:
storeEval | new Array() | textBoxArray

Resources