Preheat oven to 350 degrees F (175 degrees C). Grease and flour an 8 inch square pan. In a large bowl, mix apples and sugar together. Let stand until sugar is thoroughly dissolved, about 8 minutes.
Stir egg and vanilla into apple mixture. Sift together flour, baking soda and cinnamon; stir into apple mixture. Fold in nuts and raisins. Pour batter into prepared pan.
Bake in the preheated oven for 40 to 45 minutes, or until a toothpick inserted into the center of the cake comes out clean. Pour topping over cake while cake is still hot.
For the Topping: In a saucepan, combine 1/2 cup brown sugar, 1/2 cup white sugar and 2 tablespoons flour. Stir in the water. Cook over medium heat, stirring, until mixture boils and thickens. Remove from heat and stir in butter, vanilla, chopped walnuts and raisins. Stir until butter melts, then pour over cake.