public char[] getMainTypeName() {

    if (compilationResult.compilationUnit == null) {
      char[] fileName = compilationResult.getFileName();

      int start = CharOperation.lastIndexOf('/', fileName) + 1;
      if (start == 0 || start < CharOperation.lastIndexOf('\\', fileName))
        start = CharOperation.lastIndexOf('\\', fileName) + 1;

      int end = CharOperation.lastIndexOf('.', fileName);
      if (end == -1) end = fileName.length;

      return CharOperation.subarray(fileName, start, end);
    } else {
      return compilationResult.compilationUnit.getMainTypeName();
    }
  }