fix for functions assigned to property expressions that the name is the
identifier of the property (this will also fix the tooltip in the code
completion that depends on the right location)
diff --git a/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/ti/JSMethod.java b/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/ti/JSMethod.java
index 418b735..bc51e00 100644
--- a/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/ti/JSMethod.java
+++ b/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/ti/JSMethod.java
@@ -181,7 +181,17 @@
 	 */
 	public JSMethod(FunctionStatement node, ReferenceSource source) {
 		super(node.getArguments().size());
-		initialize(node, source, node.getName());
+		Identifier nameNode = node.getName();
+		if (nameNode == null && node.getParent() instanceof BinaryOperation) {
+			Expression left = ((BinaryOperation) node.getParent())
+					.getLeftExpression();
+			if (left instanceof PropertyExpression) {
+				Expression property = ((PropertyExpression) left).getProperty();
+				if (property instanceof Identifier)
+					nameNode = (Identifier) property;
+			}
+		}
+		initialize(node, source, nameNode);
 	}
 
 	public JSMethod(FunctionStatement node, ReferenceSource source,
diff --git a/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/typeinference/TypeInferenceTests.java b/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/typeinference/TypeInferenceTests.java
index f81295e..7bc391a 100644
--- a/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/typeinference/TypeInferenceTests.java
+++ b/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/typeinference/TypeInferenceTests.java
@@ -32,6 +32,7 @@
 import org.eclipse.dltk.javascript.parser.JavaScriptParser;
 import org.eclipse.dltk.javascript.typeinference.IValueCollection;
 import org.eclipse.dltk.javascript.typeinference.IValueReference;
+import org.eclipse.dltk.javascript.typeinference.ReferenceLocation;
 import org.eclipse.dltk.javascript.typeinference.ValueReferenceUtil;
 import org.eclipse.dltk.javascript.typeinfo.IRClassType;
 import org.eclipse.dltk.javascript.typeinfo.IRFunctionType;
@@ -1352,5 +1353,19 @@
 		Set<String> directChildren = test.getDirectChildren();
 		assertFalse(directChildren.contains("test"));
 	}
+	
+	public void testReferenceToPropertyAssignedFunction() {
+		final StringList code = new StringList();
+		code.add("var p ={};");
+		code.add("p.object.myfunc = function(){};");
+		code.add("p.object.myfunc();");
+		final IValueCollection collection = inference(code.toString());
+		IValueReference func = collection.getChild("p").getChild("object").getChild("myfunc");
+		assertTrue(func.exists());
+		
+		ReferenceLocation location = func.getLocation();
+		assertEquals(20, location.getNameStart());
+		assertEquals(26, location.getNameEnd());
+	}
 
 }