Bug 392981 - Code assist fails in this particular situation
Summary: Code assist fails in this particular situation
Status: NEW
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.2.1   Edit
Hardware: PC Windows 7
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jay Arthanareeswaran CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-27 13:29 EDT by Mauro Molinari CLA
Modified: 2022-11-07 03:47 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2012-10-27 13:29:24 EDT
Consider the following code:

###
package com.utopicmusic.app.web.seo;

import java.sql.SQLException;
import java.util.Map;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.HibernateTemplate;

public enum SitemapTypeJ
{
	INDEX()
	{
		@Override
		public String getTemplatePath()
		{
			return getClass().getPackage().getName().replace('.', '/') + "/sitemap-index.ftl";
		}

		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			throw new UnsupportedOperationException("count not implemented for this sitemap type");
		}
	},
	ARTISTS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			return hibernateTemplate.execute(new HibernateCallback<Integer>()
				{
					@Override
					public Integer doInHibernate(Session session)
					  throws HibernateException, SQLException
					{
						return (Integer) session
						  .createQuery(
						    "select count(artist) from Artist as artist join artist.owner as user where user.active and artist.active")
						  .uniqueResult();
					}
				}).int|
		}
	},
	CLUBS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	},
	LISTENERS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	},
	POSTS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	},
	SONGS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	},
	ALBUMS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	},
	PLAYLISTS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	},
	LOCATIONS()
	{
		@Override
		public Map<String, Object> buildModel(int offset, HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return null;
		}

		@Override
		public int countEntries(HibernateTemplate hibernateTemplate)
		{
			// TODO Stub di metodo generato automaticamente
			return 0;
		}
	};

	/**
	 * Returns the path within the classpath of the template that can be used to generate a sitemap of
	 * this type.
	 * 
	 * @return the full path within the classpath to retrieve the template
	 */
	public String getTemplatePath()
	{
		return getClass().getPackage().getName().replace('.', '/') + "/sitemap.ftl";
	}

	/**
	 * Builds the model and view for a sitemap of this type.
	 * <p>
	 * Actually, only a part of sitemap is built, containing up to 30,000 links at most.
	 * 
	 * @param offset
	 *          the offset for the contents to include in the requested sitemap
	 * @return the model and reference to the view name needed to generate this type of sitemap
	 */
	public abstract Map<String, Object> buildModel(final int offset,
			final HibernateTemplate hibernateTemplate);

	public abstract int countEntries(final HibernateTemplate hibernateTemplate);
}
###

To make it compile, put the following JARs on your buildpath:
http://search.maven.org/remotecontent?filepath=org/hibernate/hibernate-core/3.6.10.Final/hibernate-core-3.6.10.Final.jar
http://search.maven.org/remotecontent?filepath=org/springframework/spring-core/3.1.1.RELEASE/spring-core-3.1.1.RELEASE.jar
http://search.maven.org/remotecontent?filepath=org/springframework/spring-orm/3.1.1.RELEASE/spring-orm-3.1.1.RELEASE.jar
http://search.maven.org/remotecontent?filepath=org/springframework/spring-tx/3.1.1.RELEASE/spring-tx-3.1.1.RELEASE.jar

Then, put your cursor at "|" and invoke code assist with Ctrl+Space, to search for "intValue()": the proposal is not given, you have to type "intValue()" by hand.

Sorry, I was not able to provide a simpler reproducible test case.
Comment 1 Jay Arthanareeswaran CLA 2012-10-29 06:51:27 EDT
This is a simpler case:

	public enum X {
		A() {
			public int count(Foo foo) {
				foo.returnInteger(new Foo() {
					
				}).intV|;
				return 0;
			} 
		};
	}
	
	class Foo {
		Integer returnInteger(Foo myClass) {
			return new Integer(0);
		}
	}
Comment 2 Jay Arthanareeswaran CLA 2012-10-29 10:33:03 EDT
Srikanth, please follow up.

The following code produces right proposals. The difference between this and the one from comment #1 is that in the former case the allocation expression gets all the statements, thus producing the right context and receiver. In the buggy one the statements are missing.

	class Foo {
		Integer returnInteger(Foo myClass) {
			return new Integer(0);
		}
	}

	class TestMain {
		public int foo() {
			Foo myClass = new Foo();
			int i = myClass.returnInteger(new Foo() {
			}).intV;
			return i;
		}
	}
Comment 3 Ed Willink CLA 2013-05-31 17:55:22 EDT
Apologies editing wrong bug
Comment 4 Srikanth Sankaran CLA 2014-11-03 21:40:30 EST
I won't be able to finish this one.
Comment 5 Jay Arthanareeswaran CLA 2014-11-07 02:14:52 EST
Will keep in my list, but no promise yet.
Comment 6 Mauro Molinari CLA 2014-11-07 03:06:22 EST
Thank you Jayaprakash!
Comment 7 Jay Arthanareeswaran CLA 2015-05-12 02:57:43 EDT
Sorry, this needs to be moved out of 4.5.
Comment 8 Jay Arthanareeswaran CLA 2016-05-11 02:28:49 EDT
Sorry, no hope for 4.6. Bulk moving to 4.7.
Comment 9 Manoj N Palat CLA 2018-05-21 06:07:14 EDT
Bulk move out of 4.8
Comment 10 Eclipse Genie CLA 2020-06-23 19:27:38 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 11 Mauro Molinari CLA 2020-06-24 05:14:26 EDT
I can still reproduce the problem with the simple test case in comment #1 in 2019-12.
Comment 12 Eclipse Genie CLA 2022-11-06 12:30:20 EST
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 13 Mauro Molinari CLA 2022-11-07 03:47:46 EST
I can still reproduce the problem with the simple test case in comment #1 in 2022-06.