Version 1.11.0-dev.1.0
svn merge -r 45518:45726 https://dart.googlecode.com/svn/branches/bleeding_edge trunk
git-svn-id: https://dart.googlecode.com/svn/trunk@45728 260f80e4-7a28-3924-810f-c04153c831b5
diff --git a/dart/client/tools/buildbot_annotated_steps.py b/dart/client/tools/buildbot_annotated_steps.py
index 32f8579..658e25c 100755
--- a/dart/client/tools/buildbot_annotated_steps.py
+++ b/dart/client/tools/buildbot_annotated_steps.py
@@ -185,20 +185,17 @@
# The buildbot will set a BUILDBOT_JAVA_HOME relative to the dart
# root directory, set JAVA_HOME based on that.
FixJavaHome()
- if name.startswith('dart-editor'):
- # Run the old annotated steps script
- status = ProcessTools('release', name, version)
- elif name.startswith('pub-'):
+ if name.startswith('pub-'):
status = ProcessBot(name, 'pub')
elif name.startswith('vm-android'):
status = ProcessBot(name, 'android')
+ elif name.startswith('dart-sdk'):
+ status = ProcessBot(name, 'dart_sdk')
elif name.startswith('cross') or name.startswith('target'):
status = ProcessBot(name, 'cross-vm',
custom_env=EnvironmentWithoutBotoConfig())
elif name.startswith('linux-distribution-support'):
status = ProcessBot(name, 'linux_distribution_support')
- elif name.startswith('ft'):
- status = ProcessBot(name, 'functional_testing')
elif name.startswith('version-checker'):
status = ProcessBot(name, 'version_checker')
elif name.startswith('dart2js-dump-info'):
diff --git a/dart/dart.gyp b/dart/dart.gyp
index 93d2214..fb973e1 100644
--- a/dart/dart.gyp
+++ b/dart/dart.gyp
@@ -9,11 +9,9 @@
'type': 'none',
'dependencies': [
'analysis_server',
- 'analyzer_java',
'create_sdk',
'dart2js',
'dartanalyzer',
- 'editor',
'packages',
'runtime',
'samples',
@@ -57,13 +55,6 @@
],
},
{
- 'target_name': 'analyzer_java',
- 'type': 'none',
- 'dependencies': [
- 'editor/analyzer_java.gyp:analyzer',
- ],
- },
- {
'target_name': 'dartfmt',
'type': 'none',
'dependencies': [
@@ -78,28 +69,6 @@
],
},
{
- # This is the target that is built on the dart2dart bots.
- # It must depend on anything that is required by dart2dart
- # tests.
- 'target_name': 'dart2dart_bot',
- 'type': 'none',
- 'dependencies': [
- 'create_sdk',
- 'packages',
- ],
- },
- {
- # This is the target that is built on the dartc bots.
- # It must depend on anything that is required by dartc
- # tests.
- 'target_name': 'dartc_bot',
- 'type': 'none',
- 'dependencies': [
- 'create_sdk',
- 'packages',
- ],
- },
- {
# This is the target that is built on the dart2js build bots.
# It must depend on anything that is required by the dart2js
# test suites.
@@ -132,45 +101,6 @@
],
},
{
- 'target_name': 'editor',
- 'type': 'none',
- 'dependencies': [
- 'editor/build/generated/editor_deps.gyp:editor_deps',
-
- # This dependency on create_sdk does not mean that the
- # Editor is rebuilt if the SDK is. It only means that when you build
- # the Editor, you should also build the SDK. If we wanted to
- # make sure that the editor is rebuilt when the SDK is, we
- # should list a *file* in PRODUCT_DIR which the action below
- # uses as input.
- # This is the desired behavior as we would otherwise have to
- # rebuild the editor each time the VM, dart2js, or library
- # code changes.
- 'create_sdk',
- ],
- 'actions': [
- {
- 'action_name': 'create_editor_py',
- 'inputs': [
- 'tools/create_editor.py',
- '<(SHARED_INTERMEDIATE_DIR)/editor_deps/editor.stamp',
- '<!@(["python", "tools/list_files.py", "", "editor/tools/features/'
- 'com.google.dart.tools.deploy.feature_releng"])',
- ],
- 'outputs': [
- '<(PRODUCT_DIR)/editor/VERSION',
- ],
- 'action': [
- 'python',
- 'tools/create_editor.py',
- '--out', '<(PRODUCT_DIR)/editor',
- '--build', '<(INTERMEDIATE_DIR)',
- ],
- 'message': 'Creating editor.',
- },
- ],
- },
- {
'target_name': 'samples',
'type': 'none',
'dependencies': [],
diff --git a/dart/editor/.gitignore b/dart/editor/.gitignore
deleted file mode 100644
index 4c37602..0000000
--- a/dart/editor/.gitignore
+++ /dev/null
@@ -1,9 +0,0 @@
-/*.Makefile
-/*.target.mk
-/plugin_command_analyze_sources.gypi
-/plugin_command_analyze_sources.txt
-/plugin_command_analyze_sources.xml
-/plugin_engine_sources.gypi
-/plugin_engine_sources.txt
-/plugin_engine_sources.xml
-com.instantiations.coverage.ui_Audit.prefs
diff --git a/dart/editor/analyzer_java.gyp b/dart/editor/analyzer_java.gyp
deleted file mode 100644
index e4e60cc..0000000
--- a/dart/editor/analyzer_java.gyp
+++ /dev/null
@@ -1,65 +0,0 @@
-# Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
-# for details. All rights reserved. Use of this source code is governed by a
-# BSD-style license that can be found in the LICENSE file.
-
-{
- 'includes' : [
- # These files are generated by 'gclient runhooks'.
- 'plugin_command_analyze_sources.gypi',
- 'plugin_engine_sources.gypi',
- ],
- 'variables': {
- 'analyzer_name': 'dartanalyzer',
- # When changing the jar files that we depend on please change the list
- # below.
- 'dependent_jar_files': [
- '../third_party/commons-lang/3.2.1/commons-lang3-3.2.1.jar',
- '../third_party/json/r2_20080312/json.jar',
- '../third_party/guava/r13/guava-13.0.1.jar',
- '../third_party/args4j/2.0.12/args4j-2.0.12.jar'
- ],
- },
- 'targets': [
- {
- 'target_name': 'analyzer',
- 'type': 'none',
- 'variables': {
- # The file where we write the class path to be used in the manifest.
- 'class_path_file': '<(PRODUCT_DIR)/<(analyzer_name)/classpath_file',
- },
- 'actions': [
- {
- 'action_name': 'create_analyzer',
- 'inputs': [
- '<@(plugin_command_analyze_java_sources)',
- '<@(plugin_engine_java_sources)',
- '<@(dependent_jar_files)',
- 'tools/compile_analyzer_java.py',
- 'plugin_command_analyze_sources.gypi',
- 'plugin_engine_sources.gypi',
- '../tools/VERSION',
- ],
- 'outputs': [
- '<(PRODUCT_DIR)/<(analyzer_name)/<(analyzer_name).jar',
- ],
- 'action': [
- 'python',
- 'tools/compile_analyzer_java.py',
- '--output_dir', '<(PRODUCT_DIR)/<(analyzer_name)/',
- '--jar_file_name', '<(analyzer_name).jar',
- '--jar_entry_directory', 'com',
- '--dependent_jar_files', '"<@(dependent_jar_files)"',
- '--entry_point', 'com.google.dart.command.analyze.AnalyzerMain',
- '--class_path_file', 'classpath_file',
- # These files are generated by 'gclient runhooks'.
- # The '@filename' will instruct javac to read 'filename' and treat
- # every line as an additional commandline argument.
- '@plugin_command_analyze_sources.txt',
- '@plugin_engine_sources.txt',
- ],
- 'message': 'Creating <(_outputs).',
- },
- ],
- },
- ]
-}
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.gitignore b/dart/editor/android/DartEditorMobileConnectionService/.gitignore
deleted file mode 100644
index d6bfc95..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-.gradle
-/local.properties
-/.idea/workspace.xml
-.DS_Store
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/.name b/dart/editor/android/DartEditorMobileConnectionService/.idea/.name
deleted file mode 100644
index 7d51bb8..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/.name
+++ /dev/null
@@ -1 +0,0 @@
-Dart Editor Mobile Connection Service
\ No newline at end of file
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/compiler.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/compiler.xml
deleted file mode 100644
index 217af47..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/compiler.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="CompilerConfiguration">
- <option name="DEFAULT_COMPILER" value="Javac" />
- <resourceExtensions />
- <wildcardResourcePatterns>
- <entry name="!?*.java" />
- <entry name="!?*.form" />
- <entry name="!?*.class" />
- <entry name="!?*.groovy" />
- <entry name="!?*.scala" />
- <entry name="!?*.flex" />
- <entry name="!?*.kt" />
- <entry name="!?*.clj" />
- </wildcardResourcePatterns>
- <annotationProcessing>
- <profile default="true" name="Default" enabled="false">
- <processorPath useClasspath="true" />
- </profile>
- </annotationProcessing>
- </component>
-</project>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/copyright/profiles_settings.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/copyright/profiles_settings.xml
deleted file mode 100644
index e7bedf3..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/copyright/profiles_settings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<component name="CopyrightManager">
- <settings default="" />
-</component>
\ No newline at end of file
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/encodings.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/encodings.xml
deleted file mode 100644
index e206d70..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/encodings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" />
-</project>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/gradle.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/gradle.xml
deleted file mode 100644
index b98ff89..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/gradle.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="GradleSettings">
- <option name="linkedExternalProjectsSettings">
- <GradleProjectSettings>
- <option name="distributionType" value="DEFAULT_WRAPPED" />
- <option name="externalProjectPath" value="$PROJECT_DIR$" />
- <option name="modules">
- <set>
- <option value="$PROJECT_DIR$" />
- <option value="$PROJECT_DIR$/service" />
- </set>
- </option>
- </GradleProjectSettings>
- </option>
- </component>
-</project>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/misc.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/misc.xml
deleted file mode 100644
index b153e48..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/misc.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="EntryPointsManager">
- <entry_points version="2.0" />
- </component>
- <component name="ProjectRootManager" version="2" languageLevel="JDK_1_6" assert-keyword="true" jdk-15="true" project-jdk-name="JDK" project-jdk-type="JavaSDK">
- <output url="file://$PROJECT_DIR$/build/classes" />
- </component>
-</project>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/modules.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/modules.xml
deleted file mode 100644
index d5b5483..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/modules.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="ProjectModuleManager">
- <modules>
- <module fileurl="file://$PROJECT_DIR$/DartEditorMobileConnectionService.iml" filepath="$PROJECT_DIR$/DartEditorMobileConnectionService.iml" />
- <module fileurl="file://$PROJECT_DIR$/service/service.iml" filepath="$PROJECT_DIR$/service/service.iml" />
- </modules>
- </component>
-</project>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/scopes/scope_settings.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/scopes/scope_settings.xml
deleted file mode 100644
index 922003b..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/scopes/scope_settings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<component name="DependencyValidationManager">
- <state>
- <option name="SKIP_IMPORT_STATEMENTS" value="false" />
- </state>
-</component>
\ No newline at end of file
diff --git a/dart/editor/android/DartEditorMobileConnectionService/.idea/vcs.xml b/dart/editor/android/DartEditorMobileConnectionService/.idea/vcs.xml
deleted file mode 100644
index def6a6a..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/.idea/vcs.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project version="4">
- <component name="VcsDirectoryMappings">
- <mapping directory="" vcs="" />
- </component>
-</project>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/DartEditorMobileConnectionService.iml b/dart/editor/android/DartEditorMobileConnectionService/DartEditorMobileConnectionService.iml
deleted file mode 100644
index f25f018..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/DartEditorMobileConnectionService.iml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$" external.system.id="GRADLE" external.system.module.group="" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
- <component name="NewModuleRootManager" inherit-compiler-output="true">
- <exclude-output />
- <content url="file://$MODULE_DIR$">
- <excludeFolder url="file://$MODULE_DIR$/.gradle" />
- </content>
- <orderEntry type="jdk" jdkName="JDK" jdkType="JavaSDK" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
-</module>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/build.gradle b/dart/editor/android/DartEditorMobileConnectionService/build.gradle
deleted file mode 100644
index aadd3db..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/build.gradle
+++ /dev/null
@@ -1,19 +0,0 @@
-// Top-level build file where you can add configuration options common to all sub-projects/modules.
-
-buildscript {
- repositories {
- mavenCentral()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:0.11.+'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
- }
-}
-
-allprojects {
- repositories {
- mavenCentral()
- }
-}
diff --git a/dart/editor/android/DartEditorMobileConnectionService/gradle.properties b/dart/editor/android/DartEditorMobileConnectionService/gradle.properties
deleted file mode 100644
index 5d08ba7..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Settings specified in this file will override any Gradle settings
-# configured through the IDE.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
diff --git a/dart/editor/android/DartEditorMobileConnectionService/gradle/wrapper/gradle-wrapper.jar b/dart/editor/android/DartEditorMobileConnectionService/gradle/wrapper/gradle-wrapper.jar
deleted file mode 100644
index 8c0fb64..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/gradle/wrapper/gradle-wrapper.jar
+++ /dev/null
Binary files differ
diff --git a/dart/editor/android/DartEditorMobileConnectionService/gradle/wrapper/gradle-wrapper.properties b/dart/editor/android/DartEditorMobileConnectionService/gradle/wrapper/gradle-wrapper.properties
deleted file mode 100644
index 2d16933..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/gradle/wrapper/gradle-wrapper.properties
+++ /dev/null
@@ -1,6 +0,0 @@
-#Wed Jun 11 22:11:00 EDT 2014
-distributionBase=GRADLE_USER_HOME
-distributionPath=wrapper/dists
-zipStoreBase=GRADLE_USER_HOME
-zipStorePath=wrapper/dists
-distributionUrl=http\://services.gradle.org/distributions/gradle-1.12-all.zip
diff --git a/dart/editor/android/DartEditorMobileConnectionService/gradlew b/dart/editor/android/DartEditorMobileConnectionService/gradlew
deleted file mode 100644
index 91a7e26..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/gradlew
+++ /dev/null
@@ -1,164 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/dart/editor/android/DartEditorMobileConnectionService/gradlew.bat b/dart/editor/android/DartEditorMobileConnectionService/gradlew.bat
deleted file mode 100644
index aec9973..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/.gitignore b/dart/editor/android/DartEditorMobileConnectionService/service/.gitignore
deleted file mode 100644
index 796b96d..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/build.gradle b/dart/editor/android/DartEditorMobileConnectionService/service/build.gradle
deleted file mode 100644
index e51b699..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/build.gradle
+++ /dev/null
@@ -1,24 +0,0 @@
-apply plugin: 'android'
-
-android {
- compileSdkVersion 19
- buildToolsVersion "19.1.0"
-
- defaultConfig {
- applicationId "com.google.dart.editor.mobile.connection.service"
- minSdkVersion 15
- targetSdkVersion 19
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- runProguard false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
-}
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/proguard-rules.pro b/dart/editor/android/DartEditorMobileConnectionService/service/proguard-rules.pro
deleted file mode 100644
index bb65c6f..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Applications/Android Studio.app/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/service.iml b/dart/editor/android/DartEditorMobileConnectionService/service/service.iml
deleted file mode 100644
index a3d5648..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/service.iml
+++ /dev/null
@@ -1,74 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<module external.linked.project.path="$MODULE_DIR$" external.root.project.path="$MODULE_DIR$/.." external.system.id="GRADLE" external.system.module.group="DartEditorMobileConnectionService" external.system.module.version="unspecified" type="JAVA_MODULE" version="4">
- <component name="FacetManager">
- <facet type="android-gradle" name="Android-Gradle">
- <configuration>
- <option name="GRADLE_PROJECT_PATH" value=":service" />
- </configuration>
- </facet>
- <facet type="android" name="Android">
- <configuration>
- <option name="SELECTED_BUILD_VARIANT" value="debug" />
- <option name="ASSEMBLE_TASK_NAME" value="assembleDebug" />
- <option name="COMPILE_JAVA_TASK_NAME" value="compileDebugJava" />
- <option name="ASSEMBLE_TEST_TASK_NAME" value="assembleDebugTest" />
- <option name="SOURCE_GEN_TASK_NAME" value="generateDebugSources" />
- <option name="ALLOW_USER_CONFIGURATION" value="false" />
- <option name="MANIFEST_FILE_RELATIVE_PATH" value="/src/main/AndroidManifest.xml" />
- <option name="RES_FOLDER_RELATIVE_PATH" value="/src/main/res" />
- <option name="RES_FOLDERS_RELATIVE_PATH" value="file://$MODULE_DIR$/src/main/res" />
- <option name="ASSETS_FOLDER_RELATIVE_PATH" value="/src/main/assets" />
- </configuration>
- </facet>
- </component>
- <component name="NewModuleRootManager" inherit-compiler-output="false">
- <output url="file://$MODULE_DIR$/build/intermediates/classes/debug" />
- <exclude-output />
- <content url="file://$MODULE_DIR$">
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/test/debug" isTestSource="true" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/test/debug" isTestSource="true" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/test/debug" isTestSource="true" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/test/debug" isTestSource="true" generated="true" />
- <sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/test/debug" type="java-test-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/res" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/resources" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/aidl" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/assets" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/java" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/jni" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/debug/rs" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/res" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/assets" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/aidl" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/java" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
- <sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
- <excludeFolder url="file://$MODULE_DIR$/build/assets" />
- <excludeFolder url="file://$MODULE_DIR$/build/dependency-cache" />
- <excludeFolder url="file://$MODULE_DIR$/build/intermediates" />
- <excludeFolder url="file://$MODULE_DIR$/build/ndk" />
- <excludeFolder url="file://$MODULE_DIR$/build/outputs" />
- <excludeFolder url="file://$MODULE_DIR$/build/pre-dexed" />
- <excludeFolder url="file://$MODULE_DIR$/build/res" />
- <excludeFolder url="file://$MODULE_DIR$/build/rs" />
- <excludeFolder url="file://$MODULE_DIR$/build/source" />
- <excludeFolder url="file://$MODULE_DIR$/build/symbols" />
- </content>
- <orderEntry type="jdk" jdkName="Android API 19 Platform" jdkType="Android SDK" />
- <orderEntry type="sourceFolder" forTests="false" />
- </component>
-</module>
-
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/AndroidManifest.xml b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/AndroidManifest.xml
deleted file mode 100644
index eb7d802..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.google.dart.editor.mobile.connection.service" >
-
- <application
- android:allowBackup="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <service
- android:name=".ConnectionService"
- android:enabled="true"
- android:exported="true" >
- </service>
- </application>
-
- <uses-permission android:name="android.permission.INTERNET" />
- <!--uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /-->
-
-</manifest>
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/java/com/google/dart/editor/mobile/connection/service/ConnectionService.java b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/java/com/google/dart/editor/mobile/connection/service/ConnectionService.java
deleted file mode 100644
index a276f5d..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/java/com/google/dart/editor/mobile/connection/service/ConnectionService.java
+++ /dev/null
@@ -1,136 +0,0 @@
-package com.google.dart.editor.mobile.connection.service;
-
-import android.app.Service;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.IBinder;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-
-public class ConnectionService extends Service {
- private String prefix;
-
- @Override
- public int onStartCommand(Intent intent, int flags, int startId) {
- URL url = getUrlToTest(intent);
- prefix = intent.getStringExtra("prefix");
- if (prefix == null) {
- prefix = "com.google.dart.editor.mobile.connection.service.msg";
- }
- if (url != null) {
- new AsyncTask<URL, Void, String>() {
- @Override
- protected String doInBackground(URL... urls) {
- URL url = urls[0];
- String content = getResponse(makeRequest(url));
- if (content != null) {
- log(content);
- log("Success");
- }
- return null;
- }
- }.execute(url);
- }
- return super.onStartCommand(intent, flags, startId);
- }
-
- @Override
- public IBinder onBind(Intent intent) {
- throw new UnsupportedOperationException();
- }
-
- private URL getUrlToTest(Intent intent) {
- Uri uri = intent.getData();
- if (uri == null) {
- return null;
- }
- try {
- return new URL(uri.toString());
- } catch (MalformedURLException e) {
- logError(null, e);
- return null;
- }
- }
-
- private URLConnection makeRequest(URL url) {
- log("Test connection: " + url);
- try {
- URLConnection connection = url.openConnection();
- connection.setRequestProperty
- ("User-Agent", "com.google.dart.editor.mobile.connection.service");
- return connection;
- } catch (IOException e) {
- logError(null, e);
- return null;
- }
- }
-
- private String getResponse(URLConnection connection) {
- if (connection == null) {
- return null;
- }
- InputStream inputStream;
- try {
- inputStream = connection.getInputStream();
- } catch (IOException e) {
- logError("No response from server", e);
- return null;
- } catch (Throwable e) {
- logError(null, e);
- return null;
- }
- if (inputStream == null) {
- logError("Response stream is null", null);
- return null;
- }
- BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
- StringBuilder str = new StringBuilder();
- while (true) {
- String line = null;
- try {
- line = reader.readLine();
- } catch (IOException e) {
- logError("Failed to get server response", e);
- break;
- }
- if (line == null) {
- break;
- }
- str.append(line);
- }
- try {
- inputStream.close();
- } catch (IOException e) {
- logError("Failed to close response stream", e);
- }
- return str.toString();
- }
-
- private void logError(String message, Throwable e) {
- StringBuilder sb = new StringBuilder();
- sb.append("Error:");
- if (message != null) {
- sb.append(" ");
- sb.append(message);
- if (e != null) {
- sb.append(":");
- }
- }
- if (e != null) {
- sb.append(" ");
- sb.append(e.toString());
- }
- log(sb.toString());
- }
-
- private void log(String message) {
- System.out.println(prefix + ": " + message);
- }
-}
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-hdpi/ic_launcher.png b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 96a442e..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-mdpi/ic_launcher.png b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index 359047d..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-xhdpi/ic_launcher.png b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 71c6d76..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-xhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-xxhdpi/ic_launcher.png b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index 4df1894..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/drawable-xxhdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/values/strings.xml b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/values/strings.xml
deleted file mode 100644
index f7d3163..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<resources>
- <string name="app_name">Dart Editor Mobile Connection Service</string>
-</resources>
diff --git a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/values/styles.xml b/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/values/styles.xml
deleted file mode 100644
index ff6c9d2..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/service/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<resources>
-
- <!-- Base application theme. -->
- <style name="AppTheme" parent="android:Theme.Holo.Light.DarkActionBar">
- <!-- Customize your theme here. -->
- </style>
-
-</resources>
diff --git a/dart/editor/android/DartEditorMobileConnectionService/settings.gradle b/dart/editor/android/DartEditorMobileConnectionService/settings.gradle
deleted file mode 100644
index 232953c..0000000
--- a/dart/editor/android/DartEditorMobileConnectionService/settings.gradle
+++ /dev/null
@@ -1 +0,0 @@
-include ':service'
diff --git a/dart/editor/android/com.google.dart.editor.mobile.connection.service.apk b/dart/editor/android/com.google.dart.editor.mobile.connection.service.apk
deleted file mode 100644
index b367938..0000000
--- a/dart/editor/android/com.google.dart.editor.mobile.connection.service.apk
+++ /dev/null
Binary files differ
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/.classpath b/dart/editor/attic/plugins/com.google.dart.indexer/.classpath
deleted file mode 100644
index ad32c83..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/.gitignore b/dart/editor/attic/plugins/com.google.dart.indexer/.gitignore
deleted file mode 100644
index 5e56e04..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/bin
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/.options b/dart/editor/attic/plugins/com.google.dart.indexer/.options
deleted file mode 100644
index 85e4a21..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/.options
+++ /dev/null
@@ -1,19 +0,0 @@
-com.google.dart.indexer/debug/allIO = false
-com.google.dart.indexer/debug/anomalies = false
-com.google.dart.indexer/debug/catalogInternals = false
-com.google.dart.indexer/debug/dependentUpdates = false
-com.google.dart.indexer/debug/indexNotAvailable = false
-com.google.dart.indexer/debug/indexedFiles = false
-com.google.dart.indexer/debug/indexingTime = false
-com.google.dart.indexer/debug/infostoreCalls = false
-com.google.dart.indexer/debug/infostoreMicrostats = false
-com.google.dart.indexer/debug/infostoreSplits = false
-com.google.dart.indexer/debug/locationPathSplitting = false
-com.google.dart.indexer/debug/miscellaneous = false
-com.google.dart.indexer/debug/rareAnomalies = false
-com.google.dart.indexer/debug/sessionLifetime = false
-com.google.dart.indexer/debug/storageCalls = false
-com.google.dart.indexer/debug/storeContentsBeforeEachQuery = false
-com.google.dart.indexer/debug/treeConsistency = false
-com.google.dart.indexer/debug/treeLookups = false
-com.google.dart.indexer/debug/treeModifications = false
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/.project b/dart/editor/attic/plugins/com.google.dart.indexer/.project
deleted file mode 100644
index 37f3ebc..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/.project
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>com.google.dart.indexer</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/.settings/org.eclipse.core.resources.prefs b/dart/editor/attic/plugins/com.google.dart.indexer/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 21b7681..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Fri May 25 10:55:00 PDT 2012
-eclipse.preferences.version=1
-encoding/<project>=UTF-8
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/META-INF/MANIFEST.MF b/dart/editor/attic/plugins/com.google.dart.indexer/META-INF/MANIFEST.MF
deleted file mode 100644
index b0246c0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/META-INF/MANIFEST.MF
+++ /dev/null
@@ -1,46 +0,0 @@
-Manifest-Version: 1.0
-Bundle-ManifestVersion: 2
-Bundle-Name: %pluginName
-Bundle-SymbolicName: com.google.dart.indexer;singleton:=true
-Bundle-Version: 0.0.0.qualifier
-Bundle-Activator: com.google.dart.indexer.IndexerPlugin
-Bundle-Vendor: %providerName
-Bundle-Localization: plugin
-Export-Package: com.google.dart.indexer,
- com.google.dart.indexer.debug,
- com.google.dart.indexer.exceptions,
- com.google.dart.indexer.index,
- com.google.dart.indexer.index.configuration,
- com.google.dart.indexer.index.configuration.internal,
- com.google.dart.indexer.index.entries,
- com.google.dart.indexer.index.layers,
- com.google.dart.indexer.index.layers.bidirectional_edges,
- com.google.dart.indexer.index.layers.reverse_edges,
- com.google.dart.indexer.index.queries,
- com.google.dart.indexer.index.readonly,
- com.google.dart.indexer.index.updating,
- com.google.dart.indexer.locations,
- com.google.dart.indexer.pagedstorage,
- com.google.dart.indexer.pagedstorage.catalog,
- com.google.dart.indexer.pagedstorage.filesystem,
- com.google.dart.indexer.pagedstorage.infostore,
- com.google.dart.indexer.pagedstorage.treestore,
- com.google.dart.indexer.pagedstorage.util,
- com.google.dart.indexer.source,
- com.google.dart.indexer.standard,
- com.google.dart.indexer.storage,
- com.google.dart.indexer.storage.db,
- com.google.dart.indexer.storage.inmemory,
- com.google.dart.indexer.storage.inmemory.api,
- com.google.dart.indexer.storage.paged,
- com.google.dart.indexer.storage.paged.index,
- com.google.dart.indexer.storage.paged.store,
- com.google.dart.indexer.utilities.io,
- com.google.dart.indexer.utilities.logging,
- com.google.dart.indexer.utils,
- com.google.dart.indexer.workspace.driver,
- com.google.dart.indexer.workspace.index
-Require-Bundle: org.eclipse.core.resources;bundle-version="3.6.0",
- org.eclipse.core.runtime;bundle-version="3.6.0"
-Bundle-ActivationPolicy: lazy
-Bundle-RequiredExecutionEnvironment: JavaSE-1.6
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/build.properties b/dart/editor/attic/plugins/com.google.dart.indexer/build.properties
deleted file mode 100644
index 8b275eb..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/build.properties
+++ /dev/null
@@ -1,8 +0,0 @@
-bin.includes = plugin.properties,\
- plugin.xml,\
- META-INF/,\
- .,\
- .options
-jars.compile.order = .
-source.. = src/
-output.. = bin/
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/build.xml b/dart/editor/attic/plugins/com.google.dart.indexer/build.xml
deleted file mode 100644
index 70e7024..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/build.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<project name="com.google.gca.eclipse.analysis.indexer"
- default="build"
- basedir=".">
-
- <!-- Project-specific properties -->
- <property name="gwt.plugin.root" location="../.." />
- <property name="plugin_name" value="${ant.project.name}" />
- <property name="project.tail" value="plugins/${plugin_name}" />
-
- <import file="${gwt.plugin.root}/common.ant.xml" />
-
- <property name="plugin.version" value="${gdt.version}" />
-
- <import file="../plugins.common.ant.xml" />
-
- <target name="build">
- <copy.plugin.src />
- <gwt.plugin.eclipseantrunner builddir="."
- buildfile="build.xml"
- buildtarget="buildInEclipse" />
- </target>
-</project>
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/plugin.properties b/dart/editor/attic/plugins/com.google.dart.indexer/plugin.properties
deleted file mode 100644
index 5fd7cd3..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/plugin.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-#########################################
-# Copyright (c) 2012, the Dart project authors
-# All Rights Reserved.
-#########################################
-
-pluginName = Dart Indexer
-providerName = dartlang.org
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/plugin.xml b/dart/editor/attic/plugins/com.google.dart.indexer/plugin.xml
deleted file mode 100644
index 3a612be..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/plugin.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.2"?>
-<plugin>
-
- <extension-point id="indexerExtensions" name="Indexer Extensions" schema="schema/indexerExtensions.exsd"/>
-
-</plugin>
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/schema/indexerExtensions.exsd b/dart/editor/attic/plugins/com.google.dart.indexer/schema/indexerExtensions.exsd
deleted file mode 100644
index 0a10ed9..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/schema/indexerExtensions.exsd
+++ /dev/null
@@ -1,230 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="com.google.dart.indexer" xmlns="http://www.w3.org/2001/XMLSchema">
-<annotation>
- <appInfo>
- <meta.schema plugin="com.google.dart.indexer" id="indexerExtensions" name="Indexer Extensions"/>
- </appInfo>
- <documentation>
- [Enter description of this extension point.]
- </documentation>
- </annotation>
-
- <element name="extension">
- <annotation>
- <appInfo>
- <meta.element />
- </appInfo>
- </annotation>
- <complexType>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element ref="processor"/>
- <element ref="contributor"/>
- <element ref="layer"/>
- </choice>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="processor">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="id"/>
- </appInfo>
- </annotation>
- <complexType>
- <choice minOccurs="0" maxOccurs="unbounded">
- <element ref="uses"/>
- </choice>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":com.google.dart.indexer.index.configuration.Processor"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="extensions" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="version" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="contributorType" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":com.google.dart.indexer.index.configuration.Calculator"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="contributor">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="id"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="processorId" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn=":com.google.dart.indexer.index.configuration.Calculator"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="version" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="layerId" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="layer">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="value"/>
- </appInfo>
- </annotation>
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="com.google.dart.indexer.index.layers.Layer:"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="uses">
- <complexType>
- <attribute name="processor-id" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- [Enter the first release in which this extension point appears.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- [Enter extension point usage example here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- [Enter API information here.]
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- [Enter information about supplied implementation of this extension point.]
- </documentation>
- </annotation>
-
-
-</schema>
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/IndexerPlugin.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/IndexerPlugin.java
deleted file mode 100644
index fbe479f..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/IndexerPlugin.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer;
-
-import com.google.dart.indexer.utilities.logging.Logger;
-
-import org.eclipse.core.runtime.Plugin;
-import org.osgi.framework.BundleContext;
-
-public class IndexerPlugin extends Plugin {
- public static final String PLUGIN_ID = IndexerPlugin.class.getPackage().getName();
-
- private static IndexerPlugin plugin;
-
- // private static BundleContext context;
- private static Logger logger;
-
- public static IndexerPlugin getDefault() {
- return plugin;
- }
-
- public static Logger getLogger() {
- return logger;
- }
-
- // static BundleContext getContext() {
- // return context;
- // }
-
- @Override
- public void start(BundleContext bundleContext) throws Exception {
- super.start(bundleContext);
- // context = bundleContext;
- plugin = this;
- logger = new Logger(this);
- }
-
- @Override
- public void stop(BundleContext bundleContext) throws Exception {
- plugin = null;
- // context = null;
- super.stop(bundleContext);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/debug/IndexerDebugOptions.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/debug/IndexerDebugOptions.java
deleted file mode 100644
index 58797eb..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/debug/IndexerDebugOptions.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.debug;
-
-/**
- * The interface <code>IndexerDebugOptions</code> defines constants associated with the output of
- * debugging information within the indexer.
- */
-public interface IndexerDebugOptions {
- public static final String ALL_IO = "com.google.dart.indexer/debug/allIO";
-
- public static final String ANOMALIES = "com.google.dart.indexer/debug/anomalies";
-
- public static final String CATALOG_INTERNALS = "com.google.dart.indexer/debug/catalogInternals";
-
- public static final String DEPENDENT_UPDATES = "com.google.dart.indexer/debug/dependentUpdates";
-
- /**
- * The name of the option used to control whether tracing output should be produced when the index
- * is not available for some reason.
- */
- public static final String INDEX_NOT_AVAILABLE = "com.google.dart.indexer/debug/indexNotAvailable";
-
- /**
- * The name of the option used to control whether tracing output should be produced when indexing
- * files.
- */
- public static final String INDEXED_FILES = "com.google.dart.indexer/debug/indexedFiles";
-
- /**
- * The name of the option used to control whether tracing output should be produced to show how
- * long it takes to perform an index.
- */
- public static final String INDEXING_TIME = "com.google.dart.indexer/debug/indexingTime";
-
- public static final String INFOSTORE_CALLS = "com.google.dart.indexer/debug/infostoreCalls";
-
- public static final String INFOSTORE_MICROSTATS = "com.google.dart.indexer/debug/infostoreMicrostats";
-
- public static final String INFOSTORE_SPLITS = "com.google.dart.indexer/debug/infostoreSplits";
-
- public static final String LOCATION_PATH_SPLITTING = "com.google.dart.indexer/debug/locationPathSplitting";
-
- public static final String MISCELLANEOUS = "com.google.dart.indexer/debug/miscellaneous";
-
- public static final String RARE_ANOMALIES = "com.google.dart.indexer/debug/rareAnomalies";
-
- public static final String SESSION_LIFETIME = "com.google.dart.indexer/debug/sessionLifetime";
-
- public static final String STORAGE_CALLS = "com.google.dart.indexer/debug/storageCalls";
-
- public static final String STORE_CONTENTS_BEFORE_EACH_QUERY = "com.google.dart.indexer/debug/storeContentsBeforeEachQuery";
-
- public static final String TREE_CONSISTENCY = "com.google.dart.indexer/debug/treeConsistency";
-
- public static final String TREE_LOOKUPS = "com.google.dart.indexer/debug/treeLookups";
-
- public static final String TREE_MODIFICATIONS = "com.google.dart.indexer/debug/treeModifications";
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexIsStillBuilding.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexIsStillBuilding.java
deleted file mode 100644
index a47eb9f..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexIsStillBuilding.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-public class IndexIsStillBuilding extends Exception {
- private static final long serialVersionUID = 1L;
-
- public IndexIsStillBuilding() {
- super();
- }
-
- public IndexIsStillBuilding(String message) {
- super(message);
- }
-
- public IndexIsStillBuilding(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IndexIsStillBuilding(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequestFailed.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequestFailed.java
deleted file mode 100644
index f65b8ce..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequestFailed.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-public abstract class IndexRequestFailed extends IndexerException {
- private static final long serialVersionUID = 1L;
-
- public IndexRequestFailed() {
- super();
- }
-
- public IndexRequestFailed(String message) {
- super(message);
- }
-
- public IndexRequestFailed(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IndexRequestFailed(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequestFailedUnchecked.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequestFailedUnchecked.java
deleted file mode 100644
index fc07556..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequestFailedUnchecked.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-public final class IndexRequestFailedUnchecked extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public IndexRequestFailedUnchecked(IndexRequestFailed cause) {
- super(cause);
- }
-
- public IndexRequestFailed unwrap() {
- return (IndexRequestFailed) getCause();
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequiresFullRebuild.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequiresFullRebuild.java
deleted file mode 100644
index 4fdbfd9..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexRequiresFullRebuild.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-public class IndexRequiresFullRebuild extends IndexRequestFailed {
- private static final long serialVersionUID = 1L;
- @Deprecated
- private IFile[] filesToIndex;
- private IndexableSource[] sourcesToIndex;
- private boolean reportAsError = true;
-
- public IndexRequiresFullRebuild() {
- super();
- }
-
- public IndexRequiresFullRebuild(String message) {
- super(message);
- }
-
- public IndexRequiresFullRebuild(String message, boolean reportAsError) {
- super(message);
- this.reportAsError = reportAsError;
- }
-
- public IndexRequiresFullRebuild(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IndexRequiresFullRebuild(Throwable cause) {
- super(cause);
- }
-
- @Deprecated
- public IndexRequiresFullRebuild(Throwable cause, IFile[] filesToIndex) {
- super(cause);
- this.filesToIndex = filesToIndex;
- }
-
- public IndexRequiresFullRebuild(Throwable cause, IndexableSource[] sourcesToIndex) {
- super(cause);
- this.sourcesToIndex = sourcesToIndex;
- }
-
- @Deprecated
- public IFile[] getFilesToIndex() {
- return filesToIndex;
- }
-
- public IndexableSource[] getSourcesToIndex() {
- return sourcesToIndex;
- }
-
- public boolean shouldReportAsError() {
- return reportAsError;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexTemporarilyNonOperational.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexTemporarilyNonOperational.java
deleted file mode 100644
index 4e30684..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexTemporarilyNonOperational.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-public class IndexTemporarilyNonOperational extends IndexRequestFailed {
- private static final long serialVersionUID = 1L;
-
- public IndexTemporarilyNonOperational() {
- super();
- }
-
- public IndexTemporarilyNonOperational(String message) {
- super(message);
- }
-
- public IndexTemporarilyNonOperational(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IndexTemporarilyNonOperational(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexTemporarilyNonOperationalUnchecked.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexTemporarilyNonOperationalUnchecked.java
deleted file mode 100644
index 948bd79..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexTemporarilyNonOperationalUnchecked.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-public final class IndexTemporarilyNonOperationalUnchecked extends RuntimeException {
- private static final long serialVersionUID = 1L;
-
- public IndexTemporarilyNonOperationalUnchecked(IndexTemporarilyNonOperational cause) {
- super(cause);
- }
-
- public IndexTemporarilyNonOperational unwrap() {
- return (IndexTemporarilyNonOperational) getCause();
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexerException.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexerException.java
deleted file mode 100644
index 68353f0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/exceptions/IndexerException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.exceptions;
-
-public abstract class IndexerException extends Exception {
- private static final long serialVersionUID = -3360874641943309504L;
-
- public IndexerException() {
- super();
- }
-
- public IndexerException(String message) {
- super(message);
- }
-
- public IndexerException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public IndexerException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/ErrorFile.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/ErrorFile.java
deleted file mode 100644
index 0a9bc16..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/ErrorFile.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index;
-
-// Copyright 2009-2010 Google Inc. All Rights Reserved.
-
-// package com.instantiations.eclipse.analysis.indexer.index;
-//
-// import java.io.DataInputStream;
-// import java.io.DataOutputStream;
-// import java.io.File;
-// import java.io.FileInputStream;
-// import java.io.FileOutputStream;
-// import java.io.IOException;
-//
-// import org.eclipse.core.resources.IFile;
-// import org.eclipse.core.runtime.IPath;
-// import org.eclipse.core.runtime.Path;
-//
-// import
-// com.instantiations.eclipse.analysis.indexer.exceptions.IndexRequiresFullRebuild;
-// import
-// com.instantiations.eclipse.analysis.indexer.exceptions.IndexTemporarilyNonOperational;
-// import
-// com.instantiations.eclipse.analysis.indexer.index.configuration.IndexConfigurationInstance;
-// import
-// com.instantiations.eclipse.analysis.indexer.index.diskstorage.IndexFolder;
-//
-// /**
-// * Provides utility method to read and write a file that describes the index
-// * configuration that the index uses.
-// */
-public class ErrorFile {
- //
- // private static final String ENCODING = "utf-8";
- //
- // /**
- // * Checks that the index configuration file exists in the given folder and
- // * represents exactly the given index configuration.
- // */
- // public static IPath[] read(IndexFolder folder,
- // IndexConfigurationInstance configuration)
- // throws IndexRequiresFullRebuild {
- // File versionFile = getFile(folder);
- // try {
- // FileInputStream in = new FileInputStream(versionFile);
- // DataInputStream ds=new DataInputStream(in);
- // try {
- // int count=ds.readInt();
- // IPath[] result=new IPath[count];
- // for (int a=0;a<count;a++){
- // result[a]=new Path(ds.readUTF());
- // }
- // return result;
- // } finally {
- // in.close();
- // }
- // } catch (IOException e) {
- // throw new IndexRequiresFullRebuild("Error reading index version", e);
- // }
- // }
- //
- // /**
- // * Creates or overwrites an index configuration file in the given folder, so
- // * that it will correspond to the given index configuration.
- // */
- // public static void write(IndexFolder folder,
- // IndexConfigurationInstance configuration,IFile[] files)
- // throws IndexTemporarilyNonOperational {
- // folder.getFolder().mkdirs();
- // File versionFile = getFile(folder);
- // try {
- // FileOutputStream out = new FileOutputStream(versionFile);
- //
- // try {
- // DataOutputStream ds=new DataOutputStream(out);
- // ds.writeInt(files.length);
- // for (int a=0;a<files.length;a++){
- // ds.writeUTF(files[a].getFullPath().toString());
- // }
- // } finally {
- // out.close();
- // }
- // } catch (IOException e) {
- // throw new IndexTemporarilyNonOperational(
- // "Error writing index version", e);
- // }
- // }
- //
- // private static File getFile(IndexFolder folder) {
- // File versionFile = folder.byLocalPath("errors-info");
- // return versionFile;
- // }
- //
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexSession.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexSession.java
deleted file mode 100644
index 4f9ae4b..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexSession.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.index.readonly.DiskBackedIndexImpl;
-import com.google.dart.indexer.index.readonly.EmptyIndexImpl;
-import com.google.dart.indexer.index.readonly.Index;
-import com.google.dart.indexer.storage.AbstractIntegratedStorage;
-import com.google.dart.indexer.storage.StorageFactory;
-import com.google.dart.indexer.utilities.io.FileUtilities;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-import java.io.File;
-
-/**
- * Creates readable/writable index and update session objects in such manner that all the indexes
- * share the same configuration, and all the versions of the index are stored in the given root
- * folder.
- */
-public class IndexSession {
- public static void destroyIndexStatically() {
- FileUtilities.delete(IndexerPlugin.getDefault().getStateLocation().toFile());
- }
-
- private final IndexConfigurationInstance configuration;
- private final AbstractIntegratedStorage storage;
- private boolean disposed = false;
- private final int id;
- private static int concurrentSessions = 0;
-
- private static int instanceCount = 0;
-
- public IndexSession(File rootFolder, IndexConfigurationInstance configuration) {
- id = ++instanceCount;
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.SESSION_LIFETIME,
- "IndexSession#" + id + " created");
- if (concurrentSessions > 0) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- "WARNING: " + concurrentSessions + " sessions exist now");
- throw new IllegalStateException("Cannot create concurrent indexer sessions");
- }
- ++concurrentSessions;
- this.configuration = configuration;
- storage = StorageFactory.createStorage(configuration, rootFolder);
- }
-
- public IndexSession(IndexConfigurationInstance configuration) {
- this(IndexerPlugin.getDefault().getStateLocation().toFile(), configuration);
- }
-
- public Index createEmptyRegularIndex() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- return new EmptyIndexImpl(storage);
- }
-
- public Index createNewRegularIndex(File folder) throws IndexTemporarilyNonOperational {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- // Write a new version file.
- VersionFile.write(IndexerPlugin.getDefault().getStateLocation().toFile(), configuration);
- // Delete any existing index file.
- storage.destroy();
- DiskBackedIndexImpl diskBackedIndexImpl = new DiskBackedIndexImpl(configuration, storage);
- return diskBackedIndexImpl;
- }
-
- public Index createRegularIndex(File folder) throws IndexRequiresFullRebuild {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- VersionFile.check(folder, configuration);
- DiskBackedIndexImpl diskBackedIndexImpl = new DiskBackedIndexImpl(configuration, storage);
- return diskBackedIndexImpl;
- }
-
- public IndexTransaction createTransaction(Index index) {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- return new IndexTransaction(storage.createTransaction(), configuration);
- }
-
- public void destroyIndex() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- storage.destroy();
- }
-
- public void dispose() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- storage.close();
- disposed = true;
- --concurrentSessions;
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.SESSION_LIFETIME,
- "IndexSession#" + id + " disposed");
- }
-
- public void flushCaches() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- storage.flushCaches();
- }
-
- public IndexSessionStats gatherStatistics() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- return new IndexSessionStats(storage.gatherStatistics(), configuration.gatherTimeSpentParsing());
- }
-
- public IndexConfigurationInstance getConfiguration() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- return configuration;
- }
-
- public AbstractIntegratedStorage getStorage() {
- if (disposed) {
- throw new IllegalStateException("Index session has already been disposed");
- }
- return storage;
- }
-
- public void runConsistencyCheck(IProgressMonitor monitor) {
- storage.runConsistencyCheck(monitor);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexSessionStats.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexSessionStats.java
deleted file mode 100644
index 66980b5..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexSessionStats.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index;
-
-public class IndexSessionStats {
- private final Object storageStats;
- private final long timeSpentParsing;
-
- public IndexSessionStats(Object storageStats, long timeSpentParsing) {
- if (storageStats == null) {
- throw new NullPointerException("storageStats is null");
- }
- this.storageStats = storageStats;
- this.timeSpentParsing = timeSpentParsing;
- }
-
- public Object getStorageStats() {
- return storageStats;
- }
-
- public long getTimeSpentParsing() {
- return timeSpentParsing;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexTransaction.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexTransaction.java
deleted file mode 100644
index 5673f66..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/IndexTransaction.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.exceptions.IndexRequestFailedUnchecked;
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.index.configuration.Processor;
-import com.google.dart.indexer.index.entries.DependentEntity;
-import com.google.dart.indexer.index.entries.DependentFileInfo;
-import com.google.dart.indexer.index.entries.DependentLocation;
-import com.google.dart.indexer.index.entries.FileInfo;
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.FileInfoUpdater;
-import com.google.dart.indexer.index.updating.FileInfoUpdaterImpl;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-import com.google.dart.indexer.storage.FileTransaction;
-import com.google.dart.indexer.storage.StorageTransaction;
-import com.google.dart.indexer.workspace.index.IndexingTarget;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Platform;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * Executes an operation consisting of reindexing some files and removing some files, so that the
- * index is reliably updated as a result of this operation.
- */
-public class IndexTransaction {
- private final static boolean TRACE_INDEXED_FILES = Boolean.valueOf(
- Platform.getDebugOption(IndexerDebugOptions.INDEXED_FILES)).booleanValue();
-
- private final IndexConfigurationInstance configuration;
-
- private ArrayList<IndexingTarget> targetsWithErrors = new ArrayList<IndexingTarget>();
- private ArrayList<Throwable> errors = new ArrayList<Throwable>();
-
- private final StorageTransaction storageTransaction;
-
- public IndexTransaction(StorageTransaction storageTransaction,
- IndexConfigurationInstance configuration) {
- if (storageTransaction == null) {
- throw new NullPointerException("storageTransaction is null");
- }
- if (configuration == null) {
- throw new NullPointerException("configuration is null");
- }
- this.storageTransaction = storageTransaction;
- this.configuration = configuration;
- }
-
- public void addErrorTarget(IndexingTarget target, Throwable error) {
- targetsWithErrors.add(target);
- errors.add(error);
- }
-
- public void close() throws IndexRequestFailed {
- for (Processor processor : configuration.getKnownProcessors()) {
- try {
- processor.transactionEnded();
- } catch (Exception exception) {
- // Ignore problems from individual processors, other than to log them.
- IndexerPlugin.getLogger().logError(exception,
- "Processor failed while transaction was ending: " + processor.getClass().getName());
- }
- }
- storageTransaction.commit();
- }
-
- public Throwable[] getErrors() {
- return errors.toArray(new Throwable[errors.size()]);
- }
-
- public IndexingTarget[] getTargetsWithErrors() {
- return targetsWithErrors.toArray(new IndexingTarget[targetsWithErrors.size()]);
- }
-
- public void indexTarget(IndexingTarget target) throws IndexRequestFailed {
- try {
- IFile file = target.getFile();
- if (file == null) {
- return;
- }
- Processor[] processors = configuration.findProcessors(file);
- if (processors.length == 0) {
- return;
- }
- if (TRACE_INDEXED_FILES) {
- IndexerPlugin.getLogger().trace("Indexing " + file.getFullPath());
- }
- FileTransaction fileTransaction = storageTransaction.createFileTransaction(file);
- removeInformationThatWillBeReconstructed(file, fileTransaction.getOriginalFileInfo());
- FileInfoUpdater updater = new FileInfoUpdaterImpl(fileTransaction, file);
- for (int i = 0; i < processors.length; i++) {
- processors[i].processTarget(target, updater);
- }
- fileTransaction.commit();
- } catch (IndexRequestFailedUnchecked e) {
- throw e.unwrap();
- }
- }
-
- @Deprecated
- public IFile[] removeTarget(IndexingTarget target) {
- IFile file = target.getFile();
- FileInfo info = storageTransaction.removeFileInfo(file);
- if (info == null) {
- return new IFile[0];
- }
- removeInformationThatWillBeReconstructed(file, info);
- Collection<Location> sourceLocations = info.getSourceLocations();
- Set<IFile> affectedFiles = calculateFilesAffectedByRemovalOf(sourceLocations);
- for (Iterator<Location> iterator = sourceLocations.iterator(); iterator.hasNext();) {
- storageTransaction.removeLocationInfo(iterator.next());
- }
- return affectedFiles.toArray(new IFile[affectedFiles.size()]);
- }
-
- public IndexableSource[] removeTarget_new(IndexingTarget target) {
- IndexableSource source = IndexableSource.from(target.getUri());
- FileInfo info = storageTransaction.removeFileInfo(source);
- if (info == null) {
- return new IndexableSource[0];
- }
- removeInformationThatWillBeReconstructed(source, info);
- Collection<Location> sourceLocations = info.getSourceLocations();
- Set<IndexableSource> affectedFiles = calculateSourcesAffectedByRemovalOf(sourceLocations);
- for (Iterator<Location> iterator = sourceLocations.iterator(); iterator.hasNext();) {
- storageTransaction.removeLocationInfo(iterator.next());
- }
- return affectedFiles.toArray(new IndexableSource[affectedFiles.size()]);
- }
-
- @Deprecated
- private Set<IFile> calculateFilesAffectedByRemovalOf(Collection<Location> sourceLocations) {
- Set<IFile> affectedFiles = new HashSet<IFile>();
- for (Iterator<Location> iterator = sourceLocations.iterator(); iterator.hasNext();) {
- calculateFilesAffectedByRemovalOf(iterator.next(), affectedFiles);
- }
- return affectedFiles;
- }
-
- @Deprecated
- private void calculateFilesAffectedByRemovalOf(Layer layer, Location location, Set<IFile> result) {
- LocationInfo info = storageTransaction.readLocationInfo(layer, location);
- if (info == null) {
- return;
- }
- Location[] affectedLocations = info.getLocationsAffectedByRemovalOfSelf();
- for (int i = 0; i < affectedLocations.length; i++) {
- Location affectedLocation = affectedLocations[i];
- IFile containingFile = affectedLocation.getContainingFile();
- if (containingFile != null) {
- result.add(containingFile);
- }
- }
- }
-
- @Deprecated
- private void calculateFilesAffectedByRemovalOf(Location location, Set<IFile> result) {
- Layer[] layers = configuration.getLayers();
- for (int i = 0; i < layers.length; i++) {
- calculateFilesAffectedByRemovalOf(layers[i], location, result);
- }
- }
-
- private Set<IndexableSource> calculateSourcesAffectedByRemovalOf(
- Collection<Location> sourceLocations) {
- Set<IndexableSource> affectedFiles = new HashSet<IndexableSource>();
- for (Iterator<Location> iterator = sourceLocations.iterator(); iterator.hasNext();) {
- calculateSourcesAffectedByRemovalOf(iterator.next(), affectedFiles);
- }
- return affectedFiles;
- }
-
- private void calculateSourcesAffectedByRemovalOf(Layer layer, Location location,
- Set<IndexableSource> result) {
- LocationInfo info = storageTransaction.readLocationInfo(layer, location);
- if (info == null) {
- return;
- }
- Location[] affectedLocations = info.getLocationsAffectedByRemovalOfSelf();
- for (int i = 0; i < affectedLocations.length; i++) {
- Location affectedLocation = affectedLocations[i];
- IndexableSource containingSource = IndexableSource.from(affectedLocation.getContainingUri());
- if (containingSource != null) {
- result.add(containingSource);
- }
- }
- }
-
- private void calculateSourcesAffectedByRemovalOf(Location location, Set<IndexableSource> result) {
- Layer[] layers = configuration.getLayers();
- for (int i = 0; i < layers.length; i++) {
- calculateSourcesAffectedByRemovalOf(layers[i], location, result);
- }
- }
-
- @Deprecated
- private void removeInformationThatWillBeReconstructed(IFile staleFile, FileInfo fileInfo) {
- if (fileInfo == null) {
- return;
- }
- HashSet<Location> staleLocations = new HashSet<Location>(fileInfo.getSourceLocations());
- for (Iterator<DependentEntity> iterator = fileInfo.getInternalDependencies().iterator(); iterator.hasNext();) {
- removeInformationThatWillBeReconstructed(staleFile, staleLocations, iterator.next());
- }
- for (Iterator<DependentEntity> iterator = fileInfo.getExternalDependencies().iterator(); iterator.hasNext();) {
- removeInformationThatWillBeReconstructed(staleFile, staleLocations, iterator.next());
- }
- fileInfo.clearInternalDependencies();
- }
-
- @Deprecated
- private void removeInformationThatWillBeReconstructed(IFile staleFile,
- HashSet<Location> staleLocations, DependentEntity dependency) {
- if (dependency instanceof DependentFileInfo) {
- DependentFileInfo dfi = (DependentFileInfo) dependency;
- storageTransaction.removeStaleDependencies(dfi.getFile(), staleFile, staleLocations);
- } else if (dependency instanceof DependentLocation) {
- DependentLocation dl = (DependentLocation) dependency;
- removeStaleInformationAboutLocations(dl.getDependentLayer(), staleLocations,
- dl.getDependentLocation());
- }
- }
-
- private void removeInformationThatWillBeReconstructed(IndexableSource staleSource,
- FileInfo fileInfo) {
- if (fileInfo == null) {
- return;
- }
- HashSet<Location> staleLocations = new HashSet<Location>(fileInfo.getSourceLocations());
- for (Iterator<DependentEntity> iterator = fileInfo.getInternalDependencies().iterator(); iterator.hasNext();) {
- removeInformationThatWillBeReconstructed(staleSource, staleLocations, iterator.next());
- }
- for (Iterator<DependentEntity> iterator = fileInfo.getExternalDependencies().iterator(); iterator.hasNext();) {
- removeInformationThatWillBeReconstructed(staleSource, staleLocations, iterator.next());
- }
- fileInfo.clearInternalDependencies();
- }
-
- private void removeInformationThatWillBeReconstructed(IndexableSource staleSource,
- HashSet<Location> staleLocations, DependentEntity dependency) {
- if (dependency instanceof DependentFileInfo) {
- DependentFileInfo dfi = (DependentFileInfo) dependency;
- storageTransaction.removeStaleDependencies(dfi.getSource(), staleSource, staleLocations);
- } else if (dependency instanceof DependentLocation) {
- DependentLocation dl = (DependentLocation) dependency;
- removeStaleInformationAboutLocations(dl.getDependentLayer(), staleLocations,
- dl.getDependentLocation());
- }
- }
-
- private void removeStaleInformationAboutLocations(Layer layer,
- HashSet<Location> staleSourceLocations, Location destination) {
- storageTransaction.removeStaleLocationsFromDestination(layer, destination, staleSourceLocations);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/PerformanceRelatedConstants.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/PerformanceRelatedConstants.java
deleted file mode 100644
index b752315..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/PerformanceRelatedConstants.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index;
-
-public class PerformanceRelatedConstants {
- public static final int BUILDING_FILE_CACHE = 512;
-
- public static final int BUILDING_LOCATION_CACHE = 512;
-
- public static final int READING_LOCATION_CACHE = 128;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/VersionFile.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/VersionFile.java
deleted file mode 100644
index 0f792a1..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/VersionFile.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-/**
- * Provides utility method to read and write a file that describes the index configuration that the
- * index uses.
- */
-public class VersionFile {
- private static final String ENCODING = "utf-8";
-
- /**
- * Checks that the index configuration file exists in the given folder and represents exactly the
- * given index configuration.
- */
- public static void check(File folder, IndexConfigurationInstance configuration)
- throws IndexRequiresFullRebuild {
- File versionFile = getFile(folder);
- if (!versionFile.exists()) {
- throw new IndexRequiresFullRebuild(
- "Error reading index version: index version file does not exist");
- }
- try {
- FileInputStream in = new FileInputStream(versionFile);
- try {
- String correct = configuration.describe();
- byte[] correctBytes = correct.getBytes(ENCODING);
- byte[] actualBytes = new byte[correctBytes.length + 1];
- int actualLength = in.read(actualBytes);
- if (actualLength == -1) {
- throw new IndexRequiresFullRebuild(
- "Error reading index version: index version file is empty");
- }
- String actual = new String(actualBytes, 0, actualLength, ENCODING);
- if (!correct.equals(actual)) {
- throw new IndexRequiresFullRebuild("Index configuration has changed", false);
- }
- } finally {
- in.close();
- }
- } catch (IOException exception) {
- throw new IndexRequiresFullRebuild("Error reading index version", exception);
- }
- }
-
- /**
- * Creates or overwrites an index configuration file in the given folder, so that it will
- * correspond to the given index configuration.
- */
- public static void write(File folder, IndexConfigurationInstance configuration)
- throws IndexTemporarilyNonOperational {
- folder.mkdirs();
- File versionFile = getFile(folder);
- try {
- FileOutputStream out = new FileOutputStream(versionFile);
- try {
- String correct = configuration.describe();
- byte[] correctBytes = correct.getBytes(ENCODING);
- out.write(correctBytes);
- } finally {
- out.close();
- }
- } catch (IOException exception) {
- throw new IndexTemporarilyNonOperational("Error writing index version", exception);
- }
- }
-
- private static File getFile(File folder) {
- return new File(folder, "version-info");
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/Contributor.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/Contributor.java
deleted file mode 100644
index 4545f2e..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/Contributor.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-/**
- * Contributes information to the index. Contributors are registered per processor, and are expected
- * to update the index using the data prepared by the processor.
- * <p>
- * Note that this is a marker interface. Specific processors will define (and require implementation
- * of) corresponding specific interfaces.
- */
-public interface Contributor {
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/ContributorWrapper.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/ContributorWrapper.java
deleted file mode 100644
index 7148364..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/ContributorWrapper.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-import com.google.dart.indexer.index.layers.Layer;
-
-public class ContributorWrapper {
- private final Contributor contributor;
- private final Layer layer;
-
- public ContributorWrapper(Contributor contributor, Layer layer) {
- if (contributor == null) {
- throw new NullPointerException("contributor is null");
- }
- if (layer == null) {
- throw new NullPointerException("layer is null");
- }
- this.contributor = contributor;
- this.layer = layer;
- }
-
- public Contributor getContributor() {
- return contributor;
- }
-
- public Layer getLayer() {
- return layer;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IdentifierStableMappingBuilder.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IdentifierStableMappingBuilder.java
deleted file mode 100644
index 2c3d8fe..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IdentifierStableMappingBuilder.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class IdentifierStableMappingBuilder {
- private final Set<String> uniqueIdentifiers = new HashSet<String>();
-
- public void addUniqueIndentifier(String id) {
- uniqueIdentifiers.add(id);
- }
-
- public Map<String, Integer> build() {
- List<String> ids = new ArrayList<String>(uniqueIdentifiers);
- Collections.sort(ids);
- Map<String, Integer> map = new HashMap<String, Integer>();
- for (int i = 0; i < ids.size(); i++) {
- map.put(ids.get(i), new Integer(i));
- }
- return map;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfiguration.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfiguration.java
deleted file mode 100644
index e87796c..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfiguration.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-/**
- * Holds an immutable set of options required to build the index. Currently this set consists only
- * of the registered processors and contributors. The clients should create configurations using the
- * <code>IndexConfigurationBuilder</code> class.
- */
-public interface IndexConfiguration {
- /**
- * Returns a stable string representation of this configuration, suitable for a persistent
- * storage.
- */
- String describe();
-
- IndexConfigurationInstance instantiate();
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfigurationBuilder.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfigurationBuilder.java
deleted file mode 100644
index 3c365c4..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfigurationBuilder.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-import com.google.dart.indexer.index.configuration.internal.ConfigurationError;
-import com.google.dart.indexer.index.configuration.internal.ContributorInfo;
-import com.google.dart.indexer.index.configuration.internal.IndexConfigurationImpl;
-import com.google.dart.indexer.index.configuration.internal.LayerInfo;
-import com.google.dart.indexer.index.configuration.internal.ProcessorInfo;
-import com.google.dart.indexer.index.configuration.internal.ProcessorRegistration;
-import com.google.dart.indexer.index.layers.LayerId;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Creates index configurations based on a set of processors and contributors.
- */
-public class IndexConfigurationBuilder {
- private static class ProcessorBuilder {
- private final ProcessorInfo info;
-
- private final List<ContributorInfo> contributors = new ArrayList<ContributorInfo>();
-
- public ProcessorBuilder(ProcessorInfo info) {
- this.info = info;
- }
-
- public void add(ContributorInfo contributor) {
- contributors.add(contributor);
- }
-
- public ProcessorRegistration build() {
- ContributorInfo[] contributorsArr = contributors.toArray(new ContributorInfo[contributors.size()]);
- return new ProcessorRegistration(info, contributorsArr);
- }
- }
-
- private final Map<String, ProcessorBuilder> idsToProcessorBuilders = new HashMap<String, ProcessorBuilder>();
-
- private final Map<LayerId, LayerInfo> idsToLayers = new HashMap<LayerId, LayerInfo>();
-
- public void addContributor(String processorId, ContributorInfo contributor) {
- ProcessorBuilder builder = idsToProcessorBuilders.get(processorId);
- if (builder == null) {
- throw new IllegalArgumentException("Processor with ID {0} not found".replaceAll("\\{0}",
- processorId));
- }
- builder.add(contributor);
- }
-
- public void addLayer(LayerInfo info) {
- LayerInfo existingLayer = idsToLayers.get(info.getId());
- if (existingLayer != null) {
- throw new IllegalArgumentException("Layer with id " + info.getId()
- + " has already been registered: " + existingLayer);
- }
- idsToLayers.put(info.getId(), info);
- }
-
- public void addProcessor(ProcessorInfo info) {
- String id = info.getId();
- ProcessorBuilder builder = new ProcessorBuilder(info);
- ProcessorBuilder oldBuilder = idsToProcessorBuilders.put(id, builder);
- if (oldBuilder != null) {
- throw new IllegalArgumentException(
- "Processor with ID {0} has already been registered".replaceAll("\\{0}", id));
- }
- }
-
- public IndexConfiguration build() throws ConfigurationError {
- return new IndexConfigurationImpl(createRegistrations(), createLayers());
- }
-
- private LayerInfo[] createLayers() {
- IdentifierStableMappingBuilder builder = new IdentifierStableMappingBuilder();
- List<LayerInfo> layerInfos = new ArrayList<LayerInfo>(idsToLayers.values());
- for (Iterator<LayerInfo> iterator = layerInfos.iterator(); iterator.hasNext();) {
- builder.addUniqueIndentifier(iterator.next().getId().stringValue());
- }
- Map<String, Integer> idsToOrdinals = builder.build();
-
- for (Iterator<LayerInfo> iterator = layerInfos.iterator(); iterator.hasNext();) {
- LayerInfo info = iterator.next();
- Integer ord = idsToOrdinals.get(info.getId().stringValue());
- info.initializeOrdinal(ord.intValue());
- }
- Collections.sort(layerInfos);
- LayerInfo[] layers = layerInfos.toArray(new LayerInfo[layerInfos.size()]);
- return layers;
- }
-
- private ProcessorRegistration[] createRegistrations() {
- List<ProcessorRegistration> regs = new ArrayList<ProcessorRegistration>();
- for (Iterator<ProcessorBuilder> iterator = idsToProcessorBuilders.values().iterator(); iterator.hasNext();) {
- regs.add(iterator.next().build());
- }
- return regs.toArray(new ProcessorRegistration[regs.size()]);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfigurationInstance.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfigurationInstance.java
deleted file mode 100644
index 12ec834..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/IndexConfigurationInstance.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.layers.LayerId;
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-/**
- * Holds an immutable set of options required to build the index. Currently this set consists only
- * of the registered processors and contributors.
- * <p>
- * The clients should create configurations using the <code>IndexConfigurationBuilder</code> class.
- */
-public interface IndexConfigurationInstance {
- public String describe();
-
- /**
- * Return an array containing all of the processors that should be given an opportunity to process
- * the given file.
- *
- * @return the processors that should be given an opportunity to process the given file
- */
- @Deprecated
- public Processor[] findProcessors(IFile file);
-
- /**
- * Return an array containing all of the processors that should be given an opportunity to process
- * the given source.
- *
- * @return the processors that should be given an opportunity to process the given source
- */
- public Processor[] findProcessors(IndexableSource source);
-
- public long gatherTimeSpentParsing();
-
- /**
- * Return an array containing all of the processors that have been created.
- *
- * @return an array containing all of the processors that have been created
- */
- public Processor[] getKnownProcessors();
-
- public Layer getLayer(int ordinal);
-
- public Layer getLayer(LayerId layerId);
-
- public Layer[] getLayers();
-
- @Deprecated
- public boolean isIndexedFile(IFile file);
-
- public boolean isIndexedFile(IndexableSource source);
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/Processor.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/Processor.java
deleted file mode 100644
index 5e3a2ff..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/Processor.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.index.updating.FileInfoUpdater;
-import com.google.dart.indexer.workspace.index.IndexingTarget;
-
-import java.util.Map;
-
-/**
- * The interface <code>Processor</code> defines the behavior of objects that perform the processing
- * that is common to all contributors, so that operations such as parsing the file can be carried
- * out only once on each file. The processor determines a set of locations within a file, and calls
- * contributors to process each.
- * <p>
- * A processor handles a specific type of files, which is specified when the processor is
- * registered. The processor does not have to handle all files of that type. It should ignore
- * unsuitable files.
- * <p>
- * The processor is expected to delegate actual updating of the index to the contributors, however
- * it does not have to.
- */
-public interface Processor {
- public long getAndResetTimeSpentParsing();
-
- public void initialize(ContributorWrapper[] calculators,
- Map<String, Processor> idsToUsedProcessors);
-
- public void processTarget(IndexingTarget target, FileInfoUpdater updater)
- throws IndexRequestFailed;
-
- /**
- * Notification that the current transaction has ended. This method allows processors to cache
- * information for the duration of a single transaction in order to be more efficient.
- */
- public void transactionEnded();
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ConfigurationError.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ConfigurationError.java
deleted file mode 100644
index 227e041..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ConfigurationError.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-public class ConfigurationError extends Exception {
- private static final long serialVersionUID = 1L;
-
- public ConfigurationError(String message) {
- super(message);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ContributorInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ContributorInfo.java
deleted file mode 100644
index aa04b41..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ContributorInfo.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.configuration.Contributor;
-import com.google.dart.indexer.index.layers.LayerId;
-
-public abstract class ContributorInfo implements Comparable<ContributorInfo> {
- private final String id;
- private final String version;
- private final LayerId layerId;
-
- public ContributorInfo(String id, String version, LayerId layerId) {
- if (id == null) {
- throw new NullPointerException("id is null");
- }
- if (version == null) {
- throw new NullPointerException("version is null");
- }
- if (layerId == null) {
- throw new NullPointerException("layerId is null");
- }
- this.id = id;
- this.version = version;
- this.layerId = layerId;
- }
-
- @Override
- public int compareTo(ContributorInfo o) {
- ContributorInfo peer = o;
- return getId().compareTo(peer.getId());
- }
-
- public abstract Contributor create();
-
- public void describe(StringBuilder builder) {
- builder.append(id).append(' ').append(version);
- }
-
- public String getId() {
- return id;
- }
-
- public LayerId getLayerId() {
- return layerId;
- }
-
- public String getVersion() {
- return version;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/IndexConfigurationImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/IndexConfigurationImpl.java
deleted file mode 100644
index 9d0daec..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/IndexConfigurationImpl.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.configuration.IndexConfiguration;
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.index.layers.Layer;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-public class IndexConfigurationImpl implements IndexConfiguration {
- private static ProcessorRegistration[] sort(ProcessorRegistration[] registrations) {
- ProcessorRegistration[] res = new ProcessorRegistration[registrations.length];
- System.arraycopy(registrations, 0, res, 0, registrations.length);
- Arrays.sort(res);
- return res;
- }
-
- private final ProcessorRegistration[] registrations;
-
- private final LayerInfo[] layers;
-
- private String description;
-
- public IndexConfigurationImpl(ProcessorRegistration registrations[], LayerInfo[] layers)
- throws ConfigurationError {
- this.layers = layers;
- this.registrations = sort(registrations);
- verifyAllRegistrations(calculateAllProcessorIds(registrations));
- description = calculateDescription();
- }
-
- public Layer[] createLayers() {
- Layer[] result = new Layer[layers.length];
- for (int i = 0; i < result.length; i++) {
- result[i] = layers[i].create();
- result[i].initialize(layers[i]);
- }
- return result;
- }
-
- @Override
- public String describe() {
- return description;
- }
-
- @Override
- public IndexConfigurationInstance instantiate() {
- return new IndexConfigurationInstanceImpl(this, registrations, createLayers());
- }
-
- private Set<String> calculateAllProcessorIds(ProcessorRegistration[] registrations) {
- Set<String> allProcessorIds = new HashSet<String>();
- for (int i = 0; i < registrations.length; i++) {
- allProcessorIds.add(registrations[i].getId());
- }
- return allProcessorIds;
- }
-
- private String calculateDescription() {
- StringBuilder result = new StringBuilder();
- result.append("PROCESSORS:").append('\n');
- for (int i = 0; i < registrations.length; i++) {
- registrations[i].describe(result);
- }
- result.append("\nLAYERS:");
- for (int i = 0; i < layers.length; i++) {
- result.append("\n- ").append(layers[i].getId());
- }
- result.append('\n');
- return result.toString();
- }
-
- private void verifyAllRegistrations(Set<String> allProcessorIds) throws ConfigurationError {
- for (int i = 0; i < registrations.length; i++) {
- registrations[i].verifyRegistration(allProcessorIds);
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/IndexConfigurationInstanceImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/IndexConfigurationInstanceImpl.java
deleted file mode 100644
index 042cf65..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/IndexConfigurationInstanceImpl.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.configuration.IndexConfiguration;
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.index.configuration.Processor;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.layers.LayerId;
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public class IndexConfigurationInstanceImpl implements IndexConfigurationInstance, ProcessorFactory {
- private static Map<LayerId, Layer> indexLayersById(Layer[] layers) {
- Map<LayerId, Layer> idsToLayers = new HashMap<LayerId, Layer>();
- for (int i = 0; i < layers.length; i++) {
- idsToLayers.put(layers[i].getId(), layers[i]);
- }
- return idsToLayers;
- }
-
- private final ProcessorRegistration[] registrations;
-
- private final Map<String, Processor[]> extensionsToRegistrations = new HashMap<String, Processor[]>();
-
- private final Map<ProcessorRegistration, Processor> registrationsToProcessors = new HashMap<ProcessorRegistration, Processor>();
-
- private final Layer[] layers;
-
- private final IndexConfiguration configuration;
-
- private Map<LayerId, Layer> idsToLayers;
-
- public IndexConfigurationInstanceImpl(IndexConfiguration configuration,
- ProcessorRegistration registrations[], Layer[] layers) {
- if (configuration == null) {
- throw new NullPointerException("configuration is null");
- }
- if (registrations == null) {
- throw new NullPointerException("registrations is null");
- }
- if (layers == null) {
- throw new NullPointerException("layers is null");
- }
- this.configuration = configuration;
- this.registrations = registrations;
- this.layers = layers;
- this.idsToLayers = indexLayersById(layers);
- }
-
- @Override
- public String describe() {
- return configuration.describe();
- }
-
- @Override
- @Deprecated
- public Processor[] findProcessors(IFile file) {
- String extension = file.getFileExtension();
- Processor[] processors = extensionsToRegistrations.get(extension);
- if (processors == null) {
- processors = calculateProcessors(extension);
- extensionsToRegistrations.put(extension, processors);
- }
- return processors;
- }
-
- @Override
- public Processor[] findProcessors(IndexableSource source) {
- String extension = source.getFileExtension();
- Processor[] processors = extensionsToRegistrations.get(extension);
- if (processors == null) {
- processors = calculateProcessors(extension);
- extensionsToRegistrations.put(extension, processors);
- }
- return processors;
- }
-
- @Override
- public long gatherTimeSpentParsing() {
- long result = 0;
- for (Iterator<Processor> iterator = registrationsToProcessors.values().iterator(); iterator.hasNext();) {
- Processor processor = iterator.next();
- result += processor.getAndResetTimeSpentParsing();
- }
- return result;
- }
-
- @Override
- public Processor getInitializedProcessor(String id) {
- return getInitializedProcessor(findRegistration(id));
- }
-
- @Override
- public Processor[] getKnownProcessors() {
- HashSet<Processor> knownProcessors = new HashSet<Processor>();
- for (Processor[] processors : extensionsToRegistrations.values()) {
- for (Processor processor : processors) {
- knownProcessors.add(processor);
- }
- }
- return knownProcessors.toArray(new Processor[knownProcessors.size()]);
- }
-
- @Override
- public Layer getLayer(int ordinal) {
- return layers[ordinal];
- }
-
- @Override
- public Layer getLayer(LayerId layerId) {
- return idsToLayers.get(layerId);
- }
-
- @Override
- public Layer[] getLayers() {
- return layers;
- }
-
- @Override
- @Deprecated
- public boolean isIndexedFile(IFile file) {
- return findProcessors(file).length > 0;
- }
-
- @Override
- public boolean isIndexedFile(IndexableSource source) {
- return findProcessors(source).length > 0;
- }
-
- private Processor[] calculateProcessors(String extension) {
- Processor[] processors;
- ProcessorRegistration[] regs = findRegistrations(extension);
- processors = new Processor[regs.length];
- for (int i = 0; i < regs.length; i++) {
- processors[i] = getInitializedProcessor(regs[i]);
- }
- return processors;
- }
-
- private ProcessorRegistration findRegistration(String id) {
- for (int i = 0; i < registrations.length; i++) {
- if (registrations[i].idEquals(id)) {
- return registrations[i];
- }
- }
- throw new AssertionError("Processor with id " + id + " not found");
- }
-
- private ProcessorRegistration[] findRegistrations(String extension) {
- List<ProcessorRegistration> rr = new ArrayList<ProcessorRegistration>();
- for (int i = 0; i < registrations.length; i++) {
- if (registrations[i].mightBeInterestedIn(extension)) {
- rr.add(registrations[i]);
- }
- }
- return rr.toArray(new ProcessorRegistration[rr.size()]);
- }
-
- private Processor getInitializedProcessor(ProcessorRegistration registration) {
- Processor processor = registrationsToProcessors.get(registration);
- if (processor == null) {
- processor = registration.createAndInitializeProcessor(idsToLayers, this);
- registrationsToProcessors.put(registration, processor);
- }
- return processor;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/LayerInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/LayerInfo.java
deleted file mode 100644
index d997917..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/LayerInfo.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.layers.LayerId;
-
-public abstract class LayerInfo implements Comparable<LayerInfo> {
- private final LayerId id;
-
- private int ordinal = -1;
-
- public LayerInfo(LayerId id) {
- if (id == null) {
- throw new NullPointerException("id is null");
- }
- this.id = id;
- }
-
- @Override
- public int compareTo(LayerInfo o) {
- LayerInfo other = o;
- return getOrdinal() - other.getOrdinal();
- }
-
- public abstract Layer create();
-
- public LayerId getId() {
- return id;
- }
-
- public int getOrdinal() {
- if (ordinal < 0) {
- throw new IllegalStateException("Ordinal has not yet been set for layer " + id);
- }
- return ordinal;
- }
-
- public void initializeOrdinal(int ordinal) {
- if (this.ordinal >= 0) {
- throw new IllegalStateException("Ordinal has already been set for layer " + id);
- }
- this.ordinal = ordinal;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorFactory.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorFactory.java
deleted file mode 100644
index b0b5f04..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorFactory.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.configuration.Processor;
-
-public interface ProcessorFactory {
- Processor getInitializedProcessor(String id);
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorInfo.java
deleted file mode 100644
index 73ed367..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorInfo.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.configuration.Processor;
-
-import java.util.Set;
-
-public abstract class ProcessorInfo {
- private final String id;
- private final String version;
- private final String[] extensions;
- private final String[] usedProcessorIds;
-
- public ProcessorInfo(String id, String version, String contributorClass, String[] extensions,
- String[] usedProcessorIds) throws ConfigurationError {
- if (id == null) {
- throw new NullPointerException("id is null");
- }
- if (version == null) {
- throw new NullPointerException("version is null");
- }
- if (extensions == null) {
- throw new NullPointerException("extensions is null");
- }
- if (usedProcessorIds == null) {
- throw new NullPointerException("usedProcessorIds is null");
- }
- this.id = id;
- this.version = version;
- this.extensions = extensions;
- this.usedProcessorIds = usedProcessorIds;
- for (int i = 0; i < usedProcessorIds.length; i++) {
- if (usedProcessorIds[i].equals(id)) {
- throw new ConfigurationError(
- "Processor "
- + id
- + " tries to require itself, creating an endless entrophy loop and thus killing the Universe");
- }
- }
- }
-
- public abstract Processor create();
-
- public void describe(StringBuilder builder) {
- builder.append(id).append(' ').append(version);
- for (int i = 0; i < extensions.length; i++) {
- builder.append(" .").append(extensions[i]);
- }
- }
-
- public String[] getExtensions() {
- return extensions;
- }
-
- public String getId() {
- return id;
- }
-
- public String[] getUsedProcessorIds() {
- return usedProcessorIds;
- }
-
- public String getVersion() {
- return version;
- }
-
- public boolean mightBeInterestedIn(String extension) {
- for (int i = 0; i < extensions.length; i++) {
- if (extensions[i].equalsIgnoreCase(extension)) {
- return true;
- }
- }
- return false;
- }
-
- public void verify(Set<String> allProcessorIds) throws ConfigurationError {
- for (int i = 0; i < usedProcessorIds.length; i++) {
- if (!allProcessorIds.contains(usedProcessorIds[i])) {
- throw new ConfigurationError("Processor " + id + " require processor "
- + usedProcessorIds[i] + " which has not been registered.");
- }
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorRegistration.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorRegistration.java
deleted file mode 100644
index 1d7a136..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/configuration/internal/ProcessorRegistration.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.configuration.internal;
-
-import com.google.dart.indexer.index.configuration.ContributorWrapper;
-import com.google.dart.indexer.index.configuration.Processor;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.layers.LayerId;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-public class ProcessorRegistration implements Comparable<ProcessorRegistration> {
- private static ContributorInfo[] sort(ContributorInfo[] contributors) {
- ContributorInfo[] res = new ContributorInfo[contributors.length];
- System.arraycopy(contributors, 0, res, 0, contributors.length);
- Arrays.sort(res);
- return res;
- }
-
- private final ProcessorInfo processorInfo;
-
- private final ContributorInfo[] contributors;
-
- public ProcessorRegistration(ProcessorInfo processorInfo, ContributorInfo[] contributors) {
- this.processorInfo = processorInfo;
- this.contributors = sort(contributors);
- }
-
- @Override
- public int compareTo(ProcessorRegistration o) {
- ProcessorRegistration peer = o;
- return getId().compareTo(peer.getId());
- }
-
- public Processor createAndInitializeProcessor(Map<LayerId, Layer> idsToLayers,
- ProcessorFactory factory) {
- Processor processor = processorInfo.create();
- String[] usedIds = processorInfo.getUsedProcessorIds();
- Map<String, Processor> idsToProcessors = new HashMap<String, Processor>();
- for (int i = 0; i < usedIds.length; i++) {
- String id = usedIds[i];
- idsToProcessors.put(id, factory.getInitializedProcessor(id));
- }
- processor.initialize(createContributors(idsToLayers), idsToProcessors);
- return processor;
- }
-
- public void describe(StringBuilder builder) {
- processorInfo.describe(builder);
- for (int i = 0; i < contributors.length; i++) {
- builder.append("\n- ");
- contributors[i].describe(builder);
- }
- }
-
- public String getId() {
- return processorInfo.getId();
- }
-
- public boolean idEquals(String id) {
- return getId().equals(id);
- }
-
- public boolean mightBeInterestedIn(String extension) {
- return processorInfo.mightBeInterestedIn(extension);
- }
-
- public void verifyRegistration(Set<String> allProcessorIds) throws ConfigurationError {
- processorInfo.verify(allProcessorIds);
- }
-
- private ContributorWrapper[] createContributors(Map<LayerId, Layer> idsToLayers) {
- List<ContributorWrapper> contrs = new ArrayList<ContributorWrapper>();
- for (int i = 0; i < contributors.length; i++) {
- LayerId layerId = contributors[i].getLayerId();
- Layer layer = idsToLayers.get(layerId);
- if (layer == null) {
- throw new IllegalArgumentException("Layer with id " + layerId + " not found.");
- }
- contrs.add(new ContributorWrapper(contributors[i].create(), layer));
- }
- return contrs.toArray(new ContributorWrapper[contrs.size()]);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependencyPersistance.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependencyPersistance.java
deleted file mode 100644
index 1dad304..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependencyPersistance.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.locations.LocationPersitence;
-import com.google.dart.indexer.utils.PathUtils;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-public class DependencyPersistance {
- private static final char KIND_FILE = 'F';
-
- private static final char KIND_LOCATION = 'L';
-
- public static DependentEntity load(RandomAccessFile file, IndexConfigurationInstance configuration)
- throws IOException {
- char kind = file.readChar();
- if (kind == KIND_LOCATION) {
- Location dependentLocation = LocationPersitence.getInstance().load(file);
- Layer dependentLayer = configuration.getLayer(file.readInt());
- return new DependentLocation(dependentLocation, dependentLayer);
- } else if (kind == KIND_FILE) {
- IPath path = PathUtils.fromPortableString(file.readUTF());
- IFile dependentFile = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- return new DependentFileInfo(dependentFile);
- } else {
- throw new AssertionError("Unknown dependent entity code: " + kind);
- }
- }
-
- public static List<DependentEntity> loadDependencies(RandomAccessFile file,
- IndexConfigurationInstance configuration) throws IOException {
- int count = file.readInt();
- ArrayList<DependentEntity> result = new ArrayList<DependentEntity>();
- for (int i = 0; i < count; i++) {
- result.add(load(file, configuration));
- }
- return result;
- }
-
- public static void save(DependentEntity entity, RandomAccessFile file) throws IOException {
- if (entity instanceof DependentLocation) {
- DependentLocation dependency = (DependentLocation) entity;
- file.writeChar(KIND_LOCATION);
- LocationPersitence.getInstance().save(dependency.getDependentLocation(), file);
- file.writeInt(dependency.getDependentLayer().ordinal());
- } else if (entity instanceof DependentFileInfo) {
- DependentFileInfo dependency = (DependentFileInfo) entity;
- file.writeChar(KIND_FILE);
- file.writeUTF(PathUtils.toPortableString(dependency.getFile().getFullPath()));
- }
- }
-
- public static void saveDependencies(RandomAccessFile file,
- final Collection<DependentEntity> dependencies) throws IOException {
- file.writeInt(dependencies.size());
- for (Iterator<DependentEntity> iterator = dependencies.iterator(); iterator.hasNext();) {
- save(iterator.next(), file);
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentEntity.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentEntity.java
deleted file mode 100644
index 874c913..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentEntity.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-import java.util.Set;
-
-public interface DependentEntity {
- @Deprecated
- public boolean isStale(IFile staleFile, Set<Location> staleLocations);
-
- public boolean isStale(IndexableSource staleSource, Set<Location> staleLocations);
-
- public String toString(boolean showLayers);
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentFileInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentFileInfo.java
deleted file mode 100644
index d9958ba..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentFileInfo.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-import java.util.Set;
-
-public class DependentFileInfo implements DependentEntity {
- @Deprecated
- private IFile file;
- private IndexableSource source;
-
- @Deprecated
- public DependentFileInfo(IFile file) {
- if (file == null) {
- throw new NullPointerException("file is null");
- }
- this.file = file;
- }
-
- public DependentFileInfo(IndexableSource source) {
- if (source == null) {
- throw new NullPointerException("source is null");
- }
- this.source = source;
- }
-
- @Deprecated
- public IFile getFile() {
- return file;
- }
-
- public IndexableSource getSource() {
- return source;
- }
-
- @Override
- @Deprecated
- public boolean isStale(IFile staleFile, Set<Location> staleLocations) {
- return file.equals(staleFile);
- }
-
- @Override
- public boolean isStale(IndexableSource staleSource, Set<Location> staleLocations) {
- return source.equals(staleSource);
- }
-
- @Override
- public String toString(boolean showLayers) {
- if (source != null) {
- return "source " + source.getUri();
- }
- return "file " + file.getFullPath();
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentLocation.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentLocation.java
deleted file mode 100644
index 5633486..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/DependentLocation.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-import java.util.Set;
-
-public class DependentLocation implements DependentEntity {
- private final Location dependentLocation;
- private final Layer dependentLayer;
-
- public DependentLocation(Location dependentLocation, Layer dependentLayer) {
- this.dependentLocation = dependentLocation;
- this.dependentLayer = dependentLayer;
- if (dependentLocation == null) {
- throw new NullPointerException("dependentLocation is null");
- }
- if (dependentLayer == null) {
- throw new NullPointerException("dependentLayer is null");
- }
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final DependentLocation other = (DependentLocation) obj;
- if (dependentLayer == null) {
- if (other.dependentLayer != null) {
- return false;
- }
- } else if (!dependentLayer.equals(other.dependentLayer)) {
- return false;
- }
- if (dependentLocation == null) {
- if (other.dependentLocation != null) {
- return false;
- }
- } else if (!dependentLocation.equals(other.dependentLocation)) {
- return false;
- }
- return true;
- }
-
- public Layer getDependentLayer() {
- return dependentLayer;
- }
-
- public Location getDependentLocation() {
- return dependentLocation;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((dependentLayer == null) ? 0 : dependentLayer.hashCode());
- result = prime * result + ((dependentLocation == null) ? 0 : dependentLocation.hashCode());
- return result;
- }
-
- @Override
- @Deprecated
- public boolean isStale(IFile staleFile, Set<Location> staleLocations) {
- return staleLocations.contains(dependentLocation);
- }
-
- @Override
- public boolean isStale(IndexableSource staleSource, Set<Location> staleLocations) {
- return staleLocations.contains(dependentLocation);
- }
-
- @Override
- public String toString() {
- return "(" + dependentLocation + "; " + dependentLayer + ")";
- }
-
- @Override
- public String toString(boolean showLayers) {
- if (showLayers) {
- return dependentLocation + " @ " + dependentLayer;
- } else {
- return dependentLocation + "";
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/FileInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/FileInfo.java
deleted file mode 100644
index bdf61a4..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/FileInfo.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.locations.LocationPersitence;
-import com.google.dart.indexer.source.IndexableSource;
-import com.google.dart.indexer.utils.Debugging;
-import com.google.dart.indexer.utils.PathUtils;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Represents the information about a specific indexed file. Currently this is a list of source
- * locations (the locations defined in this file), and a list of destination locations (the
- * locations that the locations in this file are connected to).
- */
-public class FileInfo {
- private static final String BASE_SIGNATURE = "FileInfo1";
-
- // Different representations of paths are used on different versions of Eclipse, so the signatures
- // must be different too.
-
- private static final String SIGNATURE = BASE_SIGNATURE;
-
- public static FileInfo load(RandomAccessFile file, IndexConfigurationInstance configuration)
- throws IOException {
- List<Location> sourceLocations = LocationPersitence.loadLocations(file);
- List<DependentEntity> internalDependencies = DependencyPersistance.loadDependencies(file,
- configuration);
- List<DependentEntity> externalDependencies = DependencyPersistance.loadDependencies(file,
- configuration);
- return new FileInfo(sourceLocations, internalDependencies, externalDependencies);
- }
-
- public static PathAndModStamp readHeader(RandomAccessFile file) throws IOException {
- String signature = file.readUTF();
- if (!signature.equals(SIGNATURE)) {
- throw new IOException("Incorrect FileInfo signature");
- }
- String path = file.readUTF();
- long modificationStamp = file.readLong();
- return new PathAndModStamp(path, modificationStamp);
- }
-
- public static IPath readHeaderAsPath(RandomAccessFile ra) throws IOException {
- return PathUtils.fromPortableString(readHeader(ra).getPath());
- }
-
- // private long version;
-
- public static String readHeaderPath(RandomAccessFile file) throws IOException {
- String signature = file.readUTF();
- if (!signature.equals(SIGNATURE)) {
- throw new IOException("Incorrect FileInfo signature");
- }
- String path = file.readUTF();
- return path;
- }
-
- /**
- * @deprecated use {@link #writeHeader(RandomAccessFile, IndexableSource)}
- */
- @Deprecated
- public static void writeHeader(RandomAccessFile ra, IFile file) throws IOException {
- ra.writeUTF(SIGNATURE);
- ra.writeUTF(PathUtils.toPortableString(file.getFullPath()));
- ra.writeLong(file.getModificationStamp());
- }
-
- public static void writeHeader(RandomAccessFile ra, IndexableSource source) throws IOException {
- ra.writeUTF(SIGNATURE);
- ra.writeUTF(source.getUri().toString());
- ra.writeLong(source.getModificationStamp());
- }
-
- private final Collection<DependentEntity> internalDependencies = new ArrayList<DependentEntity>();
-
- private final Collection<DependentEntity> externalDependencies = new ArrayList<DependentEntity>();
-
- private final Collection<Location> sourceLocations = new ArrayList<Location>();
-
- public FileInfo() {
- }
-
- public FileInfo(Collection<Location> sourceLocations,
- Collection<DependentEntity> internalDependencies,
- Collection<DependentEntity> externalDependencies) {
- this.internalDependencies.addAll(internalDependencies);
- this.externalDependencies.addAll(externalDependencies);
- this.sourceLocations.addAll(sourceLocations);
- }
-
- public void addDependency(DependentEntity dependency, boolean internal) {
- if (dependency == null) {
- throw new NullPointerException("dependency is null");
- }
- (internal ? this.internalDependencies : this.externalDependencies).add(dependency);
- }
-
- public void addSourceLocation(Location location) {
- sourceLocations.add(location);
- }
-
- public void clearInternalDependencies() {
- internalDependencies.clear();
- }
-
- public Collection<DependentEntity> getExternalDependencies() {
- return externalDependencies;
- }
-
- public Collection<DependentEntity> getInternalDependencies() {
- return internalDependencies;
- }
-
- public Collection<Location> getSourceLocations() {
- return sourceLocations;
- }
-
- public void save(RandomAccessFile file) throws IOException {
- LocationPersitence.saveLocations(file, sourceLocations);
- DependencyPersistance.saveDependencies(file, internalDependencies);
- DependencyPersistance.saveDependencies(file, externalDependencies);
- }
-
- public void setExternalDependencies(Collection<DependentEntity> externalDependencies) {
- this.externalDependencies.clear();
- this.externalDependencies.addAll(externalDependencies);
- }
-
- public void setSourceLocations(Set<Location> sourceLocations) {
- this.sourceLocations.clear();
- this.sourceLocations.addAll(sourceLocations);
- }
-
- public void setVersion(long version) {
- // this.version=version;
- }
-
- @Override
- public String toString() {
- StringBuilder out = new StringBuilder();
- toString(out, "", true);
- return out.toString();
- }
-
- public void toString(StringBuilder out, String indent, boolean showLayers) {
- toStringDependencies(out, indent, showLayers, internalDependencies, "dependent(s)");
- if (externalDependencies.size() > 0) {
- toStringDependencies(out, indent, showLayers, externalDependencies,
- "externally contributed dependent(s)");
- }
- out.append(indent).append(sourceLocations.size()).append(" source location(s)\n");
- for (Iterator<Location> iterator = Debugging.sortByStrings1(sourceLocations).iterator(); iterator.hasNext();) {
- Location location = iterator.next();
- out.append(indent).append(Debugging.INDENT).append(location).append("\n");
- }
- }
-
- private void toStringDependencies(StringBuilder out, String indent, boolean showLayers,
- Collection<DependentEntity> dependencies, String caption) {
- out.append(indent).append(dependencies.size()).append(" " + caption + "\n");
- for (Iterator<DependentEntity> iterator = Debugging.sortByStrings(dependencies).iterator(); iterator.hasNext();) {
- DependentEntity entity = iterator.next();
- out.append(indent).append(Debugging.INDENT).append(entity.toString(showLayers)).append("\n");
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/LocationInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/LocationInfo.java
deleted file mode 100644
index 7e9e9b6..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/LocationInfo.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.locations.Location;
-
-import java.util.Set;
-
-public interface LocationInfo {
- void adjustDueToRemovalOf(Set<Location> locations);
-
- Location[] getLocationsAffectedByRemovalOfSelf();
-
- boolean isEmpty();
-
- void toString(StringBuilder result, String indent);
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/LocationInfoHeaders.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/LocationInfoHeaders.java
deleted file mode 100644
index ff0e72d..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/LocationInfoHeaders.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.locations.LocationPersitence;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-public class LocationInfoHeaders {
- private static final String SIGNATURE = "LocationInfo1";
-
- public static String readHeader(RandomAccessFile file) throws IOException {
- String signature = file.readUTF();
- if (!signature.equals(SIGNATURE)) {
- throw new IOException("Incorrect LocationInfo signature");
- }
- String locationId = file.readUTF();
- return locationId;
- }
-
- public static Location readHeaderAsLocation(RandomAccessFile file) throws IOException {
- return LocationPersitence.getInstance().byUniqueIdentifier(readHeader(file));
- }
-
- public static void writeHeader(RandomAccessFile file, Location location) throws IOException {
- file.writeUTF(SIGNATURE);
- file.writeUTF(LocationPersitence.getInstance().getUniqueIdentifier(location));
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/PathAndModStamp.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/PathAndModStamp.java
deleted file mode 100644
index 4702c4b..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/entries/PathAndModStamp.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.entries;
-
-/**
- * Combines a file path and a corresponding modification stamp, as defined by
- * <code>IResource.getModificationStamp</code>.
- */
-public class PathAndModStamp {
- private final String path;
- private final long modificationStamp;
-
- public PathAndModStamp(String path, long modificationStamp) {
- this.path = path;
- this.modificationStamp = modificationStamp;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- PathAndModStamp other = (PathAndModStamp) obj;
- if (modificationStamp != other.modificationStamp) {
- return false;
- }
- if (path == null) {
- if (other.path != null) {
- return false;
- }
- } else if (!path.equals(other.path)) {
- return false;
- }
- return true;
- }
-
- public long getModificationStamp() {
- return modificationStamp;
- }
-
- public String getPath() {
- return path;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + (int) (modificationStamp ^ (modificationStamp >>> 32));
- result = prime * result + ((path == null) ? 0 : path.hashCode());
- return result;
- }
-
- @Override
- public String toString() {
- return path + ":" + modificationStamp;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/Layer.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/Layer.java
deleted file mode 100644
index e04b14d..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/Layer.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers;
-
-import com.google.dart.indexer.index.configuration.internal.LayerInfo;
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.updating.LayerUpdater;
-import com.google.dart.indexer.storage.FileTransaction;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-public abstract class Layer {
- private LayerInfo layerInfo;
-
- private int ordinal;
-
- public abstract LocationInfo createEmptyLocationInfo();
-
- public abstract LayerUpdater createLayerUpdater(FileTransaction fileTransaction);
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final Layer other = (Layer) obj;
- if (ordinal != other.ordinal) {
- return false;
- }
- return true;
- }
-
- public LayerId getId() {
- return layerInfo.getId();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ordinal;
- return result;
- }
-
- public void initialize(LayerInfo layerInfo) {
- this.layerInfo = layerInfo;
- ordinal = layerInfo.getOrdinal();
- }
-
- public abstract boolean isBidirectional();
-
- public abstract LocationInfo loadLocationInfo(RandomAccessFile ra) throws IOException;
-
- public int ordinal() {
- return layerInfo.getOrdinal();
- }
-
- public abstract void save(LocationInfo info, RandomAccessFile ra) throws IOException;
-
- @Override
- public String toString() {
- String id = layerInfo.getId().stringValue();
- int pos = id.lastIndexOf('.');
- if (pos > 0) {
- return id.substring(pos + 1);
- } else {
- return id;
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/LayerId.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/LayerId.java
deleted file mode 100644
index ce333c5..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/LayerId.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers;
-
-public class LayerId {
- private final String id;
-
- public LayerId(String id) {
- if (id == null) {
- throw new NullPointerException("id is null");
- }
- this.id = id;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- final LayerId other = (LayerId) obj;
- if (id == null) {
- if (other.id != null) {
- return false;
- }
- } else if (!id.equals(other.id)) {
- return false;
- }
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((id == null) ? 0 : id.hashCode());
- return result;
- }
-
- public String stringValue() {
- return id;
- }
-
- @Override
- public String toString() {
- return id;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayer.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayer.java
deleted file mode 100644
index eea1c48..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.LayerUpdater;
-import com.google.dart.indexer.storage.FileTransaction;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-public class BidirectionalEdgesLayer extends Layer {
- @Override
- public LocationInfo createEmptyLocationInfo() {
- return new BidirectionalEdgesLocationInfo();
- }
-
- @Override
- public LayerUpdater createLayerUpdater(FileTransaction fileTransaction) {
- return new BidirectionalEdgesLayerUpdater(fileTransaction, this);
- }
-
- @Override
- public boolean isBidirectional() {
- return true;
- }
-
- @Override
- public LocationInfo loadLocationInfo(RandomAccessFile ra) throws IOException {
- return BidirectionalEdgesLocationInfo.load(ra);
- }
-
- @Override
- public void save(LocationInfo info, RandomAccessFile ra) throws IOException {
- ((BidirectionalEdgesLocationInfo) info).save(ra);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerForwardEdgesQuery.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerForwardEdgesQuery.java
deleted file mode 100644
index e51bf05..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerForwardEdgesQuery.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.queries.Query;
-import com.google.dart.indexer.index.readonly.Index;
-import com.google.dart.indexer.locations.Location;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-
-public class BidirectionalEdgesLayerForwardEdgesQuery implements Query {
- private final Location location;
- private Location[] sources;
- private final Layer layer;
-
- public BidirectionalEdgesLayerForwardEdgesQuery(Location location, Layer layer) {
- if (location == null) {
- throw new NullPointerException("location is null");
- }
- this.location = location;
- this.layer = layer;
- }
-
- @Override
- public void executeUsing(Index index) throws IndexTemporarilyNonOperational,
- IndexRequiresFullRebuild {
- BidirectionalEdgesLocationInfo info = (BidirectionalEdgesLocationInfo) index.getLocationInfo(
- location, layer);
- if (info == null) {
- sources = Location.EMPTY_ARRAY;
- } else {
- sources = info.getDestinationLocations();
- }
- }
-
- @Override
- public IProject getContainingProject() {
- IFile file = location.getContainingFile();
- if (file == null) {
- return null;
- } else {
- return file.getProject();
- }
- }
-
- public Location[] getDestinations() {
- return sources;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerReverseEdgesQuery.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerReverseEdgesQuery.java
deleted file mode 100644
index 8941775..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerReverseEdgesQuery.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.layers.reverse_edges.ReverseEdgesLocationInfo;
-import com.google.dart.indexer.index.queries.Query;
-import com.google.dart.indexer.index.readonly.Index;
-import com.google.dart.indexer.locations.Location;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-
-public class BidirectionalEdgesLayerReverseEdgesQuery implements Query {
- private final Location location;
- private Location[] sources;
- private final Layer layer;
-
- public BidirectionalEdgesLayerReverseEdgesQuery(Location location, Layer layer) {
- if (location == null) {
- throw new NullPointerException("location is null");
- }
- this.location = location;
- this.layer = layer;
- }
-
- @Override
- public void executeUsing(Index index) throws IndexTemporarilyNonOperational,
- IndexRequiresFullRebuild {
- LocationInfo info = index.getLocationInfo(location, layer);
- if (info instanceof ReverseEdgesLocationInfo) {
- sources = ((ReverseEdgesLocationInfo) info).getSourceLocations();
- } else if (info instanceof BidirectionalEdgesLocationInfo) {
- sources = ((BidirectionalEdgesLocationInfo) info).getSourceLocations();
- } else {
- sources = Location.EMPTY_ARRAY;
- }
- }
-
- @Override
- public IProject getContainingProject() {
- IFile file = location.getContainingFile();
- if (file == null) {
- return null;
- } else {
- return file.getProject();
- }
- }
-
- public Location[] getSources() {
- return sources;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerUpdater.java
deleted file mode 100644
index bf714a9..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLayerUpdater.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.LayerUpdater;
-import com.google.dart.indexer.index.updating.LocationUpdater;
-import com.google.dart.indexer.index.updating.PerLocationDependenciesBuilder;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.storage.FileTransaction;
-
-public class BidirectionalEdgesLayerUpdater implements LayerUpdater {
- private final FileTransaction fileTransaction;
- private final Layer layer;
-
- public BidirectionalEdgesLayerUpdater(FileTransaction fileTransaction, Layer layer) {
- if (fileTransaction == null) {
- throw new NullPointerException("fileTransaction is null");
- }
- if (layer == null) {
- throw new NullPointerException("layer is null");
- }
- this.fileTransaction = fileTransaction;
- this.layer = layer;
- }
-
- @Override
- public LocationUpdater startLocation(Location location) throws IndexRequestFailed {
- fileTransaction.addSourceLocation(location);
-
- return new BidirectionalEdgesLocationUpdaterImpl(fileTransaction, location, layer,
- new PerLocationDependenciesBuilder(location, layer, fileTransaction));
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationInfo.java
deleted file mode 100644
index 9f9cec3..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationInfo.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.locations.LocationPersitence;
-import com.google.dart.indexer.utils.Debugging;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * Represents the information of a specific location that is stored in the index. Currently this is
- * a list of source locations that are connected to this location.
- */
-public class BidirectionalEdgesLocationInfo implements LocationInfo {
- public static BidirectionalEdgesLocationInfo load(RandomAccessFile file) throws IOException {
- BidirectionalEdgesLocationInfo result = new BidirectionalEdgesLocationInfo();
- result.setSourceLocations(LocationPersitence.loadLocations(file));
- result.setDestinationLocations(LocationPersitence.loadLocations(file));
- return result;
- }
-
- private Collection<Location> sourceLocations = new ArrayList<Location>();
-
- private Collection<Location> destinationLocations = new ArrayList<Location>();
-
- public BidirectionalEdgesLocationInfo() {
- sourceLocations = new ArrayList<Location>();
- destinationLocations = new ArrayList<Location>();
- }
-
- public BidirectionalEdgesLocationInfo(Collection<Location> source,
- Collection<Location> destination) {
- this.sourceLocations = source;
- this.destinationLocations = destination;
- }
-
- public void addDestinationLocation(Location location) {
- if (destinationLocations == Collections.EMPTY_LIST) {
- destinationLocations = new ArrayList<Location>();
- }
- destinationLocations.add(location);
- }
-
- public void addSourceLocation(Location location) {
- if (sourceLocations == Collections.EMPTY_LIST) {
- sourceLocations = new ArrayList<Location>();
- }
- sourceLocations.add(location);
- }
-
- @Override
- public void adjustDueToRemovalOf(Set<Location> locations) {
- removeSourceLocations(locations);
- Set<Location> sourceLocationsSet = new HashSet<Location>(destinationLocations);
- sourceLocationsSet.removeAll(locations);
- destinationLocations.clear();
- destinationLocations.addAll(sourceLocationsSet);
- }
-
- public Location[] getDestinationLocations() {
- return destinationLocations.toArray(new Location[destinationLocations.size()]);
- }
-
- @Override
- public Location[] getLocationsAffectedByRemovalOfSelf() {
- ArrayList<Location> result = new ArrayList<Location>();
- result.addAll(sourceLocations);
- result.addAll(destinationLocations);
- return result.toArray(new Location[result.size()]);
- }
-
- public Location[] getSourceLocations() {
- return sourceLocations.toArray(new Location[sourceLocations.size()]);
- }
-
- @Override
- public boolean isEmpty() {
- return sourceLocations.isEmpty() && destinationLocations.isEmpty();
- }
-
- public void removeSourceLocations(Set<Location> locationsToRemove) {
- Set<Location> sourceLocationsSet = new HashSet<Location>(sourceLocations);
-
- sourceLocationsSet.removeAll(locationsToRemove);
- sourceLocations.clear();
- sourceLocations.addAll(sourceLocationsSet);
- }
-
- public void save(RandomAccessFile file) throws IOException {
- LocationPersitence.saveLocations(file, sourceLocations);
- LocationPersitence.saveLocations(file, destinationLocations);
- }
-
- @Override
- public String toString() {
- StringBuilder out = new StringBuilder();
- toString(out, "");
- return out.toString();
- }
-
- @Override
- public void toString(StringBuilder out, String indent) {
- out.append(indent).append(sourceLocations.size()).append(" source location(s)\n");
- for (Iterator<Location> iterator = Debugging.sortByStrings(sourceLocations).iterator(); iterator.hasNext();) {
- Location location = iterator.next();
- out.append(indent).append(Debugging.INDENT).append(location).append("\n");
- }
- out.append(indent).append(destinationLocations.size()).append(" destination location(s)\n");
- for (Iterator<Location> iterator = Debugging.sortByStrings(destinationLocations).iterator(); iterator.hasNext();) {
- Location location = iterator.next();
- out.append(indent).append(Debugging.INDENT).append(location).append("\n");
- }
- }
-
- private void setDestinationLocations(Collection<Location> locations) {
- destinationLocations.clear();
- destinationLocations.addAll(locations);
- }
-
- private void setSourceLocations(Collection<Location> locations) {
- sourceLocations.clear();
- sourceLocations.addAll(locations);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationUpdater.java
deleted file mode 100644
index 18c7886..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationUpdater.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.locations.Location;
-
-public interface BidirectionalEdgesLocationUpdater {
- void hasReferenceTo(Location location) throws IndexRequestFailed;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationUpdaterImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationUpdaterImpl.java
deleted file mode 100644
index f18d9a0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/bidirectional_edges/BidirectionalEdgesLocationUpdaterImpl.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.bidirectional_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.DependenciesBuilder;
-import com.google.dart.indexer.index.updating.LocationUpdater;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.storage.FileTransaction;
-
-import org.eclipse.core.resources.IFile;
-
-public class BidirectionalEdgesLocationUpdaterImpl implements LocationUpdater {
- private final Location sourceLocation;
- private final Layer layer;
- private final DependenciesBuilder dependenciesBuilder;
- private final FileTransaction fileTransaction;
-
- public BidirectionalEdgesLocationUpdaterImpl(FileTransaction fileTransaction,
- Location sourceLocation, Layer layer, DependenciesBuilder dependenciesBuilder) {
- this.fileTransaction = fileTransaction;
- this.sourceLocation = sourceLocation;
- this.layer = layer;
- this.dependenciesBuilder = dependenciesBuilder;
- }
-
- @Override
- public Location getSourceLocation() {
- return sourceLocation;
- }
-
- @Override
- public void hasReferenceTo(Location destinationLocation) throws IndexRequestFailed {
- dependenciesBuilder.currentFileAffectsLocationOfCurrentLayer(destinationLocation);
- IFile destinationFile = destinationLocation.getContainingFile();
- if (destinationFile != null) {
- dependenciesBuilder.currentLocationDependsOnFile(destinationFile);
- }
-
- fileTransaction.addReference(layer, sourceLocation, destinationLocation);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLayer.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLayer.java
deleted file mode 100644
index 3c376f0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLayer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.reverse_edges;
-
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.LayerUpdater;
-import com.google.dart.indexer.storage.FileTransaction;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-public class ReverseEdgesLayer extends Layer {
- @Override
- public LocationInfo createEmptyLocationInfo() {
- return new ReverseEdgesLocationInfo();
- }
-
- @Override
- public LayerUpdater createLayerUpdater(FileTransaction fileTransaction) {
- return new ReverseEdgesLayerUpdater(fileTransaction, this);
- }
-
- @Override
- public boolean isBidirectional() {
- return false;
- }
-
- @Override
- public LocationInfo loadLocationInfo(RandomAccessFile ra) throws IOException {
- return ReverseEdgesLocationInfo.load(ra);
- }
-
- @Override
- public void save(LocationInfo info, RandomAccessFile ra) throws IOException {
- ((ReverseEdgesLocationInfo) info).save(ra);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLayerUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLayerUpdater.java
deleted file mode 100644
index 4a54b48..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLayerUpdater.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.reverse_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.LayerUpdater;
-import com.google.dart.indexer.index.updating.LocationUpdater;
-import com.google.dart.indexer.index.updating.PerLocationDependenciesBuilder;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.storage.FileTransaction;
-
-public class ReverseEdgesLayerUpdater implements LayerUpdater {
- private final Layer layer;
- private final FileTransaction fileTransaction;
-
- public ReverseEdgesLayerUpdater(FileTransaction fileTransaction, Layer layer) {
- if (fileTransaction == null) {
- throw new NullPointerException("fileTransaction is null");
- }
- if (layer == null) {
- throw new NullPointerException("layer is null");
- }
- this.fileTransaction = fileTransaction;
- this.layer = layer;
- }
-
- @Override
- public LocationUpdater startLocation(final Location location) throws IndexRequestFailed {
- fileTransaction.addSourceLocation(location);
- return new ReverseEdgesLocationUpdaterImpl(fileTransaction, location, layer,
- new PerLocationDependenciesBuilder(location, layer, fileTransaction));
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationInfo.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationInfo.java
deleted file mode 100644
index a9acace..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationInfo.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.reverse_edges;
-
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.locations.LocationPersitence;
-import com.google.dart.indexer.utils.Debugging;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * Represents the information of a specific location that is stored in the index. Currently this is
- * a list of source locations that are connected to this location.
- */
-public class ReverseEdgesLocationInfo implements LocationInfo {
- public static ReverseEdgesLocationInfo load(RandomAccessFile file) throws IOException {
- ReverseEdgesLocationInfo result = new ReverseEdgesLocationInfo();
- result.setSourceLocations(LocationPersitence.loadLocations(file));
- return result;
- }
-
- private Collection<Location> sourceLocations;
-
- public ReverseEdgesLocationInfo() {
- sourceLocations = new ArrayList<Location>();
- }
-
- public ReverseEdgesLocationInfo(Collection<Location> source) {
- sourceLocations = source;
- }
-
- public void addSourceLocation(Location location) {
- if (sourceLocations == Collections.EMPTY_LIST) {
- sourceLocations = new ArrayList<Location>();
- }
- sourceLocations.add(location);
- }
-
- @Override
- public void adjustDueToRemovalOf(Set<Location> locations) {
- removeSourceLocations(locations);
- }
-
- @Override
- public Location[] getLocationsAffectedByRemovalOfSelf() {
- return getSourceLocations();
- }
-
- public Location[] getSourceLocations() {
- return sourceLocations.toArray(new Location[sourceLocations.size()]);
- }
-
- @Override
- public boolean isEmpty() {
- return sourceLocations.isEmpty();
- }
-
- public void removeSourceLocations(Set<Location> locationsToRemove) {
- Set<Location> sourceLocationsSet = new HashSet<Location>(sourceLocations);
-
- sourceLocationsSet.removeAll(locationsToRemove);
- sourceLocations.clear();
- sourceLocations.addAll(sourceLocationsSet);
- }
-
- public void save(RandomAccessFile file) throws IOException {
- LocationPersitence.saveLocations(file, sourceLocations);
- }
-
- @Override
- public String toString() {
- StringBuilder out = new StringBuilder();
- toString(out, "");
- return out.toString();
- }
-
- @Override
- public void toString(StringBuilder out, String indent) {
- out.append(indent).append(sourceLocations.size()).append(" source location(s)\n");
- for (Iterator<Location> iterator = Debugging.sortByStrings(sourceLocations).iterator(); iterator.hasNext();) {
- Location location = iterator.next();
- out.append(indent).append(Debugging.INDENT).append(location).append("\n");
- }
- }
-
- private void setSourceLocations(Collection<Location> locations) {
- sourceLocations.clear();
- sourceLocations.addAll(locations);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationUpdater.java
deleted file mode 100644
index 6f698bd..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationUpdater.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.reverse_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.locations.Location;
-
-public interface ReverseEdgesLocationUpdater {
- void hasReferenceTo(Location location) throws IndexRequestFailed;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationUpdaterImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationUpdaterImpl.java
deleted file mode 100644
index 49a86b2..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesLocationUpdaterImpl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.reverse_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.updating.DependenciesBuilder;
-import com.google.dart.indexer.index.updating.LocationUpdater;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.storage.FileTransaction;
-
-public class ReverseEdgesLocationUpdaterImpl implements LocationUpdater {
- private final Location sourceLocation;
- private final Layer layer;
- private final DependenciesBuilder dependenciesBuilder;
- private final FileTransaction fileTransaction;
-
- public ReverseEdgesLocationUpdaterImpl(FileTransaction fileTransaction, Location sourceLocation,
- Layer layer, DependenciesBuilder dependenciesBuilder) {
- this.fileTransaction = fileTransaction;
- this.sourceLocation = sourceLocation;
- this.layer = layer;
- this.dependenciesBuilder = dependenciesBuilder;
- }
-
- @Override
- public Location getSourceLocation() {
- return sourceLocation;
- }
-
- @Override
- public void hasReferenceTo(Location destinationLocation) throws IndexRequestFailed {
- fileTransaction.addReference(layer, sourceLocation, destinationLocation);
- dependenciesBuilder.currentFileAffectsLocationOfCurrentLayer(destinationLocation);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesQuery.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesQuery.java
deleted file mode 100644
index 66a1446..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/layers/reverse_edges/ReverseEdgesQuery.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.layers.reverse_edges;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.queries.Query;
-import com.google.dart.indexer.index.readonly.Index;
-import com.google.dart.indexer.locations.Location;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-
-public class ReverseEdgesQuery implements Query {
- private final Location location;
- private Location[] sources;
- private final Layer layer;
-
- public ReverseEdgesQuery(Location location, Layer layer) {
- if (location == null) {
- throw new NullPointerException("location is null");
- }
- this.location = location;
- this.layer = layer;
- }
-
- @Override
- public void executeUsing(Index index) throws IndexTemporarilyNonOperational,
- IndexRequiresFullRebuild {
- ReverseEdgesLocationInfo info = (ReverseEdgesLocationInfo) index.getLocationInfo(location,
- layer);
- if (info == null) {
- sources = Location.EMPTY_ARRAY;
- } else {
- sources = info.getSourceLocations();
- }
- }
-
- @Override
- public IProject getContainingProject() {
- IFile file = location.getContainingFile();
- if (file == null) {
- return null;
- } else {
- return file.getProject();
- }
- }
-
- public Location[] getSources() {
- return sources;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/queries/DummyQuery.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/queries/DummyQuery.java
deleted file mode 100644
index 9c18da3..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/queries/DummyQuery.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.queries;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.readonly.Index;
-
-import org.eclipse.core.resources.IProject;
-
-public class DummyQuery implements Query {
- @Override
- public void executeUsing(Index index) throws IndexTemporarilyNonOperational,
- IndexRequiresFullRebuild {
- }
-
- @Override
- public IProject getContainingProject() {
- return null;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/queries/Query.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/queries/Query.java
deleted file mode 100644
index 960f73c..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/queries/Query.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.queries;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.index.readonly.Index;
-
-import org.eclipse.core.resources.IProject;
-
-public interface Query {
- void executeUsing(Index index) throws IndexTemporarilyNonOperational, IndexRequiresFullRebuild;
-
- IProject getContainingProject();
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/DiskBackedIndexImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/DiskBackedIndexImpl.java
deleted file mode 100644
index b542d88..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/DiskBackedIndexImpl.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*
- * Copyright (c) 2012, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.readonly;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.index.configuration.IndexConfigurationInstance;
-import com.google.dart.indexer.index.entries.FileInfo;
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.entries.PathAndModStamp;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-import com.google.dart.indexer.storage.AbstractIntegratedStorage;
-import com.google.dart.indexer.utils.Debugging;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Map;
-
-public class DiskBackedIndexImpl implements Index {
- private IPath[] errors;
-
- private final IndexConfigurationInstance configuration;
-
- private AbstractIntegratedStorage storage;
-
- public DiskBackedIndexImpl(IndexConfigurationInstance configuration,
- AbstractIntegratedStorage storage) {
- this.configuration = configuration;
- // errors = ErrorFile.read(folder, configuration);
- errors = new IPath[0];
- this.storage = storage;
- }
-
- @Override
- public String diskIndexAsString() throws IOException {
- Layer[] layers = configuration.getLayers();
-
- StringBuilder result = new StringBuilder();
- if (layers.length == 1) {
- toStringLocations(storage.readAllLayerLocations(layers[0]), result);
- } else {
- for (int i = 0; i < layers.length; i++) {
- result.append("=== LAYER ").append(i).append(" ===\n");
- toStringLocations(storage.readAllLayerLocations(layers[i]), result);
- }
- }
- toStringFiles(storage.readAllFileInfos(configuration), result, (layers.length > 1));
- return result.toString();
- }
-
- @Override
- public IPath[] getFilesWithErrors() {
- return errors.clone();
- }
-
- @Override
- public LocationInfo getLocationInfo(Location location, Layer layer)
- throws IndexRequiresFullRebuild {
- return storage.readLocationInfo(location, layer);
- }
-
- @Override
- public AbstractIntegratedStorage getUnderlyingStorage() {
- return storage;
- }
-
- @Override
- public boolean hasErrors() {
- return errors.length != 0;
- }
-
- @Override
- public PathAndModStamp[] loadAllFileHeaders() throws IOException {
- return storage.readFileNamesAndStamps(new HashSet<IFile>());
- }
-
- @Override
- public String toString() {
- try {
- return diskIndexAsString();
- } catch (IOException exception) {
- IndexerPlugin.getLogger().logError(exception);
-
- StringWriter writer = new StringWriter();
- exception.printStackTrace(new PrintWriter(writer));
- return writer.toString();
- }
- }
-
- @Deprecated
- private void toStringFiles(Map<IFile, FileInfo> map, StringBuilder out, boolean showLayers) {
- out.append("Files:\n");
- for (Iterator<IFile> iterator = Debugging.sortByStrings(map.keySet()).iterator(); iterator.hasNext();) {
- IFile file = iterator.next();
- FileInfo info = map.get(file);
- out.append(Debugging.INDENT).append(file).append("\n");
- info.toString(out, Debugging.INDENT + Debugging.INDENT, showLayers);
- }
- }
-
- private void toStringLocations(Map<Location, LocationInfo> map, StringBuilder out) {
- out.append("Locations:\n");
- for (Iterator<Location> iterator = Debugging.sortByStrings(map.keySet()).iterator(); iterator.hasNext();) {
- Location location = iterator.next();
- LocationInfo info = map.get(location);
- out.append(Debugging.INDENT).append(location).append("\n");
- info.toString(out, Debugging.INDENT + Debugging.INDENT);
- }
- }
-
- @SuppressWarnings("unused")
- private void toStringSources(Map<IndexableSource, FileInfo> map, StringBuilder out,
- boolean showLayers) {
- out.append("Sources:\n");
- for (Iterator<IndexableSource> iterator = Debugging.sortByStrings(map.keySet()).iterator(); iterator.hasNext();) {
- IndexableSource source = iterator.next();
- FileInfo info = map.get(source);
- out.append(Debugging.INDENT).append(source).append("\n");
- info.toString(out, Debugging.INDENT + Debugging.INDENT, showLayers);
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/EmptyIndexImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/EmptyIndexImpl.java
deleted file mode 100644
index b6c1d8f..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/EmptyIndexImpl.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.readonly;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.entries.PathAndModStamp;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.storage.AbstractIntegratedStorage;
-
-import org.eclipse.core.runtime.IPath;
-
-import java.io.IOException;
-
-/**
- * Represents an empty read-only index. It might be substituted for a real index when there no
- * suitable real index exists.
- */
-public class EmptyIndexImpl implements Index {
- private AbstractIntegratedStorage storage;
-
- public EmptyIndexImpl(AbstractIntegratedStorage storage) {
- this.storage = storage;
- }
-
- @Override
- public String diskIndexAsString() throws IOException {
- return "<Empty>";
- }
-
- @Override
- public IPath[] getFilesWithErrors() {
- return new IPath[0];
- }
-
- @Override
- public LocationInfo getLocationInfo(Location location, Layer layer)
- throws IndexRequiresFullRebuild {
- return null;
- }
-
- @Override
- public AbstractIntegratedStorage getUnderlyingStorage() {
- return storage;
- }
-
- @Override
- public boolean hasErrors() {
- return false;
- }
-
- @Override
- public PathAndModStamp[] loadAllFileHeaders() throws IOException {
- return new PathAndModStamp[0];
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/Index.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/Index.java
deleted file mode 100644
index 98f443b..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/readonly/Index.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.readonly;
-
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.index.entries.LocationInfo;
-import com.google.dart.indexer.index.entries.PathAndModStamp;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.storage.AbstractIntegratedStorage;
-
-import org.eclipse.core.runtime.IPath;
-
-import java.io.IOException;
-
-/**
- * Represents an object that manages a read-only index.
- */
-public interface Index {
- /**
- * @return list of files which may be indexed with errors
- */
- public IPath[] getFilesWithErrors();
-
- /**
- * @return true if index may be inconsistent
- */
- public boolean hasErrors();
-
- /**
- * Returns a string representation of the entire index contents stored on the hard drive. This
- * method is intended to be used from tests.
- */
- String diskIndexAsString() throws IOException;
-
- /**
- * Loads and returns the information about the specified location.
- *
- * @param layer
- * @return The information about the location if the one is found in the index, <code>null</code>
- * otherwise.
- */
- LocationInfo getLocationInfo(Location location, Layer layer) throws IndexRequiresFullRebuild;
-
- AbstractIntegratedStorage getUnderlyingStorage();
-
- /**
- * Loads and returns the information about every indexed file.
- */
- PathAndModStamp[] loadAllFileHeaders() throws IOException;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/DependenciesBuilder.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/DependenciesBuilder.java
deleted file mode 100644
index 0eb1999..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/DependenciesBuilder.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.exceptions.IndexRequiresFullRebuild;
-import com.google.dart.indexer.exceptions.IndexTemporarilyNonOperational;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-
-import org.eclipse.core.resources.IFile;
-
-public interface DependenciesBuilder {
- public void currentFileAffectsLocationOfCurrentLayer(Location location)
- throws IndexRequiresFullRebuild, IndexTemporarilyNonOperational, IndexRequestFailed;
-
- @Deprecated
- public void currentLocationDependsOnFile(IFile file) throws IndexRequiresFullRebuild,
- IndexTemporarilyNonOperational, IndexRequestFailed;
-
- public void currentLocationDependsOnFile(IndexableSource source) throws IndexRequiresFullRebuild,
- IndexTemporarilyNonOperational, IndexRequestFailed;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoBuilder.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoBuilder.java
deleted file mode 100644
index 7a94960..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoBuilder.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.index.entries.DependentLocation;
-import com.google.dart.indexer.index.entries.FileInfo;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-import com.google.dart.indexer.storage.StorageTransaction;
-
-import org.eclipse.core.resources.IFile;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.LinkedHashSet;
-import java.util.Map;
-import java.util.Set;
-
-public class FileInfoBuilder {
- private final Set<Location> sourceLocations = new LinkedHashSet<Location>();
- private final Map<IFile, Set<DependentLocation>> filesToDependencySets = new HashMap<IFile, Set<DependentLocation>>();
- private final Map<IndexableSource, Set<DependentLocation>> sourcesToDependencySets = new HashMap<IndexableSource, Set<DependentLocation>>();
-
- public FileInfoBuilder() {
- super();
- }
-
- @Deprecated
- public FileInfoBuilder(IFile currentFile) {
- super();
- }
-
- @Deprecated
- public void addDependency(IFile masterFile, DependentLocation dependency) {
- dependencySetFor(masterFile).add(dependency);
- }
-
- public void addDependency(IndexableSource masterSource, DependentLocation dependency) {
- dependencySetFor(masterSource).add(dependency);
- }
-
- public void addSourceLocation(Location location) {
- if (location == null) {
- throw new NullPointerException("location is null");
- }
- sourceLocations.add(location);
- }
-
- public void storeDependenciesInto(StorageTransaction storageTransaction) {
- }
-
- public void storeSourceLocationsInto(FileInfo fileInfo) {
- fileInfo.setSourceLocations(sourceLocations);
- }
-
- @Deprecated
- private Set<DependentLocation> dependencySetFor(IFile file) {
- Set<DependentLocation> result = filesToDependencySets.get(file);
- if (result == null) {
- result = new HashSet<DependentLocation>();
- filesToDependencySets.put(file, result);
- }
- return result;
- }
-
- private Set<DependentLocation> dependencySetFor(IndexableSource source) {
- Set<DependentLocation> result = sourcesToDependencySets.get(source);
- if (result == null) {
- result = new HashSet<DependentLocation>();
- sourcesToDependencySets.put(source, result);
- }
- return result;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoUpdater.java
deleted file mode 100644
index af10718..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoUpdater.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.index.layers.Layer;
-
-public interface FileInfoUpdater {
- LayerUpdater getLayerUpdater(Layer layer);
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoUpdaterImpl.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoUpdaterImpl.java
deleted file mode 100644
index c8de33f..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/FileInfoUpdaterImpl.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.index.layers.LayerId;
-import com.google.dart.indexer.storage.FileTransaction;
-
-import org.eclipse.core.resources.IFile;
-
-import java.util.HashMap;
-import java.util.Map;
-
-public class FileInfoUpdaterImpl implements FileInfoUpdater {
- private Map<LayerId, LayerUpdater> layerIdsToUpdaters = new HashMap<LayerId, LayerUpdater>();
- private FileTransaction fileTransaction;
-
- public FileInfoUpdaterImpl(FileTransaction fileTransaction) {
- if (fileTransaction == null) {
- throw new NullPointerException("fileTransaction is null");
- }
- this.fileTransaction = fileTransaction;
- }
-
- @Deprecated
- public FileInfoUpdaterImpl(FileTransaction fileTransaction, IFile file) {
- if (fileTransaction == null) {
- throw new NullPointerException("fileTransaction is null");
- }
- if (file == null) {
- throw new NullPointerException("file is null");
- }
- this.fileTransaction = fileTransaction;
- }
-
- @Override
- public LayerUpdater getLayerUpdater(Layer layer) {
- LayerId layerId = layer.getId();
- LayerUpdater layerUpdater = layerIdsToUpdaters.get(layerId);
- if (layerUpdater == null) {
- layerUpdater = layer.createLayerUpdater(fileTransaction);
- layerIdsToUpdaters.put(layerId, layerUpdater);
- }
- return layerUpdater;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/LayerUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/LayerUpdater.java
deleted file mode 100644
index 3a0f128..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/LayerUpdater.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.locations.Location;
-
-public interface LayerUpdater {
- LocationUpdater startLocation(Location location) throws IndexRequestFailed;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/LocationUpdater.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/LocationUpdater.java
deleted file mode 100644
index 388d5ce..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/LocationUpdater.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.locations.Location;
-
-public interface LocationUpdater {
- /**
- * Return the source location used when recording references.
- *
- * @return the source location used when recording references
- */
- public Location getSourceLocation();
-
- /**
- * Record that there is a reference from the source location to the given location.
- *
- * @param location the location referenced from the source location
- * @throws IndexRequestFailed if the reference could not be recorded
- */
- public void hasReferenceTo(Location location) throws IndexRequestFailed;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/PerLocationDependenciesBuilder.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/PerLocationDependenciesBuilder.java
deleted file mode 100644
index a46ce9a..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/index/updating/PerLocationDependenciesBuilder.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.index.updating;
-
-import com.google.dart.indexer.exceptions.IndexRequestFailed;
-import com.google.dart.indexer.index.entries.DependentLocation;
-import com.google.dart.indexer.index.layers.Layer;
-import com.google.dart.indexer.locations.Location;
-import com.google.dart.indexer.source.IndexableSource;
-import com.google.dart.indexer.storage.FileTransaction;
-
-import org.eclipse.core.resources.IFile;
-
-public final class PerLocationDependenciesBuilder implements DependenciesBuilder {
- private final Location currentLocation;
- private final Layer currentLayer;
- private final FileTransaction fileTransaction;
-
- public PerLocationDependenciesBuilder(Location currentLocation, Layer currentLayer,
- FileTransaction fileTransaction) {
- if (currentLocation == null) {
- throw new NullPointerException("currentLocation is null");
- }
- if (currentLayer == null) {
- throw new NullPointerException("currentLayer is null");
- }
- if (fileTransaction == null) {
- throw new NullPointerException("fileTransaction is null");
- }
- this.currentLocation = currentLocation;
- this.currentLayer = currentLayer;
- this.fileTransaction = fileTransaction;
- }
-
- @Override
- public void currentFileAffectsLocationOfCurrentLayer(Location location) throws IndexRequestFailed {
- IFile containingFile = currentLocation.getContainingFile();
- if (containingFile != null) {
- fileTransaction.addDependency(containingFile, new DependentLocation(location, currentLayer));
- }
- }
-
- @Override
- @Deprecated
- public void currentLocationDependsOnFile(IFile file) throws IndexRequestFailed {
- fileTransaction.addDependency(file, new DependentLocation(currentLocation, currentLayer));
- }
-
- @Override
- public void currentLocationDependsOnFile(IndexableSource source) throws IndexRequestFailed {
- fileTransaction.addDependency(source, new DependentLocation(currentLocation, currentLayer));
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/Location.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/Location.java
deleted file mode 100644
index 7e90154..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/Location.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.locations;
-
-import org.eclipse.core.resources.IFile;
-
-import java.net.URI;
-
-/**
- * The interface <code>Location</code> defines the behavior of objects that represent the location
- * in which a reference to a program element occurs.
- */
-public interface Location {
- public static final Location[] EMPTY_ARRAY = new Location[0];
-
- @Override
- public boolean equals(Object obj);
-
- @Deprecated
- public IFile getContainingFile();
-
- /**
- * Return the URI of the file that contains this location, or <code>null</code> if this location
- * is not contained in a file.
- *
- * @return the URI of the file that contains this location
- */
- public URI getContainingUri();
-
- public LocationType getLocationType();
-
- public String getSemiUniqueIdentifier();
-
- @Override
- public int hashCode();
-
- @Override
- public String toString();
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/LocationPersitence.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/LocationPersitence.java
deleted file mode 100644
index 4d93cd0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/LocationPersitence.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.locations;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-public final class LocationPersitence {
- /**
- * The unique instance of this class.
- */
- private static final LocationPersitence INSTANCE = new LocationPersitence();
-
- /**
- * Return the unique instance of this class.
- *
- * @return the unique instance of this class.
- */
- public static LocationPersitence getInstance() {
- return INSTANCE;
- }
-
- public static List<Location> loadLocations(RandomAccessFile file) throws IOException {
- int count = file.readInt();
- LocationPersitence locationPersitence = getInstance();
- ArrayList<Location> locations = new ArrayList<Location>();
- for (int i = 0; i < count; i++) {
- Location location = locationPersitence.load(file);
- locations.add(location);
- }
- return locations;
- }
-
- public static void saveLocations(RandomAccessFile file, final Collection<Location> locations)
- throws IOException {
- file.writeInt(locations.size());
- LocationPersitence locationPersitence = getInstance();
- for (Iterator<Location> iterator = locations.iterator(); iterator.hasNext();) {
- Location location = iterator.next();
- locationPersitence.save(location, file);
- }
- }
-
- private final Map<Character, LocationType> locationTypes = new HashMap<Character, LocationType>();
-
- /**
- * Prevent the creation of instances of this class.
- */
- private LocationPersitence() {
- }
-
- public Location byUniqueIdentifier(String identifier) {
- char typeCode = identifier.charAt(identifier.length() - 1);
- String name = identifier.substring(0, identifier.length() - 1);
- LocationType locationType = locationTypes.get(new Character(typeCode));
- if (locationType == null) {
- throw new IllegalArgumentException("Invalid identifier: unknown type code");
- }
- return locationType.byUniqueIdentifier(name);
- }
-
- public String getUniqueIdentifier(Location location) {
- return location.getSemiUniqueIdentifier() + location.getLocationType().getMarker();
- }
-
- public Location load(RandomAccessFile file) throws IOException {
- char marker = file.readChar();
- LocationType locationType = locationTypes.get(new Character(marker));
- if (locationType == null) {
- throw new IllegalArgumentException("Invalid stored location: unknown type code '" + marker
- + "'");
- }
- return locationType.load(file);
- }
-
- public void registerLocationType(LocationType locationType) {
- char marker = locationType.getMarker();
- Character markerChar = new Character(marker);
- LocationType previousLocationType = locationTypes.get(markerChar);
- if (previousLocationType != null) {
- if (previousLocationType == locationType) {
- return;
- } else {
- throw new IllegalArgumentException("Location types "
- + previousLocationType.getClass().getName() + " and "
- + locationType.getClass().getName() + " use the same marker character '" + marker + "'");
- }
- }
- locationTypes.put(markerChar, locationType);
- }
-
- public void save(Location location, RandomAccessFile file) throws IOException {
- LocationType locationType = location.getLocationType();
- file.writeChar(locationType.getMarker());
- locationType.save(location, file);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/LocationType.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/LocationType.java
deleted file mode 100644
index f3efe23..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/locations/LocationType.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.locations;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-public abstract class LocationType {
- private final char marker;
-
- protected LocationType(char marker) {
- this.marker = marker;
- }
-
- public abstract Location byUniqueIdentifier(String identifier);
-
- public char getMarker() {
- return marker;
- }
-
- public abstract Location load(RandomAccessFile file) throws IOException;
-
- public abstract void save(Location location, RandomAccessFile file) throws IOException;
-
- @Override
- public String toString() {
- return getClass().getSimpleName() + "(" + marker + ")";
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/DebugConstants.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/DebugConstants.java
deleted file mode 100644
index 3296698..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/DebugConstants.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage;
-
-public class DebugConstants {
- public static final boolean CHECK_LOCATION_PATH_SPLITTING = false;
-
- public static final boolean CHECK = true;
-
- public static final boolean CHECK2 = false;
-
- public static final boolean DONT_SPLIT_LOCATION_PATH_ON_UNDERSCORE = false;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/PageAllocationBitmapPage.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/PageAllocationBitmapPage.java
deleted file mode 100644
index 2e26697..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/PageAllocationBitmapPage.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageCorruptedException;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.pagestore.Record;
-import com.google.dart.indexer.pagedstorage.util.BitField;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-/**
- * The list of free pages of a page store. The format of a free list trunk page is:
- * <ul>
- * <li>0-3: parent page id (always 0)</li>
- * <li>4-4: page type</li>
- * <li>5-remainder: data</li>
- * </ul>
- */
-public class PageAllocationBitmapPage extends Record {
- private static final int DATA_START = 5;
-
- private final PagedStorage storage;
- private final BitField used = new BitField();
- private final int pageCount;
- private boolean full;
- private Data data;
-
- public static final int TYPE_FREE_LIST = 6;
-
- public static final int TYPE_EMPTY = 0;
-
- /**
- * Get the number of pages that can fit in a free list.
- *
- * @param pageSize the page size
- * @return the number of pages
- */
- public static int getPagesAddressed(int pageSize) {
- return (pageSize - DATA_START) * 8;
- }
-
- public PageAllocationBitmapPage(PagedStorage storage, int pageId) {
- setPos(pageId);
- this.storage = storage;
- pageCount = (storage.getPageSize() - DATA_START) * 8;
- used.set(0);
- }
-
- /**
- * Get the estimated memory size.
- *
- * @return number of double words (4 bytes)
- */
- @Override
- public int getMemorySize() {
- return storage.getPageSize() >> 2;
- }
-
- @Override
- public void write() throws PagedStorageException {
- data = storage.createData();
- data.writeInt(0);
- int type = PageAllocationBitmapPage.TYPE_FREE_LIST;
- data.writeByte((byte) type);
- for (int i = 0; i < pageCount; i += 8) {
- data.writeByte((byte) used.getByte(i));
- }
- storage.writePage(getPos(), data);
- }
-
- /**
- * Allocate a page from the free list.
- *
- * @return the page, or -1 if all pages are used
- */
- int allocate() throws PagedStorageException {
- if (full) {
- return -1;
- }
- // TODO cache last result
- int free = used.nextClearBit(0);
- if (free >= pageCount) {
- full = true;
- return -1;
- }
- used.set(free);
- storage.updateRecord(this, true, data);
- return free + getPos();
- }
-
- /**
- * Mark a page as used.
- *
- * @param pos the page id
- * @return the page id, or -1
- */
- int allocate(int pos) throws PagedStorageException {
- int idx = pos - getPos();
- if (idx >= 0 && !used.get(idx)) {
- used.set(idx);
- storage.updateRecord(this, true, data);
- }
- return pos;
- }
-
- /**
- * Add a page to the free list.
- *
- * @param pageId the page id to add
- */
- void free(int pageId) throws PagedStorageException {
- full = false;
- used.clear(pageId - getPos());
- storage.updateRecord(this, true, data);
- }
-
- /**
- * Check if a page is already in use.
- *
- * @param pageId the page to check
- * @return true if it is in use
- */
- boolean isUsed(int pageId) {
- return used.get(pageId - getPos());
- }
-
- /**
- * Read the page from the disk.
- */
- void read() throws PagedStorageException {
- data = storage.createData();
- storage.readPage(getPos(), data);
- int p = data.readInt();
- int t = data.readByte();
- if (t == PageAllocationBitmapPage.TYPE_EMPTY) {
- return;
- }
- if (t != PageAllocationBitmapPage.TYPE_FREE_LIST || p != 0) {
- throw new PagedStorageCorruptedException("Page allocation bitmap corrupted, pos:" + getPos()
- + " type:" + t + " parent:" + p + " expected type:"
- + PageAllocationBitmapPage.TYPE_FREE_LIST);
- }
- for (int i = 0; i < pageCount; i += 8) {
- used.setByte(i, data.readByte() & 255);
- }
- full = false;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/PagedStorage.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/PagedStorage.java
deleted file mode 100644
index 2b130e4..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/PagedStorage.java
+++ /dev/null
@@ -1,582 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageCorruptedException;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageNonexistentPageReferenceException;
-import com.google.dart.indexer.pagedstorage.filesystem.AccessMode;
-import com.google.dart.indexer.pagedstorage.filesystem.FileSystem;
-import com.google.dart.indexer.pagedstorage.pagestore.Record;
-import com.google.dart.indexer.pagedstorage.pagestore.RecordFactory;
-import com.google.dart.indexer.pagedstorage.util.Cache;
-import com.google.dart.indexer.pagedstorage.util.CacheTQ;
-import com.google.dart.indexer.pagedstorage.util.FileUtils;
-import com.google.dart.indexer.pagedstorage.util.ObjectArray;
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-import com.google.dart.indexer.storage.paged.store.CacheWriter;
-import com.google.dart.indexer.storage.paged.store.Data;
-import com.google.dart.indexer.storage.paged.store.DataHandler;
-import com.google.dart.indexer.storage.paged.store.FileStore;
-
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.zip.CRC32;
-
-/**
- * This class represents a file that is organized as a number of pages. Page 0 contains a static
- * file header, and pages 1 and 2 both contain the variable file header (page 2 is a copy of page 1
- * and is only read if the checksum of page 1 is invalid). The format of page 0 is:
- * <ul>
- * <li>0-47: file header (static string, repeated 3 times)</li>
- * <li>48-51: page size in bytes (512 - 32768, must be a power of 2)</li>
- * <li>52: write version (if not 0 the file is opened in read-only mode)</li>
- * <li>53: read version (if not 0 opening the file fails)</li>
- * </ul>
- * The format of page 1 and 2 is:
- * <ul>
- * <li>0-7: write counter (incremented each time the header changes)</li>
- * <li>8-X: special pages (2 bytes per special page)</li>
- * <li>X-(X+8): checksum of bytes 0-X (CRC32)</li>
- * </ul>
- * Page 3 contains the first free list page. Page 4 contains the first special page.
- */
-public class PagedStorage implements CacheWriter, DataHandler {
- public static final int PAGE_SIZE_MIN = 128;
-
- public static final int PAGE_SIZE_MAX = 32768;
-
- public static final int PAGE_SIZE_DEFAULT = 1024 * 32;
-
- private static final int FIRST_PAGE_ALLOCATION_BITMAP_PAGE = 3;
-
- private static final int MIN_PAGE_COUNT = 6;
-
- private static final int INCREMENT_PAGES = 128;
-
- private static final int READ_VERSION = 0;
- private static final int WRITE_VERSION = 0;
-
- private String fileName;
- private FileStore file;
- private AccessMode accessMode;
- private int pageSize;
- private int pageSizeShift;
- private long writeCount;
- private int[] specialPages;
- private int specialPageCount;
-
- private int cacheSize;
- private Cache cache;
-
- private int freeListPagesPerList;
-
- private boolean recoveryRunning;
-
- /**
- * The file size in bytes.
- */
- private long fileLength;
-
- /**
- * Number of pages (including free pages).
- */
- private int pageCount;
-
- /**
- * Create a new page store object.
- *
- * @param database the database
- * @param fileName the file name
- * @param accessMode the access mode
- * @param cacheSizeDefault the default cache size
- */
- public PagedStorage(String fileName, AccessMode accessMode, int cacheSizeDefault,
- int specialPageCount) {
- this.fileName = fileName;
- this.accessMode = accessMode;
- this.specialPageCount = specialPageCount;
- this.specialPages = new int[specialPageCount];
- this.cacheSize = cacheSizeDefault;
- this.cache = new CacheTQ(this, cacheSize);
- setPageSize(PAGE_SIZE_DEFAULT);
- }
-
- /**
- * Allocate a page.
- *
- * @return the page id
- */
- public synchronized int allocatePage() throws PagedStorageException {
- int pos;
- int i = -1;
- do {
- i++;
- PageAllocationBitmapPage bitmap = getAllocationBitmapPage(i);
- pos = bitmap.allocate();
- } while (pos < 0);
- if (pos >= pageCount) {
- increaseFileSize(INCREMENT_PAGES);
- }
- return pos;
- }
-
- public void cacheRecord(Record record) throws PagedStorageException {
- cache.put(record);
- }
-
- /**
- * Flush all pending changes to disk, and re-open the log file.
- */
- public synchronized void checkpoint() throws PagedStorageException {
- writeBack();
- byte[] empty = new byte[pageSize];
- // TODO avoid to write empty pages
- for (int i = FIRST_PAGE_ALLOCATION_BITMAP_PAGE; i < pageCount; i++) {
- if (!isUsed(i)) {
- file.seek((long) i << pageSizeShift);
- file.write(empty, 0, pageSize);
- writeCount++;
- }
- }
- // TODO shrink file if required here
- // int pageCount = getFreeList().getLastUsed() + 1;
- // trace.debug("pageCount:" + pageCount);
- // file.setLength((long) pageCount << pageSizeShift);
- }
-
- /**
- * Close the file without further writing.
- */
- public void close() {
- if (file != null) {
- try {
- file.close();
- } catch (IOException e) {
- // ignore: can't do anything about a failed close() anyway
- IndexerPlugin.getLogger().logError(e, "Could not close file: \"" + file + "\"");
- } finally {
- file = null;
- }
- }
- }
-
- /**
- * Create a data object.
- *
- * @return the data page.
- */
- public Data createData() {
- return Data.create(this, new byte[pageSize]);
- }
-
- /**
- * Add a page to the free list.
- *
- * @param pageId the page id
- * @param logUndo if an undo entry need to be logged
- * @param old the old data (if known)
- */
- public synchronized void freePage(int pageId) throws PagedStorageException {
- cache.remove(pageId);
- doFreePage(pageId);
- if (recoveryRunning) {
- writePage(pageId, createData());
- }
- }
-
- @Override
- public int getChecksum(byte[] data, int start, int end) {
- // TODO implement checksum
- return 0;
- }
-
- /**
- * Get the number of pages (including free pages).
- *
- * @return the page count
- */
- public int getPageCount() {
- return pageCount;
- }
-
- /**
- * Get the page size.
- *
- * @return the page size
- */
- public int getPageSize() {
- return pageSize;
- }
-
- /**
- * Get the record if it is stored in the file, or null if not.
- *
- * @param pos the page id
- * @return the record or null
- */
- public synchronized Record getRecord(int pos) {
- CacheObject obj = cache.find(pos);
- return (Record) obj;
- }
-
- public int getSpecialPage(int index) {
- if (index < 0 || index >= specialPageCount) {
- throw new IllegalArgumentException("special page index incorrect: " + index);
- }
- return specialPages[index];
- }
-
- public long getWriteCount() {
- return writeCount;
- }
-
- @Override
- public void handleInvalidChecksum() throws PagedStorageException {
- // TODO implement checksum
- }
-
- /**
- * Open the file and read the header.
- */
- public void open() throws PagedStorageException {
- try {
- if (FileSystem.getInstance(fileName).exists(fileName)) {
- if (FileUtils.length(fileName) < MIN_PAGE_COUNT * PAGE_SIZE_MIN) {
- // the database was not fully created
- openNew();
- } else {
- openExisting();
- }
- } else {
- openNew();
- }
- // lastUsedPage = getFreeList().getLastUsed() + 1;
- } catch (PagedStorageException e) {
- close();
- throw e;
- }
- }
-
- /**
- * Read a page.
- *
- * @param pos the page id
- * @return the page
- */
- public Data readPage(int pos) throws PagedStorageException {
- Data page = createData();
- readPage(pos, page);
- return page;
- }
-
- public Record readRecord(int pageId, RecordFactory factory) throws PagedStorageException {
- if (pageId <= 0) {
- pageId = allocatePage();
- Data data = createData();
- Record record = factory.read(this, data, pageId, true);
- updateRecord(record);
- return record;
- }
- Record record = getRecord(pageId);
- if (record != null) {
- return record;
- }
- Data data = readPage(pageId);
- record = factory.read(this, data, pageId, false);
- cacheRecord(record);
- return record;
- }
-
- /**
- * Remove a page from the cache.
- *
- * @param pageId the page id
- */
- public synchronized void removeRecord(int pageId) {
- cache.remove(pageId);
- }
-
- /**
- * Set the page size. The size must be a power of two. This method must be called before opening.
- *
- * @param size the page size
- */
- public void setPageSize(int size) {
- if (size < PAGE_SIZE_MIN || size > PAGE_SIZE_MAX) {
- throw new IllegalArgumentException("Invalid page size");
- }
- boolean good = false;
- int shift = 0;
- for (int i = 1; i <= size;) {
- if (size == i) {
- good = true;
- break;
- }
- shift++;
- i += i;
- }
- if (!good) {
- throw new IllegalArgumentException("Page size is not a power of two");
- }
- pageSize = size;
- pageSizeShift = shift;
- }
-
- public void setSpecialPage(int index, int page) {
- if (index < 0 || index >= specialPageCount) {
- throw new IllegalArgumentException("special page index incorrect: " + index);
- }
- specialPages[index] = page;
- writeVariableHeader();
- }
-
- /**
- * Update a record.
- *
- * @param record the record
- * @param logUndo if an undo entry need to be logged
- * @param old the old data (if known)
- */
- public void updateRecord(Record record) throws PagedStorageException {
- updateRecord(record, false, null);
- }
-
- public synchronized void updateRecord(Record record, boolean logUndo, Data old)
- throws PagedStorageException {
- checkOpen();
- record.setChanged(true);
- int pos = record.getPos();
- allocatePage(pos);
- cache.update(pos, record);
- if (logUndo && !recoveryRunning) {
- if (old == null) {
- old = readPage(pos);
- }
- // log.addUndo(pos, old);
- }
- }
-
- @Override
- public synchronized void writeBack(CacheObject obj) throws PagedStorageException {
- Record record = (Record) obj;
- record.write();
- record.setChanged(false);
- }
-
- /**
- * Write a page.
- *
- * @param pageId the page id
- * @param data the data
- */
- public synchronized void writePage(int pageId, Data data) {
- file.seek((long) pageId << pageSizeShift);
- file.write(data.getBytes(), 0, pageSize);
- writeCount++;
- }
-
- /**
- * Set the bit of an already allocated page.
- *
- * @param pageId the page to allocate
- */
- void allocatePage(int pageId) throws PagedStorageException {
- PageAllocationBitmapPage bitmap = getAllocationBitmapPageForPage(pageId);
- bitmap.allocate(pageId);
- }
-
- /**
- * Read a page.
- *
- * @param pos the page id
- * @param page the page
- */
- synchronized void readPage(int pos, Data page) throws PagedStorageException {
- if (pos >= pageCount) {
- throw new PagedStorageNonexistentPageReferenceException(pos + " of " + pageCount);
- }
- file.seek((long) pos << pageSizeShift);
- file.readFully(page.getBytes(), 0, pageSize);
- }
-
- private void checkOpen() {
- if (file == null) {
- throw new IllegalStateException("File is not open");
- }
- }
-
- private void doFreePage(int pageId) throws PagedStorageException {
- PageAllocationBitmapPage bitmap = getAllocationBitmapPageForPage(pageId);
- bitmap.free(pageId);
- }
-
- private PageAllocationBitmapPage getAllocationBitmapPage(int ordinal)
- throws PagedStorageException {
- int p = FIRST_PAGE_ALLOCATION_BITMAP_PAGE + ordinal * freeListPagesPerList;
- while (p >= pageCount) {
- increaseFileSize(INCREMENT_PAGES);
- }
- PageAllocationBitmapPage bitmap = (PageAllocationBitmapPage) getRecord(p);
- if (bitmap == null) {
- bitmap = new PageAllocationBitmapPage(this, p);
- if (p < pageCount) {
- bitmap.read();
- }
- cache.put(bitmap);
- }
- return bitmap;
- }
-
- private PageAllocationBitmapPage getAllocationBitmapPageForPage(int pageId)
- throws PagedStorageException {
- return getAllocationBitmapPage((pageId - FIRST_PAGE_ALLOCATION_BITMAP_PAGE)
- / freeListPagesPerList);
- }
-
- private void increaseFileSize(int increment) {
- pageCount += increment;
- long newLength = (long) pageCount << pageSizeShift;
- file.setLength(newLength);
- writeCount++;
- fileLength = newLength;
- }
-
- private boolean isUsed(int pageId) throws PagedStorageException {
- return getAllocationBitmapPageForPage(pageId).isUsed(pageId);
- }
-
- private void openExisting() throws PagedStorageException {
- FileStore store = FileStore.open(this, fileName, accessMode);
- try {
- store.init();
- } catch (PagedStorageException e) {
- store.closeSilently();
- throw e;
- }
- file = store;
- readStaticHeader();
- freeListPagesPerList = PageAllocationBitmapPage.getPagesAddressed(pageSize);
- fileLength = file.length();
- pageCount = (int) (fileLength / pageSize);
- if (pageCount < MIN_PAGE_COUNT) {
- close();
- openNew();
- return;
- }
- readVariableHeader();
- checkpoint();
- }
-
- private void openNew() throws PagedStorageException {
- freeListPagesPerList = PageAllocationBitmapPage.getPagesAddressed(pageSize);
- FileStore store = FileStore.open(this, fileName, accessMode);
- try {
- store.init();
- } catch (PagedStorageException e) {
- store.closeSilently();
- throw e;
- }
- file = store;
- recoveryRunning = true;
- writeStaticHeader();
-
- writeVariableHeader();
- increaseFileSize(MIN_PAGE_COUNT);
-
- // openMetaIndex();
- // log.openForWriting(logFirstTrunkPage);
- recoveryRunning = false;
- increaseFileSize(INCREMENT_PAGES);
-
- for (int i = 0; i < specialPageCount; i++) {
- specialPages[i] = allocatePage();
- allocatePage(specialPages[i]);
- }
- writeVariableHeader();
- checkpoint();
- }
-
- private void readStaticHeader() throws PagedStorageException {
- file.seek(FileStore.HEADER_LENGTH);
- Data page = Data.create(this, new byte[PAGE_SIZE_MIN - FileStore.HEADER_LENGTH]);
- file.readFully(page.getBytes(), 0, PAGE_SIZE_MIN - FileStore.HEADER_LENGTH);
- setPageSize(page.readInt());
- int writeVersion = page.readByte();
- int readVersion = page.readByte();
- if (readVersion != 0) {
- throw new PagedStorageCorruptedException("readVersion - expected:0 got:" + readVersion);
- }
- if (writeVersion != 0) {
- throw new PagedStorageCorruptedException("writeVersion - expected:0 got:" + writeVersion);
- }
- }
-
- private void readVariableHeader() throws PagedStorageException {
- Data page = Data.create(this, pageSize);
- for (int i = 1;; i++) {
- if (i == 3) {
- throw new PagedStorageCorruptedException("All copies of the variable header are corrupted");
- }
- page.reset();
- readPage(i, page);
- writeCount = page.readLong();
- for (int pp = 0; pp < specialPageCount; pp++) {
- specialPages[pp] = page.readInt();
- }
- CRC32 crc = new CRC32();
- crc.update(page.getBytes(), 0, page.length());
- long expected = crc.getValue();
- long got = page.readLong();
- if (expected == got) {
- break;
- }
- }
- }
-
- private void writeBack() throws PagedStorageException {
- ObjectArray<CacheObject> list = cache.getAllChanged();
- CacheObject.sort(list);
- for (Iterator<CacheObject> iterator = list.iterator(); iterator.hasNext();) {
- CacheObject rec = iterator.next();
- writeBack(rec);
- }
- }
-
- private void writeStaticHeader() {
- Data page = Data.create(this, new byte[pageSize - FileStore.HEADER_LENGTH]);
- page.writeInt(pageSize);
- page.writeByte((byte) WRITE_VERSION);
- page.writeByte((byte) READ_VERSION);
- file.seek(FileStore.HEADER_LENGTH);
- file.write(page.getBytes(), 0, pageSize - FileStore.HEADER_LENGTH);
- }
-
- private void writeVariableHeader() {
- Data page = Data.create(this, pageSize);
- page.writeLong(writeCount);
- for (int pp = 0; pp < specialPageCount; pp++) {
- page.writeInt(specialPages[pp]);
- }
- CRC32 crc = new CRC32();
- crc.update(page.getBytes(), 0, page.length());
- page.writeLong(crc.getValue());
- file.seek(pageSize);
- file.write(page.getBytes(), 0, pageSize);
- file.seek(pageSize + pageSize);
- file.write(page.getBytes(), 0, pageSize);
- writeCount++;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/SpeedTest.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/SpeedTest.java
deleted file mode 100644
index 2427dce..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/SpeedTest.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.filesystem.AccessMode;
-import com.google.dart.indexer.pagedstorage.filesystem.DiskFileSystem;
-import com.google.dart.indexer.pagedstorage.filesystem.FileObject;
-import com.google.dart.indexer.pagedstorage.filesystem.FileSystem;
-import com.google.dart.indexer.pagedstorage.filesystem.InMemoryFileSystem;
-import com.google.dart.indexer.pagedstorage.filesystem.MemoryMappedFileSystem;
-import com.google.dart.indexer.pagedstorage.filesystem.NioFileSystem;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.Random;
-
-public class SpeedTest {
- public static void main(String[] args) throws Exception {
- File file = new File("/tmp/test.foo");
- int fileSize = 1024 * 1024 * 100;
- int readAttemps = 1000000;
- int readSize = 1024;
-
- Random random = new Random();
-
- byte[] buf = new byte[readSize];
-
- FileSystem[] fileSystems = new FileSystem[] {
- InMemoryFileSystem.getInstance(), MemoryMappedFileSystem.getInstance(),
- DiskFileSystem.getInstance(), NioFileSystem.getInstance(),};
- for (int i = 0; i < fileSystems.length; i++) {
- FileSystem fileSystem = fileSystems[i];
- if (!fileSystem.exists(file.getPath())) {
- createFile(fileSystem, fileSize, file, random);
- }
-
- FileObject fileObject = fileSystem.openFileObject(file.getPath(), AccessMode.READ_WRITE);
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- "Running read test with " + fileSystem.getClass().getName() + "... ");
- long start = System.currentTimeMillis();
- for (int attemp = 0; attemp < readAttemps; attemp++) {
- long offset = random.nextInt(fileSize - readSize);
- fileObject.seek(offset);
- fileObject.readFully(buf, 0, buf.length);
- }
- fileObject.close();
- long end = System.currentTimeMillis();
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS, (end - start) + " ms.");
- }
- }
-
- private static void createFile(FileSystem fileSystem, int fileSize, File file, Random random)
- throws FileNotFoundException, IOException, PagedStorageException {
- OutputStream os = fileSystem.openFileOutputStream(file.getPath(), false);
- byte[] buf = new byte[1024];
- random.nextBytes(buf);
- int rows = fileSize / buf.length;
- for (int i = 0; i < rows; i++) {
- os.write(buf);
- }
- os.close();
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/CatalogPos.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/CatalogPos.java
deleted file mode 100644
index c9b3e32..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/CatalogPos.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.catalog;
-
-import com.google.dart.indexer.pagedstorage.catalog.FixedLengthPagedArray.DataPage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-public class CatalogPos {
- public static final int SIZE = 4;
-
- public static CatalogPos read(FixedLengthPagedArray container, Data data) {
- int rowId = data.readInt();
- return new CatalogPos(container, rowId, null, -1);
- }
-
- private final int rowId;
- private DataPage page;
- private int index;
-
- private final FixedLengthPagedArray container;
-
- public CatalogPos(FixedLengthPagedArray container, int rowId, DataPage page, int index) {
- if (container == null) {
- throw new NullPointerException("container is null");
- }
- if (rowId <= 0) {
- throw new IllegalArgumentException("Invalid rowId: " + rowId);
- }
- if (index < 0 || index >= page.getCount()) {
- throw new IllegalArgumentException("Invalid index " + index + " (max: " + page.getCount()
- + ") on page " + page.getPos() + ", rowId " + rowId);
- }
- this.container = container;
- this.rowId = rowId;
- this.page = page;
- this.index = index;
- }
-
- public void delete() throws PagedStorageException {
- needResolved();
- page.delete(index);
- }
-
- public int getInfoPage(int layer) throws PagedStorageException {
- needResolved();
- return page.getInfoPage(index, layer);
- }
-
- public int getPageId() throws PagedStorageException {
- needResolved();
- return page.getPos();
- }
-
- public int getParentRowId() throws PagedStorageException {
- needResolved();
- return page.getParentRowId(index);
- }
-
- public int getRowId() {
- return rowId;
- }
-
- public boolean isDeleted() throws PagedStorageException {
- needResolved();
- return page.isDeleted(index);
- }
-
- public Data readableData() throws PagedStorageException {
- needResolved();
- return page.readableData(index);
- }
-
- public void setInfoPage(int layer, int infoPage) throws PagedStorageException {
- needResolved();
- page.setInfoPage(index, layer, infoPage);
- }
-
- public void setParentRowId(int parentRowId) throws PagedStorageException {
- writableData().seek(0).writeInt(parentRowId);
- }
-
- public Data writableData() throws PagedStorageException {
- needResolved();
- return page.writableData(index);
- }
-
- public void write(Data data) {
- data.writeInt(rowId);
- }
-
- private void needResolved() throws PagedStorageException {
- if (page == null) {
- CatalogPos pos = container.resolve(rowId);
- page = pos.page;
- index = pos.index;
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/FixedLengthPagedArray.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/FixedLengthPagedArray.java
deleted file mode 100644
index bfa14a3..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/FixedLengthPagedArray.java
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.catalog;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.infostore.InfoPos;
-import com.google.dart.indexer.pagedstorage.pagestore.FullyDeserializedRecord;
-import com.google.dart.indexer.pagedstorage.pagestore.Record;
-import com.google.dart.indexer.pagedstorage.pagestore.RecordFactory;
-import com.google.dart.indexer.pagedstorage.pagestore.StdRecord;
-import com.google.dart.indexer.pagedstorage.treestore.PageRecPos;
-import com.google.dart.indexer.pagedstorage.util.StringUtils;
-import com.google.dart.indexer.storage.paged.CatalogStats;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class FixedLengthPagedArray {
- class CatalogPage extends FullyDeserializedRecord {
- private int count;
- private int itemCount;
- private int nextPageId;
- private int[] pages;
-
- public CatalogPage(Data data, int pageId) {
- super(pagedStorage, pageId);
- data.reset();
- nextPageId = data.readInt();
- itemCount = data.readInt();
- count = data.readShortInt();
- pages = new int[catalogEntriesPerPage]; // leave room for additions
- for (int i = 0; i < count; i++) {
- pages[i] = data.readInt();
- }
- }
-
- public void dump(int itemsDone, StringBuilder out, int level, boolean detailed)
- throws PagedStorageException {
- out.append(StringUtils.indent(level)).append("CatalogPage ").append(getPos()).append(": ").append(
- itemCount).append(" items on ").append(count).append(" subpages\n");
- for (int i = 0; i < count; i++) {
- DataPage dataPage = readDataPage(pages[i]);
- dataPage.dump(itemsDone, out, level + 1, detailed);
- itemsDone += dataPage.count;
- }
- }
-
- public int get(int index) {
- if (index >= count) {
- throw new IllegalArgumentException("Invalid index " + index + " for catalog page "
- + getPos());
- }
- return pages[index];
- }
-
- public void increaseItemCount() {
- itemCount++;
- changed();
- }
-
- public int lastPageId() {
- if (count == 0) {
- return -1;
- }
- return pages[count - 1];
- }
-
- public void setNextPageId(int pos) {
- this.nextPageId = pos;
- changed();
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- try {
- dump(0, result, 0, true);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- return result.toString();
- }
-
- public boolean tryAddDataPage(int pos) {
- if (count == catalogEntriesPerPage) {
- return false;
- }
- pages[count++] = pos;
- changed();
- return true;
- }
-
- @Override
- protected void serializeCached(Data data) {
- data.reset();
- data.writeInt(nextPageId);
- data.writeInt(itemCount);
- data.writeShortInt(count);
- for (int i = 0; i < count; i++) {
- data.writeInt(pages[i]);
- }
- }
- }
-
- class DataPage extends StdRecord {
- private int count;
-
- public DataPage(Data data, int pageId) {
- super(pagedStorage, data, pageId);
- data.reset();
- count = data.readShortInt();
- }
-
- public void delete(int index) {
- // TODO mark this rowId for reuse
- writableData(index).seek(0).writeInt(-2);
- }
-
- public void dump(int itemsDone, StringBuilder out, int level, boolean detailed) {
- out.append(StringUtils.indent(level)).append("DataPage ").append(getPos()).append(": ").append(
- count).append(" items\n");
- for (int i = 0; i < count; i++) {
- dumpItem(1 + itemsDone + i, i, out, level + 1, detailed);
- }
- }
-
- public int getCount() {
- return count;
- }
-
- public int getInfoPage(int index, int layer) {
- return readableData(index).seek(4 + PageRecPos.SIZE + layer * CatalogPos.SIZE).readInt();
- }
-
- public int getParentRowId(int index) {
- return readableData(index).seek(0).readInt();
- }
-
- public boolean isDeleted(int index) {
- return readableData(index).seek(0).readInt() == -2;
- }
-
- public Data readableData(int index) {
- data.setPos(DATA_OVERHEAD + index * dataSize);
- return data;
- }
-
- public void setInfoPage(int index, int layer, int infoPage) {
- writableData(index).seek(4 + PageRecPos.SIZE + layer * CatalogPos.SIZE).writeInt(infoPage);
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- dump(0, result, 0, true);
- return result.toString();
- }
-
- public int tryAllocateNewPos() {
- if (count == dataEntriesPerPage) {
- return -1;
- }
- changed();
- return count++;
- }
-
- public Data writableData(int index) {
- changed();
- return readableData(index);
- }
-
- public void zeroData(int index) {
- changed();
- data.zeroFill(DATA_OVERHEAD + index * dataSize, dataSize);
- }
-
- @Override
- protected void serializeCached() {
- data.reset();
- data.writeShortInt(count);
- }
-
- private void dumpItem(int rowId, int index, StringBuilder out, int level, boolean detailed) {
- out.append(StringUtils.indent(level)).append("ID ").append(rowId).append(": ");
- if (isDeleted(index)) {
- out.append("--deleted--");
- } else {
- Data data = readableData(index);
- int parentRowId = data.readInt();
- int treePage = data.readInt();
- int treeRec = data.readShortInt();
- int treePos = data.readShortInt();
- out.append("parentRowId=").append(parentRowId).append(" ");
- out.append("treePos=<").append(treePage).append(",").append(treeRec).append(",").append(
- treePos).append(">");
- for (int i = 0; i < (dataSize - 4 - PageRecPos.SIZE) / InfoPos.SIZE; i++) {
- int page = data.readInt();
- out.append(" info=<").append(page).append(">");
- }
- }
- out.append("\n");
- }
- }
-
- private static final int CATALOG_COUNT_SIZE = 2;
-
- private static final int PAGE_ID_SIZE = 4;
-
- private static final int CB_ITEM_COUNT_PER_CATALOG_PAGE = 4;
-
- private static final int CATALOG_OVERHEAD = CATALOG_COUNT_SIZE + PAGE_ID_SIZE
- + CB_ITEM_COUNT_PER_CATALOG_PAGE;
-
- private static final int DATA_COUNT_SIZE = 2;
- private static final int DATA_OVERHEAD = DATA_COUNT_SIZE;
- private final PagedStorage pagedStorage;
- private final int dataSize;
-
- private final int catalogEntriesPerPage;
- private final List<CatalogPage> catalogPages;
-
- private int dataEntriesPerPage;
-
- private int overallItemCount;
-
- private final RecordFactory catalogPageFactory = new RecordFactory() {
-
- @Override
- public Record read(PagedStorage pagedStorage, Data data, int pageId, boolean isNew)
- throws PagedStorageException {
- return new CatalogPage(data, pageId);
- }
-
- };
-
- private final RecordFactory dataPageFactory = new RecordFactory() {
-
- @Override
- public Record read(PagedStorage pagedStorage, Data data, int pageId, boolean isNew)
- throws PagedStorageException {
- return new DataPage(data, pageId);
- }
-
- };
-
- public FixedLengthPagedArray(PagedStorage pagedStorage, int rootPageId, int dataSize)
- throws PagedStorageException {
- this.pagedStorage = pagedStorage;
- this.dataSize = dataSize;
- this.catalogEntriesPerPage = (pagedStorage.getPageSize() - CATALOG_OVERHEAD) / PAGE_ID_SIZE;
- this.dataEntriesPerPage = (pagedStorage.getPageSize() - DATA_OVERHEAD) / dataSize;
- this.catalogPages = readAllCatalogPages(rootPageId);
- this.overallItemCount = computeOverallItemCount();
- }
-
- public CatalogPos allocateNew() throws PagedStorageException {
- CatalogPage lastCatalogPage = catalogPages.get(catalogPages.size() - 1);
- int lastPageId = lastCatalogPage.lastPageId();
- DataPage dataPage;
- if (lastPageId < 0) {
- dataPage = addNewDataPage();
- } else {
- dataPage = readDataPage(lastPageId);
- }
- int index = dataPage.tryAllocateNewPos();
- if (index < 0) {
- dataPage = addNewDataPage();
- index = dataPage.tryAllocateNewPos();
- if (index < 0) {
- throw new AssertionError("Cannot add an item to an empty data page");
- }
- }
-
- lastCatalogPage = catalogPages.get(catalogPages.size() - 1); // might have
- // added a new
- // one
- if (overallItemCount != (catalogPages.size() - 1) * catalogEntriesPerPage * dataEntriesPerPage
- + lastCatalogPage.itemCount) {
- throw new AssertionError("Internal state error: item counts are corrupted");
- }
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.CATALOG_INTERNALS,
- "Catalog: added item to page " + dataPage.getPos());
- lastCatalogPage.increaseItemCount();
- int rowId = ++overallItemCount;
- dataPage.zeroData(index);
- return new CatalogPos(this, rowId, dataPage, index);
- }
-
- public void dump(StringBuilder out, int level, boolean detailed) throws PagedStorageException {
- out.append(StringUtils.indent(level)).append("Catalog\n");
- int itemsDone = 0;
- for (Iterator<CatalogPage> iterator = catalogPages.iterator(); iterator.hasNext();) {
- CatalogPage catalogPage = iterator.next();
- catalogPage.dump(itemsDone, out, level + 1, detailed);
- itemsDone += catalogPage.itemCount;
- }
- }
-
- public int getOverallItemCount() {
- return overallItemCount;
- }
-
- public Data readableData(int pageId, int index) throws PagedStorageException {
- DataPage page = readDataPage(pageId);
- return page.readableData(index);
- }
-
- public CatalogPos resolve(int rowId) throws PagedStorageException {
- if (rowId <= 0) {
- throw new IllegalArgumentException("Attemp to resolve invalid row ID " + rowId);
- }
- if (rowId > overallItemCount) {
- throw new IllegalArgumentException("Row ID is too large: " + rowId);
- }
- int zeroBasedRowId = rowId - 1;
- int dataPageOrdinal = zeroBasedRowId / dataEntriesPerPage;
- int catalogPageOrdinal = dataPageOrdinal / catalogEntriesPerPage;
-
- CatalogPage catalogPage = catalogPages.get(catalogPageOrdinal);
- int dataPageId = catalogPage.get(dataPageOrdinal % catalogEntriesPerPage);
- DataPage dataPage = readDataPage(dataPageId);
- return new CatalogPos(this, rowId, dataPage, zeroBasedRowId % dataEntriesPerPage);
- }
-
- public void stats(CatalogStats stats) {
- stats.catalogPages = catalogPages.size();
- stats.dataPages = (overallItemCount + dataEntriesPerPage - 1) / dataEntriesPerPage;
- stats.dataEntriesPerPage = dataEntriesPerPage;
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- try {
- dump(result, 0, true);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- return result.toString();
- }
-
- public Data writableData(int pageId, int index) throws PagedStorageException {
- DataPage page = readDataPage(pageId);
- return page.writableData(index);
- }
-
- int getDataEntriesPerPage() {
- return dataEntriesPerPage;
- }
-
- private CatalogPage addNewCatalogPage() throws PagedStorageException {
- CatalogPage lastCatalogPage = catalogPages.get(catalogPages.size() - 1);
-
- CatalogPage newCatalogPage = (CatalogPage) pagedStorage.readRecord(-1, catalogPageFactory);
- catalogPages.add(newCatalogPage);
-
- lastCatalogPage.setNextPageId(newCatalogPage.getPos());
- return newCatalogPage;
- }
-
- private DataPage addNewDataPage() throws PagedStorageException {
- DataPage page = (DataPage) pagedStorage.readRecord(-1, dataPageFactory);
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.CATALOG_INTERNALS,
- "Catalog: added page " + page.getPos());
-
- CatalogPage lastCatalogPage = catalogPages.get(catalogPages.size() - 1);
- if (!lastCatalogPage.tryAddDataPage(page.getPos())) {
- lastCatalogPage = addNewCatalogPage();
- if (!lastCatalogPage.tryAddDataPage(page.getPos())) {
- throw new AssertionError("Cannot add an item to an empty catalog page");
- }
- }
-
- return page;
- }
-
- private int computeOverallItemCount() {
- int overallItemCount = 0;
- for (Iterator<CatalogPage> iterator = catalogPages.iterator(); iterator.hasNext();) {
- CatalogPage page = iterator.next();
- overallItemCount += page.itemCount;
- }
- return overallItemCount;
- }
-
- private List<CatalogPage> readAllCatalogPages(int rootPageId) throws PagedStorageException {
- List<CatalogPage> catalogPagesList = new ArrayList<CatalogPage>(100);
- int nextPageId = rootPageId;
- while (nextPageId > 0) {
- CatalogPage page = readCatalogPage(nextPageId);
- catalogPagesList.add(page);
- nextPageId = page.nextPageId;
- }
- return catalogPagesList;
- }
-
- private CatalogPage readCatalogPage(int pageId) throws PagedStorageException {
- return (CatalogPage) pagedStorage.readRecord(pageId, catalogPageFactory);
- }
-
- private DataPage readDataPage(int pageId) throws PagedStorageException {
- return (DataPage) pagedStorage.readRecord(pageId, dataPageFactory);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/Mapping.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/Mapping.java
deleted file mode 100644
index a211336..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/catalog/Mapping.java
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.catalog;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.infostore.InfoPos;
-import com.google.dart.indexer.pagedstorage.infostore.InfoStore;
-import com.google.dart.indexer.pagedstorage.infostore.InfoStore.Page;
-import com.google.dart.indexer.pagedstorage.infostore.InfoStoreItemsHierarchy;
-import com.google.dart.indexer.pagedstorage.stats.MappingLayerStats;
-import com.google.dart.indexer.pagedstorage.treestore.PageRec;
-import com.google.dart.indexer.pagedstorage.treestore.PageRecPos;
-import com.google.dart.indexer.pagedstorage.treestore.TreeCoordListener;
-import com.google.dart.indexer.pagedstorage.treestore.TreeStore;
-import com.google.dart.indexer.pagedstorage.util.StringUtils;
-import com.google.dart.indexer.storage.paged.MappingStats;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-public class Mapping implements TreeCoordListener, InfoStoreItemsHierarchy {
- public static final int ID_NONE = -1;
-
- public static final int CB_ID = 4;
-
- private FixedLengthPagedArray catalog;
-
- private final TreeStore treeStore;
-
- private final InfoStore[] infoStores;
-
- static int lookupCount = 0;
-
- public Mapping(PagedStorage pagedStorage, int rootPageId, TreeStore treeStore,
- InfoStore[] infoStores) throws PagedStorageException {
- if (treeStore == null) {
- throw new NullPointerException("treeStore is null");
- }
- this.treeStore = treeStore;
- this.infoStores = infoStores;
- catalog = new FixedLengthPagedArray(pagedStorage, rootPageId, CB_ID + PageRecPos.SIZE
- + InfoPos.SIZE * infoStores.length);
- treeStore.setCoordListener(this);
- }
-
- public void addToInfo(int id, int layerId, int item) throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- throw new IllegalArgumentException("Catalog ID not found: " + id);
- }
- Data data = pos.readableData().seek(infoOffset(layerId));
- InfoStore infoStore = infoStores[layerId];
- InfoPos infoPos = infoStore.readPos(data);
- if (infoPos == null || !infoPos.hasItem(id)) {
- infoPos = infoStore.writeNew(id, new int[] {item});
- pos.setInfoPage(layerId, infoPos.getPageId());
- } else {
- if (infoPos.addItem(id, item)) {
- pos.setInfoPage(layerId, infoPos.getPageId());
- }
- }
- if (!infoPos.hasItem(id)) {
- throw new AssertionError("Adding failed");
- }
- }
-
- public void addToInfo(int id, int layerId, int[] actual) throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- throw new IllegalArgumentException("Catalog ID not found: " + id);
- }
- Data data = pos.readableData().seek(infoOffset(layerId));
- InfoStore infoStore = infoStores[layerId];
- InfoPos infoPos = infoStore.readPos(data);
- if (infoPos == null) {
- infoPos = infoStore.writeNew(id, actual);
- pos.setInfoPage(layerId, infoPos.getPageId());
- } else {
- if (infoPos.addItems(id, actual)) {
- pos.setInfoPage(layerId, infoPos.getPageId());
- }
- }
- if (!infoPos.hasItem(id)) {
- throw new AssertionError("Adding failed");
- }
- }
-
- public synchronized void delete(int id) throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- return; // does not exist, hmm...
- }
- if (pos.isDeleted()) {
- return;
- }
- Data data = pos.readableData().seek(CB_ID);
- PageRecPos treePos = treeStore.readPos(data);
- InfoPos[] infoPos = new InfoPos[infoStores.length];
- for (int i = 0; i < infoStores.length; i++) {
- infoPos[i] = infoStores[i].readPos(data);
- }
- treePos.delete();
- for (int i = 0; i < infoStores.length; i++) {
- if (infoPos[i] != null) {
- infoPos[i].delete(id);
- }
- }
- pos.delete();
- }
-
- public synchronized int find(String[] path) throws PagedStorageException {
- return lookup(path, false);
- }
-
- public synchronized int findOrCreate(String[] path) throws PagedStorageException {
- return lookup(path, true);
- }
-
- @Override
- public int findPageOf(int storeId, int itemId) {
- try {
- CatalogPos pos = catalog.resolve(itemId);
- int page = pos.getInfoPage(storeId);
- while (page <= 0) {
- itemId = pos.getParentRowId();
- if (itemId <= 0) {
- break;
- }
- pos = catalog.resolve(itemId);
- page = pos.getInfoPage(storeId);
- }
- return (page > 0 ? page : -1);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- throw new RuntimeException(exception);
- }
- }
-
- public int getMaxId() {
- return catalog.getOverallItemCount() - 1;
- }
-
- @Override
- public int getParent(int itemId) {
- try {
- CatalogPos pos = catalog.resolve(itemId);
- return pos.getParentRowId();
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- throw new RuntimeException(exception);
- }
- }
-
- public synchronized int[] load(int id) throws PagedStorageException {
- int[] result = new int[infoStores.length];
- CatalogPos pos = catalog.resolve(id);
- Data data = pos.readableData();
- for (int i = 0; i < result.length; i++) {
- result[i] = data.readInt();
- }
- return result;
- }
-
- public synchronized InfoPos locateInfo(int id, int layerId) throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- return null;
- }
- Data data = pos.readableData().seek(infoOffset(layerId));
- return infoStores[layerId].readPos(data);
- }
-
- public synchronized int parentOf(int id) throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- return -1;
- }
- Data data = pos.readableData().seek(0);
- return data.readInt();
- }
-
- public synchronized String[] resolve(int id) throws PagedStorageException {
- List<String> path = new ArrayList<String>();
- do {
- CatalogPos pos = catalog.resolve(id);
- if (pos.isDeleted()) {
- return null;
- }
- PageRecPos treePos = treeStore.readPos(pos.readableData().seek(CB_ID));
- String component = treePos.readName();
- path.add(component);
- id = parentOf(id);
- } while (id > 0);
- Collections.reverse(path);
- return path.toArray(new String[path.size()]);
- }
-
- @SuppressWarnings("unchecked")
- public void stats(MappingStats stats) throws PagedStorageException {
- stats.itemCount = catalog.getOverallItemCount();
- Set<Integer>[] pages = new Set[infoStores.length];
- for (int i = 0; i < infoStores.length; i++) {
- pages[i] = new HashSet<Integer>();
- }
- MappingLayerStats[] layerStats = new MappingLayerStats[infoStores.length];
- for (int i = 0; i < infoStores.length; i++) {
- layerStats[i] = new MappingLayerStats();
- }
- for (int id = 1; id < stats.itemCount; id++) {
- CatalogPos pos = catalog.resolve(id);
- if (pos.isDeleted()) {
- ++stats.deletedItemCount;
- }
- for (int i = 0; i < infoStores.length; i++) {
- int page = pos.getInfoPage(i);
- if (page > 0) {
- pages[i].add(new Integer(page));
- }
- }
- }
- for (int i = 0; i < infoStores.length; i++) {
- layerStats[i].usedPages = pages[i].size();
- for (Iterator<Integer> iterator = pages[i].iterator(); iterator.hasNext();) {
- int page = iterator.next().intValue();
- Page p = infoStores[i].readPage(page);
- p.stats(layerStats[i]);
- }
- }
- for (int i = 0; i < infoStores.length; i++) {
- stats.pageCount += layerStats[i].usedPages;
- stats.usedPageCounts.add(layerStats[i].usedPages);
- stats.pageFillFactors.addAll(layerStats[i].pageFillFactors);
- stats.itemLength.addAll(layerStats[i].itemLength);
- stats.itemsPerPage.addAll(layerStats[i].itemsPerPage);
- }
- treeStore.stats(stats.treeStoreStats);
- catalog.stats(stats.catalogStats);
- }
-
- @Override
- public String toString() {
- return catalog.toString();
- }
-
- @Override
- public void treeCoordChanged(int id, int newPage, int newRecord, int newPos)
- throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- "Hm, catalog does not have an entry for id " + id);
- return;
- }
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.DEPENDENT_UPDATES,
- "Item ID " + id + " new coords: <" + newPage + "," + newRecord + "," + newPos + ">");
- Data data = pos.writableData().seek(CB_ID);
- data.writeInt(newPage);
- data.writeShortInt(newRecord);
- data.writeShortInt(newPos);
- }
-
- @Override
- public void updatePageId(int storeId, int itemId, int newPage) {
- try {
- CatalogPos pos = catalog.resolve(itemId);
- pos.setInfoPage(storeId, newPage);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- throw new RuntimeException(exception);
- }
- }
-
- public synchronized void writeInfo(int id, int layerId, int[] payload)
- throws PagedStorageException {
- CatalogPos pos = catalog.resolve(id);
- if (pos == null) {
- throw new IllegalArgumentException("Catalog ID not found: " + id);
- }
- Data data = pos.readableData().seek(infoOffset(layerId));
- InfoStore infoStore = infoStores[layerId];
- InfoPos infoPos = infoStore.readPos(data);
- if (infoPos == null) {
- infoPos = infoStore.writeNew(id, payload);
- pos.setInfoPage(layerId, infoPos.getPageId());
- } else {
- if (infoPos.update(id, payload)) {
- pos.setInfoPage(layerId, infoPos.getPageId());
- }
- }
- if (!infoPos.hasItem(id)) {
- throw new AssertionError("Adding failed");
- }
- }
-
- @Override
- public void writeNewlyAllocatedPageId(int storeId, int itemId, int newPage) {
- try {
- CatalogPos pos = catalog.resolve(itemId);
- int oldPage = pos.getInfoPage(storeId);
- if (oldPage > 0) {
- throw new IllegalArgumentException("Item " + itemId + " on page " + pos.getPageId()
- + " already has an assigned page");
- }
- do {
- pos.setInfoPage(storeId, newPage);
-
- itemId = pos.getParentRowId();
- if (itemId <= 0) {
- break;
- }
- pos = catalog.resolve(itemId);
- oldPage = pos.getInfoPage(storeId);
- } while (oldPage <= 0);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- throw new RuntimeException(exception);
- }
- }
-
- protected void fillTreeDataForNewItem(String[] path, PageRecPos pos) {
-
- }
-
- private int infoOffset(int layerId) {
- return CB_ID + PageRecPos.SIZE + layerId * InfoPos.SIZE;
- }
-
- private int lookup(String[] path, boolean add) throws PagedStorageException {
- ++lookupCount;
- PageRec pageRec = treeStore.root();
- int pathLength = path.length;
- int rowId = 0;
- for (int i = 0; i < pathLength; i++) {
- String component = path[i];
- PageRecPos pos = pageRec.lookup(component, add);
- if (pos == null) {
- if (add && IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.ANOMALIES)) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ANOMALIES,
- "Item creation failed for path " + StringUtils.join(path));
- } else {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- " NOT FOUND at #" + i + " " + component);
- }
- return ID_NONE;
- }
-
- int parentRowId = rowId;
- rowId = pos.getRowId();
- if (rowId > 0 && catalog.resolve(rowId).isDeleted()) {
- if (add) {
- rowId = -1;
- } else {
- return ID_NONE;
- }
- }
- if (rowId <= 0) {
- CatalogPos catPos = catalog.allocateNew();
- Data data = catPos.writableData();
- pos.write(data.seek(CB_ID));
- for (int k = 0; k < infoStores.length; k++) {
- infoStores[k].writeEmptyPos(data);
- }
-
- catPos.setParentRowId(parentRowId);
- rowId = catPos.getRowId();
- pos.setRowId(rowId);
- fillTreeDataForNewItem(path, pos);
- }
-
- if (i < pathLength - 1) {
- pageRec = pos.children(add);
- if (pageRec == null) {
- if (add && IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.ANOMALIES)) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ANOMALIES,
- "Child record creation failed for path " + StringUtils.join(path));
- } else {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- " NO CHILDREN at #" + i + " " + component);
- }
- return ID_NONE;
- }
- }
- }
- return rowId;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageCorruptedException.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageCorruptedException.java
deleted file mode 100644
index 7d6e9cc..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageCorruptedException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.exceptions;
-
-public class PagedStorageCorruptedException extends PagedStorageException {
- private static final long serialVersionUID = 1L;
-
- public PagedStorageCorruptedException() {
- super();
- }
-
- public PagedStorageCorruptedException(String message) {
- super(message);
- }
-
- public PagedStorageCorruptedException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public PagedStorageCorruptedException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageException.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageException.java
deleted file mode 100644
index c8ccd10..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.exceptions;
-
-public class PagedStorageException extends Exception {
- private static final long serialVersionUID = 1L;
-
- public PagedStorageException() {
- super();
- }
-
- public PagedStorageException(String message) {
- super(message);
- }
-
- public PagedStorageException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public PagedStorageException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageNonexistentPageReferenceException.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageNonexistentPageReferenceException.java
deleted file mode 100644
index 9492d1a..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/exceptions/PagedStorageNonexistentPageReferenceException.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.exceptions;
-
-public class PagedStorageNonexistentPageReferenceException extends PagedStorageException {
- private static final long serialVersionUID = 1L;
-
- public PagedStorageNonexistentPageReferenceException() {
- super();
- }
-
- public PagedStorageNonexistentPageReferenceException(String message) {
- super(message);
- }
-
- public PagedStorageNonexistentPageReferenceException(String message, Throwable cause) {
- super(message, cause);
- }
-
- public PagedStorageNonexistentPageReferenceException(Throwable cause) {
- super(cause);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/AccessMode.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/AccessMode.java
deleted file mode 100644
index 2816934..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/AccessMode.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-/**
- * Values of the enum <code>AccessMode</code> represent the access modes that are valid for a
- * {@link FileObject}.
- */
-public enum AccessMode {
- /**
- * Open for reading only. Invoking any of the <tt>write</tt> methods of the resulting object will
- * cause an {@link java.io.IOException} to be thrown.
- */
- READ_ONLY("r"),
-
- /**
- * Open for reading and writing. If the file does not already exist then an attempt will be made
- * to create it.
- */
- READ_WRITE("rw"),
-
- /**
- * Open for reading and writing, as with <tt>READ_WRITE</tt>, and also require that every update
- * to the file's content or metadata be written synchronously to the underlying storage device.
- */
- READ_WRITE_SYNC("rws"),
-
- /**
- * Open for reading and writing, as with <tt>READ_WRITE</tt>, and also require that every update
- * to the file's content be written synchronously to the underlying storage device.
- */
- READ_WRITE_DATA("rwd");
-
- /**
- * The String representation of this mode.
- */
- private String mode;
-
- /**
- * Prevent the creation of new instances of this type.
- */
- private AccessMode(String mode) {
- this.mode = mode;
- }
-
- /**
- * Return the String representation of this mode.
- *
- * @return the String representation of this mode
- */
- public String getMode() {
- return mode;
- }
-
- /**
- * Return <code>true</code> if this mode requires that some or all of the writes be synchronous.
- *
- * @return <code>true</code> if this mode requires that some or all of the writes be synchronous
- */
- public boolean isSynchronous() {
- return mode.length() > 2;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/DiskFileObject.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/DiskFileObject.java
deleted file mode 100644
index 9d5b9e5..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/DiskFileObject.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.pagedstorage.util.FileUtils;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-
-/**
- * This class is extends a java.io.RandomAccessFile.
- */
-public class DiskFileObject extends RandomAccessFile implements FileObject {
- private final String name;
-
- DiskFileObject(String fileName, String mode) throws FileNotFoundException {
- super(fileName, mode);
- this.name = fileName;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public void setFileLength(long newLength) throws IOException {
- FileUtils.setLength(this, newLength);
- }
-
- @Override
- public void sync() throws IOException {
- getFD().sync();
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/DiskFileSystem.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/DiskFileSystem.java
deleted file mode 100644
index 7be51ef..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/DiskFileSystem.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.util.Constants;
-import com.google.dart.indexer.pagedstorage.util.FileUtils;
-import com.google.dart.indexer.pagedstorage.util.IOUtils;
-import com.google.dart.indexer.pagedstorage.util.SysProperties;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.URL;
-
-/**
- * This file system stores files on disk. This is the most common file system.
- */
-public class DiskFileSystem extends FileSystem {
- private static final DiskFileSystem INSTANCE = new DiskFileSystem();
- // TODO detection of 'case in sensitive filesystem'
- // could maybe implemented using some other means
- @SuppressWarnings("unused")
- private static final boolean IS_FILE_SYSTEM_CASE_INSENSITIVE = File.separatorChar == '\\';
-
- public static DiskFileSystem getInstance() {
- return INSTANCE;
- }
-
- private static void wait(int i) {
- if (i > 8) {
- System.gc();
- }
- try {
- // sleep at most 256 ms
- long sleep = Math.min(256, i * i);
- Thread.sleep(sleep);
- } catch (InterruptedException e) {
- // ignore
- }
- }
-
- protected DiskFileSystem() {
- // nothing to do
- }
-
- @Override
- public boolean canWrite(String fileName) {
- fileName = translateFileName(fileName);
- return new File(fileName).canWrite();
- }
-
- @Override
- public void copy(String original, String copy) throws PagedStorageException {
- original = translateFileName(original);
- copy = translateFileName(copy);
- OutputStream out = null;
- InputStream in = null;
- try {
- out = FileUtils.openFileOutputStream(copy, false);
- in = FileUtils.openFileInputStream(original);
- byte[] buffer = new byte[Constants.IO_BUFFER_SIZE];
- while (true) {
- int len = in.read(buffer);
- if (len < 0) {
- break;
- }
- out.write(buffer, 0, len);
- }
- out.close();
- } catch (IOException e) {
- throw new RuntimeException(e);
- } finally {
- IOUtils.closeSilently(in);
- IOUtils.closeSilently(out);
- }
- }
-
- @Override
- public void createDirs(String fileName) throws PagedStorageException {
- fileName = translateFileName(fileName);
- File f = new File(fileName);
- if (!f.exists()) {
- String parent = f.getParent();
- if (parent == null) {
- return;
- }
- File dir = new File(parent);
- for (int i = 0; i < SysProperties.MAX_FILE_RETRY; i++) {
- if (dir.exists() || dir.mkdirs()) {
- return;
- }
- wait(i);
- }
- throw new RuntimeException();
- }
- }
-
- @Override
- public boolean createNewFile(String fileName) {
- fileName = translateFileName(fileName);
- File file = new File(fileName);
- for (int i = 0; i < SysProperties.MAX_FILE_RETRY; i++) {
- try {
- return file.createNewFile();
- } catch (IOException e) {
- // 'access denied' is really a concurrent access problem
- wait(i);
- }
- }
- return false;
- }
-
- @Override
- public String createTempFile(String name, String suffix, boolean deleteOnExit, boolean inTempDir)
- throws IOException {
- name = translateFileName(name);
- name += ".";
- String prefix = new File(name).getName();
- File dir;
- if (inTempDir) {
- dir = null;
- } else {
- dir = new File(name).getAbsoluteFile().getParentFile();
- dir.mkdirs();
- }
- if (prefix.length() < 3) {
- prefix += "0";
- }
- File f = File.createTempFile(prefix, suffix, dir);
- if (deleteOnExit) {
- try {
- f.deleteOnExit();
- } catch (Throwable e) {
- // sometimes this throws a NullPointerException
- // at java.io.DeleteOnExitHook.add(DeleteOnExitHook.java:33)
- // we can ignore it
- }
- }
- return f.getCanonicalPath();
- }
-
- @Override
- public void delete(String fileName) throws PagedStorageException {
- fileName = translateFileName(fileName);
- File file = new File(fileName);
- if (file.exists()) {
- for (int i = 0; i < SysProperties.MAX_FILE_RETRY; i++) {
- trace("delete", fileName, null);
- boolean ok = file.delete();
- if (ok) {
- return;
- }
- wait(i);
- }
- throw new RuntimeException("delete failed: " + fileName);
- }
- }
-
- @Override
- public void deleteRecursive(String fileName) throws PagedStorageException {
- fileName = translateFileName(fileName);
- if (FileUtils.isDirectory(fileName)) {
- String[] list = listFiles(fileName);
- for (int i = 0; list != null && i < list.length; i++) {
- deleteRecursive(list[i]);
- }
- }
- delete(fileName);
- }
-
- @Override
- public boolean exists(String fileName) {
- fileName = translateFileName(fileName);
- return new File(fileName).exists();
- }
-
- @Override
- public String getAbsolutePath(String fileName) {
- fileName = translateFileName(fileName);
- File parent = new File(fileName).getAbsoluteFile();
- return parent.getAbsolutePath();
- }
-
- @Override
- public String getFileName(String name) throws PagedStorageException {
- name = translateFileName(name);
- String separator = File.separator;
- String path = getParent(name);
- if (!path.endsWith(separator)) {
- path += separator;
- }
- String fullFileName = normalize(name);
- if (!fullFileName.startsWith(path)) {
- throw new RuntimeException();
- // Message.throwInternalError("file utils error: " + fullFileName +
- // " does not start with " + path);
- }
- String fileName = fullFileName.substring(path.length());
- return fileName;
- }
-
- @Override
- public long getLastModified(String fileName) {
- fileName = translateFileName(fileName);
- return new File(fileName).lastModified();
- }
-
- @Override
- public String getParent(String fileName) {
- fileName = translateFileName(fileName);
- return new File(fileName).getParent();
- }
-
- @Override
- public boolean isAbsolute(String fileName) {
- fileName = translateFileName(fileName);
- File file = new File(fileName);
- return file.isAbsolute();
- }
-
- @Override
- public boolean isDirectory(String fileName) {
- fileName = translateFileName(fileName);
- return new File(fileName).isDirectory();
- }
-
- @Override
- public boolean isReadOnly(String fileName) {
- fileName = translateFileName(fileName);
- File f = new File(fileName);
- return f.exists() && !f.canWrite();
- }
-
- @Override
- public long length(String fileName) {
- fileName = translateFileName(fileName);
- return new File(fileName).length();
- }
-
- @Override
- public String[] listFiles(String path) throws PagedStorageException {
- path = translateFileName(path);
- File f = new File(path);
- try {
- String[] list = f.list();
- if (list == null) {
- return new String[0];
- }
- String base = f.getCanonicalPath();
- if (!base.endsWith(File.separator)) {
- base += File.separator;
- }
- for (int i = 0; i < list.length; i++) {
- list[i] = base + list[i];
- }
- return list;
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- @Override
- public String normalize(String fileName) throws PagedStorageException {
- fileName = translateFileName(fileName);
- File f = new File(fileName);
- try {
- return f.getCanonicalPath();
- } catch (IOException e) {
- throw new RuntimeException(e);
- // throw Message.convertIOException(e, fileName);
- }
- }
-
- @Override
- public InputStream openFileInputStream(String fileName) throws IOException {
- if (fileName.indexOf(':') > 1) {
- // if the : is in position 1, a windows file access is assumed: C:.. or D:
- // otherwise a URL is assumed
- URL url = new URL(fileName);
- InputStream in = url.openStream();
- return in;
- }
- fileName = translateFileName(fileName);
- FileInputStream in = new FileInputStream(fileName);
- trace("openFileInputStream", fileName, in);
- return in;
- }
-
- @Override
- public FileObject openFileObject(String fileName, AccessMode mode) throws IOException {
- fileName = translateFileName(fileName);
- DiskFileObject f;
- try {
- f = new DiskFileObject(fileName, mode.getMode());
- trace("openRandomAccessFile", fileName, f);
- } catch (IOException e) {
- freeMemoryAndFinalize();
- try {
- f = new DiskFileObject(fileName, mode.getMode());
- } catch (IOException e2) {
- throw e;
- }
- }
- return f;
- }
-
- @Override
- public OutputStream openFileOutputStream(String fileName, boolean append)
- throws PagedStorageException {
- fileName = translateFileName(fileName);
- try {
- File file = new File(fileName);
- createDirs(file.getAbsolutePath());
- FileOutputStream out = new FileOutputStream(fileName, append);
- trace("openFileOutputStream", fileName, out);
- return out;
- } catch (IOException e) {
- freeMemoryAndFinalize();
- try {
- return new FileOutputStream(fileName);
- } catch (IOException e2) {
- throw new RuntimeException(e2);
- }
- }
- }
-
- @Override
- public void rename(String oldName, String newName) throws PagedStorageException {
- oldName = translateFileName(oldName);
- newName = translateFileName(newName);
- File oldFile = new File(oldName);
- File newFile = new File(newName);
- if (oldFile.getAbsolutePath().equals(newFile.getAbsolutePath())) {
- throw new RuntimeException("Rename failed: old=new: " + oldName + " -> " + newName);
- }
- if (!oldFile.exists()) {
- throw new RuntimeException("Rename failed: " + oldName + " -> " + newName);
- }
- if (newFile.exists()) {
- throw new RuntimeException("Rename failed: " + oldName + " -> " + newName);
- }
- for (int i = 0; i < SysProperties.MAX_FILE_RETRY; i++) {
- trace("rename", oldName + " >" + newName, null);
- boolean ok = oldFile.renameTo(newFile);
- if (ok) {
- return;
- }
- wait(i);
- }
- throw new RuntimeException("Rename failed: " + oldName + " -> " + newName);
- }
-
- @Override
- public boolean tryDelete(String fileName) {
- fileName = translateFileName(fileName);
- trace("tryDelete", fileName, null);
- return new File(fileName).delete();
- }
-
- /**
- * Call the garbage collection and run finalization. This close all files that were not closed,
- * and are no longer referenced.
- */
- protected void freeMemoryAndFinalize() {
- trace("freeMemoryAndFinalize", null, null);
- Runtime rt = Runtime.getRuntime();
- long mem = rt.freeMemory();
- for (int i = 0; i < 16; i++) {
- rt.gc();
- long now = rt.freeMemory();
- rt.runFinalization();
- if (now == mem) {
- break;
- }
- mem = now;
- }
- }
-
- /**
- * Print a trace message if tracing is enabled.
- *
- * @param method the method
- * @param fileName the file name
- * @param o the object
- */
- protected void trace(String method, String fileName, Object o) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ALL_IO,
- "FileSystem." + method + " " + fileName + " " + o);
- }
-
- /**
- * Translate the file name to the native format. This will expand the home directory (~).
- *
- * @param fileName the file name
- * @return the native file name
- */
- protected String translateFileName(String fileName) {
- return fileName;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObject.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObject.java
deleted file mode 100644
index 5fd59b8..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObject.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import java.io.IOException;
-
-/**
- * This interface represents a random access file.
- */
-public interface FileObject {
- /**
- * Close the file.
- */
- void close() throws IOException;
-
- /**
- * Get the file pointer.
- *
- * @return the current file pointer
- */
- long getFilePointer() throws IOException;
-
- /**
- * Get the full qualified name of this file.
- *
- * @return the name
- */
- String getName();
-
- /**
- * Get the length of the file.
- *
- * @return the length
- */
- long length() throws IOException;
-
- /**
- * Read from the file.
- *
- * @param b the byte array
- * @param off the offset
- * @param len the number of bytes
- */
- void readFully(byte[] b, int off, int len) throws IOException;
-
- /**
- * Go to the specified position in the file.
- *
- * @param pos the new position
- */
- void seek(long pos) throws IOException;
-
- /**
- * Change the length of the file.
- *
- * @param newLength the new length
- */
- void setFileLength(long newLength) throws IOException;
-
- /**
- * Force changes to the physical location.
- */
- void sync() throws IOException;
-
- /**
- * Write to the file.
- *
- * @param b the byte array
- * @param off the offset
- * @param len the number of bytes
- */
- void write(byte[] b, int off, int len) throws IOException;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObjectInputStream.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObjectInputStream.java
deleted file mode 100644
index 881dbe0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObjectInputStream.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * Allows to read from a file object like an input stream.
- */
-public class FileObjectInputStream extends InputStream {
- private FileObject file;
- private byte[] buffer = new byte[1];
-
- /**
- * Create a new file object input stream from the file object.
- *
- * @param file the file object
- */
- public FileObjectInputStream(FileObject file) {
- this.file = file;
- }
-
- @Override
- public void close() throws IOException {
- file.close();
- }
-
- @Override
- public int read() throws IOException {
- if (file.getFilePointer() >= file.length()) {
- return -1;
- }
- file.readFully(buffer, 0, 1);
- return buffer[0] & 0xff;
- }
-
- @Override
- public int read(byte[] b) throws IOException {
- return read(b, 0, b.length);
- }
-
- @Override
- public int read(byte[] b, int off, int len) throws IOException {
- if (file.getFilePointer() + len < file.length()) {
- file.readFully(b, off, len);
- return len;
- }
- return super.read(b, off, len);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObjectOutputStream.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObjectOutputStream.java
deleted file mode 100644
index d426a11..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileObjectOutputStream.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import java.io.IOException;
-import java.io.OutputStream;
-
-/**
- * Allows to write to a file object like an output stream.
- */
-public class FileObjectOutputStream extends OutputStream {
- private FileObject file;
- private byte[] buffer = new byte[1];
-
- /**
- * Create a new file object output stream from the file object.
- *
- * @param file the file object
- * @param append true for append mode, false for truncate and overwrite
- */
- public FileObjectOutputStream(FileObject file, boolean append) throws IOException {
- this.file = file;
- if (append) {
- file.seek(file.length());
- } else {
- file.seek(0);
- file.setFileLength(0);
- }
- }
-
- @Override
- public void close() throws IOException {
- file.close();
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- file.write(b, 0, b.length);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- file.write(b, off, len);
- }
-
- @Override
- public void write(int b) throws IOException {
- buffer[0] = (byte) b;
- file.write(buffer, 0, 1);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileSystem.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileSystem.java
deleted file mode 100644
index 153e41e..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/FileSystem.java
+++ /dev/null
@@ -1,267 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-/**
- * The file system is a storage abstraction.
- */
-public abstract class FileSystem {
- /**
- * The prefix used for an in-memory file system.
- */
- public static final String PREFIX_MEMORY = "memFS:";
-
- /**
- * The prefix used for the NIO FileChannel file system.
- */
- public static final String PREFIX_NIO = "nio:";
-
- /**
- * The prefix used for the NIO (memory mapped) file system.
- */
- public static final String PREFIX_NIO_MAPPED = "nioMapped:";
-
- /**
- * Get the file system object.
- *
- * @param fileName the file name or prefix
- * @return the file system
- */
- public static FileSystem getInstance(String fileName) {
- if (fileName == null) {
- return DiskFileSystem.getInstance();
- } else if (fileName.startsWith(PREFIX_MEMORY)) {
- return InMemoryFileSystem.getInstance();
- } else if (fileName.startsWith(PREFIX_NIO)) {
- return NioFileSystem.getInstance();
- } else if (fileName.startsWith(PREFIX_NIO_MAPPED)) {
- return MemoryMappedFileSystem.getInstance();
- }
- return DiskFileSystem.getInstance();
- }
-
- /**
- * Check if the file is writable.
- *
- * @param fileName the file name
- * @return if the file is writable
- */
- public abstract boolean canWrite(String fileName);
-
- /**
- * Copy a file from one directory to another, or to another file.
- *
- * @param original the original file name
- * @param copy the file name of the copy
- */
- public abstract void copy(String original, String copy) throws PagedStorageException;
-
- /**
- * Create all required directories that are required for this file.
- *
- * @param fileName the file name (not directory name)
- */
- public abstract void createDirs(String fileName) throws PagedStorageException;
-
- /**
- * Create a new file.
- *
- * @param fileName the file name
- * @return true if creating was successful
- */
- public abstract boolean createNewFile(String fileName) throws PagedStorageException;
-
- /**
- * Create a new temporary file.
- *
- * @param prefix the prefix of the file name (including directory name if required)
- * @param suffix the suffix
- * @param deleteOnExit if the file should be deleted when the virtual machine exists
- * @param inTempDir if the file should be stored in the temporary directory
- * @return the name of the created file
- */
- public abstract String createTempFile(String prefix, String suffix, boolean deleteOnExit,
- boolean inTempDir) throws IOException;
-
- /**
- * Delete a file.
- *
- * @param fileName the file name
- */
- public abstract void delete(String fileName) throws PagedStorageException;
-
- /**
- * Delete a directory or file and all subdirectories and files.
- *
- * @param directory the directory
- */
- public abstract void deleteRecursive(String directory) throws PagedStorageException;
-
- /**
- * Checks if a file exists.
- *
- * @param fileName the file name
- * @return true if it exists
- */
- public abstract boolean exists(String fileName);
-
- /**
- * Get the absolute file name.
- *
- * @param fileName the file name
- * @return the absolute file name
- */
- public abstract String getAbsolutePath(String fileName);
-
- /**
- * Get the file name (without directory part).
- *
- * @param name the directory and file name
- * @return just the file name
- */
- public abstract String getFileName(String name) throws PagedStorageException;
-
- /**
- * Get the last modified date of a file
- *
- * @param fileName the file name
- * @return the last modified date
- */
- public abstract long getLastModified(String fileName);
-
- /**
- * Get the parent directory of a file or directory.
- *
- * @param fileName the file or directory name
- * @return the parent directory name
- */
- public abstract String getParent(String fileName);
-
- /**
- * Check if the file name includes a path.
- *
- * @param fileName the file name
- * @return if the file name is absolute
- */
- public abstract boolean isAbsolute(String fileName);
-
- /**
- * Check if it is a file or a directory.
- *
- * @param fileName the file or directory name
- * @return true if it is a directory
- */
- public abstract boolean isDirectory(String fileName);
-
- /**
- * Check if a file is read-only.
- *
- * @param fileName the file name
- * @return if it is read only
- */
- public abstract boolean isReadOnly(String fileName);
-
- /**
- * Get the length of a file.
- *
- * @param fileName the file name
- * @return the length in bytes
- */
- public abstract long length(String fileName);
-
- /**
- * List the files in the given directory.
- *
- * @param directory the directory
- * @return the list of fully qualified file names
- */
- public abstract String[] listFiles(String directory) throws PagedStorageException;
-
- /**
- * Create all required directories.
- *
- * @param directoryName the directory name
- */
- public void mkdirs(String directoryName) throws PagedStorageException {
- createDirs(directoryName + "/x");
- }
-
- /**
- * Normalize a file name.
- *
- * @param fileName the file name
- * @return the normalized file name
- */
- public abstract String normalize(String fileName) throws PagedStorageException;
-
- /**
- * Create an input stream to read from the file.
- *
- * @param fileName the file name
- * @return the input stream
- */
- public abstract InputStream openFileInputStream(String fileName) throws IOException;
-
- /**
- * Open a random access file object.
- *
- * @param fileName the file name
- * @param mode the access mode
- * @return the file object
- */
- public abstract FileObject openFileObject(String fileName, AccessMode mode) throws IOException;
-
- /**
- * Create an output stream to write into the file.
- *
- * @param fileName the file name
- * @param append if true, the file will grow, if false, the file will be truncated first
- * @return the output stream
- */
- public abstract OutputStream openFileOutputStream(String fileName, boolean append)
- throws PagedStorageException;
-
- /**
- * Rename a file if this is allowed.
- *
- * @param oldName the old fully qualified file name
- * @param newName the new fully qualified file name
- * @throws PagedStorageException
- */
- public abstract void rename(String oldName, String newName) throws PagedStorageException;
-
- /**
- * Try to delete a file.
- *
- * @param fileName the file name
- * @return true if it could be deleted
- */
- public abstract boolean tryDelete(String fileName);
-
- /**
- * Check if the file system is responsible for this file name.
- *
- * @param fileName the file name
- * @return true if it is
- */
- protected boolean accepts(String fileName) {
- return false;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/InMemoryFileObject.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/InMemoryFileObject.java
deleted file mode 100644
index 91cf538..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/InMemoryFileObject.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.pagedstorage.util.MathUtils;
-
-import java.io.EOFException;
-import java.io.IOException;
-
-/**
- * This class is an abstraction of an in-memory random access file. Data compression using the LZF
- * algorithm is supported as well.
- */
-public class InMemoryFileObject implements FileObject {
- private static final int BLOCK_SIZE_SHIFT = 16;
- private static final int BLOCK_SIZE = 1 << BLOCK_SIZE_SHIFT;
- private static final int BLOCK_SIZE_MASK = BLOCK_SIZE - 1;
-
- private String name;
- private long length;
- private long pos;
- private byte[][] data;
- private long lastModified;
-
- InMemoryFileObject(String name) {
- this.name = name;
- data = new byte[0][];
- touch();
- }
-
- @Override
- public void close() {
- pos = 0;
- }
-
- @Override
- public long getFilePointer() {
- return pos;
- }
-
- public long getLastModified() {
- return lastModified;
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public long length() {
- return length;
- }
-
- @Override
- public void readFully(byte[] b, int off, int len) throws IOException {
- readWrite(b, off, len, false);
- }
-
- @Override
- public void seek(long pos) {
- this.pos = (int) pos;
- }
-
- @Override
- public void setFileLength(long newLength) {
- touch();
- if (newLength < length) {
- pos = Math.min(pos, newLength);
- changeLength(newLength);
- long end = MathUtils.roundUpLong(newLength, BLOCK_SIZE);
- if (end != newLength) {
- int lastPage = (int) (newLength >>> BLOCK_SIZE_SHIFT);
- byte[] d = data[lastPage];
- for (int i = (int) (newLength & BLOCK_SIZE_MASK); i < BLOCK_SIZE; i++) {
- d[i] = 0;
- }
- }
- } else {
- changeLength(newLength);
- }
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public void sync() {
- // nothing to do
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- touch();
- readWrite(b, off, len, true);
- }
-
- private void changeLength(long len) {
- length = len;
- len = MathUtils.roundUpLong(len, BLOCK_SIZE);
- int blocks = (int) (len >>> BLOCK_SIZE_SHIFT);
- if (blocks != data.length) {
- byte[][] n = new byte[blocks][];
- System.arraycopy(data, 0, n, 0, Math.min(data.length, n.length));
- for (int i = data.length; i < blocks; i++) {
- n[i] = new byte[BLOCK_SIZE];
- }
- data = n;
- }
-
- }
-
- private void readWrite(byte[] b, int off, int len, boolean write) throws IOException {
- long end = pos + len;
- if (end > length) {
- if (write) {
- changeLength(end);
- } else {
- if (len == 0) {
- return;
- }
- throw new EOFException("File: " + name);
- }
- }
- while (len > 0) {
- int l = (int) Math.min(len, BLOCK_SIZE - (pos & BLOCK_SIZE_MASK));
- int page = (int) (pos >>> BLOCK_SIZE_SHIFT);
- byte[] block = data[page];
- int blockOffset = (int) (pos & BLOCK_SIZE_MASK);
- if (write) {
- System.arraycopy(b, off, block, blockOffset, l);
- } else {
- System.arraycopy(block, blockOffset, b, off, l);
- }
- off += l;
- pos += l;
- len -= l;
- }
- }
-
- private void touch() {
- lastModified = System.currentTimeMillis();
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/InMemoryFileSystem.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/InMemoryFileSystem.java
deleted file mode 100644
index 08911a3..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/InMemoryFileSystem.java
+++ /dev/null
@@ -1,261 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.util.IOUtils;
-import com.google.dart.indexer.pagedstorage.util.ObjectArray;
-import com.google.dart.indexer.pagedstorage.util.RandomUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-
-/**
- * This file system keeps files fully in memory. There is an option to compress file blocks to safe
- * memory.
- */
-public class InMemoryFileSystem extends FileSystem {
- private static final InMemoryFileSystem INSTANCE = new InMemoryFileSystem();
- private static final HashMap<String, InMemoryFileObject> MEMORY_FILES = new HashMap<String, InMemoryFileObject>();
-
- public static InMemoryFileSystem getInstance() {
- return INSTANCE;
- }
-
- private InMemoryFileSystem() {
- // don't allow construction
- }
-
- @Override
- public boolean canWrite(String fileName) {
- return true;
- }
-
- @Override
- public void copy(String original, String copy) throws PagedStorageException {
- try {
- OutputStream out = openFileOutputStream(copy, false);
- InputStream in = openFileInputStream(original);
- IOUtils.copyAndClose(in, out);
- } catch (IOException e) {
- throw new RuntimeException(e);
- // throw Message.convertIOException(e, "Can not copy " + original + " to "
- // + copy);
- }
- }
-
- @Override
- public void createDirs(String fileName) {
- // TODO directories are not really supported
- }
-
- @Override
- public boolean createNewFile(String fileName) {
- synchronized (MEMORY_FILES) {
- if (exists(fileName)) {
- return false;
- }
- getObjectFile(fileName);
- }
- return true;
- }
-
- @Override
- public String createTempFile(String name, String suffix, boolean deleteOnExit, boolean inTempDir) {
- name += ".";
- synchronized (MEMORY_FILES) {
- while (true) {
- String n = name + (RandomUtils.getSecureLong() >>> 1) + suffix;
- if (!exists(n)) {
- getObjectFile(n);
- return n;
- }
- }
- }
- }
-
- @Override
- public void delete(String fileName) {
- fileName = normalize(fileName);
- synchronized (MEMORY_FILES) {
- MEMORY_FILES.remove(fileName);
- }
- }
-
- @Override
- public void deleteRecursive(String fileName) {
- fileName = normalize(fileName);
- synchronized (MEMORY_FILES) {
- Iterator<String> it = MEMORY_FILES.keySet().iterator();
- while (it.hasNext()) {
- String name = it.next();
- if (name.startsWith(fileName)) {
- it.remove();
- }
- }
- }
- }
-
- @Override
- public boolean exists(String fileName) {
- fileName = normalize(fileName);
- synchronized (MEMORY_FILES) {
- return MEMORY_FILES.get(fileName) != null;
- }
- }
-
- public boolean fileStartsWith(String fileName, String prefix) {
- fileName = normalize(fileName);
- prefix = normalize(prefix);
- return fileName.startsWith(prefix);
- }
-
- @Override
- public String getAbsolutePath(String fileName) {
- // TODO relative files are not supported
- return normalize(fileName);
- }
-
- @Override
- public String getFileName(String name) {
- // TODO directories are not supported
- return name;
- }
-
- @Override
- public long getLastModified(String fileName) {
- return getObjectFile(fileName).getLastModified();
- }
-
- @Override
- public String getParent(String fileName) {
- fileName = normalize(fileName);
- int idx = fileName.lastIndexOf('/');
- if (idx < 0) {
- idx = fileName.indexOf(':') + 1;
- }
- return fileName.substring(0, idx);
- }
-
- @Override
- public boolean isAbsolute(String fileName) {
- // TODO relative files are not supported
- return true;
- }
-
- @Override
- public boolean isDirectory(String fileName) {
- // TODO in memory file system currently doesn't support directories
- return false;
- }
-
- @Override
- public boolean isReadOnly(String fileName) {
- return false;
- }
-
- @Override
- public long length(String fileName) {
- return getObjectFile(fileName).length();
- }
-
- @Override
- public String[] listFiles(String path) {
- ObjectArray<String> list = ObjectArray.newInstance();
- synchronized (MEMORY_FILES) {
- for (Iterator<String> iterator = MEMORY_FILES.keySet().iterator(); iterator.hasNext();) {
- String name = iterator.next();
- if (name.startsWith(path)) {
- list.add(name);
- }
- }
- String[] array = new String[list.size()];
- list.toArray(array);
- return array;
- }
- }
-
- @Override
- public String normalize(String fileName) {
- fileName = fileName.replace('\\', '/');
- int idx = fileName.indexOf(":/");
- if (idx > 0) {
- fileName = fileName.substring(0, idx + 1) + fileName.substring(idx + 2);
- }
- return fileName;
- }
-
- @Override
- public InputStream openFileInputStream(String fileName) {
- InMemoryFileObject obj = getObjectFile(fileName);
- obj.seek(0);
- return new FileObjectInputStream(obj);
- }
-
- @Override
- public FileObject openFileObject(String fileName, AccessMode mode) {
- InMemoryFileObject obj = getObjectFile(fileName);
- obj.seek(0);
- return obj;
- }
-
- @Override
- public OutputStream openFileOutputStream(String fileName, boolean append)
- throws PagedStorageException {
- try {
- InMemoryFileObject obj = getObjectFile(fileName);
- obj.seek(0);
- return new FileObjectOutputStream(obj, append);
- } catch (IOException e) {
- throw new RuntimeException(e);
- // throw Message.convertIOException(e, fileName);
- }
- }
-
- @Override
- public void rename(String oldName, String newName) {
- oldName = normalize(oldName);
- newName = normalize(newName);
- synchronized (MEMORY_FILES) {
- InMemoryFileObject f = getObjectFile(oldName);
- f.setName(newName);
- MEMORY_FILES.remove(oldName);
- MEMORY_FILES.put(newName, f);
- }
- }
-
- @Override
- public boolean tryDelete(String fileName) {
- fileName = normalize(fileName);
- synchronized (MEMORY_FILES) {
- MEMORY_FILES.remove(fileName);
- }
- return true;
- }
-
- private InMemoryFileObject getObjectFile(String fileName) {
- fileName = normalize(fileName);
- synchronized (MEMORY_FILES) {
- InMemoryFileObject m = MEMORY_FILES.get(fileName);
- if (m == null) {
- m = new InMemoryFileObject(fileName);
- MEMORY_FILES.put(fileName, m);
- }
- return m;
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/MemoryMappedFileObject.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/MemoryMappedFileObject.java
deleted file mode 100644
index d57c22c..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/MemoryMappedFileObject.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.pagedstorage.util.FileUtils;
-import com.google.dart.indexer.pagedstorage.util.SysProperties;
-
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.lang.ref.WeakReference;
-import java.lang.reflect.Method;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel.MapMode;
-
-/**
- * FileObject which is using NIO MappedByteBuffer mapped to memory from file.
- */
-public class MemoryMappedFileObject implements FileObject {
- // TODO support files over 2 GB by using multiple buffers
- private static final long GC_TIMEOUT_MS = 10000;
- private final String name;
- private final MapMode mode;
- private RandomAccessFile file;
- private MappedByteBuffer mapped;
-
- MemoryMappedFileObject(String fileName, String mode) throws IOException {
- if ("r".equals(mode)) {
- this.mode = MapMode.READ_ONLY;
- } else {
- this.mode = MapMode.READ_WRITE;
- }
- this.name = fileName;
- file = new RandomAccessFile(fileName, mode);
- reMap();
- }
-
- @Override
- public void close() throws IOException {
- unMap();
- file.close();
- file = null;
- }
-
- @Override
- public long getFilePointer() {
- return mapped.position();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public long length() throws IOException {
- return file.length();
- }
-
- @Override
- public void readFully(byte[] b, int off, int len) {
- mapped.get(b, off, len);
- }
-
- @Override
- public void seek(long pos) {
- mapped.position((int) pos);
- }
-
- @Override
- public void setFileLength(long newLength) throws IOException {
- FileUtils.setLength(file, newLength);
- reMap();
- }
-
- @Override
- public void sync() throws IOException {
- file.getFD().sync();
- mapped.force();
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- // check if need to expand file
- if (mapped.capacity() < mapped.position() + len) {
- setFileLength(mapped.position() + len);
- }
- mapped.put(b, off, len);
- }
-
- /**
- * Re-map byte buffer into memory, called when file size has changed or file was created.
- */
- private void reMap() throws IOException {
- if (file.length() > Integer.MAX_VALUE) {
- throw new RuntimeException("File over 2GB is not supported yet");
- }
- int oldPos = 0;
- if (mapped != null) {
- oldPos = mapped.position();
- mapped.force();
- unMap();
- }
-
- // maps new MappedByteBuffer, old one is disposed during GC
- mapped = file.getChannel().map(mode, 0, file.length());
- if (SysProperties.NIO_LOAD_MAPPED) {
- mapped.load();
- }
- mapped.position(oldPos);
- }
-
- private void unMap() {
- if (mapped != null) {
- // first write all data
- mapped.force();
-
- // need to dispose old direct buffer, see bug
- // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4724038
-
- boolean useSystemGc;
- if (SysProperties.NIO_CLEANER_HACK) {
- try {
- useSystemGc = false;
- Method cleanerMethod = mapped.getClass().getMethod("cleaner", new Class[0]);
- cleanerMethod.setAccessible(true);
- Object cleaner = cleanerMethod.invoke(mapped, new Object[0]);
- Method clearMethod = cleaner.getClass().getMethod("clear", new Class[0]);
- clearMethod.invoke(cleaner, new Object[0]);
- } catch (Throwable e) {
- useSystemGc = true;
- }
- } else {
- useSystemGc = true;
- }
- if (useSystemGc) {
- WeakReference<MappedByteBuffer> bufferWeakRef = new WeakReference<MappedByteBuffer>(mapped);
- mapped = null;
- long start = System.currentTimeMillis();
- while (bufferWeakRef.get() != null) {
- if (System.currentTimeMillis() - start > GC_TIMEOUT_MS) {
- throw new RuntimeException("Timeout (" + GC_TIMEOUT_MS
- + " ms) reached while trying to GC mapped buffer");
- }
- System.gc();
- Thread.yield();
- }
- }
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/MemoryMappedFileSystem.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/MemoryMappedFileSystem.java
deleted file mode 100644
index e2ebcf7..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/MemoryMappedFileSystem.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import java.io.IOException;
-
-/**
- * This file system stores files on disk and uses java.nio to access the files. This class used
- * memory mapped files.
- */
-public class MemoryMappedFileSystem extends NioFileSystem {
- private static final MemoryMappedFileSystem INSTANCE = new MemoryMappedFileSystem();
-
- public static DiskFileSystem getInstance() {
- return INSTANCE;
- }
-
- @Override
- protected String getPrefix() {
- return FileSystem.PREFIX_NIO_MAPPED;
- }
-
- protected FileObject open(String fileName, String mode) throws IOException {
- return new MemoryMappedFileObject(fileName, mode);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/NioFileObject.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/NioFileObject.java
deleted file mode 100644
index 47fa037..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/NioFileObject.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.RandomAccessFile;
-import java.nio.ByteBuffer;
-import java.nio.channels.FileChannel;
-
-/**
- * File which uses NIO FileChannel.
- */
-public class NioFileObject implements FileObject {
- private final String name;
-
- private FileChannel channel;
-
- NioFileObject(String fileName, AccessMode mode) throws FileNotFoundException {
- this.name = fileName;
- RandomAccessFile file = new RandomAccessFile(fileName, mode.getMode());
- channel = file.getChannel();
- }
-
- @Override
- public void close() throws IOException {
- channel.close();
- }
-
- @Override
- public long getFilePointer() throws IOException {
- return channel.position();
- }
-
- @Override
- public String getName() {
- return name;
- }
-
- @Override
- public long length() throws IOException {
- return channel.size();
- }
-
- @Override
- public void readFully(byte[] b, int off, int len) throws IOException {
- if (len == 0) {
- return;
- }
- // reading the size can reduce the performance
- // if (channel.size() <= off + len) {
- // throw new java.io.EOFException();
- // }
- ByteBuffer buf = ByteBuffer.wrap(b);
- buf.position(off);
- buf.limit(off + len);
- channel.read(buf);
- }
-
- @Override
- public void seek(long pos) throws IOException {
- channel.position(pos);
- }
-
- @Override
- public void setFileLength(long newLength) throws IOException {
- if (newLength <= channel.size()) {
- long oldPos = channel.position();
- channel.truncate(newLength);
- if (oldPos > newLength) {
- oldPos = newLength;
- }
- channel.position(oldPos);
- } else {
- // extend by writing to the new location
- ByteBuffer b = ByteBuffer.allocate(1);
- channel.write(b, newLength - 1);
- }
- }
-
- @Override
- public void sync() throws IOException {
- channel.force(true);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- ByteBuffer buf = ByteBuffer.wrap(b);
- buf.position(off);
- buf.limit(off + len);
- channel.write(buf);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/NioFileSystem.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/NioFileSystem.java
deleted file mode 100644
index 98d18f7..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/filesystem/NioFileSystem.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.filesystem;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-/**
- * This file system stores files on disk and uses java.nio to access the files. This class uses
- * FileChannel.
- */
-public class NioFileSystem extends DiskFileSystem {
- private static final NioFileSystem INSTANCE = new NioFileSystem();
-
- public static DiskFileSystem getInstance() {
- return INSTANCE;
- }
-
- @Override
- public String createTempFile(String name, String suffix, boolean deleteOnExit, boolean inTempDir)
- throws IOException {
- String file = super.createTempFile(name, suffix, deleteOnExit, inTempDir);
- return getPrefix() + file;
- }
-
- @Override
- public String getAbsolutePath(String fileName) {
- return getPrefix() + super.getAbsolutePath(fileName);
- }
-
- @Override
- public String getParent(String fileName) {
- return getPrefix() + super.getParent(fileName);
- }
-
- @Override
- public String[] listFiles(String path) throws PagedStorageException {
- String[] list = super.listFiles(path);
- for (int i = 0; list != null && i < list.length; i++) {
- list[i] = getPrefix() + list[i];
- }
- return list;
- }
-
- @Override
- public String normalize(String fileName) throws PagedStorageException {
- return getPrefix() + super.normalize(fileName);
- }
-
- @Override
- public InputStream openFileInputStream(String fileName) throws IOException {
- return super.openFileInputStream(translateFileName(fileName));
- }
-
- @Override
- public FileObject openFileObject(String fileName, AccessMode mode) throws IOException {
- fileName = translateFileName(fileName);
- FileObject f;
- try {
- f = open(fileName, mode);
- trace("openRandomAccessFile", fileName, f);
- } catch (IOException e) {
- freeMemoryAndFinalize();
- try {
- f = open(fileName, mode);
- } catch (IOException e2) {
- throw e;
- }
- }
- return f;
- }
-
- /**
- * Get the prefix for this file system.
- *
- * @return the prefix
- */
- protected String getPrefix() {
- return FileSystem.PREFIX_NIO;
- }
-
- /**
- * Try to open a file with this name and mode.
- *
- * @param fileName the file name
- * @param mode the open mode
- * @return the file object
- * @throws IOException if opening fails
- */
- protected FileObject open(String fileName, AccessMode mode) throws IOException {
- return new NioFileObject(fileName, mode);
- }
-
- @Override
- protected String translateFileName(String fileName) {
- if (fileName.startsWith(getPrefix())) {
- fileName = fileName.substring(getPrefix().length());
- }
- return super.translateFileName(fileName);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoPos.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoPos.java
deleted file mode 100644
index 3f83a18..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoPos.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.infostore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.infostore.InfoStore.Page;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-public class InfoPos {
- public static final int SIZE = 4;
- private Page page;
-
- public InfoPos(Page page) {
- if (page == null) {
- throw new NullPointerException("page is null");
- }
- this.page = page;
- }
-
- public boolean addItem(int id, int item) throws PagedStorageException {
- InfoPos newPos = page.getInfoStore().addItem(page.getPos(), id, item);
- if (newPos.page == page) {
- return false;
- } else {
- page = newPos.page;
- return true;
- }
- }
-
- public boolean addItems(int id, int[] payload) throws PagedStorageException {
- InfoPos newPos = page.getInfoStore().addItems(page.getPos(), id, payload);
- if (newPos.page == page) {
- return false;
- } else {
- page = newPos.page;
- return true;
- }
- }
-
- public void delete(int id) {
- page.delete(id);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- InfoPos other = (InfoPos) obj;
- if (page == null) {
- if (other.page != null) {
- return false;
- }
- } else if (!page.equals(other.page)) {
- return false;
- }
- return true;
- }
-
- public Page getPage() {
- return page;
- }
-
- public int getPageId() {
- return page.getPos();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((page == null) ? 0 : page.hashCode());
- return result;
- }
-
- public boolean hasItem(int id) {
- return page.hasItem(id);
- }
-
- public int[] readEntireData(int itemId) {
- return page.read(itemId);
- }
-
- @Override
- public String toString() {
- return "<" + page.getPos() + ">";
- }
-
- public boolean update(int id, int[] payload) {
- try {
- InfoPos newPos = page.getInfoStore().replace(page.getPos(), id, payload, true);
- if (newPos.page == page) {
- return false;
- } else {
- page = newPos.page;
- return true;
- }
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- return false;
- }
- }
-
- public void write(Data data) {
- data.writeInt(page.getPos());
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoStore.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoStore.java
deleted file mode 100644
index 157720d..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoStore.java
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.infostore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.pagestore.Record;
-import com.google.dart.indexer.pagedstorage.pagestore.RecordFactory;
-import com.google.dart.indexer.pagedstorage.pagestore.StdRecord;
-import com.google.dart.indexer.pagedstorage.stats.MappingLayerStats;
-import com.google.dart.indexer.pagedstorage.util.ArrayUtils;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Set;
-
-public class InfoStore {
- public class Page extends StdRecord {
- private static final int COUNT_SIZE = 2;
- private static final int OFFSET_SIZE = 2;
- private static final int ID_SIZE = 4;
- private static final int ITEM_SIZE = 4;
- private static final int PAGE_METADATA = COUNT_SIZE + OFFSET_SIZE;
- private static final int PER_ITEM_METADATA = OFFSET_SIZE + ID_SIZE;
-
- private int count;
- private int[] offsets;
- private int[] ids;
- private int[][] items;
- private int totalSize;
-
- public Page(Data data, int pageId) {
- super(pagedStorage, data, pageId);
-
- data.reset();
- count = data.readShortInt();
- ids = new int[count];
- items = new int[count][];
- if (count > 0) {
- offsets = new int[count];
- for (int i = 0; i < count; i++) {
- offsets[i] = data.readShortInt();
- ids[i] = data.readInt();
- }
- }
- totalSize = data.readShortInt();
- if (totalSize == 0) {
- if (count > 0) {
- throw new AssertionError("totalSize == 0 when count > 0");
- }
- totalSize = PAGE_METADATA;
- }
- }
-
- public boolean addItem(int itemId, int payloadItem) {
- return addItems(itemId, new int[] {payloadItem});
- }
-
- public boolean addItems(int itemId, int[] payload) {
- int item = find(itemId);
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.INFOSTORE_CALLS,
- "InfoStore.Page.addItems(): page" + getPos() + " item id " + itemId + " at " + item);
- if (item < 0) {
- replace(itemId, payload, false);
- return true;
- }
-
- deserialize(item);
-
- int[] oldPayload = items[item];
- int[] newPayload = ArrayUtils.addSorted(oldPayload, payload);
- int sizeDelta = ITEM_SIZE * (newPayload.length - oldPayload.length);
- if (sizeDelta == 0) {
- return true; // no new items
- }
-
- deserializeAll();
-
- if (count == 1 && (totalSize + sizeDelta) > pagedStorage.getPageSize()) {
- return false;
- }
-
- items[item] = newPayload;
- totalSize += sizeDelta;
- changed();
- return true;
- }
-
- public int[] chooseItemsToMove() {
- deserializeAll();
-
- int[] additionalIds = new int[count * 100];
- int additionalIdCount = 0;
-
- // find parent indexes of each item
- int[] parents = new int[count * 100];
- for (int i = 0; i < count; i++) {
- int id = hierarchy.getParent(ids[i]);
- while (id > 0) {
- if (find(id) < 0) {
- int pos = binarySearch(additionalIds, additionalIdCount, id);
- if (pos < 0) {
- pos = -pos - 1;
- System.arraycopy(additionalIds, pos, additionalIds, pos + 1, additionalIdCount - pos);
- additionalIds[pos] = id;
- ++additionalIdCount;
- }
- }
- id = hierarchy.getParent(id);
- }
- }
- int virtualCount = count + additionalIdCount;
-
- for (int i = 0; i < count; i++) {
- int id = hierarchy.getParent(ids[i]);
- int k = i;
- while (id > 0) {
- int pos = find(id);
- if (pos >= 0) {
- parents[k] = pos;
- } else {
- pos = binarySearch(additionalIds, additionalIdCount, id);
- if (pos < 0) {
- throw new AssertionError("WTF? should have added " + id);
- }
- parents[k] = count + pos;
- }
- k = parents[k];
- id = hierarchy.getParent(id);
- }
- }
-
- // topological sort using iterative DFS
- int[] sorted = new int[virtualCount];
- int sortedCount = 0;
- boolean[] visited = new boolean[virtualCount];
- int[] stack = new int[virtualCount * 2];
- int stackSize;
- for (int i = 0; i < virtualCount; i++) {
- if (!visited[i]) {
- stack[0] = i;
- stackSize = 1;
- visited[i] = true;
- while (stackSize > 0) {
- int item = stack[--stackSize];
- if (item < 0) {
- // endvisit
- item = -item - 1;
- sorted[sortedCount++] = item;
- } else {
- stack[stackSize++] = -item - 1; // enqueue endvisit
-
- // visit children
- for (int k = 0; k < virtualCount; k++) {
- if (parents[k] == item && !visited[k]) {
- stack[stackSize++] = k;
- visited[k] = true;
- }
- }
- }
- }
- }
- }
-
- // compute deep sizes
- int[] deepSize = new int[virtualCount];
- int[] childrenCounts = new int[virtualCount];
- for (int i = 0; i < count; i++) {
- deepSize[i] = PER_ITEM_METADATA + ITEM_SIZE * items[i].length;
- }
- for (int i = 0; i < virtualCount; i++) {
- childrenCounts[i] = 1;
- }
- for (int i = 0; i < virtualCount; i++) {
- int item = sorted[i];
- if (parents[item] >= 0) {
- deepSize[parents[item]] += deepSize[item];
- childrenCounts[parents[item]] += childrenCounts[item];
- }
- }
-
- // choose the item to move
- int idealSize = pagedStorage.getPageSize() / 2;
- int bestDeviation = -1;
- int bestItem = -1;
- for (int i = 0; i < virtualCount; i++) {
- int deviation = Math.abs(idealSize - (totalSize - deepSize[i]));
- if (bestItem == -1 || deviation < bestDeviation) {
- bestDeviation = deviation;
- bestItem = i;
- }
- }
-
- if (childrenCounts[bestItem] == virtualCount) {
- if (count > 1) {
- IndexerPlugin.getLogger().trace(
- IndexerDebugOptions.MISCELLANEOUS,
- "InfoStore.Page.chooseItemsToMove() hmmmm, can only happen if a single item is left, but count="
- + count);
- }
- return null;
- }
-
- int[] itemsToMove = new int[childrenCounts[bestItem]];
- int itemsToMoveCount = 0;
- Set<Integer> itemsToMoveSet = new HashSet<Integer>();
- itemsToMoveSet.add(new Integer(bestItem));
- itemsToMove[itemsToMoveCount++] = bestItem;
- for (int i = virtualCount - 1; i >= 0; --i) {
- int item = sorted[i];
- int parent = parents[item];
- if (parent >= 0 && itemsToMoveSet.contains(new Integer(parent))) {
- itemsToMoveSet.add(new Integer(item));
- itemsToMove[itemsToMoveCount++] = item;
- }
- }
- if (itemsToMoveCount != childrenCounts[bestItem]) {
- throw new AssertionError("Internal alg error: itemsToMoveCount != childrenCounts[bestItem]");
- }
-
- for (int i = 0; i < itemsToMove.length; i++) {
- if (itemsToMove[i] < count) {
- itemsToMove[i] = ids[itemsToMove[i]];
- } else {
- itemsToMove[i] = additionalIds[itemsToMove[i] - count];
- }
- }
-
- Arrays.sort(itemsToMove);
-
- return itemsToMove;
- }
-
- public void delete(int itemId) {
- int item = find(itemId);
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.INFOSTORE_CALLS,
- "InfoStore.Page.delete(): page " + getPos() + " item id " + itemId + " at " + item);
- if (item < 0) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ANOMALIES,
- "InfoStore.delete: item id " + itemId + " does not exist on page " + getPos());
- return;
- }
-
- deserializeAll();
- totalSize -= PER_ITEM_METADATA + ITEM_SIZE * items[item].length;
- items = ArrayUtils.remove(items, item);
- ids = ArrayUtils.remove(ids, item);
- --count;
-
- changed();
- // if (count > 0)
- // changed();
- // else
- // try {
- // pagedStorage.freePage(getPos());
- // } catch (PagedStorageException exception) {
- // IndexerPlugin.getLogger().logError(exception);
- // }
- }
-
- public boolean fits() {
- return totalSize <= pagedStorage.getPageSize();
- }
-
- public int getCount() {
- return count;
- }
-
- public double getFillFactor() {
- return totalSize * 1.0 / pagedStorage.getPageSize();
- }
-
- public InfoStore getInfoStore() {
- return InfoStore.this;
- }
-
- public boolean hasItem(int id) {
- return find(id) >= 0;
- }
-
- public boolean itemsToMoveContainsId(int[] itemsToMove, int itemId) {
- return Arrays.binarySearch(itemsToMove, itemId) >= 0;
- }
-
- public int maximumPayloadLength() {
- return (pagedStorage.getPageSize() - PAGE_METADATA - PER_ITEM_METADATA) / ITEM_SIZE - 10;
- }
-
- public void move(int[] itemsToMove, Page newPage) {
- deserializeAll();
- for (int i = 0; i < itemsToMove.length; i++) {
- int item = find(itemsToMove[i]);
- if (item >= 0) {
- newPage.replace(itemsToMove[i], items[item], false);
- }
- }
- for (int i = 0; i < itemsToMove.length; i++) {
- if (find(itemsToMove[i]) >= 0) {
- delete(itemsToMove[i]);
- }
- }
- for (int i = 0; i < itemsToMove.length; i++) {
- hierarchy.updatePageId(storeId, itemsToMove[i], newPage.getPos());
- }
- }
-
- public int[] read(int itemId) {
- int item = find(itemId);
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.INFOSTORE_CALLS,
- "InfoStore.Page.read(): page " + getPos() + " item id " + itemId + " at " + item);
- if (item < 0) {
- // throw new IllegalArgumentException("Item id " + itemId +
- // " not found on page " + getPos());
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ANOMALIES,
- "InfoStore$Page.read: item id " + itemId + " not found on page " + getPos());
- return new int[0];
- }
- deserialize(item);
- return items[item];
- }
-
- public void replace(int itemId, int[] payload, boolean shouldExist) {
- int item = find(itemId);
- IndexerPlugin.getLogger().trace(
- IndexerDebugOptions.INFOSTORE_CALLS,
- "InfoStore.Page.replace" + (shouldExist ? "Existing" : "New") + "(): page " + getPos()
- + " item id " + itemId + " at " + item);
- // if (shouldExist && item < 0)
- // throw new IllegalArgumentException("Item id " + itemId +
- // " does not exist on page " + getPos());
- if (!shouldExist && item >= 0) {
- throw new IllegalArgumentException("Item id " + itemId + " already exists on page "
- + getPos());
- }
-
- Arrays.sort(payload);
-
- deserializeAll();
-
- int oldSize = 0;
- if (item >= 0) {
- oldSize = PER_ITEM_METADATA + ITEM_SIZE * items[item].length;
- }
- int newSize = PER_ITEM_METADATA + ITEM_SIZE * payload.length;
- int sizeDelta = newSize - oldSize;
-
- if (item < 0) {
- item = -item - 1;
- items = ArrayUtils.add(items, payload, item);
- ids = ArrayUtils.add(ids, itemId, item);
- ++count;
- } else {
- items[item] = payload;
- }
- totalSize += sizeDelta;
- changed();
- }
-
- public void stats(MappingLayerStats stats) {
- deserializeAll();
- for (int i = 0; i < count; i++) {
- stats.itemLength.add(items[i].length);
- }
- stats.itemsPerPage.add(count);
- stats.pageFillFactors.add(getFillFactor() * 100);
- }
-
- @Override
- protected void changed() {
- updateOffsets();
- }
-
- @Override
- protected void serializeCached() {
- deserializeAll();
-
- updateOffsets();
-
- data.reset();
- data.writeShortInt(count);
- for (int i = 0; i < count; i++) {
- data.writeShortInt(offsets[i]);
- data.writeInt(ids[i]);
- }
- data.writeShortInt(totalSize);
- for (int i = 0; i < count; i++) {
- int[] payload = items[i];
- int len = payload.length;
- for (int k = 0; k < len; k++) {
- data.writeInt(payload[k]);
- }
- }
- }
-
- private void deserialize(int item) {
- if (item < 0 || item > count) {
- throw new IllegalArgumentException("Info page " + getPos() + ": illegal item id " + item
- + ", max is " + count);
- }
- if (items[item] != null) {
- return;
- }
- data.setPos(offsets[item]);
- int cb = itemSize(item);
- if (cb % 4 != 0) {
- throw new AssertionError("Invalid size " + cb + " of item " + item + " on info page "
- + getPos());
- }
- int length = cb / 4;;
- int[] result = new int[length];
- for (int i = 0; i < length; i++) {
- result[i] = data.readInt();
- }
- items[item] = result;
- }
-
- private void deserializeAll() {
- if (offsets == null) {
- return;
- }
- for (int i = 0; i < count; i++) {
- if (items[i] == null) {
- deserialize(i);
- }
- }
- offsets = null;
- }
-
- private int find(int itemId) {
- return Arrays.binarySearch(ids, itemId);
- }
-
- private int itemSize(int item) {
- if (item == count - 1) {
- return totalSize - offsets[item];
- } else {
- return offsets[item + 1] - offsets[item];
- }
- }
-
- private void updateOffsets() {
- int offset = COUNT_SIZE + count * PER_ITEM_METADATA + OFFSET_SIZE;
- offsets = new int[count];
- for (int i = 0; i < count; i++) {
- offsets[i] = offset;
- offset += ITEM_SIZE * items[i].length;
- }
- if (offset != totalSize) {
- throw new AssertionError("totalSize != final offset: " + totalSize + " != " + offset);
- }
- }
- }
-
- static int binarySearch(int[] a, int count, int key) {
- int low = 0;
- int high = count - 1;
-
- while (low <= high) {
- int mid = (low + high) >> 1;
- int midVal = a[mid];
-
- if (midVal < key) {
- low = mid + 1;
- } else if (midVal > key) {
- high = mid - 1;
- } else {
- return mid; // key found
- }
- }
- return -(low + 1); // key not found.
- }
-
- private final PagedStorage pagedStorage;
-
- private InfoStoreItemsHierarchy hierarchy;
-
- private int storeId;
-
- private RecordFactory recordFactory = new RecordFactory() {
-
- @Override
- public Record read(PagedStorage pagedStorage, Data data, int pageId, boolean isNew)
- throws PagedStorageException {
- return new Page(data, pageId);
- }
-
- };
-
- public InfoStore(PagedStorage pagedStorage) {
- if (pagedStorage == null) {
- throw new NullPointerException("pageStore is null");
- }
- this.pagedStorage = pagedStorage;
- }
-
- public InfoPos addItem(int page, int itemId, int payloadItem) throws PagedStorageException {
- Page p = readPage(page);
- if (p.addItem(itemId, payloadItem)) {
- p = makePageFit(itemId, p);
- }
- return new InfoPos(p);
- }
-
- public InfoPos addItems(int page, int itemId, int[] payload) throws PagedStorageException {
- Page p = readPage(page);
- if (p.addItems(itemId, payload)) {
- p = makePageFit(itemId, p);
- }
- return new InfoPos(p);
- }
-
- public Page readPage(int pageId) throws PagedStorageException {
- return (Page) pagedStorage.readRecord(pageId, recordFactory);
- }
-
- public InfoPos readPos(Data data) throws PagedStorageException {
- int pageId = data.readInt();
- if (pageId <= 0) {
- return null;
- }
- return new InfoPos(readPage(pageId));
- }
-
- public InfoPos replace(int page, int itemId, int[] payload, boolean shouldExist)
- throws PagedStorageException {
- Page p = readPage(page);
-
- if (payload.length > p.maximumPayloadLength()) {
- payload = ArrayUtils.truncate(payload, p.maximumPayloadLength());
- }
-
- // if (DebugConstants.INFOSTORE_EACH_ITEM_ON_SEPARATE_PAGE && !shouldExist)
- // {
- // if (page > 0)
- // p = readPage(-1);
- // p.replace(itemId, payload, shouldExist);
- // if (!p.fits())
- // throw new AssertionError("Cannot add payload of size " + payload.length +
- // " to an empty page with maxPayloadLenth=" + p.maximumPayloadLength());
- // return new InfoPos(p);
- // }
-
- p.replace(itemId, payload, shouldExist);
- p = makePageFit(itemId, p);
- return new InfoPos(p);
- }
-
- public void setHierarchy(InfoStoreItemsHierarchy hierarchy, int storeId) {
- if (hierarchy == null) {
- throw new NullPointerException("hierarchy is null");
- }
- this.hierarchy = hierarchy;
- this.storeId = storeId;
- }
-
- public void writeEmptyPos(Data data) {
- data.writeInt(0);
- }
-
- public InfoPos writeNew(int itemId, int[] payload) throws PagedStorageException {
- int page = hierarchy.findPageOf(storeId, itemId);
- InfoPos newPos = replace(page, itemId, payload, false);
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.INFOSTORE_MICROSTATS)) {
- if (page > 0 && newPos.getPageId() == page) {
- IndexerPlugin.getLogger().trace(
- IndexerDebugOptions.INFOSTORE_MICROSTATS,
- "New item " + itemId + " (size " + payload.length + ") fits on existing page " + page
- + " which now has " + newPos.getPage().getCount() + " items.");
- } else if (page > 0 && newPos.getPageId() != page) {
- IndexerPlugin.getLogger().trace(
- IndexerDebugOptions.INFOSTORE_MICROSTATS,
- "New item " + itemId + " (size " + payload.length + ") did not fit on existing page "
- + page + ".");
- } else {
- IndexerPlugin.getLogger().trace(
- IndexerDebugOptions.INFOSTORE_MICROSTATS,
- "New item " + itemId + " (size " + payload.length
- + ") saved to a new page, because no candidate page existed.");
- }
- }
- if (newPos.getPageId() != page) {
- if (page <= 0) {
- hierarchy.writeNewlyAllocatedPageId(storeId, itemId, newPos.getPageId());
- } else {
- hierarchy.updatePageId(storeId, itemId, newPos.getPageId());
- }
- }
- return newPos;
- }
-
- private Page makePageFit(int itemId, Page p) throws PagedStorageException {
- while (!p.fits()) {
- try {
- int[] itemsToMove = p.chooseItemsToMove();
-
- boolean willMoveCurrent = p.itemsToMoveContainsId(itemsToMove, itemId);
- Page newPage = readPage(-1);
- p.move(itemsToMove, newPage);
-
- IndexerPlugin.getLogger().trace(
- IndexerDebugOptions.INFOSTORE_SPLITS,
- "Moving " + itemsToMove.length + " items from page " + p.getPos() + " to page "
- + newPage.getPos());
-
- if (willMoveCurrent) {
- Page t = p;
- p = newPage;
- newPage = t;
- }
- makePageFit(itemId, newPage); // dunno, but maybe newPage may need
- // fitting too
-
- } catch (RuntimeException exception) {
- IndexerPlugin.getLogger().logError(exception);
- throw exception;
- } catch (Error exception) {
- IndexerPlugin.getLogger().logError(exception);
- throw exception;
- }
- // if (DebugConstants.TRACE_INFOSTORE_SPLITS)
- // if (!shouldExist) {
- // IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- // "New item " + itemId + " (payload size " +
- // payload.length + ") does not fit on page "
- // + p.getPos() + " with " + p.getCount() +
- // " items, allocating new page");
- // } else {
- // IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- // "Existing item " + itemId + " (payload size " +
- // payload.length + ") no longer fits on page "
- // + p.getPos() + " with " + p.getCount() +
- // " items, moving to a new page");
- // }
- }
- return p;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoStoreItemsHierarchy.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoStoreItemsHierarchy.java
deleted file mode 100644
index 77b6d05..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/infostore/InfoStoreItemsHierarchy.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.infostore;
-
-public interface InfoStoreItemsHierarchy {
- /**
- * @return <code>-1</code> if not found
- */
- int findPageOf(int storeId, int itemId);
-
- int getParent(int id);
-
- void updatePageId(int storeId, int itemId, int page);
-
- void writeNewlyAllocatedPageId(int storeId, int itemId, int page);
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/FullyDeserializedRecord.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/FullyDeserializedRecord.java
deleted file mode 100644
index 3098dd3..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/FullyDeserializedRecord.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.pagestore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-public abstract class FullyDeserializedRecord extends Record {
- private final PagedStorage pagedStorage;
-
- public FullyDeserializedRecord(PagedStorage pagedStorage, int pageId) {
- if (pagedStorage == null) {
- throw new NullPointerException("pageStore is null");
- }
- this.pagedStorage = pagedStorage;
- setPos(pageId);
- }
-
- @Override
- public int getMemorySize() {
- return pagedStorage.getPageSize() >> 1;
- }
-
- @Override
- public final void write() throws PagedStorageException {
- Data data = pagedStorage.createData();
- serializeCached(data);
- pagedStorage.writePage(pageId, data);
- }
-
- protected final void changed() {
- try {
- pagedStorage.updateRecord(this);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- }
-
- protected void serializeCached(Data data) {
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/Record.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/Record.java
deleted file mode 100644
index b683437..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/Record.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.pagestore;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-
-/**
- * A record represents a persisted page.
- */
-public abstract class Record extends CacheObject {
- @Override
- public boolean canRemove() {
- return true;
- }
-
- public abstract void write() throws PagedStorageException;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/RecordFactory.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/RecordFactory.java
deleted file mode 100644
index f3b5184..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/RecordFactory.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.pagestore;
-
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-public interface RecordFactory {
- Record read(PagedStorage pagedStorage, Data data, int pageId, boolean isNew)
- throws PagedStorageException;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/StdRecord.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/StdRecord.java
deleted file mode 100644
index b942b49..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/pagestore/StdRecord.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.pagestore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-public abstract class StdRecord extends Record {
- public final Data data;
- private final PagedStorage pagedStorage;
-
- public StdRecord(PagedStorage pagedStorage, Data data, int pageId) {
- if (pagedStorage == null) {
- throw new NullPointerException("pageStore is null");
- }
- if (data == null) {
- throw new NullPointerException("data is null");
- }
- this.pagedStorage = pagedStorage;
- this.data = data;
- setPos(pageId);
- }
-
- @Override
- public int getMemorySize() {
- return pagedStorage.getPageSize() >> 2;
- }
-
- @Override
- public final void write() throws PagedStorageException {
- serializeCached();
- pagedStorage.writePage(pageId, data);
- }
-
- protected void changed() {
- try {
- pagedStorage.updateRecord(this);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- }
-
- protected void serializeCached() {
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/stats/MappingLayerStats.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/stats/MappingLayerStats.java
deleted file mode 100644
index 8c9caea..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/stats/MappingLayerStats.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.stats;
-
-public class MappingLayerStats {
- public int usedPages;
-
- public NumericDistribution pageFillFactors = new NumericDistribution();
-
- public NumericDistribution itemLength = new NumericDistribution();
-
- public NumericDistribution itemsPerPage = new NumericDistribution();
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/stats/NumericDistribution.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/stats/NumericDistribution.java
deleted file mode 100644
index 28755db..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/stats/NumericDistribution.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.stats;
-
-import java.text.DecimalFormat;
-
-public class NumericDistribution {
- static class Computed {
- final double avg;
- final double s;
-
- public Computed(double avg, double s) {
- this.avg = avg;
- this.s = s;
- }
- }
-
- private double min, max, sum1, sum2, sum3;
- private int count;
- private transient Computed computed;
-
- public void add(double value) {
- computed = null;
- if (value < min || count == 0) {
- min = value;
- }
- if (value > max || count == 0) {
- max = value;
- }
- sum1 += value;
- sum2 += value * value;
- sum3 += value * value * value;
- ++count;
- }
-
- public void addAll(NumericDistribution other) {
- computed = null;
- min = (count > 0 ? Math.min(min, other.min) : other.min);
- max = (count > 0 ? Math.max(max, other.max) : other.max);
- sum1 += other.sum1;
- sum2 += other.sum2;
- sum3 += other.sum3;
- count += other.count;
- }
-
- public double average() {
- return computed().avg;
- }
-
- public double deviation() {
- return computed().s;
- }
-
- public String toDetailedString() {
- computed();
- DecimalFormat f = new DecimalFormat("##0.0");
- return "<" + f.format(computed.avg) + " ±" + f.format(computed.s) + " (" + f.format(min) + ".."
- + f.format(max) + ")>";
- }
-
- @Override
- public String toString() {
- computed();
- DecimalFormat f = new DecimalFormat("##0.0");
- return f.format(computed.avg) + "±" + f.format(computed.s);
- }
-
- private Computed computed() {
- if (computed == null) {
- double avg = sum1 / count;
- double s2 = sum2 / count - avg * avg;
- double s = Math.sqrt(s2);
- computed = new Computed(avg, s);
- }
- return computed;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/PageRec.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/PageRec.java
deleted file mode 100644
index 3b768be..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/PageRec.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.treestore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.treestore.TreeStore.Page;
-import com.google.dart.indexer.utilities.io.PrintStringWriter;
-
-public class PageRec {
- Page page;
- int record;
-
- public PageRec(Page page, int record) {
- this.page = page;
- this.record = record;
- }
-
- public void delete() {
- // TODO recursive deletion of all children
- if (record > 0) {
- page.delete(record);
- }
- }
-
- public PageRecPos lookup(String component, boolean add) throws PagedStorageException {
- int pos = page.find(record, component);
- if (pos < 0) {
- if (!add) {
- return null;
- } else {
- int offset;
- while ((offset = page.tryAdd(record, component)) < 0) {
- if (offset == TreeStore.ADD_EXISTS) {
- throw new AssertionError("Component exists, but not found by find(): " + component);
- }
- if (offset == TreeStore.ADD_NOROOM) {
- int largestRecord = page.findLargestRecord();
- if (largestRecord < 0) {
- return null; // should have added an overflow page, but can't yet
- }
- try {
- Page subpage = page.createSubpage();
- int[] newRecs = page.move(largestRecord, subpage);
- int oldRec = record;
- if (newRecs[record] >= 0) {
- page = subpage;
- record = newRecs[record];
- } else {
- // adjust record # according to deleted recs
- for (int r = 0; r < oldRec; ++r) {
- if (newRecs[r] >= 0) {
- --record;
- }
- }
- }
- if (record >= page.getRecordCount()) {
- throw new AssertionError("Incorrect fixup of record # after move");
- // IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- // page.getTreeStore().toString().trim());
- }
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- } else {
- throw new AssertionError("Unknown error code returned from treeStore's page.add(): "
- + offset);
- }
- }
- page.data.zeroFill(offset, page.additionalDataSize());
- pos = -(pos + 1);
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_MODIFICATIONS)) {
- PrintStringWriter writer = new PrintStringWriter();
- writer.println("==========================================");
- writer.println("*** Added " + component + " ***");
- writer.println(page.getTreeStore().toString().trim());
- writer.println("==========================================");
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_MODIFICATIONS, writer.toString());
- }
- }
- }
-
- return new PageRecPos(page, record, pos);
- }
-
- @Override
- public String toString() {
- return "<" + page.getPos() + "," + record + ">";
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/PageRecPos.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/PageRecPos.java
deleted file mode 100644
index 8714bea..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/PageRecPos.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.treestore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.treestore.TreeStore.Page;
-import com.google.dart.indexer.storage.paged.store.Data;
-import com.google.dart.indexer.utilities.io.PrintStringWriter;
-
-public class PageRecPos {
- public static final int SIZE = 4 + 2 + 2;
-
- final Page page;
- final int record;
- final int pos;
-
- public PageRecPos(Page page, int record, int pos) {
- if (page == null) {
- throw new NullPointerException("page is null");
- }
- if (record < 0 || record >= page.getRecordCount()) {
- throw new IllegalArgumentException("Invalid record: " + record);
- }
- if (pos < 0 || pos >= page.itemCount(record)) {
- throw new IllegalArgumentException("Invalid index " + pos + " in record " + record);
- }
- this.page = page;
- this.record = record;
- this.pos = pos;
- }
-
- public PageRec children(boolean add) throws PagedStorageException {
- int childRecord = page.getChildren(record, pos);
- if (childRecord == 0) {
- if (add) {
- childRecord = page.addEmptyChildRecord(record, pos);
- if (childRecord < 0) {
- Page subpage = page.addEmptyPageWithAnEmptyChildRecord();
- page.setChildPage(record, pos, subpage.getPos());
- return new PageRec(subpage, 0);
- } else {
- // IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- // "Added child record " + childRecord +
- // " to page " + page.getPos());
- }
- } else {
- return null;
- }
- } else {
- // IndexerPlugin.getLogger().trace(IndexerDebugOptions.MISCELLANEOUS,
- // "Existing child record " + childRecord + " on page "
- // + page.getPos());
- }
- if (childRecord > TreeStore.PAGE_MARKER) {
- int childPageId = childRecord - TreeStore.PAGE_MARKER;
- Page subpage = page.getTreeStore().readPage(childPageId);
- return new PageRec(subpage, 0);
- }
- return new PageRec(page, childRecord);
- }
-
- public void delete() throws PagedStorageException {
- PageRec children = children(false);
- page.deleteItem(record, pos);
-
- if (children != null) {
- children.delete();
- }
-
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_MODIFICATIONS)) {
- PrintStringWriter writer = new PrintStringWriter();
- writer.println("==========================================");
- writer.println("*** Removed " + toString()
- + (children != null ? " and " + children.toString() : "") + " ***");
- writer.println(page.getTreeStore().toString().trim());
- writer.println("==========================================");
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_MODIFICATIONS, writer.toString());
- }
- }
-
- public int getRowId() {
- return page.getRowId(record, pos);
- }
-
- public long getTimestamp() {
- return page.getTimestamp(record, pos);
- }
-
- public String readName() {
- return page.readName(record, pos);
- }
-
- public void setRowId(int rowId) {
- page.setRowId(record, pos, rowId);
- }
-
- public void setTimestamp(long stamp) {
- page.setTimestamp(record, pos, stamp);
- }
-
- @Override
- public String toString() {
- return "<" + page.getPos() + "," + record + "," + pos + ">";
- }
-
- public void write(Data data) {
- data.writeInt(page.getPos());
- data.writeShortInt(record);
- data.writeShortInt(pos);
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeCoordListener.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeCoordListener.java
deleted file mode 100644
index c332c9a..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeCoordListener.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.treestore;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-
-public interface TreeCoordListener {
- public void treeCoordChanged(int id, int newPage, int newRecord, int newPos)
- throws PagedStorageException;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeLeaf.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeLeaf.java
deleted file mode 100644
index 30cda64..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeLeaf.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.treestore;
-
-public class TreeLeaf {
- private final String[] path;
- private final PageRecPos pos;
-
- public TreeLeaf(String[] path, PageRecPos pos) {
- if (path == null) {
- throw new NullPointerException("path is null");
- }
- if (pos == null) {
- throw new NullPointerException("pos is null");
- }
- this.path = path;
- this.pos = pos;
- }
-
- public String[] getPath() {
- return path;
- }
-
- public PageRecPos getPos() {
- return pos;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeStore.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeStore.java
deleted file mode 100644
index 958a440..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/treestore/TreeStore.java
+++ /dev/null
@@ -1,1042 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.treestore;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.PagedStorage;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.pagestore.Record;
-import com.google.dart.indexer.pagedstorage.pagestore.RecordFactory;
-import com.google.dart.indexer.pagedstorage.pagestore.StdRecord;
-import com.google.dart.indexer.pagedstorage.util.ArrayUtils;
-import com.google.dart.indexer.pagedstorage.util.StringUtils;
-import com.google.dart.indexer.storage.paged.TreeStoreStats;
-import com.google.dart.indexer.storage.paged.store.Data;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-
-public class TreeStore {
- class LeafIterator implements Iterator<TreeLeaf> {
- private static final int MAX_LEVEL = 20;
-
- private String[] components;
- private Page[] page;
- private int[] record, index;
- private int level;
- private boolean hasNext;
-
- public LeafIterator() {
- page = new Page[MAX_LEVEL];
- record = new int[MAX_LEVEL];
- index = new int[MAX_LEVEL];
- components = new String[MAX_LEVEL];
- level = -1;
- hasNext = moveDownOrRight(rootPage, 0, 0);
- }
-
- @Override
- public boolean hasNext() {
- return hasNext;
- }
-
- @Override
- public TreeLeaf next() {
- String[] path = new String[level + 1];
- System.arraycopy(components, 0, path, 0, path.length);
- TreeLeaf result = new TreeLeaf(path, new PageRecPos(page[level], record[level], index[level]));
- hasNext = moveRightOrUp();
- return result;
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- boolean moveDown(Page p, int r, int i) {
- if (i >= p.itemCount(r)) {
- return false;
- }
- push(p, r, i);
- int children = p.getChildren(r, i);
- if (children == 0) {
- return true; // leaf
- }
- Page pp;
- int rr;
- if (children >= PAGE_MARKER) {
- try {
- pp = readPage(children - PAGE_MARKER);
- } catch (PagedStorageException e) {
- IndexerPlugin.getLogger().logError(e);
- return false;
- }
- rr = 0;
- } else {
- pp = page[level];
- rr = children;
- }
- if (moveDownOrRight(pp, rr, 0)) {
- return true;
- }
- pop();
- return false;
- }
-
- boolean moveDownOrRight(Page p, int r, int i) {
- if (moveDown(p, r, i)) {
- return true;
- }
- return moveRight(p, r, i);
- }
-
- boolean moveRight(Page p, int r, int i) {
- int itemCount = p.itemCount(r);
- while (++i < itemCount) {
- if (moveDown(p, r, i)) {
- return true;
- }
- }
- return false;
- }
-
- boolean moveRightOrUp() {
- while (level >= 0) {
- Page p = page[level];
- int r = record[level];
- int i = index[level];
- pop();
- if (moveRight(p, r, i)) {
- return true;
- }
- }
- return false;
- }
-
- void pop() {
- --level;
- }
-
- void push(Page p, int r, int i) {
- ++level;
- // TODO extend when needed
- page[level] = p;
- record[level] = r;
- index[level] = i;
- components[level] = p.readName(r, i);
- }
- }
-
- /**
- * <p>
- * Page: N off1 off2 ... offN offL rec1 rec2 ... recN
- * </p>
- * <p>
- * Each record: N off1 child1 off2 child2 ... offN childN offL data1 data2 ... dataN
- * </p>
- */
- class Page extends StdRecord {
- private static final int COUNT_LEN = 2;
- private static final int OFFSET_LEN = 2;
- private static final int CHILDREN_LEN = 2;
-
- private static final int CB_EMPTY_PAGE_METADATA = COUNT_LEN + OFFSET_LEN /*
- * N, offL
- */;
- private static final int CB_PAGE_METADATA_PER_RECORD = OFFSET_LEN /* offX */;
- // private static final int CB_RECORD_PREFIX_METADATA = COUNT_LEN /* N */;
- private static final int CB_EMPTY_RECORD_METADATA = COUNT_LEN + OFFSET_LEN;
- private static final int CB_RECORD_METADATA_PER_ITEM = OFFSET_LEN + CHILDREN_LEN;
-
- private int recordCount;
- private int[] recordOffsets;
-
- private int totalSize;
- private int[] itemCounts;
- private int[][] itemOffsets;
- private int[][] itemChildren;
- private int[][] itemRowIds;
- private String[][] itemNames;
- private byte[][][] itemNamesEncoded;
- private long[][] itemTimeStamps;
-
- public Page(Data data, int pageId) {
- super(pagedStorage, data, pageId);
- data.reset();
- recordCount = data.readShortInt();
- recordOffsets = new int[recordCount + 1];
- for (int i = 0; i <= recordCount; i++) {
- recordOffsets[i] = data.readShortInt();
- }
-
- if (recordCount == 0) {
- recordOffsets = new int[1];
- recordOffsets[0] = CB_EMPTY_PAGE_METADATA /* ??? */;
- }
- totalSize = recordOffsets[recordCount];
- itemCounts = new int[recordCount];
- itemOffsets = new int[recordCount][];
- itemChildren = new int[recordCount][];
- itemRowIds = new int[recordCount][];
- if (additionalData >= 12) {
- itemTimeStamps = new long[recordCount][];
- }
- itemNames = new String[recordCount][];
- itemNamesEncoded = new byte[recordCount][][];
- }
-
- public int addChildRecord(int recordSize) {
- if (totalSize + recordSize + CB_PAGE_METADATA_PER_RECORD > pagedStorage.getPageSize()) {
- return ADD_NOROOM;
- }
-
- deserializeAll();
-
- int newRecord = recordCount;
- recordCount += 1;
- totalSize += CB_PAGE_METADATA_PER_RECORD + recordSize;
- changed();
-
- return newRecord;
- }
-
- public int addEmptyChildRecord() {
- int newRecord = addChildRecord(CB_EMPTY_RECORD_METADATA);
- if (newRecord < 0) {
- return newRecord;
- }
- itemCounts = ArrayUtils.add(itemCounts, 0, newRecord);
- itemOffsets = ArrayUtils.add(itemOffsets, null, newRecord);
- itemChildren = ArrayUtils.add(itemChildren, new int[0], newRecord);
- itemRowIds = ArrayUtils.add(itemRowIds, new int[0], newRecord);
- if (itemTimeStamps != null) {
- itemTimeStamps = ArrayUtils.add(itemTimeStamps, new long[0], newRecord);
- }
- itemNames = ArrayUtils.add(itemNames, new String[0], newRecord);
- itemNamesEncoded = ArrayUtils.add(itemNamesEncoded, new byte[0][], newRecord);
-
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- return newRecord;
- }
-
- public int addEmptyChildRecord(int record, int item) {
- checkItem(record, item);
-
- int newRecord = addEmptyChildRecord();
- if (newRecord < 0) {
- return newRecord;
- }
- itemChildren[record][item] = newRecord;
-
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- return newRecord;
- }
-
- public Page addEmptyPageWithAnEmptyChildRecord() throws PagedStorageException {
- Page page = readPage(-1);
- int rec = page.addEmptyChildRecord();
- if (rec != 0) {
- throw new AssertionError("First record of an empty page is expected to be 0");
- }
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- return page;
- }
-
- public int additionalDataSize() {
- return additionalData;
- }
-
- public Page createSubpage() throws PagedStorageException {
- return (Page) pagedStorage.readRecord(-1, recordFactory);
- }
-
- public void delete(int record) {
- if (record == 0) {
- throw new IllegalArgumentException("Cannot delete record 0");
- }
- if (record < 0 || record >= recordCount) {
- throw new IllegalArgumentException("Invalid record ID " + record);
- }
- deserializeAll();
-
- int size = CB_PAGE_METADATA_PER_RECORD + CB_EMPTY_RECORD_METADATA
- + CB_RECORD_METADATA_PER_ITEM * itemCounts[record];
- for (int item = 0; item < itemCounts[record]; item++) {
- size += additionalData + itemNamesEncoded[record][item].length;
- }
- for (int rec = 0; rec < recordCount; rec++) {
- int count = itemCounts[rec];
- for (int item = 0; item < count; item++) {
- if (itemChildren[rec][item] == record) {
- throw new IllegalArgumentException(
- "Cannot delete a record that is still referenced by another record");
- }
- }
- }
-
- for (int rec = 0; rec < recordCount; rec++) {
- int count = itemCount(rec);
- for (int item = 0; item < count; item++) {
- int child = itemChildren[rec][item];
- if (child > 0 && child < PAGE_MARKER && child > record) {
- itemChildren[rec][item] = child - 1;
- }
- }
- }
-
- itemCounts = ArrayUtils.remove(itemCounts, record);
- itemChildren = ArrayUtils.remove(itemChildren, record);
- itemRowIds = ArrayUtils.remove(itemRowIds, record);
- if (itemTimeStamps != null) {
- itemTimeStamps = ArrayUtils.remove(itemTimeStamps, record);
- }
- itemNames = ArrayUtils.remove(itemNames, record);
- itemNamesEncoded = ArrayUtils.remove(itemNamesEncoded, record);
- totalSize -= size;
- --recordCount;
- if (recordCount == 0) {
- throw new AssertionError("Record count is zero after record deletion");
- }
- changed();
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- }
-
- public void deleteItem(int record, int item) throws PagedStorageException {
- checkItem(record, item);
- deserializeAll();
-
- int nameLength = itemNamesEncoded[record][item].length;
- itemChildren[record] = ArrayUtils.remove(itemChildren[record], item);
- itemRowIds[record] = ArrayUtils.remove(itemRowIds[record], item);
- if (itemTimeStamps != null) {
- itemTimeStamps[record] = ArrayUtils.remove(itemTimeStamps[record], item);
- }
- itemNames[record] = ArrayUtils.remove(itemNames[record], item);
- itemNamesEncoded[record] = ArrayUtils.remove(itemNamesEncoded[record], item);
- --itemCounts[record];
- totalSize -= CB_RECORD_METADATA_PER_ITEM + additionalData + nameLength;
- notifyRecordItemsPosChanged(record, item);
-
- changed();
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- }
-
- public void dump(List<Page> pagesToDump, StringBuilder out, int level, boolean detailed)
- throws PagedStorageException {
- out.append(StringUtils.indent(level));
- out.append("PAGE ").append(pageId).append(": ").append(recordCount).append(" records\n");
- for (int rec = 0; rec < recordCount; rec++) {
- dumpRecord(pagesToDump, out, rec, level + 1, detailed);
- }
- }
-
- public int find(int record, String name) {
- if (record < 0 || record >= recordCount) {
- throw new IllegalArgumentException("Invalid record: " + record);
- }
-
- deserializeRecordEntirely(record);
-
- int count = itemCounts[record];
- int l = 0, r = count;
- while (l < r) {
- int m = (l + r) >>> 1;
- int cmp = itemNames[record][m].compareTo(name);
- if (cmp == 0) {
- return m;
- }
- if (cmp < 0) {
- l = m + 1;
- } else {
- r = m;
- }
- }
- return -l - 1;
- }
-
- public int findLargestRecord() {
- if (recordCount < 2) {
- return -1;
- }
-
- updateRecordOffsets();
-
- int maxRecord = 1;
- int maxRecordSize = recordOffsets[2] - recordOffsets[1];
- for (int rec = 2; rec < recordCount; rec++) {
- int size = recordOffsets[rec + 1] - recordOffsets[rec];
- if (size > maxRecordSize) {
- maxRecord = rec;
- maxRecordSize = size;
- }
- }
- return maxRecord;
- }
-
- public int getChildren(int record, int index) {
- deserializeMeta(record);
- return itemChildren[record][index];
- }
-
- public int getRecordCount() {
- return recordCount;
- }
-
- public int getRowId(int record, int item) {
- deserializeRecordEntirely(record);
- return itemRowIds[record][item];
- }
-
- public long getTimestamp(int record, int item) {
- deserializeRecordEntirely(record);
- return itemTimeStamps[record][item];
- }
-
- public TreeStore getTreeStore() {
- return TreeStore.this;
- }
-
- public int itemCount(int record) {
- deserializeMeta(record);
- return itemCounts[record];
- }
-
- public int[] move(int record, Page targetPage) throws PagedStorageException {
- if (record < 0 || record >= recordCount) {
- throw new IllegalArgumentException("Invalid record: " + record);
- }
- if (record == 0) {
- throw new IllegalArgumentException("Cannot move record 0");
- }
- if (targetPage.getRecordCount() > 0) {
- throw new IllegalArgumentException("Can only move records to an empty page");
- }
-
- deserializeAll();
-
- boolean[] marks = new boolean[recordCount];
- int[] newRecords = new int[recordCount];
- for (int i = 0; i < newRecords.length; ++i) {
- newRecords[i] = -1;
- }
- int newRecord = recursiveCopy(record, targetPage, marks, newRecords);
- if (newRecord != 0) {
- throw new AssertionError("Top-level moved record should have become record 0");
- }
-
- fixupChildReferences(record, PAGE_MARKER + targetPage.getPos());
-
- for (int rec = recordCount - 1; rec > 0; --rec) {
- if (marks[rec]) {
- delete(rec);
- }
- }
-
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- targetPage.consistencyCheck();
- }
-
- for (int rec = 1; rec < recordCount; rec++) {
- notifyRecordItemsPosChanged(rec, 0);
- }
-
- for (int rec = 0; rec < targetPage.getRecordCount(); rec++) {
- targetPage.notifyRecordItemsPosChanged(rec, 0);
- }
-
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- targetPage.consistencyCheck();
- }
-
- return newRecords;
- }
-
- public String readName(int record, int item) {
- deserializeMeta(record);
- checkItem(record, item);
- return itemNames[record][item];
- }
-
- public void setChildPage(int record, int index, int pageId) {
- checkItem(record, index);
- deserializeAll();
- itemChildren[record][index] = PAGE_MARKER + pageId;
- changed();
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- }
-
- public void setRowId(int record, int item, int rowId) {
- deserializeAll();
- itemRowIds[record][item] = rowId;
- changed();
- }
-
- public void setTimestamp(int record, int item, long timestamp) {
- deserializeAll();
- itemTimeStamps[record][item] = timestamp;
- changed();
- }
-
- public void stats(TreeStoreStats stats, List<Page> pagesToDump) throws PagedStorageException {
- for (int rec = 0; rec < recordCount; rec++) {
- statsRecord(stats, pagesToDump, rec);
- }
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- try {
- dump(new ArrayList<Page>(), result, 0, true);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- return result.toString();
- }
-
- public int tryAdd(int record, String name) throws PagedStorageException {
- if (record >= recordCount) {
- throw new IllegalArgumentException("Invalid record: " + record);
- }
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- byte[] nameEncoded = Data.encodeStringAndCopy(name, new byte[10240]);
- int size = CB_RECORD_METADATA_PER_ITEM + additionalData + nameEncoded.length;
- if (totalSize + size > pagedStorage.getPageSize()) {
- return ADD_NOROOM;
- }
- deserializeAll();
-
- // decide a position to insert at
- int item = find(record, name);
- if (item >= 0) {
- return ADD_EXISTS;
- }
- item = -(item + 1);
-
- itemChildren[record] = ArrayUtils.add(itemChildren[record], 0, item);
- itemRowIds[record] = ArrayUtils.add(itemRowIds[record], 0, item);
- if (itemTimeStamps != null) {
- itemTimeStamps[record] = ArrayUtils.add(itemTimeStamps[record], 0, item);
- }
- itemNames[record] = ArrayUtils.add(itemNames[record], name, item);
- itemNamesEncoded[record] = ArrayUtils.add(itemNamesEncoded[record], nameEncoded, item);
- totalSize += size;
- ++itemCounts[record];
-
- if (coordListener != null) {
- for (int k = item + 1; k < itemCounts[record]; k++) {
- int id = itemRowIds[record][k];
- coordListener.treeCoordChanged(id, this.getPos(), record, k);
- }
- }
- changed();
- if (IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.TREE_CONSISTENCY)) {
- consistencyCheck();
- }
- return 1;
- }
-
- @Override
- protected void serializeCached() {
- if (recordOffsets != null) {
- return;
- }
-
- updateRecordOffsets();
-
- data.reset();
- data.writeShortInt(recordCount);
- for (int i = 0; i <= recordCount; i++) {
- data.writeShortInt(recordOffsets[i]);
- }
-
- for (int record = 0; record < recordCount; record++) {
- if (data.getPos() != recordOffsets[record]) {
- throw new AssertionError("TreeStore page record offset calculation failed (at record "
- + record + ")");
- }
-
- int count = itemCounts[record];
- int[] offsets = itemOffsets[record];
- int[] children = itemChildren[record];
- int[] rowIds = itemRowIds[record];
- long[] timeStamps = (itemTimeStamps == null ? null : itemTimeStamps[record]);
- byte[][] namesEncoded = itemNamesEncoded[record];
-
- data.writeShortInt(count);
- for (int item = 0; item < count; item++) {
- data.writeShortInt(offsets[item]);
- data.writeShortInt(children[item]);
- }
- data.writeShortInt(offsets[count]);
-
- for (int item = 0; item < count; item++) {
- if (data.getPos() != recordOffsets[record] + offsets[item]) {
- throw new AssertionError("TreeStore page item offset calculation failed (at item "
- + item + " of rec " + record + ")");
- }
- data.writeInt(rowIds[item]);
- if (timeStamps != null) {
- data.writeLong(timeStamps[item]);
- }
- data.write(namesEncoded[item]);
- }
- if (data.getPos() != recordOffsets[record] + offsets[count]) {
- throw new AssertionError("TreeStore page item offset calculation failed (at count="
- + count + " of record " + record + ")");
- }
- }
- if (data.getPos() != recordOffsets[recordCount]) {
- throw new AssertionError("TreeStore page record offset calculation failed (at recordCount="
- + recordCount + ")");
- }
- }
-
- private int addChildRecord(int size, Page page, int record) {
- int newRecord = addChildRecord(size);
- if (newRecord < 0) {
- return newRecord;
- }
-
- itemCounts = ArrayUtils.add(itemCounts, page.itemCounts[record], newRecord);
- itemOffsets = ArrayUtils.add(itemOffsets, page.itemOffsets[record], newRecord);
- itemChildren = ArrayUtils.add(itemChildren, page.itemChildren[record], newRecord);
- itemRowIds = ArrayUtils.add(itemRowIds, page.itemRowIds[record], newRecord);
- if (itemTimeStamps != null) {
- itemTimeStamps = ArrayUtils.add(itemTimeStamps, page.itemTimeStamps[record], newRecord);
- }
- itemNames = ArrayUtils.add(itemNames, page.itemNames[record], newRecord);
- itemNamesEncoded = ArrayUtils.add(itemNamesEncoded, page.itemNamesEncoded[record], newRecord);
-
- return newRecord;
- }
-
- private void checkItem(int record, int item) {
- if (record < 0 || record >= recordCount) {
- throw new IllegalArgumentException("Invalid record: " + record);
- }
- if (item < 0 || item >= itemCounts[record]) {
- throw new IllegalArgumentException("Invalid index " + item + " in record " + record);
- }
- }
-
- private void consistencyCheck() {
- updateRecordOffsets();
-
- for (int rec = 0; rec < recordCount; ++rec) {
- int count = itemCount(rec);
- for (int index = 0; index < count; ++index) {
- int child = getChildren(rec, index);
- if (child < 0) {
- throw new AssertionError("Consistency check failed for page " + getPos() + ", rec "
- + rec + ", item " + index + ": invalid child: " + child);
- } else if (child > 0 && child < PAGE_MARKER) {
- if (child > recordCount) {
- throw new AssertionError("Consistency check failed for page " + getPos() + ", rec "
- + rec + ", item " + index + ": child does not exist: " + child);
- }
- }
- }
- }
- }
-
- private void deserializeAll() {
- if (recordOffsets == null) {
- return;
- }
- for (int record = 0; record < recordCount; record++) {
- deserializeRecordEntirely(record);
- itemOffsets[record] = null;
- }
- recordOffsets = null;
- }
-
- private void deserializeMeta(int record) {
- deserializeRecordEntirely(record);
- }
-
- private void deserializeRecordEntirely(int record) {
- if (record < 0 || record >= recordCount) {
- throw new IllegalArgumentException("Invalid record: " + record);
- }
-
- if (recordOffsets == null || itemChildren[record] != null) {
- return;
- }
-
- data.setPos(recordOffsets[record]);
- int count = itemCounts[record] = data.readShortInt();
-
- int[] offsets = itemOffsets[record] = new int[count + 1];
- int[] children = itemChildren[record] = new int[count];
- int[] rowIds = itemRowIds[record] = new int[count];
- long[] timeStamps = (itemTimeStamps == null ? null
- : (itemTimeStamps[record] = new long[count]));
- String[] names = itemNames[record] = new String[count];
- byte[][] namesEncoded = itemNamesEncoded[record] = new byte[count][];
-
- for (int item = 0; item < count; item++) {
- offsets[item] = data.readShortInt();
- children[item] = data.readShortInt();
- }
- offsets[count] = data.readShortInt();
-
- for (int item = 0; item < count; item++) {
- data.setPos(recordOffsets[record] + offsets[item]);
- rowIds[item] = data.readInt();
- if (timeStamps != null) {
- timeStamps[item] = data.readLong();
- }
- int nameLength = offsets[item + 1] - offsets[item] - additionalData;
-
- byte[] nameEncoded = namesEncoded[item] = new byte[nameLength];
- data.read(nameEncoded, 0, nameEncoded.length);
- names[item] = Data.decodeString(nameEncoded, nameEncoded.length);
- }
- }
-
- private void dumpItem(List<Page> pagesToDump, StringBuilder out, int rec, int index, int level,
- boolean detailed) throws PagedStorageException {
- int child = itemChildren[rec][index];
- out.append(StringUtils.indent(level)).append("Item").append(index).append(":");
- out.append(" child ").append(
- child == 0 ? "NONE" : (child < PAGE_MARKER ? "Rec" + child : "Page"
- + (child - PAGE_MARKER)));
- if (child > PAGE_MARKER) {
- Page childPage = readPage(child - PAGE_MARKER);
- pagesToDump.add(childPage);
- }
- out.append(" ").append('"').append(itemNames[rec][index]).append('"');
- out.append(" 0 0 0 ").append(itemRowIds[rec][index]);
- out.append("\n");
- }
-
- private void dumpRecord(List<Page> pagesToDump, StringBuilder out, int rec, int level,
- boolean detailed) throws PagedStorageException {
- deserializeRecordEntirely(rec);
-
- int count = itemCounts[rec];
- out.append(StringUtils.indent(level)).append("Rec").append(rec).append(": ").append(count).append(
- " items");
- out.append("\n");
- for (int i = 0; i < count; i++) {
- dumpItem(pagesToDump, out, rec, i, level + 1, detailed);
- }
- }
-
- private void fixupChildReferences(int oldChild, int newChild) {
- for (int rec = 0; rec < recordCount; rec++) {
- if (rec == oldChild) {
- continue;
- }
- int count = itemCount(rec);
- for (int item = 0; item < count; item++) {
- if (getChildren(rec, item) == oldChild) {
- setChildrenX(rec, item, newChild);
- }
- }
- }
- }
-
- private void notifyRecordItemsPosChanged(int record, int lowerItem)
- throws PagedStorageException {
- int count = itemCount(record);
- if (coordListener != null) {
- for (int item = lowerItem; item < count; item++) {
- int id = itemRowIds[record][item];
- coordListener.treeCoordChanged(id, this.getPos(), record, item);
- }
- }
- }
-
- private int recordSize(int record) {
- int count = itemCounts[record];
- String[] names = itemNames[record];
-
- int size = CB_EMPTY_RECORD_METADATA + CB_RECORD_METADATA_PER_ITEM * count;
- for (int item = 0; item < count; item++) {
- size += additionalData + Data.encodeString(names[item], null);
- }
- return size;
- }
-
- private int recursiveCopy(int record, Page targetPage, boolean[] marks, int[] newRecords) {
- int newRecord = shallowCopy(record, targetPage);
- marks[record] = true;
- newRecords[record] = newRecord;
-
- int count = itemCount(record);
- for (int item = 0; item < count; item++) {
- int child = getChildren(record, item);
- if (child > 0 && child < PAGE_MARKER) {
- int newChild = recursiveCopy(child, targetPage, marks, newRecords);
- targetPage.setChildrenX(newRecord, item, newChild);
-
- // remove our child ref so that delete() does not complain
- // (completely unnecessary algorithm-wise)
- setChildrenX(record, item, 0);
- }
- }
-
- return newRecord;
- }
-
- private void setChildrenX(int rec, int item, int child) {
- itemChildren[rec][item] = child;
- }
-
- private int shallowCopy(int record, Page targetPage) throws AssertionError {
- int size = recordSize(record);
- return targetPage.addChildRecord(size, this, record);
- }
-
- private void statsItem(TreeStoreStats stats, List<Page> pagesToDump, int rec, int index)
- throws PagedStorageException {
- int child = itemChildren[rec][index];
- if (child > PAGE_MARKER) {
- Page childPage = readPage(child - PAGE_MARKER);
- pagesToDump.add(childPage);
- }
- stats.componentLength.add(itemNames[rec][index].length());
- }
-
- private void statsRecord(TreeStoreStats stats, List<Page> pagesToDump, int rec)
- throws PagedStorageException {
- deserializeRecordEntirely(rec);
- int count = itemCounts[rec];
- for (int i = 0; i < count; i++) {
- statsItem(stats, pagesToDump, rec, i);
- }
- }
-
- private void updateRecordOffsets() {
- if (recordOffsets != null) {
- return;
- }
-
- recordOffsets = new int[recordCount + 1];
-
- byte[] buf = new byte[10240];
- int offset = CB_EMPTY_PAGE_METADATA + recordCount * CB_PAGE_METADATA_PER_RECORD;
- for (int record = 0; record < recordCount; record++) {
- recordOffsets[record] = offset;
-
- int count = itemCounts[record];
- byte[][] namesEncoded = itemNamesEncoded[record];
- String[] names = itemNames[record];
- int[] offsets = itemOffsets[record] = new int[count + 1];
-
- for (int item = 0; item < count; item++) {
- if (namesEncoded[item] == null) {
- namesEncoded[item] = Data.encodeStringAndCopy(names[item], buf);
- }
- }
-
- int itemOffset = CB_EMPTY_RECORD_METADATA + CB_RECORD_METADATA_PER_ITEM * count;
- for (int item = 0; item < count; item++) {
- offsets[item] = itemOffset;
- itemOffset += additionalData + namesEncoded[item].length;
- }
- offsets[count] = itemOffset;
-
- offset += itemOffset;
- }
- recordOffsets[recordCount] = offset;
- if (recordOffsets[recordCount] != totalSize) {
- throw new AssertionError("totalSize != finalRecordOffset: " + totalSize + " != " + offset);
- }
- }
- }
-
- public static final int ADD_NOROOM = -1;
-
- public static final int ADD_EXISTS = -2;
- static final int PAGE_MARKER = 10000;
- private final PagedStorage pagedStorage;
-
- private Page rootPage;
-
- private final int additionalData;
-
- private RecordFactory recordFactory = new RecordFactory() {
-
- @Override
- public Record read(PagedStorage pagedStorage, Data data, int pageId, boolean isNew)
- throws PagedStorageException {
- return new Page(data, pageId);
- }
-
- };
-
- private TreeCoordListener coordListener;
-
- public TreeStore(PagedStorage pagedStorage, int additionalData, int rootPageId)
- throws PagedStorageException {
- this.pagedStorage = pagedStorage;
- this.additionalData = additionalData;
- open(rootPageId);
- }
-
- public void dump(StringBuilder out, int level, boolean detailed) {
- out.append(StringUtils.indent(level)).append("TreeStore");
- out.append(" root=").append(rootPage.pageId);
- out.append("\n");
- List<Page> pagesToDump = new LinkedList<Page>();
- pagesToDump.add(rootPage);
- while (!pagesToDump.isEmpty()) {
- Page page = pagesToDump.remove(0);
- try {
- page.dump(pagesToDump, out, level + 1, detailed);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- }
- }
-
- public PageRecPos lookup(String[] path, boolean add) throws PagedStorageException {
- if (add) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- "TreeStore<" + rootPage.pageId + "> search-or-add: " + StringUtils.join(path));
- } else {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- "TreeStore<" + rootPage.pageId + "> search: " + StringUtils.join(path));
- }
- PageRec pageRec = root();
- int pathLength = path.length;
- PageRecPos result = null;
- for (int i = 0; i < pathLength; i++) {
- String component = path[i];
- if (component == null) {
- throw new NullPointerException("Path component is null");
- }
-
- PageRecPos pos = pageRec.lookup(component, add);
- if (pos == null) {
- if (add && IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.ANOMALIES)) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ANOMALIES,
- "Item creation failed for path " + StringUtils.join(path));
- } else {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- " NOT FOUND at #" + i + " " + component);
- }
- return null;
- }
- if (i == pathLength - 1) {
- result = pos;
- } else {
- pageRec = pos.children(add);
- if (pageRec == null) {
- if (add && IndexerPlugin.getLogger().isTracing(IndexerDebugOptions.ANOMALIES)) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ANOMALIES,
- "Child record creation failed for path " + StringUtils.join(path));
- } else {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- " NO CHILDREN at #" + i + " " + component);
- }
- return null;
- }
- }
- }
- if (result == null) {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS, "result is null");
- } else {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.TREE_LOOKUPS,
- " FOUND " + result.page.pageId + " - " + toString().trim());
- }
- return result;
- }
-
- public Iterator<TreeLeaf> pathIterator() {
- return new LeafIterator();
- }
-
- public PageRecPos readPos(Data data) throws PagedStorageException {
- int pageId = data.readInt();
- int record = data.readShortInt();
- int index = data.readShortInt();
- return new PageRecPos(readPage(pageId), record, index);
- }
-
- public PageRec root() {
- return new PageRec(rootPage, 0);
- }
-
- public void setCoordListener(TreeCoordListener coordListener) {
- this.coordListener = coordListener;
- }
-
- public void stats(TreeStoreStats stats) {
- List<Page> pagesToDump = new LinkedList<Page>();
- pagesToDump.add(rootPage);
- while (!pagesToDump.isEmpty()) {
- Page page = pagesToDump.remove(0);
- ++stats.pages;
- try {
- page.stats(stats, pagesToDump);
- } catch (PagedStorageException exception) {
- IndexerPlugin.getLogger().logError(exception);
- }
- }
- }
-
- @Override
- public String toString() {
- StringBuilder result = new StringBuilder();
- dump(result, 0, true);
- return result.toString();
- }
-
- public String toTestableString() {
- StringBuilder result = new StringBuilder();
- dump(result, 0, false);
- return result.toString();
- }
-
- Page readPage(int pageId) throws PagedStorageException {
- return (Page) pagedStorage.readRecord(pageId, recordFactory);
- }
-
- private void open(int rootPageId) throws PagedStorageException {
- if (rootPageId < 0) {
- rootPageId = pagedStorage.allocatePage();
- rootPage = new Page(pagedStorage.createData(), rootPageId);
- pagedStorage.updateRecord(rootPage);
- } else {
- rootPage = readPage(rootPageId);
- }
- if (rootPage.recordCount == 0) {
- rootPage.addEmptyChildRecord();
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/ArrayUtils.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/ArrayUtils.java
deleted file mode 100644
index d0972d5..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/ArrayUtils.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import java.util.Arrays;
-
-public class ArrayUtils {
- public static byte[][] add(byte[][] array, byte[] newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- byte[][] result = new byte[array.length + 1][];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static byte[][][] add(byte[][][] array, byte[][] newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- byte[][][] result = new byte[array.length + 1][][];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static int[] add(int[] array, int newValue) {
- int[] result = new int[array.length + 1];
- System.arraycopy(array, 0, result, 0, array.length);
- result[array.length] = newValue;
- return result;
- }
-
- public static int[] add(int[] array, int newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- int[] result = new int[array.length + 1];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static int[][] add(int[][] array, int[] newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- int[][] result = new int[array.length + 1][];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static long[] add(long[] array, long newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- long[] result = new long[array.length + 1];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static long[][] add(long[][] array, long[] newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- long[][] result = new long[array.length + 1][];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static String[] add(String[] array, String newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- String[] result = new String[array.length + 1];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static String[][] add(String[][] array, String[] newValue, int pos) {
- if (pos < 0 || pos > array.length) {
- throw new IllegalArgumentException("Invalid pos to insert an item at");
- }
- String[][] result = new String[array.length + 1][];
- System.arraycopy(array, 0, result, 0, pos);
- result[pos] = newValue;
- System.arraycopy(array, pos, result, pos + 1, array.length - pos);
- return result;
- }
-
- public static int[] addSorted(int[] array, int[] newValues) {
- if (newValues.length == 0) {
- return array;
- }
-
- int[] interim = new int[array.length + newValues.length];
- System.arraycopy(array, 0, interim, 0, array.length);
- System.arraycopy(newValues, 0, interim, array.length, newValues.length);
- Arrays.sort(interim);
-
- int count = 1;
- for (int i = 1; i < interim.length; i++) {
- if (interim[i] != interim[i - 1]) {
- ++count;
- }
- }
-
- if (count == interim.length) {
- return interim;
- }
-
- int[] result = new int[count];
- int index = 0;
- result[index++] = interim[0];
- for (int i = 1; i < interim.length; i++) {
- if (interim[i] != interim[i - 1]) {
- result[index++] = interim[i];
- }
- }
- if (index != count) {
- throw new AssertionError("addSorted internal error");
- }
-
- return result;
- }
-
- public static byte[][] remove(byte[][] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- byte[][] result = new byte[array.length - 1][];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static byte[][][] remove(byte[][][] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- byte[][][] result = new byte[array.length - 1][][];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static int[] remove(int[] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- int[] result = new int[array.length - 1];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static int[][] remove(int[][] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- int[][] result = new int[array.length - 1][];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static long[] remove(long[] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- long[] result = new long[array.length - 1];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static long[][] remove(long[][] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- long[][] result = new long[array.length - 1][];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static String[] remove(String[] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- String[] result = new String[array.length - 1];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static String[][] remove(String[][] array, int pos) {
- if (pos < 0 || pos >= array.length) {
- throw new IllegalArgumentException("Invalid pos to remove an item at");
- }
- String[][] result = new String[array.length - 1][];
- System.arraycopy(array, 0, result, 0, pos);
- if (pos < array.length - 1) {
- System.arraycopy(array, pos + 1, result, pos, array.length - pos - 1);
- }
- return result;
- }
-
- public static int[] truncate(int[] array, int maxLen) {
- if (array.length < maxLen) {
- return array;
- }
- int[] result = new int[maxLen];
- System.arraycopy(array, 0, result, 0, maxLen);
- return result;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/BitField.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/BitField.java
deleted file mode 100644
index 6b7b7ce..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/BitField.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-/**
- * A list of bits.
- */
-public class BitField {
- private static final int ADDRESS_BITS = 6;
- private static final int BITS = 64;
- private static final int ADDRESS_MASK = BITS - 1;
- private long[] data = new long[10];
-
- /**
- * Set bit at the given index to 'false'.
- *
- * @param i the index
- */
- public void clear(int i) {
- int addr = getAddress(i);
- if (addr >= data.length) {
- return;
- }
- data[addr] &= ~getBitMask(i);
- }
-
- /**
- * Get the bit at the given index.
- *
- * @param i the index
- * @return true if the bit is enabled
- */
- public boolean get(int i) {
- int addr = getAddress(i);
- if (addr >= data.length) {
- return false;
- }
- return (data[addr] & getBitMask(i)) != 0;
- }
-
- /**
- * Get the next 8 bits at the given index. The index must be a multiple of 8.
- *
- * @param i the index
- * @return the next 8 bits
- */
- public int getByte(int i) {
- int addr = getAddress(i);
- if (addr >= data.length) {
- return 0;
- }
- return (int) (data[addr] >>> (i & (7 << 3)) & 255);
- }
-
- /**
- * Get the index of the last bit that is set.
- *
- * @return the index of the last enabled bit, or -1
- */
- public int getLastSetBit() {
- int i = (data.length << ADDRESS_BITS) - 1;
- while (i >= 0) {
- if (get(i)) {
- return i;
- }
- i--;
- }
- return -1;
- }
-
- /**
- * Get the bit mask of the bits at the given index.
- *
- * @param i the index (must be a multiple of 64)
- * @return the bit mask as a long
- */
- public long getLong(int i) {
- int addr = getAddress(i);
- if (addr >= data.length) {
- return 0;
- }
- return data[addr];
- }
-
- /**
- * Get the index of the next bit that is not set.
- *
- * @param fromIndex where to start searching
- * @return the index of the next disabled bit
- */
- public int nextClearBit(int fromIndex) {
- int i = fromIndex >> ADDRESS_BITS;
- int max = data.length;
- for (; i < max; i++) {
- if (data[i] == -1) {
- continue;
- }
- int j = Math.max(fromIndex, i << ADDRESS_BITS);
- for (int end = j + 64; j < end; j++) {
- if (!get(j)) {
- return j;
- }
- }
- }
- return max << ADDRESS_BITS;
- }
-
- /**
- * Get the index of the next bit that is set.
- *
- * @param fromIndex where to start searching
- * @return the index of the next enabled bit
- */
- public int nextSetBit(int fromIndex) {
- int i = fromIndex >> ADDRESS_BITS;
- int max = data.length;
- int maxAddress = data.length << ADDRESS_BITS;
- for (; i < max; i++) {
- if (data[i] == 0) {
- continue;
- }
- int j = Math.max(fromIndex, i << ADDRESS_BITS);
- for (int end = Math.min(maxAddress, j + 64); j < end; j++) {
- if (get(j)) {
- return j;
- }
- }
- }
- return -1;
- }
-
- /**
- * Set bit at the given index to 'true'.
- *
- * @param i the index
- */
- public void set(int i) {
- int addr = getAddress(i);
- checkCapacity(addr);
- data[addr] |= getBitMask(i);
- }
-
- /**
- * Combine the next 8 bits at the given index with OR. The index must be a multiple of 8.
- *
- * @param i the index
- * @param x the next 8 bits (0 - 255)
- */
- public void setByte(int i, int x) {
- int addr = getAddress(i);
- checkCapacity(addr);
- data[addr] |= ((long) x) << (i & (7 << 3));
- }
-
- /**
- * Enable or disable a number of bits.
- *
- * @param start the index of the first bit to enable or disable
- * @param len the number of bits to enable or disable
- * @param value the new value
- */
- public void setRange(int start, int len, boolean value) {
- // go backwards so that OutOfMemory happens
- // before some bytes are modified
- for (int i = start + len - 1; i >= start; i--) {
- set(i, value);
- }
- }
-
- private void checkCapacity(int size) {
- if (size >= data.length) {
- expandCapacity(size);
- }
- }
-
- private void expandCapacity(int size) {
- while (size >= data.length) {
- int newSize = data.length == 0 ? 1 : data.length * 2;
- long[] d = new long[newSize];
- System.arraycopy(data, 0, d, 0, data.length);
- data = d;
- }
- }
-
- private int getAddress(int i) {
- return i >> ADDRESS_BITS;
- }
-
- private long getBitMask(int i) {
- return 1L << (i & ADDRESS_MASK);
- }
-
- private void set(int i, boolean value) {
- if (value) {
- set(i);
- } else {
- clear(i);
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/ByteUtils.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/ByteUtils.java
deleted file mode 100644
index 0347b3b..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/ByteUtils.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-public class ByteUtils {
- /**
- * Compare the contents of two byte arrays. If the content or length of the first array is smaller
- * than the second array, -1 is returned. If the content or length of the second array is smaller
- * than the first array, 1 is returned. If the contents and lengths are the same, 0 is returned.
- *
- * @param data1 the first byte array (must not be null)
- * @param data2 the second byte array (must not be null)
- * @return the result of the comparison (-1, 1 or 0)
- */
- public static int compareNotNull(byte[] data1, byte[] data2) {
- int len = Math.min(data1.length, data2.length);
- for (int i = 0; i < len; i++) {
- byte b = data1[i];
- byte b2 = data2[i];
- if (b != b2) {
- return b > b2 ? 1 : -1;
- }
- }
- int c = data1.length - data2.length;
- return c == 0 ? 0 : (c < 0 ? -1 : 1);
- }
-
- private ByteUtils() {
- // utility class
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/Cache.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/Cache.java
deleted file mode 100644
index d0100d0..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/Cache.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-
-/**
- * The cache keeps frequently used objects in the main memory.
- */
-public interface Cache {
- /**
- * Clear the cache.
- */
- void clear();
-
- /**
- * Get an element from the cache if it is available. This will not move the item to the front of
- * the list.
- *
- * @param pos the unique key of the element
- * @return the element or null
- */
- CacheObject find(int pos);
-
- /**
- * Get an element in the cache if it is available. This will move the item to the front of the
- * list.
- *
- * @param pos the unique key of the element
- * @return the element or null
- */
- CacheObject get(int pos);
-
- /**
- * Get all objects in the cache that have been changed.
- *
- * @return the list of objects
- */
- ObjectArray<CacheObject> getAllChanged();
-
- /**
- * Get the maximum size in words (4 bytes).
- *
- * @return the maximum size in number of double words (4 bytes)
- */
- int getMaxSize();
-
- /**
- * Get the used size in words (4 bytes).
- *
- * @return the current size in number of double words (4 bytes)
- */
- int getSize();
-
- /**
- * Get the name of the cache type in a human readable form.
- *
- * @return the cache type name
- */
- String getTypeName();
-
- /**
- * Add an element to the cache. Other items may fall out of the cache because of this. It is not
- * allowed to add the same record twice.
- *
- * @param r the object
- */
- void put(CacheObject r) throws PagedStorageException;
-
- /**
- * Remove an object from the cache.
- *
- * @param pos the unique key of the element
- */
- void remove(int pos);
-
- /**
- * Set the maximum memory to be used by this cache.
- *
- * @param size in number of double words (4 bytes)
- */
- void setMaxSize(int size) throws PagedStorageException;
-
- /**
- * Update an element in the cache. This will move the item to the front of the list.
- *
- * @param pos the unique key of the element
- * @param record the element
- * @return the element
- */
- CacheObject update(int pos, CacheObject record) throws PagedStorageException;
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheHead.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheHead.java
deleted file mode 100644
index a22adf8..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheHead.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-
-/**
- * The head element of the linked list.
- */
-public class CacheHead extends CacheObject {
- @Override
- public boolean canRemove() {
- return false;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheLRU.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheLRU.java
deleted file mode 100644
index 5f22eb1..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheLRU.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.DebugConstants;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-import com.google.dart.indexer.storage.paged.store.CacheWriter;
-
-/**
- * A cache implementation based on the last recently used (LRU) algorithm.
- */
-public class CacheLRU implements Cache {
- static final String TYPE_NAME = "LRU";
-
- private final CacheWriter writer;
- private final CacheObject head = new CacheHead();
- private final int len;
- private final int mask;
- private int maxSize;
- private CacheObject[] values;
- private int recordCount;
- private int sizeMemory;
-
- private CacheLRU(CacheWriter writer, int maxKb) {
- this.maxSize = maxKb * 1024 / 4;
- this.writer = writer;
- this.len = MathUtils.nextPowerOf2(maxSize / 64);
- this.mask = len - 1;
- MathUtils.checkPowerOf2(len);
- clear();
- }
-
- @Override
- public void clear() {
- head.next = head.previous = head;
- // first set to null - avoiding out of memory
- values = null;
- values = new CacheObject[len];
- recordCount = 0;
- sizeMemory = 0;
- }
-
- @Override
- public CacheObject find(int pos) {
- CacheObject rec = values[pos & mask];
- while (rec != null && rec.getPos() != pos) {
- rec = rec.chained;
- }
- return rec;
- }
-
- @Override
- public CacheObject get(int pos) {
- CacheObject rec = find(pos);
- if (rec != null) {
- removeFromLinkedList(rec);
- addToFront(rec);
- }
- return rec;
- }
-
- @Override
- public ObjectArray<CacheObject> getAllChanged() {
- // TODO cache: should probably use the LRU list
- ObjectArray<CacheObject> list = ObjectArray.newInstance();
- for (int i = 0; i < len; i++) {
- CacheObject rec = values[i];
- while (rec != null) {
- if (rec.isChanged()) {
- list.add(rec);
- if (list.size() >= recordCount) {
- if (DebugConstants.CHECK) {
- if (list.size() > recordCount) {
- throw new AssertionError("cache chain error");
- }
- } else {
- break;
- }
- }
- }
- rec = rec.chained;
- }
- }
- return list;
- }
-
- @Override
- public int getMaxSize() {
- return maxSize;
- }
-
- @Override
- public int getSize() {
- return sizeMemory;
- }
-
- @Override
- public String getTypeName() {
- return TYPE_NAME;
- }
-
- @Override
- public void put(CacheObject rec) throws PagedStorageException {
- if (DebugConstants.CHECK) {
- // int pos = rec.getPos();
- // for (int i = 0; i < rec.getBlockCount(); i++) {
- // CacheObject old = find(pos + i);
- // if (old != null) {
- // Message.throwInternalError("try to add a record twice pos:" + pos +
- // " i:" + i);
- // }
- // }
- }
- int index = rec.getPos() & mask;
- rec.chained = values[index];
- values[index] = rec;
- recordCount++;
- sizeMemory += rec.getMemorySize();
- addToFront(rec);
- removeOldIfRequired();
- }
-
- @Override
- public void remove(int pos) {
- int index = pos & mask;
- CacheObject rec = values[index];
- if (rec == null) {
- return;
- }
- if (rec.getPos() == pos) {
- values[index] = rec.chained;
- } else {
- CacheObject last;
- do {
- last = rec;
- rec = rec.chained;
- if (rec == null) {
- return;
- }
- } while (rec.getPos() != pos);
- last.chained = rec.chained;
- }
- recordCount--;
- sizeMemory -= rec.getMemorySize();
- removeFromLinkedList(rec);
- if (DebugConstants.CHECK) {
- rec.chained = null;
- if (find(pos) != null) {
- throw new AssertionError("not removed!");
- }
- }
- }
-
- @Override
- public void setMaxSize(int maxKb) throws PagedStorageException {
- int newSize = maxKb * 1024 / 4;
- maxSize = newSize < 0 ? 0 : newSize;
- // can not resize, otherwise existing records are lost
- // resize(maxSize);
- removeOldIfRequired();
- }
-
- @Override
- public CacheObject update(int pos, CacheObject rec) throws PagedStorageException {
- CacheObject old = find(pos);
- if (old == null) {
- put(rec);
- } else {
- if (DebugConstants.CHECK) {
- if (old != rec) {
- throw new IllegalArgumentException(
- "Attemp to write conflicting records into cache - pos:" + pos + " old:" + old
- + " new:" + rec);
- }
- }
- removeFromLinkedList(rec);
- addToFront(rec);
- }
- return old;
- }
-
- private void addToFront(CacheObject rec) {
- if (DebugConstants.CHECK && rec == head) {
- throw new IllegalArgumentException("try to move head");
- }
- rec.next = head;
- rec.previous = head.previous;
- rec.previous.next = rec;
- head.previous = rec;
- }
-
- private void removeFromLinkedList(CacheObject rec) {
- if (DebugConstants.CHECK && rec == head) {
- throw new IllegalArgumentException("try to remove head");
- }
- rec.previous.next = rec.next;
- rec.next.previous = rec.previous;
- // TODO cache: mystery: why is this required? needs more memory if we
- // don't do this
- rec.next = null;
- rec.previous = null;
- }
-
- private void removeOld() throws PagedStorageException {
- int i = 0;
- ObjectArray<CacheObject> changed = ObjectArray.newInstance();
- while (sizeMemory * 4 > maxSize * 3 && recordCount > Constants.CACHE_MIN_RECORDS) {
- i++;
- if (i >= recordCount * 2) {
- // hopefully this does not happen too much, but it could happen
- // theoretically
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.RARE_ANOMALIES,
- "Cannot remove records, cache size too small?");
- break;
- }
- CacheObject last = head.next;
- if (DebugConstants.CHECK && last == head) {
- throw new AssertionError("try to remove head");
- }
- // we are not allowed to remove it if the log is not yet written
- // (because we need to log before writing the data)
- // also, can't write it if the record is pinned
- if (!last.canRemove()) {
- removeFromLinkedList(last);
- addToFront(last);
- continue;
- }
- remove(last.getPos());
- if (last.isChanged()) {
- changed.add(last);
- }
- }
- if (changed.size() > 0) {
- CacheObject.sort(changed);
- for (i = 0; i < changed.size(); i++) {
- CacheObject rec = changed.get(i);
- writer.writeBack(rec);
- }
- }
- }
-
- private void removeOldIfRequired() throws PagedStorageException {
- // a small method, to allow inlining
- if (sizeMemory >= maxSize) {
- removeOld();
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheSecondLevel.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheSecondLevel.java
deleted file mode 100644
index 75d231e..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheSecondLevel.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-
-import java.util.Map;
-
-/**
- * Cache which wraps another cache (proxy pattern) and adds caching using map. This is useful for
- * WeakReference, SoftReference or hard reference cache.
- */
-class CacheSecondLevel implements Cache {
- private final Cache baseCache;
- private final String prefix;
- private final Map<Integer, CacheObject> map;
-
- CacheSecondLevel(Cache cache, String prefix, Map<Integer, CacheObject> map) {
- this.baseCache = cache;
- this.prefix = prefix;
- this.map = map;
- }
-
- @Override
- public void clear() {
- map.clear();
- baseCache.clear();
- }
-
- @Override
- public CacheObject find(int pos) {
- CacheObject ret = baseCache.find(pos);
- if (ret == null) {
- ret = map.get(new Integer(pos));
- }
- return ret;
- }
-
- @Override
- public CacheObject get(int pos) {
- CacheObject ret = baseCache.get(pos);
- if (ret == null) {
- ret = map.get(new Integer(pos));
- }
- return ret;
- }
-
- @Override
- public ObjectArray<CacheObject> getAllChanged() {
- return baseCache.getAllChanged();
- }
-
- @Override
- public int getMaxSize() {
- return baseCache.getMaxSize();
- }
-
- @Override
- public int getSize() {
- return baseCache.getSize();
- }
-
- @Override
- public String getTypeName() {
- return prefix + baseCache.getTypeName();
- }
-
- @Override
- public void put(CacheObject r) throws PagedStorageException {
- baseCache.put(r);
- map.put(new Integer(r.getPos()), r);
- }
-
- @Override
- public void remove(int pos) {
- baseCache.remove(pos);
- map.remove(new Integer(pos));
- }
-
- @Override
- public void setMaxSize(int size) throws PagedStorageException {
- baseCache.setMaxSize(size);
- }
-
- @Override
- public CacheObject update(int pos, CacheObject record) throws PagedStorageException {
- CacheObject oldRec = baseCache.update(pos, record);
- map.put(new Integer(pos), record);
- return oldRec;
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheTQ.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheTQ.java
deleted file mode 100644
index 709bfe1..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/CacheTQ.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.DebugConstants;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.storage.paged.store.CacheObject;
-import com.google.dart.indexer.storage.paged.store.CacheWriter;
-
-/**
- * A cache implementation based on the 2Q algorithm. For about the algorithm, see
- * http://www.vldb.org/conf/1994/P439.PDF . In this implementation, items are moved from 'in' queue
- * and move to the 'main' queue if the are referenced again.
- */
-public class CacheTQ implements Cache {
- static final String TYPE_NAME = "TQ";
-
- private static final int MAIN = 1, IN = 2, OUT = 3;
- private static final int PERCENT_IN = 20, PERCENT_OUT = 50;
-
- private final CacheWriter writer;
- private final CacheObject headMain = new CacheHead();
- private final CacheObject headIn = new CacheHead();
- private final CacheObject headOut = new CacheHead();
- private final int len;
- private final int mask;
- private int maxSize;
- private int maxMain, maxIn, maxOut;
- private int sizeMain, sizeIn, sizeOut;
- private int recordCount;
- private CacheObject[] values;
-
- public CacheTQ(CacheWriter writer, int maxKb) {
- int maxSize = maxKb * 1024 / 4;
- this.writer = writer;
- this.maxSize = maxSize;
- this.len = MathUtils.nextPowerOf2(maxSize / 64);
- this.mask = len - 1;
- MathUtils.checkPowerOf2(len);
- recalculateMax();
- clear();
- }
-
- @Override
- public void clear() {
- headMain.next = headMain.previous = headMain;
- headIn.next = headIn.previous = headIn;
- headOut.next = headOut.previous = headOut;
- // first set to null - avoiding out of memory
- values = null;
- values = new CacheObject[len];
- sizeIn = sizeOut = sizeMain = 0;
- recordCount = 0;
- }
-
- @Override
- public CacheObject find(int pos) {
- CacheObject o = findCacheObject(pos);
- if (o != null && o.cacheQueue != OUT) {
- return o;
- }
- return null;
- }
-
- @Override
- public CacheObject get(int pos) {
- CacheObject r = findCacheObject(pos);
- if (r == null) {
- return null;
- }
- if (r.cacheQueue == MAIN) {
- removeFromList(r);
- addToFront(headMain, r);
- } else if (r.cacheQueue == OUT) {
- return null;
- } else if (r.cacheQueue == IN) {
- removeFromList(r);
- sizeIn -= r.getMemorySize();
- sizeMain += r.getMemorySize();
- r.cacheQueue = MAIN;
- addToFront(headMain, r);
- }
- return r;
- }
-
- @Override
- public ObjectArray<CacheObject> getAllChanged() {
- ObjectArray<CacheObject> list = ObjectArray.newInstance();
- for (CacheObject o = headMain.next; o != headMain; o = o.next) {
- if (o.isChanged()) {
- list.add(o);
- }
- }
- for (CacheObject o = headIn.next; o != headIn; o = o.next) {
- if (o.isChanged()) {
- list.add(o);
- }
- }
- CacheObject.sort(list);
- return list;
- }
-
- @Override
- public int getMaxSize() {
- return maxSize;
- }
-
- @Override
- public int getSize() {
- return sizeIn + sizeOut + sizeMain;
- }
-
- @Override
- public String getTypeName() {
- return TYPE_NAME;
- }
-
- @Override
- public void put(CacheObject rec) throws PagedStorageException {
- int pos = rec.getPos();
- CacheObject r = findCacheObject(pos);
- if (r != null) {
- if (r.cacheQueue == OUT) {
- removeCacheObject(pos);
- removeFromList(r);
- removeOldIfRequired();
- rec.cacheQueue = MAIN;
- putCacheObject(rec);
- addToFront(headMain, rec);
- sizeMain += rec.getMemorySize();
- }
- } else if (sizeMain < maxMain) {
- removeOldIfRequired();
- rec.cacheQueue = MAIN;
- putCacheObject(rec);
- addToFront(headMain, rec);
- sizeMain += rec.getMemorySize();
- } else {
- removeOldIfRequired();
- rec.cacheQueue = IN;
- putCacheObject(rec);
- addToFront(headIn, rec);
- sizeIn += rec.getMemorySize();
- }
- }
-
- @Override
- public void remove(int pos) {
- CacheObject r = removeCacheObject(pos);
- if (r != null) {
- removeFromList(r);
- if (r.cacheQueue == MAIN) {
- sizeMain -= r.getMemorySize();
- } else if (r.cacheQueue == IN) {
- sizeIn -= r.getMemorySize();
- }
- }
- }
-
- @Override
- public void setMaxSize(int maxKb) throws PagedStorageException {
- int newSize = maxKb * 1024 / 4;
- maxSize = newSize < 0 ? 0 : newSize;
- recalculateMax();
- // can not resize, otherwise existing records are lost
- // resize(maxSize);
- removeOldIfRequired();
- }
-
- @Override
- public CacheObject update(int pos, CacheObject rec) throws PagedStorageException {
- CacheObject old = find(pos);
- if (old == null || old.cacheQueue == OUT) {
- put(rec);
- } else {
- if (old == rec) {
- if (rec.cacheQueue == MAIN) {
- removeFromList(rec);
- addToFront(headMain, rec);
- }
- }
- }
- return old;
- }
-
- private void addToFront(CacheObject head, CacheObject rec) {
- if (DebugConstants.CHECK) {
- if (rec == head) {
- throw new IllegalArgumentException("try to move head");
- }
- if (rec.next != null || rec.previous != null) {
- throw new IllegalArgumentException("already linked");
- }
- }
- rec.next = head;
- rec.previous = head.previous;
- rec.previous.next = rec;
- head.previous = rec;
- }
-
- private CacheObject findCacheObject(int pos) {
- CacheObject rec = values[pos & mask];
- while (rec != null && rec.getPos() != pos) {
- rec = rec.chained;
- }
- return rec;
- }
-
- private void putCacheObject(CacheObject rec) {
- if (DebugConstants.CHECK) {
- // for (int i = 0; i < rec.getBlockCount(); i++) {
- // CacheObject old = find(rec.getPos() + i);
- // if (old != null) {
- // Message.throwInternalError("try to add a record twice i=" + i);
- // }
- // }
- }
- int index = rec.getPos() & mask;
- rec.chained = values[index];
- values[index] = rec;
- recordCount++;
- }
-
- private void recalculateMax() {
- maxMain = maxSize;
- maxIn = maxSize * PERCENT_IN / 100;
- maxOut = maxSize * PERCENT_OUT / 100;
- }
-
- private CacheObject removeCacheObject(int pos) {
- int index = pos & mask;
- CacheObject rec = values[index];
- if (rec == null) {
- return null;
- }
- if (rec.getPos() == pos) {
- values[index] = rec.chained;
- } else {
- CacheObject last;
- do {
- last = rec;
- rec = rec.chained;
- if (rec == null) {
- return null;
- }
- } while (rec.getPos() != pos);
- last.chained = rec.chained;
- }
- recordCount--;
- if (DebugConstants.CHECK) {
- rec.chained = null;
- }
- return rec;
- }
-
- private void removeFromList(CacheObject rec) {
- if (DebugConstants.CHECK && (rec instanceof CacheHead && rec.cacheQueue != OUT)) {
- throw new AssertionError("CacheTQ internal inconsistency");
- }
- rec.previous.next = rec.next;
- rec.next.previous = rec.previous;
- // TODO cache: mystery: why is this required? needs more memory if we
- // don't do this
- rec.next = null;
- rec.previous = null;
- }
-
- private void removeOld() throws PagedStorageException {
- int i = 0;
- ObjectArray<CacheObject> changed = ObjectArray.newInstance();
- while (((sizeIn * 4 > maxIn * 3) || (sizeOut * 4 > maxOut * 3) || (sizeMain * 4 > maxMain * 3))
- && recordCount > Constants.CACHE_MIN_RECORDS) {
- i++;
- if (i >= recordCount * 2) {
- // hopefully this does not happen too much, but it could happen
- // theoretically
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.RARE_ANOMALIES,
- "Cannot remove records, cache size too small?");
- break;
- }
- if (sizeIn > maxIn) {
- CacheObject r = headIn.next;
- if (!r.canRemove()) {
- removeFromList(r);
- addToFront(headIn, r);
- continue;
- }
- sizeIn -= r.getMemorySize();
- int pos = r.getPos();
- removeCacheObject(pos);
- removeFromList(r);
- if (r.isChanged()) {
- changed.add(r);
- }
- r = new CacheHead();
- r.setPos(pos);
- r.cacheQueue = OUT;
- putCacheObject(r);
- addToFront(headOut, r);
- sizeOut++;
- if (sizeOut >= maxOut) {
- r = headOut.next;
- sizeOut--;
- removeCacheObject(r.getPos());
- removeFromList(r);
- }
- } else if (sizeMain > 0) {
- CacheObject r = headMain.next;
- if (!r.canRemove() && !(r instanceof CacheHead)) {
- removeFromList(r);
- addToFront(headMain, r);
- continue;
- }
- sizeMain -= r.getMemorySize();
- removeCacheObject(r.getPos());
- removeFromList(r);
- if (r.isChanged()) {
- changed.add(r);
- }
- }
- }
- if (changed.size() > 0) {
- CacheObject.sort(changed);
- for (i = 0; i < changed.size(); i++) {
- CacheObject rec = changed.get(i);
- writer.writeBack(rec);
- }
- }
- }
-
- private void removeOldIfRequired() throws PagedStorageException {
- // a small method, to allow inlining
- if ((sizeIn >= maxIn) || (sizeOut >= maxOut) || (sizeMain >= maxMain)) {
- removeOld();
- }
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/Constants.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/Constants.java
deleted file mode 100644
index da6c287..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/Constants.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-public class Constants {
- public static final int CACHE_MIN_RECORDS = 16;
-
- public static final int FILE_BLOCK_SIZE = 16;
-
- public static final int IO_BUFFER_SIZE = 4 * 1024;
-
- public static final String MAGIC_FILE_HEADER = "JavaIndexer 1.0- ".substring(0,
- FILE_BLOCK_SIZE - 1) + "\n";
-
- public static final String UTF8 = "UTF8";
-
- private Constants() {
- // utility class
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/FileUtils.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/FileUtils.java
deleted file mode 100644
index a36a049..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/FileUtils.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import com.google.dart.indexer.IndexerPlugin;
-import com.google.dart.indexer.debug.IndexerDebugOptions;
-import com.google.dart.indexer.pagedstorage.exceptions.PagedStorageException;
-import com.google.dart.indexer.pagedstorage.filesystem.FileSystem;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.RandomAccessFile;
-
-public class FileUtils {
- /**
- * Check if it is a file or a directory.
- *
- * @param fileName the file or directory name
- * @return true if it is a directory
- */
- public static boolean isDirectory(String fileName) {
- return FileSystem.getInstance(fileName).isDirectory(fileName);
- }
-
- /**
- * Get the length of a file.
- *
- * @param fileName the file name
- * @return the length in bytes
- */
- public static long length(String fileName) {
- return FileSystem.getInstance(fileName).length(fileName);
- }
-
- /**
- * Create an input stream to read from the file.
- *
- * @param fileName the file name
- * @return the input stream
- */
- public static InputStream openFileInputStream(String fileName) throws IOException {
- return FileSystem.getInstance(fileName).openFileInputStream(fileName);
- }
-
- /**
- * Create an output stream to write into the file.
- *
- * @param fileName the file name
- * @param append if true, the file will grow, if false, the file will be truncated first
- * @return the output stream
- */
- public static OutputStream openFileOutputStream(String fileName, boolean append)
- throws PagedStorageException {
- return FileSystem.getInstance(fileName).openFileOutputStream(fileName, append);
- }
-
- /**
- * Change the length of the file.
- *
- * @param file the random access file
- * @param newLength the new length
- */
- public static void setLength(RandomAccessFile file, long newLength) throws IOException {
- try {
- IndexerPlugin.getLogger().trace(IndexerDebugOptions.ALL_IO, "FileUtils.setLength " + file);
- file.setLength(newLength);
- } catch (IOException e) {
- long length = file.length();
- if (newLength < length) {
- throw e;
- }
- long pos = file.getFilePointer();
- file.seek(length);
- long remaining = newLength - length;
- int maxSize = 1024 * 1024;
- int block = (int) Math.min(remaining, maxSize);
- byte[] buffer = new byte[block];
- while (remaining > 0) {
- int write = (int) Math.min(remaining, maxSize);
- file.write(buffer, 0, write);
- remaining -= write;
- }
- file.seek(pos);
- }
- }
-
- private FileUtils() {
- // utility class
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/IOUtils.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/IOUtils.java
deleted file mode 100644
index 3f56c46..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/IOUtils.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.Writer;
-
-public class IOUtils {
- /**
- * Close an input stream without throwing an exception.
- *
- * @param in the input stream or null
- */
- public static void closeSilently(InputStream in) {
- if (in != null) {
- try {
- in.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- /**
- * Close an output stream without throwing an exception.
- *
- * @param out the output stream or null
- */
- public static void closeSilently(OutputStream out) {
- if (out != null) {
- try {
- out.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- /**
- * Close a reader without throwing an exception.
- *
- * @param reader the reader or null
- */
- public static void closeSilently(Reader reader) {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- /**
- * Close a writer without throwing an exception.
- *
- * @param writer the writer or null
- */
- public static void closeSilently(Writer writer) {
- if (writer != null) {
- try {
- writer.flush();
- writer.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
-
- /**
- * Copy all data from the input stream to the output stream. Both streams are kept open.
- *
- * @param in the input stream
- * @param out the output stream
- * @return the number of bytes copied
- */
- public static long copy(InputStream in, OutputStream out) throws IOException {
- long written = 0;
- byte[] buffer = new byte[4 * 1024];
- while (true) {
- int len = in.read(buffer);
- if (len < 0) {
- break;
- }
- out.write(buffer, 0, len);
- written += len;
- }
- return written;
- }
-
- /**
- * Copy all data from the input stream to the output stream and close both streams. Exceptions
- * while closing are ignored.
- *
- * @param in the input stream
- * @param out the output stream
- * @return the number of bytes copied
- */
- public static long copyAndClose(InputStream in, OutputStream out) throws IOException {
- try {
- long len = copyAndCloseInput(in, out);
- out.close();
- return len;
- } finally {
- closeSilently(out);
- }
- }
-
- /**
- * Copy all data from the input stream to the output stream and close the input stream. Exceptions
- * while closing are ignored.
- *
- * @param in the input stream
- * @param out the output stream
- * @return the number of bytes copied
- */
- public static long copyAndCloseInput(InputStream in, OutputStream out) throws IOException {
- try {
- return copy(in, out);
- } finally {
- closeSilently(in);
- }
- }
-
- /**
- * Copy all data from the reader to the writer and close the reader. Exceptions while closing are
- * ignored.
- *
- * @param in the reader
- * @param out the writer
- * @return the number of characters copied
- */
- public static long copyAndCloseInput(Reader in, Writer out) throws IOException {
- long written = 0;
- try {
- char[] buffer = new char[4 * 1024];
- while (true) {
- int len = in.read(buffer);
- if (len < 0) {
- break;
- }
- out.write(buffer, 0, len);
- written += len;
- }
- } finally {
- in.close();
- }
- return written;
- }
-
- private IOUtils() {
- // utility class
- }
-}
diff --git a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/MathUtils.java b/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/MathUtils.java
deleted file mode 100644
index 1799061..0000000
--- a/dart/editor/attic/plugins/com.google.dart.indexer/src/com/google/dart/indexer/pagedstorage/util/MathUtils.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (c) 2011, the Dart project authors.
- *
- * Licensed under the Eclipse Public License v1.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.eclipse.org/legal/epl-v10.html
- *
- * 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.
- */
-package com.google.dart.indexer.pagedstorage.util;
-
-/**
- * This is a utility class with mathematical helper functions.
- */
-public class MathUtils {
- /**
- * Check if a value is a power of two.
- *
- * @param len the value to check
- * @throws RuntimeException if it is not a power of two
- */
- public static void checkPowerOf2(int len) {
- if ((len & (len - 1)) != 0 && len > 0) {
- throw new AssertionError("not a power of 2: " + len);
- }
- }
-
- /**
- * Get the value that is equal or higher than this value, and that is a power of two.
- *
- * @param x the original value
- * @return the next power of two value
- */
- public static int nextPowerOf2(int x) {
- long i = 1;
- while (i < x && i < (Integer.MAX_VALUE / 2)) {
- i += i;
- }
- return (int) i;
- }
-
- /**
- * Round the value up to the next block size. The block size must be a power of two. As an
- * example, using the block size of 8, the following rounding operations are done: 0 stays 0;
- * values 1..8 results in 8, 9..16 results in 16, and so on.
- *
- * @param x the value to be rounded
- * @param blockSizePowerOf2 the block size
- * @return the rounded value
- */
- public static int roundUp(int x, int blockSizePowerOf2) {
- return (x + blockSizePowerOf2 - 1) & (-blockSizePowerOf2);
- }
-
- /**
- * Round the value up to the next block size. The block size must be a power of two. As an
- * example, using the block size of 8, the following rounding operations are done: 0 stays 0;
- * values 1..8 results in 8, 9..16 results in 16, and so on.
- *
- * @param x the value to be rounded
- * @param blockSizePowerOf2 the block size
- *