diff --git a/libraries/stdlib/js/src/org.w3c/org.khronos.webgl.kt b/libraries/stdlib/js/src/org.w3c/org.khronos.webgl.kt index 0227afccf74..adb9786c885 100644 --- a/libraries/stdlib/js/src/org.w3c/org.khronos.webgl.kt +++ b/libraries/stdlib/js/src/org.w3c/org.khronos.webgl.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.khronos.webgl diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.css.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.css.kt index 01d343d3578..44ea79442c1 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.css.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.css.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.dom.css diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.events.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.events.kt index 7aef44e7a45..6e69f5b4b8a 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.events.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.events.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.dom.events diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.kt index 6b57b7c1480..b62671d1432 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.dom diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.parsing.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.parsing.kt index f39e1f823b8..f0c3d7375c2 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.parsing.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.parsing.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.dom.parsing diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.svg.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.svg.kt index 4d3847948cd..75f9045f5ac 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.svg.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.svg.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.dom.svg diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.url.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.url.kt index d17496aa366..f460c774d60 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.dom.url.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.dom.url.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.dom.url diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.fetch.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.fetch.kt index cdb5aeee4c4..7a01e68b0b6 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.fetch.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.fetch.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.fetch diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.files.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.files.kt index bc8429b0966..2647be2622e 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.files.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.files.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.files diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.notifications.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.notifications.kt index 60c824b5c21..770bb7ced36 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.notifications.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.notifications.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.notifications diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.performance.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.performance.kt index 2102a713391..156ff0bd0b2 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.performance.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.performance.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.performance diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.workers.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.workers.kt index 601e728234e..0d743e8d6cf 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.workers.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.workers.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.workers diff --git a/libraries/stdlib/js/src/org.w3c/org.w3c.xhr.kt b/libraries/stdlib/js/src/org.w3c/org.w3c.xhr.kt index ec386a66b4c..165f0b79fc2 100644 --- a/libraries/stdlib/js/src/org.w3c/org.w3c.xhr.kt +++ b/libraries/stdlib/js/src/org.w3c/org.w3c.xhr.kt @@ -1,10 +1,11 @@ /* - * Generated file - * DO NOT EDIT - * - * See libraries/tools/idl2k for details + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. */ +// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT! +// See libraries/tools/idl2k for details + @file:Suppress("NESTED_CLASS_IN_EXTERNAL_INTERFACE") package org.w3c.xhr diff --git a/libraries/tools/idl2k/src/main/kotlin/copyright.kt b/libraries/tools/idl2k/src/main/kotlin/copyright.kt new file mode 100644 index 00000000000..1b0f8cf890f --- /dev/null +++ b/libraries/tools/idl2k/src/main/kotlin/copyright.kt @@ -0,0 +1,21 @@ +/* + * Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license + * that can be found in the license/LICENSE.txt file. + */ + +package org.jetbrains.idl2k.util + +import org.xml.sax.InputSource +import java.io.File +import javax.xml.xpath.XPathFactory + +fun readCopyrightNoticeFromProfile(copyrightProfile: File): String { + val template = copyrightProfile.reader().use { reader -> + XPathFactory.newInstance().newXPath().evaluate("/component/copyright/option[@name='notice']/@value", InputSource(reader)) + } + val yearTemplate = "$today.year" + val year = java.time.LocalDate.now().year.toString() + assert(yearTemplate in template) + + return template.replace(yearTemplate, year).lines().joinToString("", prefix = "/*\n", postfix = " */\n") { " * $it\n" } +} \ No newline at end of file diff --git a/libraries/tools/idl2k/src/main/kotlin/main.kt b/libraries/tools/idl2k/src/main/kotlin/main.kt index 9146eea24be..932b9025fb0 100644 --- a/libraries/tools/idl2k/src/main/kotlin/main.kt +++ b/libraries/tools/idl2k/src/main/kotlin/main.kt @@ -1,6 +1,7 @@ package org.jetbrains.idl2k import org.antlr.v4.runtime.ANTLRFileStream +import org.jetbrains.idl2k.util.readCopyrightNoticeFromProfile import java.io.* import java.net.* import java.util.* @@ -16,6 +17,8 @@ fun main(args: Array) { return } + val copyrightNotice = readCopyrightNoticeFromProfile(File("../../../.idea/copyright/apache.xml")) + val repositoryPre = srcDir.walkTopDown().filter { it.isDirectory || it.extension == "idl" }.asSequence().filter { it.isFile }.toList().sortedBy { it.absolutePath }.fold(Repository(emptyMap(), emptyMap(), emptyMap(), emptyMap())) { acc, e -> System.err.flush() System.err.println("Parsing ${e.absolutePath}") @@ -82,12 +85,10 @@ fun main(args: Array) { File(outDir, pkg + ".kt").bufferedWriter().use { w -> println("Generating for package $pkg...") - w.appendln("/*") - w.appendln(" * Generated file") - w.appendln(" * DO NOT EDIT") - w.appendln(" * ") - w.appendln(" * See libraries/tools/idl2k for details") - w.appendln(" */") + w.appendln(copyrightNotice) + + w.appendln("// NOTE: THIS FILE IS AUTO-GENERATED, DO NOT EDIT!") + w.appendln("// See libraries/tools/idl2k for details") w.appendln() w.appendln("@file:Suppress(\"NESTED_CLASS_IN_EXTERNAL_INTERFACE\")")