/*
 * Copyright 2000-2009 JetBrains s.r.o.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/*
 * @author max
 */
package com.intellij.psi.impl.source;

import com.intellij.lang.ASTNode;
import com.intellij.lang.PsiBuilder;
import com.intellij.lang.StdLanguages;
import com.intellij.lang.java.JavaParserDefinition;
import com.intellij.lang.java.parser.FileParser;
import com.intellij.lang.java.parser.JavaParserUtil;
import com.intellij.lexer.JavaLexer;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiManager;
import com.intellij.psi.StubBuilder;
import com.intellij.psi.impl.java.stubs.PsiJavaFileStub;
import com.intellij.psi.impl.java.stubs.impl.PsiJavaFileStubImpl;
import com.intellij.psi.impl.source.parsing.FileTextParsing;
import com.intellij.psi.impl.source.tree.FileElement;
import com.intellij.psi.stubs.IndexSink;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.stubs.StubInputStream;
import com.intellij.psi.stubs.StubOutputStream;
import com.intellij.psi.tree.IStubFileElementType;
import com.intellij.psi.util.PsiUtil;
import com.intellij.util.io.StringRef;

import java.io.IOException;

public class JavaFileElementType extends IStubFileElementType<PsiJavaFileStub> {
  public static final int STUB_VERSION = JavaParserDefinition.USE_NEW_PARSER ? 5 : 4;

  public JavaFileElementType() {
    super("java.FILE", StdLanguages.JAVA);
  }

  public StubBuilder getBuilder() {
    return new JavaFileStubBuilder();
  }

  public int getStubVersion() {
    return STUB_VERSION;
  }

  @Override
  public boolean shouldBuildStubFor(final VirtualFile file) {
    final VirtualFile dir = file.getParent();
    return dir == null || dir.getUserData(LanguageLevel.KEY) != null;
  }

  public ASTNode parseContents(final ASTNode chameleon) {
    if (JavaParserDefinition.USE_NEW_PARSER) {
      final PsiBuilder builder = JavaParserUtil.createBuilder(chameleon);

      final PsiBuilder.Marker root = builder.mark();
      FileParser.parse(builder);
      root.done(this);

      return builder.getTreeBuilt().getFirstChildNode();
    }

    FileElement node = (FileElement)chameleon;
    final CharSequence seq = node.getChars();

    final PsiManager manager = node.getManager();
    final JavaLexer lexer = new JavaLexer(PsiUtil.getLanguageLevel(node.getPsi()));
    return FileTextParsing.parseFileText(manager, lexer, seq, 0, seq.length(), node.getCharTable());
  }

  public String getExternalId() {
    return "java.FILE";
  }

  public void serialize(final PsiJavaFileStub stub, final StubOutputStream dataStream)
      throws IOException {
    dataStream.writeBoolean(stub.isCompiled());
    dataStream.writeName(stub.getPackageName());
  }

  public PsiJavaFileStub deserialize(final StubInputStream dataStream, final StubElement parentStub) throws IOException {
    boolean compiled = dataStream.readBoolean();
    StringRef packName = dataStream.readName();
    return new PsiJavaFileStubImpl(packName, compiled);
  }

  public void indexStub(final PsiJavaFileStub stub, final IndexSink sink) {
  }
}

@@ -1935,32 +1935,44 @@
 ges.JAVA);%0A  %7D%0A%0A
+  @Override%0A
   public StubBui
@@ -1987,24 +1987,24 @@
 Builder() %7B%0A
-
     return n
@@ -2026,32 +2026,44 @@
 Builder();%0A  %7D%0A%0A
+  @Override%0A
   public int get
@@ -2299,24 +2299,36 @@
  null;%0A  %7D%0A%0A
+  @Override%0A
   public AST
@@ -2995,32 +2995,44 @@
 rTable());%0A  %7D%0A%0A
+  @Override%0A
   public String 
@@ -3074,24 +3074,36 @@
 FILE%22;%0A  %7D%0A%0A
+  @Override%0A
   public voi
@@ -3298,32 +3298,44 @@
 geName());%0A  %7D%0A%0A
+  @Override%0A
   public PsiJava
@@ -3598,16 +3598,28 @@
 );%0A  %7D%0A%0A
+  @Override%0A
   public

Insert @Override