deprication is not reported
Try to get as much as possble from the real method in the wrapper
diff --git a/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/RMethodFunctionWrapper.java b/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/RMethodFunctionWrapper.java
index c83c782..ac70672 100644
--- a/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/RMethodFunctionWrapper.java
+++ b/plugins/org.eclipse.dltk.javascript.core/src/org/eclipse/dltk/internal/javascript/validation/RMethodFunctionWrapper.java
@@ -18,6 +18,7 @@
import org.eclipse.dltk.compiler.problem.IProblemIdentifier;
import org.eclipse.dltk.internal.javascript.ti.IReferenceAttributes;
import org.eclipse.dltk.javascript.typeinference.IValueReference;
+import org.eclipse.dltk.javascript.typeinfo.IModelBuilder.IMember;
import org.eclipse.dltk.javascript.typeinfo.IModelBuilder.IMethod;
import org.eclipse.dltk.javascript.typeinfo.IRFunctionType;
import org.eclipse.dltk.javascript.typeinfo.IRMember;
@@ -32,7 +33,7 @@
public class RMethodFunctionWrapper implements IRMethod {
private final IRFunctionType functionType;
- private final Visibility visibility;
+ private final Object source;
public RMethodFunctionWrapper(IRFunctionType functionType,
IValueReference reference) {
@@ -40,26 +41,32 @@
IMethod method = (IMethod) reference.getAttribute(
IReferenceAttributes.METHOD, true);
if (method != null)
- visibility = method.getVisibility();
- else {
- IRMember member = (IRMember) reference.getAttribute(
- IReferenceAttributes.ELEMENT, true);
- if (member != null)
- visibility = member.getVisibility();
- else
- visibility = Visibility.PUBLIC;
- }
+ source = method;
+ else
+ source = reference.getAttribute(IReferenceAttributes.ELEMENT, true);
}
public boolean isDeprecated() {
+ if (source instanceof IRMember)
+ return ((IRMember) source).isDeprecated();
+ if (source instanceof IMember)
+ return ((IMember) source).isDeprecated();
return false;
}
public Visibility getVisibility() {
- return visibility;
+ if (source instanceof IRMember)
+ return ((IRMember) source).getVisibility();
+ if (source instanceof IMember)
+ return ((IMember) source).getVisibility();
+ return Visibility.PUBLIC;
}
public String getName() {
+ if (source instanceof IRMember)
+ return ((IRMember) source).getName();
+ if (source instanceof IMember)
+ return ((IMember) source).getName();
return null;
}
@@ -68,10 +75,16 @@
}
public Set<IProblemCategory> getSuppressedWarnings() {
+ if (source instanceof IRMember)
+ return ((IRMember) source).getSuppressedWarnings();
+ if (source instanceof IMember)
+ return ((IMember) source).getSuppressedWarnings();
return null;
}
public boolean isSuppressed(IProblemIdentifier problemIdentifier) {
+ if (source instanceof IRMember)
+ return ((IRMember) source).isSuppressed(problemIdentifier);
return false;
}
@@ -101,22 +114,32 @@
}
public IRTypeDeclaration getDeclaringType() {
+ if (source instanceof IRMember)
+ return ((IRMember) source).getDeclaringType();
return null;
}
public boolean isStatic() {
+ if (source instanceof IRMember)
+ return ((IRMember) source).isStatic();
return false;
}
public boolean isAbstract() {
+ if (source instanceof IRMethod)
+ return ((IRMethod) source).isAbstract();
return false;
}
public boolean isVisible() {
+ if (source instanceof IRMember)
+ return ((IRMember) source).isVisible();
return true;
}
public boolean isGeneric() {
+ if (source instanceof IRMethod)
+ return ((IRMethod) source).isGeneric();
return false;
}
diff --git a/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/validation/TypeInfoValidationTests.java b/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/validation/TypeInfoValidationTests.java
index cbc9e85..ae841e5 100644
--- a/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/validation/TypeInfoValidationTests.java
+++ b/tests/org.eclipse.dltk.javascript.core.tests/src/org/eclipse/dltk/javascript/core/tests/validation/TypeInfoValidationTests.java
@@ -3823,4 +3823,38 @@
final List<IProblem> problems = validate(code.toString());
assertEquals(problems.toString(), 0, problems.size());
}
+
+
+ public void testDeprecatedProrotypeFunctions() {
+ final StringList code = new StringList();
+ code.add("function Sub(name, age) {");
+ code.add(" this.age = age");
+ code.add("}");
+ code.add("Sub.prototype = {");
+ code.add(" /**");
+ code.add(" * @deprecated");
+ code.add(" */");
+ code.add(" baseMethod: function() {");
+ code.add(" return 'baseMethod called'");
+ code.add(" }");
+ code.add(" }");
+ code.add(" /**");
+ code.add(" * @deprecated");
+ code.add(" */");
+ code.add("Sub.prototype.subMethod2 = function(a,b,c) {");
+ code.add(" return 'subMethod2 called'");
+ code.add("}");
+ code.add("function test2() {");
+ code.add(" var y = new Sub('test2',2);");
+ code.add(" y.subMethod2(1,2,3);");
+ code.add(" y.baseMethod();");
+ code.add("}");
+ final List<IProblem> problems = validate(code.toString());
+ assertEquals(problems.toString(), 3, problems.size());
+ assertEquals(JavaScriptProblems.DEPRECATED_FUNCTION, problems.get(0)
+ .getID());
+ assertEquals(JavaScriptProblems.DEPRECATED_FUNCTION, problems.get(1)
+ .getID());
+ assertEquals(JavaScriptProblems.DEPRECATED_FUNCTION, problems.get(2)
+ .getID()); }
}