Results 1 to 12 of 12
  1. #1
    Stud1 is offline Member
    Join Date
    Jan 2014
    Posts
    44
    Rep Power
    0

    Default See all variables and arrays?

    Is there any way to set in Eclipse so it automatically shows a list of variables / arrays that have been declared in the code? Preferably so that it updates simultaneously when writing it.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: See all variables and arrays?

    In what code? The code in a particular method? A particular class? A particular package? A particular project? Your entire workspace? Your entire file system? Something else?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: See all variables and arrays?

    Not that I know of, the best I know is the "outline" view which shows you the properties and methods of the class you're working in.

    If I remember correctly Netbeans has such a feature though where it shows the code in a tree structure (which I remember labeling as "totally useless and unreadable" to never look at it again). There might be a third party plugin for Eclipse you can install that mimics that behavior.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: See all variables and arrays?

    I'm still not sure what the actual question is, but the Outline view (as well as the Package Explorer) does indeed list all of the variables and methods in a class.

    If you want to change the name of a variable or method everywhere, you can simply right click said variable or method, go to refactor, then click rename.

    I'm still just guessing at the actual question though.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Stud1 is offline Member
    Join Date
    Jan 2014
    Posts
    44
    Rep Power
    0

    Default Re: See all variables and arrays?

    Quote Originally Posted by KevinWorkman View Post
    In what code? The code in a particular method? A particular class? A particular package? A particular project? Your entire workspace? Your entire file system? Something else?
    To be able to see the declared variabels/arrays in one class at a time would be good.

    The "outline" doesn't show this unfortunately. At least not in the default settings. It only shows methods and attributes. Maybe I should specify, I want to be able to see what values variables have been given in the code. How can I do that?
    Last edited by Stud1; 01-15-2014 at 05:46 PM.

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: See all variables and arrays?

    For me it shows class properties too, without changing a thing. Which perspective do you use?

    But you are still not specific on what a "variable" is to you and which you specifically want to see.

    Java Code:
    public class Person {
      private String name;  // This one? Its in the outline
    
      public void doSomething(){
        int somenumber = 5; // This one too? Its not in the outline, a class will potentially have hundreds of variables (potentially with the same name) spread across many methods
      }
    }
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: See all variables and arrays?

    Are you saying you want to see the variables declared inside a method as well?

    Why?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  8. #8
    Stud1 is offline Member
    Join Date
    Jan 2014
    Posts
    44
    Rep Power
    0

    Default Re: See all variables and arrays?

    Quote Originally Posted by gimbal2 View Post
    For me it shows class properties too, without changing a thing. Which perspective do you use?

    But you are still not specific on what a "variable" is to you and which you specifically want to see.

    Java Code:
    public class Person {
      private String name;  // This one? Its in the outline
    
      public void doSomething(){
        int somenumber = 5; // This one too? Its not in the outline, a class will potentially have hundreds of variables (potentially with the same name) spread across many methods
      }
    }
    Yes, I also want to see the second kind. Like a list of declared variables and what values they have been given. (Similar to what happens in Debug mode, but in real time, simultaneously as I'm writing the code). How can I do that?


    Quote Originally Posted by KevinWorkman View Post
    Are you saying you want to see the variables declared inside a method as well?

    Why?
    Because it would be easier and more overviewable for me than to go through the code "by hand".

  9. #9
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: See all variables and arrays?

    Quote Originally Posted by Stud1 View Post
    How can I do that?
    I already answered to that. I don't know of any built in way to do it.

    Because it would be easier and more overviewable for me than to go through the code "by hand".
    ... nor can I imagine how it would ever be something that will be easy to read, nor what kind of information you can scrape from it. "This class has a variable in some method somewhere named 'monkey'". Okay, good to know!
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  10. #10
    Stud1 is offline Member
    Join Date
    Jan 2014
    Posts
    44
    Rep Power
    0

    Default Re: See all variables and arrays?

    Quote Originally Posted by gimbal2 View Post
    ... nor can I imagine how it would ever be something that will be easy to read, nor what kind of information you can scrape from it. "This class has a variable in some method somewhere named 'monkey'". Okay, good to know!
    I guess you've never used the debugger in Eclipse. Because then you would have know that the debugger does this (among other things) although not in real time. I'm looking for some way to do it in real time.

  11. #11
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    4,034
    Rep Power
    6

    Default Re: See all variables and arrays?

    Using the debugger in Eclipse and seeing the variables change is different that just running the program and seeing the variables change (assuming that's what you want to do). First, they would change so fast you couldn't glean anything meaningful. On the other hand, Eclipse will flag re-defining a variable or hiding a variable. I have used the debugger and I do not understand what benefit you would get from this capability.

    Regards,
    Jim
    The JavaTM Tutorials | SSCCE | Java Naming Conventions
    Poor planning on your part does not constitute an emergency on my part

  12. #12
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,365
    Rep Power
    6

    Default Re: See all variables and arrays?

    Quote Originally Posted by Stud1 View Post
    I guess you've never used the debugger in Eclipse. Because then you would have know that the debugger does this (among other things) although not in real time. I'm looking for some way to do it in real time.
    I use it every day, you are making absolutely no sense at all.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Creating variables/arrays while the program runs
    By AGuyWhoSkis in forum New To Java
    Replies: 3
    Last Post: 05-31-2013, 05:40 AM
  2. Replies: 4
    Last Post: 08-12-2011, 06:47 PM
  3. Using Arrays as Variables.
    By wired-in=p in forum New To Java
    Replies: 4
    Last Post: 07-24-2011, 04:32 PM
  4. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 02:40 AM
  5. What are Instance variables and static variables?
    By sandeshforu in forum New To Java
    Replies: 3
    Last Post: 09-09-2009, 06:48 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •