Bug 33133 - 'this' allowed in scrapbook page
Summary: 'this' allowed in scrapbook page
Status: RESOLVED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.1   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 3.3 RC4   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-02-25 16:24 EST by Joe Szurszewski CLA
Modified: 2007-06-21 07:20 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joe Szurszewski CLA 2003-02-25 16:24:18 EST
In a scrapbook page, if you type 'this.', you get CodeAssist suggestions showing the 
methods on Object.  This makes it look to the user as if 'this' is valid in a scrapbook page.  
If you then actually code something like 'this.toString()', you get an error message when 
executing to the effect that "'this' cannot be used in a static context".
Comment 1 Andre Weinand CLA 2003-02-25 17:04:50 EST
Is this a MacOS X specific problem?
If not please change Platform to "All"
(I'm tracking all problems where platform == Macintosh)
Comment 2 Joe Szurszewski CLA 2003-02-25 17:10:41 EST
This is a problem on WinXP as well.
Comment 3 Darin Wright CLA 2003-02-26 16:21:06 EST
Hmm. We have to allow "this" for code like:

Runnable r = new Runnable() {
	public void run() {
		System.out.println(this.toString());
	}
};
r.run();
Comment 4 Darin Wright CLA 2003-02-26 16:26:10 EST
The code completions actually come from our IEvaluationContext, which is 
genereated from the associated java project (i.e. 
IJavaProject#newEvaluationContext()). Moving to JDT core for comment.

NOTE: not critical.
Comment 5 Joe Szurszewski CLA 2003-02-26 16:27:46 EST
Is it possible to just disallow 'this' in the top-level context?
Comment 6 Philipe Mulet CLA 2003-02-27 05:25:10 EST
This is exactly what it should be already. Need to investigate, not critical 
though.
Comment 7 Philipe Mulet CLA 2003-02-27 09:38:43 EST
Actually, the code completion API doesn't carry the information about being in 
a static context. It will default to non-static.

Would need to introduce a new API with isStatic flag (like evaluation APIs).

Deferring
Comment 8 Philipe Mulet CLA 2003-03-03 08:04:06 EST
Deferring
Comment 9 Philipe Mulet CLA 2003-04-02 06:41:58 EST
reopen
Comment 10 Philipe Mulet CLA 2004-03-25 06:25:51 EST
Not for 3.0
Comment 11 Philipe Mulet CLA 2004-05-19 10:32:56 EDT
Removing milestone of deferred item.
Comment 12 Frederic Fusier CLA 2007-06-21 07:20:19 EDT
Reopen as LATER is deprecated...
Comment 13 Frederic Fusier CLA 2007-06-21 07:20:42 EDT
Comment 3 code snippet is now accepted, I got following output while executing it:
CodeSnippet_1$1@1a42792