arunnair85 / jsdt-jquery

Automatically exported from code.google.com/p/jsdt-jquery
0 stars 0 forks source link

NPE in JQueryXhrInferer.inferXhrFunctionCall() during type inferencing #16

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Clone the angular-phonecat project from GitHub and switch it to the tag 
'step-12':
> git clone https://github.com/angular/angular-phonecat.git
> cd angular-phonecat
> git checkout step-12
2. Import the project and configure it as JavaScript project
3. Add jQuery Library (by jsdt-jquery)
4. After the following issues are fixed: 
- https://code.google.com/a/eclipselabs.org/p/jsdt-jquery/issues/detail?id=14
- https://code.google.com/a/eclipselabs.org/p/jsdt-jquery/issues/detail?id=15
the following NPE happens while inferring types for 
angular-phonecat/app/lib/jquery/jquery-1.10.2.js javascript:

!ENTRY org.eclipse.wst.jsdt.core 4 4 2015-03-20 17:30:44.906
!MESSAGE error during type inferencing
!STACK 0
java.lang.NullPointerException
    at org.eclipselabs.jsdt.jquery.api.infer.JQueryXhrInferer.inferXhrFunctionCall(JQueryXhrInferer.java:57)
    at org.eclipselabs.jsdt.jquery.api.infer.JQueryXhrInferer.visit(JQueryXhrInferer.java:46)
    at org.eclipse.wst.jsdt.internal.compiler.DelegateASTVisitor.visit(DelegateASTVisitor.java:719)
    at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:318)
    at org.eclipse.wst.jsdt.internal.compiler.ast.Block.traverse(Block.java:116)
    at org.eclipse.wst.jsdt.internal.compiler.ast.IfStatement.traverse(IfStatement.java:203)
    at org.eclipse.wst.jsdt.internal.compiler.ast.MethodDeclaration.traverse(MethodDeclaration.java:164)
    at org.eclipse.wst.jsdt.internal.compiler.ast.FunctionExpression.traverse(FunctionExpression.java:48)
    at org.eclipse.wst.jsdt.internal.compiler.ast.MessageSend.traverse(MessageSend.java:320)
    at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:627)
    at org.eclipse.wst.jsdt.internal.compiler.ast.CompilationUnitDeclaration.traverse(CompilationUnitDeclaration.java:607)
    at org.eclipselabs.jsdt.jquery.api.infer.JQueryInferEngine.doInfer(JQueryInferEngine.java:46)
    at org.eclipse.wst.jsdt.internal.compiler.parser.Parser.inferTypes(Parser.java:7108)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:144)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:218)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:184)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFunctions(SourceTypeBinding.java:596)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:259)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope.connectMixins(ClassScope.java:508)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.ClassScope.connectTypeHierarchy(ClassScope.java:541)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.connectTypeHierarchy(CompilationUnitScope.java:859)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:512)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFields(SourceTypeBinding.java:365)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:260)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.askForBinding(LookupEnvironment.java:287)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.PackageBinding.getTypeOrPackage(PackageBinding.java:249)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getTypeOrPackage(Scope.java:2156)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.Scope.getType(Scope.java:1927)
    at org.eclipse.wst.jsdt.core.infer.InferredType.resolveType(InferredType.java:492)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:218)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.MethodScope.createMethod(MethodScope.java:184)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFunctions(SourceTypeBinding.java:596)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:259)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.SourceTypeBinding.buildFieldsAndMethods(SourceTypeBinding.java:195)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildFieldsAndMethods(CompilationUnitScope.java:246)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.completeTypeBindings(LookupEnvironment.java:516)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.accept(HierarchyResolver.java:152)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.addUnitsContainingBindings(LookupEnvironment.java:184)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.CompilationUnitScope.buildTypeBindings(CompilationUnitScope.java:417)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:343)
    at org.eclipse.wst.jsdt.internal.compiler.lookup.LookupEnvironment.buildTypeBindings(LookupEnvironment.java:323)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:687)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyResolver.resolve(HierarchyResolver.java:575)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.HierarchyBuilder.buildSupertypes(HierarchyBuilder.java:126)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.IndexBasedHierarchyBuilder.build(IndexBasedHierarchyBuilder.java:182)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.TypeHierarchy.compute(TypeHierarchy.java:306)
    at org.eclipse.wst.jsdt.internal.core.hierarchy.TypeHierarchy.refresh(TypeHierarchy.java:1026)
    at org.eclipse.wst.jsdt.internal.core.CreateTypeHierarchyOperation.executeOperation(CreateTypeHierarchyOperation.java:90)
    at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:742)
    at org.eclipse.wst.jsdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802)
    at org.eclipse.wst.jsdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:624)
    at org.eclipse.wst.jsdt.internal.core.SourceType.newSupertypeHierarchy(SourceType.java:599)
    at org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:119)
    at org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache.getTypeHierarchy(SuperTypeHierarchyCache.java:79)
    at org.eclipse.wst.jsdt.internal.corext.util.SuperTypeHierarchyCache.getMethodOverrideTester(SuperTypeHierarchyCache.java:88)
    at org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator.getOverrideIndicators(OverrideIndicatorLabelDecorator.java:158)
    at org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator.computeAdornmentFlags(OverrideIndicatorLabelDecorator.java:126)
    at org.eclipse.wst.jsdt.ui.OverrideIndicatorLabelDecorator.decorate(OverrideIndicatorLabelDecorator.java:221)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorDefinition.decorate(LightweightDecoratorDefinition.java:273)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorManager$LightweightRunnable.run(LightweightDecoratorManager.java:83)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.decorate(LightweightDecoratorManager.java:367)
    at org.eclipse.ui.internal.decorators.LightweightDecoratorManager.getDecorations(LightweightDecoratorManager.java:349)
    at org.eclipse.ui.internal.decorators.DecorationScheduler$1.ensureResultCached(DecorationScheduler.java:372)
    at org.eclipse.ui.internal.decorators.DecorationScheduler$1.run(DecorationScheduler.java:332)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

What is the expected output? What do you see instead?

- no exceptions in Error Log

What version of the product are you using? On what operating system?

Eclipse Mars + WTP 3.7

Please provide any additional information below.

- It looks like locator can be null here, but, again, there is no a check for 
null value

Original issue reported on code.google.com by victor.r...@gmail.com on 20 Mar 2015 at 2:52

GoogleCodeExporter commented 9 years ago
The fix could be in adding an additional null-check for locator value.

See jsdt-jquery-issue16.diff patch attached

Original comment by victor.r...@gmail.com on 20 Mar 2015 at 2:57

Attachments:

GoogleCodeExporter commented 9 years ago
Fixed in 1.8.0

Original comment by philippe...@gmail.com on 10 Apr 2015 at 11:48