Resolve Unit by Type lazarus / 9-Editor ---------------------------------------------------------------------- Gawie · 2016-03-09 17:15 Hi, I am looking into Lazarus and seem to be missing a critical function (critical in my mind anyway).  Is there a way in Lazarus to find the Unit that holds the declaration for a specific type.  There are various other very good articles on what you should do in order to get the environment set up and please note that this question is not about that at all. Simple example: I am using a TSize but cannot recall what Unit to Uses in order to resolve the type.  So what I do now is I drill down into the Graphics source and then from there, search for TSize and drill down into TSize to see that it is defined in Types.  This process is extremely tedious...   and I am really hoping that there is an option, tool, plugin or other that already performs this task (using the search path). Regards, Gawie ---------------------------------------------------------------------- Leledumbo · 2016-03-09 18:49 F1? If there are multiple instances, a dialog will popup listing the units in which the identifier exists. Note that this requires context sensitive help to work. ---------------------------------------------------------------------- Gawie · 2016-03-09 20:34 Thank you. It definitely answers the question even though the functionality behind is neither efficient nor effective. For 1... Using Lazarus 1.6.0 I have crashed this functionality 4 times in 5 tries (Access violation that ended up in having to kill Lazarus with end task to really get rid of it) while playing with the selectable options looking for TSize.  Furthermore it does a begins or contains search only (no exact option) and seems to duplicate items (many many times over)... I am still in denial as to the idea that this is the best way to find a type.  I know the Free Pascal developers probably know every unit and contained types out there...  but as a prospective returning Delphi developer (since D7) and having used tools like IntelliJ, Eclipse, Visual Studio etc I simply find it very hard with Lazarus to find the unit of a type - which is something that is really well supported in these other IDEs. ---------------------------------------------------------------------- Leledumbo · 2016-03-10 03:08 Silly me, Ctrl+Shift+I does it correctly without hacking any other feature actually. ---------------------------------------------------------------------- FTurtle · 2016-03-10 04:36 Quote from: Leledumbo on March 10, 2016, 04:08:06 amSilly me, Ctrl+Shift+I does it correctly without hacking any other feature actually. It works if necessary unit already in uses. But his task is reverse: he need find unit to include in uses. ---------------------------------------------------------------------- balazsszekely · 2016-03-10 05:10 Other then the not so practical F1, there is no such feature(AFAIK) implemented. We need something similar to "Resolve" in Visual Studio.  @Gawie you should try to implement it, it would be a nice feature. ---------------------------------------------------------------------- Abelisto · 2016-03-10 08:39 View -> Code Browser? ---------------------------------------------------------------------- balazsszekely · 2016-03-10 08:47 @Abelisto  F1 = View -> Code Browser, already discussed. Unfortunately not good enough. ---------------------------------------------------------------------- Abelisto · 2016-03-10 09:19 @GetMem It seems that I missed something. Context help = Code browser? ---------------------------------------------------------------------- Gawie · 2016-03-10 12:45 @Abelisto - yes.. the two are the same.  Feels like I have heard this before...    but there I said it again. One interesting thing is...  (and I can think of one good reason why) - but the Code Browser assistance seems to be much more helpful on Linux than on Windows.  (Still very wonky though if you start playing with the filters). My guess is simply that the Linux Unit files for the type I am testing with (TSize) has less and "better organised" units than with the Windows unit files - assuming there is a difference (unlike e.g. Java where the jar contents remain the same between the OSses) ---------------------------------------------------------------------- marcov · 2016-03-10 15:44 Quote from: GetMem on March 10, 2016, 06:10:10 amOther then the not so practical F1, there is no such feature(AFAIK) implemented. We need something similar to "Resolve" in Visual Studio.  @Gawie you should try to implement it, it would be a nice feature. Afaik resolve requires all files to be in the project. This is typically not done in Lazarus/Delphi. I also use NetBeans, but opening a not even very complicated project takes ages compared to Lazarus. Delphi also only has the help. ---------------------------------------------------------------------- balazsszekely · 2016-03-10 16:32 @marcov QuoteAfaik resolve requires all files to be in the project.I just double checked "Resolve" in Visual Studio and you're right,  it's not so magical after all. Unfortunately Lazarus "Code browser"(F1) it crashes too often, at least under windows. I prefer to use an external tool, like Total Commander's "Search" functionality, it's incredibly fast, still not perfect because finds every occurrence not just the declaration. QuoteI also use NetBeans, but opening a not even very complicated project takes ages compared to Lazarus.Yes I agree, from this point of view Lazarus is much superior. ---------------------------------------------------------------------- Martin_fr · 2016-03-10 16:37 Try this: install the package "Cody" and use the "Show Unit/Identifier Dictionary" (menu "Source") ---------------------------------------------------------------------- balazsszekely · 2016-03-10 16:48 Quote@Martin_fr Try this: install the package "Cody" and use the "Show Unit/Identifier Dictionary" (menu "Source")Wow, this really works. Thanks for the hint! I already mapped a key combination to "Show Unit/Identifier Dictionary".  PS: I believe this package should be installed by default! Very useful! ---------------------------------------------------------------------- Gawie · 2016-03-11 07:39 Thanks Martin.  That is much better. @GetMem , @Marcov When talking about features I wouldn't quote Visual Studio...  but IntelliJ/Resharper for their assistance with this type of problem is simply putting 3 hours back in my day every day over other "IDEs".  Consider that in Pascal/Lazarus you regularly find yourself dealing with hordes of base "primitives" + whatever you are working, other peoples' code and packages which are scattered all over, it makes sense to me that Lazarus appeal would be greatly enhanced if mimicking JetBrains on the following 3 aspects: 1. Consistent keyboard shortcuts with intelligent behaviour behind "one key".  (The Alt-Enter (be smart), Alt-Ins idea (generate)) 2. Navigation...  go anywhere with a few key presses 3. Resolving of types...  near magical (filters, scopes, maven (I know maven is not applicable- just throwing it in there) the works). I can also fully understand that Pascal is a much different beast to Java and .NET - but if anybody is listening - for any keyboard centric development (which Pascal certainly is) - if you can (IMHO) get these 3 issues top notch then the IDEs appeal will be much much stronger.  I know that Lazarus do address these issues in some way or other - but I find it to be menu driven instead of context sensitive. Please don't troll - the opinion is sincere with the intent of somebody smart to maybe consider it and make Lazarus even better. ---------------------------------------------------------------------- SymbolicFrank · 2016-03-11 08:29 The problem with intelligent behavior is, that what one person considers intelligent, another one thinks it's dumb. See the thread where we voted to get the behavior of the F1 key changed. What I value first and foremost is consistency. On the other hand, the behavior of ++C and the other code templating could be further expanded, like with declaring loop counters. When you're talking Resharper: I hate it. The last time I was on a C# project, one of the team members spend all his time "Resharping" the code of the other team members, with each and every option turned on, and telling them they were only allowed to produce that exact code. And especially that anything that could be done as a Lambda expression, should be done like that. Talk about obfuscating your nicely readable code... I agree about the navigation and finding of types. What I would like most to be added, is a better debugging inspector. For example, it is hard to see what is inside a TStringList. And that doesn't even work when you run your application and it throws an exception. ---------------------------------------------------------------------- Gawie · 2016-03-12 16:05 Oh goodness me... here we go.  @SymbolicFrank So you are telling me that when a tool gives you a suggestion that you not only have to follow it... but it really seems to me like you are also offended by the fact that a tool gives  a suggestion.  I too are offended sometimes at suggestion - especially if it is better than what I have done.  PS:  You know you could switch it off... very funny - by the same hotkey that got it there    Alt-Enter! BTW:  Talking about consistency...  when I go through the provided Lazarus code - one thing that I really find annoying is that the case of things gets mixed up a lot.  I am talking about simple things like somebody spelling begin as begin and finally as Finally - and consistently.  Instead of fighting about coding standards in corporate world why not let the tool do it for you - so if it tells you your code is bad/inconsitent - maybe be less offended than when a peer tells you so...  so in all honesty - I agree to disagree.  Back to my point:  what IntelliJ does well is (among 1000s other things): Type finding, navigation and keybaord centric code assistence.  And not cut over 50 menu options...  IntelliJ (JetBrains) does this for a environments (Java/.Net) which are syntactically much simpler than Pascal - so my point remains (Pascal needs it more than these) - if somebody is hearing me - that would make Lazarus much sweeter. In all honesty - I have left the academics of coding behind...  it is about how good and quick you can do it in my environment... so if the tool isn't making me more efficient it is going to be left behind. ---------------------------------------------------------------------- marcov · 2016-03-12 21:53 Quote from: Gawie on March 12, 2016, 05:05:02 pmOh goodness me... here we go.  @SymbolicFrank So you are telling me that when a tool gives you a suggestion that you not only have to follow it... No. Just that when the suggestion is not correct enough most of the time, it is not worth having at all. This is the big problem with comparative suggestions with IDEs for other languages. Exactly the same functionality might have a different hit rate because of language circumstances (like having separate namespaces for types and other identifiers). Even if you are right, it is kicking in an open door. The crux of the matter is actually coming up with the code that has a sufficient enough hitrate not to be annoying. (and even then I prefer an escape option, Too many of those Java IDEs suck if your application doesn't match their ideal application profile, is bogged down with legacy etc ) QuoteBTW:  Talking about consistency...  when I go through the provided Lazarus code - one thing that I really find annoying is that the case of things gets mixed up a lot.  I am talking about simple things like somebody spelling begin as begin and finally as Finally - and consistently.  That is normal for people coming from languages where case matters. You have been trained to pay attention to it, even if in the normal written word capitalization is only meant as a readability aid, rather than an absolute namesake. It takes time to detox. QuoteInstead of fighting about coding standards in corporate world why not let the tool do it for you - so if it tells you your code is bad/inconsitent - maybe be less offended than when a peer tells you so...  so in all honesty - I agree to disagree.  Assuming you are in a big corporation that subscribes to some arbitrary "golden" standard to begin with. And even then there is a big difference in going with the flow, and being a style fanatic. QuoteBack to my point:  what IntelliJ does well is (among 1000s other things): Type finding, navigation and keybaord centric code assistence.  And not cut over 50 menu options...  IntelliJ (JetBrains) does this for a environments (Java/.Net) which are syntactically much simpler than Pascal - so my point remains (Pascal needs it more than these) - if somebody is hearing me - that would make Lazarus much sweeter. If  I just digest what you are literally saying is that if you reduce menu options to 50, all problems will magically go away.  I find that hard to believe, but I never was good with blind faith and religions to begin with  Still, despite by making fun of things, simplicity of interface might hold some attractions. But the real skill will be in the practical implementation, not regurgitation of the dry principles. QuoteIn all honesty - I have left the academics of coding behind...  it is about how good and quick you can do it in my environment... so if the tool isn't making me more efficient it is going to be left behind. That's not my experience. While such things might be true for the tool in management monthlies, they are notoriously fickle, and will pick the next shiny toy that comes a long. In the end, whatever gets the job done. ---------------------------------------------------------------------- SymbolicFrank · 2016-03-13 02:25 I agree, Marco. To add (for Gawie): I don't capitalize "string", while I do for all the other types, simply because it is bolded by the IDE, for being a reserved word. And I don't capitalize any of the other bolded ones. That's consistency, introduced by the programming environment. But I'm a programmer. Or, actually a Software Engineer. Engineer, as in: someone who builds and creates the things asked. Most of the time, that requires me to be the Man with the Plan, and do the actual (technical) project management, as well as (some of) the programming. Not that there isn't a "real" project manager, but more that he doesn't have a clue about the technical aspects. And, yes, I'm also somewhat autistic. That goes with it. And that does mean, that I want everything ordered and logical. Part of the job. But the thing that is hardest to grasp, is delegating. Most people simply think that it is: "Do as I tell you, or you're fired!" But that's just being authoritarian. Delegating is the art of having other people make good decisions, and being motivated. And the "good" in "making good decisions" is not solely your opinion. It is theirs. So, if it is an important decision, make sure to coach them on forehand. But if they make that decision, you have to stick with it and support them. That is what motivates them. And, especially for creative processes, like creating a new (software) product, that is essential. If you think it was a bad decision, tell them about the problems you expect, and discuss how they can be circumvented. Corporate code guidelines are like: "Do as I tell you, or you're fired!". ---------------------------------------------------------------------- Gawie · 2016-03-13 08:34 You win.  I give up.  I am making a simply suggestion and it is obvious that any other suggestion than what was done offends you. So - sorry for offending you.  It is obvious that you have it all under control and is driving Lazarus back towards mainstream development with a bang. Again apologies.  Cheers ---------------------------------------------------------------------- Thaddy · 2016-03-13 10:11 Well, don't give up. When the DWIM ide supports the DWIM language or the other way around, everything will be OK. A computer has defeated the GO world champion. DWIM is Turing complete. We will get DWIM eventually. Within the next 10 years. https://en.wikipedia.org/wiki/DWIM