private void createVariable(VariableDeclaration declaration) { final JSVariable variable = new JSVariable(declaration.getVariableName()); variable.setLocation( declaration.getInitializer() != null ? ReferenceLocation.create( referenceSource, declaration.start(), declaration.end(), declaration.getIdentifier()) : ReferenceLocation.create(referenceSource, declaration.start(), declaration.end())); jsdocSupport.processVariable(declaration, variable, fReporter, fTypeChecker); final VariableNode variableNode = new VariableNode(peek(), declaration, variable); peek().addChild(variableNode); if (scopes.size() == 1) { // TODO (alex) option to treat it as field or local addFieldDeclaration(declaration.getIdentifier(), variable.getType()); } else { nodes.add( new LocalVariableDeclarationNode( declaration.getIdentifier(), referenceSource.getSourceModule(), variable.getType())); } }
public void addFieldDeclaration(Expression identifier, JSType type) { nodes.add(new FieldDeclarationNode(identifier, referenceSource.getSourceModule(), type)); }