# HG changeset patch # User wenzelm # Date 1503230603 -7200 # Node ID 9098c36abd1a3728856f7992f9b3cef6f320e85b # Parent 158c513a39f5ae9bc914506c3f8da420d9d93f6e separate base plugin for important services that should be always available, despite startup errors of the main plugin; diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/lib/Tools/jedit --- a/src/Tools/jEdit/lib/Tools/jedit Fri Aug 18 22:55:54 2017 +0200 +++ b/src/Tools/jEdit/lib/Tools/jedit Sun Aug 20 14:03:23 2017 +0200 @@ -19,6 +19,16 @@ ## sources +declare -a SOURCES_BASE=( + "src-base/isabelle_encoding.scala" + "src-base/plugin.scala" +) + +declare -a RESOURCES_BASE=( + "src-base/Isabelle_Base.props" + "src-base/services.xml" +) + declare -a SOURCES=( "src/active.scala" "src/completion_popup.scala" @@ -248,6 +258,7 @@ # target +TARGET_BASE="dist/jars/Isabelle-jEdit-base.jar" TARGET="dist/jars/Isabelle-jEdit.jar" declare -a UPDATED=() @@ -256,23 +267,28 @@ OUTDATED=true else OUTDATED=false - if [ ! -e "$TARGET" ]; then + if [ ! -e "$TARGET_BASE" -a ! -e "$TARGET" ]; then OUTDATED=true else if [ -n "$ISABELLE_JEDIT_BUILD_HOME" ]; then declare -a DEPS=( "$JEDIT_JAR" "${JEDIT_JARS[@]}" "$PURE_JAR" + "${SOURCES_BASE[@]}" "${RESOURCES_BASE[@]}" "${SOURCES[@]}" "${RESOURCES[@]}" ) elif [ -e "$ISABELLE_HOME/Admin/build" ]; then - declare -a DEPS=("$PURE_JAR" "${SOURCES[@]}" "${RESOURCES[@]}") + declare -a DEPS=( + "$PURE_JAR" + "${SOURCES_BASE[@]}" "${RESOURCES_BASE[@]}" + "${SOURCES[@]}" "${RESOURCES[@]}" + ) else declare -a DEPS=() fi for DEP in "${DEPS[@]}" do [ ! -e "$DEP" ] && fail "Missing file: $DEP" - [ "$DEP" -nt "$TARGET" ] && { + [ "$DEP" -nt "$TARGET_BASE" -o "$DEP" -nt "$TARGET" ] && { OUTDATED=true UPDATED["${#UPDATED[@]}"]="$DEP" } @@ -283,6 +299,37 @@ # build +function init_resources () +{ + mkdir -p dist/classes || failed + cp -p -R -f "$@" dist/classes/. +} + +function compile_sources () +{ + ( + #FIXME workarounds for scalac 2.11.0 + export CYGWIN="nodosfilewarning" + function stty() { :; } + export -f stty + + for JAR in "$JEDIT_JAR" "${JEDIT_JARS[@]}" "$PURE_JAR" + do + classpath "$JAR" + done + export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")" + isabelle_scala scalac $ISABELLE_SCALAC_OPTIONS -d dist/classes "$@" + ) || fail "Failed to compile sources" +} + +function make_jar () +{ + cd dist/classes + isabelle_jdk jar cf "../../$1" * || failed + cd ../.. + rm -rf dist/classes +} + if [ "$OUTDATED" = true ] then echo "### Building Isabelle/jEdit ..." @@ -299,10 +346,15 @@ fail "Unknown ISABELLE_JEDIT_BUILD_HOME -- missing auxiliary component" rm -rf dist || failed - mkdir -p dist dist/classes || failed + mkdir -p dist || failed cp -p -R -f "$ISABELLE_JEDIT_BUILD_HOME/contrib/$ISABELLE_JEDIT_BUILD_VERSION/." dist/. - cp -p -R -f "${RESOURCES[@]}" dist/classes/. + + init_resources "${RESOURCES_BASE[@]}" + compile_sources "${SOURCES_BASE[@]}" + make_jar "$TARGET_BASE" + + init_resources "${RESOURCES[@]}" cp src/jEdit.props dist/properties/. cp -p -R -f src/modes/. dist/modes/. @@ -334,24 +386,8 @@ cd .. cp -p -R -f "${JEDIT_JARS[@]}" dist/jars/. || failed - ( - #FIXME workarounds for scalac 2.11.0 - export CYGWIN="nodosfilewarning" - function stty() { :; } - export -f stty - - for JAR in "$JEDIT_JAR" "${JEDIT_JARS[@]}" "$PURE_JAR" - do - classpath "$JAR" - done - export CLASSPATH="$(platform_path "$ISABELLE_CLASSPATH")" - isabelle_scala scalac $ISABELLE_SCALAC_OPTIONS -d dist/classes "${SOURCES[@]}" - ) || fail "Failed to compile sources" - - cd dist/classes - isabelle_jdk jar cf "../jars/Isabelle-jEdit.jar" * || failed - cd ../.. - rm -rf dist/classes + compile_sources "${SOURCES[@]}" + make_jar "$TARGET" cp "$ISABELLE_JEDIT_BUILD_HOME/doc/jedit5.4.0manual-a4.pdf" dist/doc/jedit-manual.pdf cp dist/doc/CHANGES.txt dist/doc/jedit-changes diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/src-base/isabelle_encoding.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Tools/jEdit/src-base/isabelle_encoding.scala Sun Aug 20 14:03:23 2017 +0200 @@ -0,0 +1,54 @@ +/* Title: Tools/jEdit/src-base/isabelle_encoding.scala + Author: Makarius + +Isabelle encoding -- based on UTF-8. +*/ + +package isabelle.jedit_base + + +import isabelle._ + +import org.gjt.sp.jedit.io.Encoding + +import java.nio.charset.{Charset, CodingErrorAction} +import java.io.{InputStream, OutputStream, Reader, Writer, InputStreamReader, OutputStreamWriter, + CharArrayReader, ByteArrayOutputStream} + +import scala.io.{Codec, BufferedSource} + + +class Isabelle_Encoding extends Encoding +{ + private val BUFSIZE = 32768 + + private def text_reader(in: InputStream, codec: Codec): Reader = + { + val source = new BufferedSource(in)(codec) + new CharArrayReader(Symbol.decode(source.mkString).toArray) + } + + override def getTextReader(in: InputStream): Reader = text_reader(in, UTF8.codec()) + + override def getPermissiveTextReader(in: InputStream): Reader = + { + val codec = UTF8.codec() + codec.onMalformedInput(CodingErrorAction.REPLACE) + codec.onUnmappableCharacter(CodingErrorAction.REPLACE) + text_reader(in, codec) + } + + override def getTextWriter(out: OutputStream): Writer = + { + val buffer = new ByteArrayOutputStream(BUFSIZE) { + override def flush() + { + val text = Symbol.encode(toString(UTF8.charset_name)) + out.write(UTF8.bytes(text)) + out.flush() + } + override def close() { out.close() } + } + new OutputStreamWriter(buffer, UTF8.charset.newEncoder()) + } +} diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/src-base/plugin.scala --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Tools/jEdit/src-base/plugin.scala Sun Aug 20 14:03:23 2017 +0200 @@ -0,0 +1,21 @@ +/* Title: Tools/jEdit/src-base/plugin.scala + Author: Makarius + +Isabelle base environment for jEdit. +*/ + +package isabelle.jedit_base + + +import isabelle._ + +import org.gjt.sp.jedit.EBPlugin + + +class Plugin extends EBPlugin +{ + override def start() + { + Isabelle_System.init() + } +} diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/src-base/services.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/Tools/jEdit/src-base/services.xml Sun Aug 20 14:03:23 2017 +0200 @@ -0,0 +1,8 @@ + + + + + + new isabelle.jedit_base.Isabelle_Encoding(); + + diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/src/Isabelle.props --- a/src/Tools/jEdit/src/Isabelle.props Fri Aug 18 22:55:54 2017 +0200 +++ b/src/Tools/jEdit/src/Isabelle.props Sun Aug 20 14:03:23 2017 +0200 @@ -18,6 +18,7 @@ plugin.isabelle.jedit.Plugin.depend.2=plugin console.ConsolePlugin 5.1.4 plugin.isabelle.jedit.Plugin.depend.3=plugin errorlist.ErrorListPlugin 2.3 plugin.isabelle.jedit.Plugin.depend.4=plugin sidekick.SideKickPlugin 1.8 +plugin.isabelle.jedit.Plugin.depend.5=plugin isabelle.jedit_base.Plugin 1.0 #options plugin.isabelle.jedit.Plugin.option-group=isabelle-general isabelle-rendering diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/src/isabelle_encoding.scala --- a/src/Tools/jEdit/src/isabelle_encoding.scala Fri Aug 18 22:55:54 2017 +0200 +++ b/src/Tools/jEdit/src/isabelle_encoding.scala Sun Aug 20 14:03:23 2017 +0200 @@ -9,58 +9,14 @@ import isabelle._ -import org.gjt.sp.jedit.io.Encoding import org.gjt.sp.jedit.buffer.JEditBuffer -import java.nio.charset.{Charset, CodingErrorAction} -import java.io.{InputStream, OutputStream, Reader, Writer, InputStreamReader, OutputStreamWriter, - CharArrayReader, ByteArrayOutputStream} - -import scala.io.{Codec, BufferedSource} - object Isabelle_Encoding { - val NAME = "UTF-8-Isabelle" - def is_active(buffer: JEditBuffer): Boolean = - buffer.getStringProperty(JEditBuffer.ENCODING).asInstanceOf[String] == NAME + buffer.getStringProperty(JEditBuffer.ENCODING).asInstanceOf[String] == "UTF-8-Isabelle" def maybe_decode(buffer: JEditBuffer, s: String): String = if (is_active(buffer)) Symbol.decode(s) else s } - -class Isabelle_Encoding extends Encoding -{ - private val BUFSIZE = 32768 - - private def text_reader(in: InputStream, codec: Codec): Reader = - { - val source = new BufferedSource(in)(codec) - new CharArrayReader(Symbol.decode(source.mkString).toArray) - } - - override def getTextReader(in: InputStream): Reader = text_reader(in, UTF8.codec()) - - override def getPermissiveTextReader(in: InputStream): Reader = - { - val codec = UTF8.codec() - codec.onMalformedInput(CodingErrorAction.REPLACE) - codec.onUnmappableCharacter(CodingErrorAction.REPLACE) - text_reader(in, codec) - } - - override def getTextWriter(out: OutputStream): Writer = - { - val buffer = new ByteArrayOutputStream(BUFSIZE) { - override def flush() - { - val text = Symbol.encode(toString(UTF8.charset_name)) - out.write(UTF8.bytes(text)) - out.flush() - } - override def close() { out.close() } - } - new OutputStreamWriter(buffer, UTF8.charset.newEncoder()) - } -} diff -r 158c513a39f5 -r 9098c36abd1a src/Tools/jEdit/src/services.xml --- a/src/Tools/jEdit/src/services.xml Fri Aug 18 22:55:54 2017 +0200 +++ b/src/Tools/jEdit/src/services.xml Sun Aug 20 14:03:23 2017 +0200 @@ -11,9 +11,6 @@ new isabelle.jedit.PIDE_Docking_Framework(); - - new isabelle.jedit.Isabelle_Encoding(); - new isabelle.jedit.Isabelle_Sidekick_Default();