[JS] Extract sourcemap generating related files to a separate module
It's required to reuse the same infrastructure in the new backend.
This commit is contained in:
committed by
TeamCityServer
parent
a63c179227
commit
a908e5576d
@@ -252,6 +252,7 @@ extra["compilerModules"] = arrayOf(
|
|||||||
":compiler:incremental-compilation-impl",
|
":compiler:incremental-compilation-impl",
|
||||||
":compiler:compiler.version",
|
":compiler:compiler.version",
|
||||||
":js:js.ast",
|
":js:js.ast",
|
||||||
|
":js:js.sourcemap",
|
||||||
":js:js.serializer",
|
":js:js.serializer",
|
||||||
":js:js.parser",
|
":js:js.parser",
|
||||||
":js:js.config",
|
":js:js.config",
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ dependencies {
|
|||||||
compile(project(":js:js.translator"))
|
compile(project(":js:js.translator"))
|
||||||
compile(project(":js:js.serializer"))
|
compile(project(":js:js.serializer"))
|
||||||
compile(project(":js:js.dce"))
|
compile(project(":js:js.dce"))
|
||||||
|
compile(project(":js:js.sourcemap"))
|
||||||
|
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
|
|||||||
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
|
||||||
import org.jetbrains.kotlin.config.Services
|
import org.jetbrains.kotlin.config.Services
|
||||||
import org.jetbrains.kotlin.js.dce.*
|
import org.jetbrains.kotlin.js.dce.*
|
||||||
import org.jetbrains.kotlin.js.inline.util.RelativePathCalculator
|
import org.jetbrains.kotlin.js.sourceMap.RelativePathCalculator
|
||||||
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
||||||
import java.io.*
|
import java.io.*
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -9,7 +9,7 @@ package org.jetbrains.kotlin.cli.js.internal
|
|||||||
import com.google.gwt.dev.js.ThrowExceptionOnErrorReporter
|
import com.google.gwt.dev.js.ThrowExceptionOnErrorReporter
|
||||||
import org.jetbrains.kotlin.js.backend.JsToStringGenerationVisitor
|
import org.jetbrains.kotlin.js.backend.JsToStringGenerationVisitor
|
||||||
import org.jetbrains.kotlin.js.backend.ast.*
|
import org.jetbrains.kotlin.js.backend.ast.*
|
||||||
import org.jetbrains.kotlin.js.facade.SourceMapBuilderConsumer
|
import org.jetbrains.kotlin.js.sourceMap.SourceMapBuilderConsumer
|
||||||
import org.jetbrains.kotlin.js.inline.util.fixForwardNameReferences
|
import org.jetbrains.kotlin.js.inline.util.fixForwardNameReferences
|
||||||
import org.jetbrains.kotlin.js.parser.parse
|
import org.jetbrains.kotlin.js.parser.parse
|
||||||
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
||||||
@@ -17,7 +17,6 @@ import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
|||||||
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
||||||
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.StringReader
|
|
||||||
import kotlin.system.exitProcess
|
import kotlin.system.exitProcess
|
||||||
|
|
||||||
fun main(args: Array<String>) {
|
fun main(args: Array<String>) {
|
||||||
@@ -133,4 +132,4 @@ private fun collectFiles(rootFile: File, target: MutableList<File>) {
|
|||||||
} else if (rootFile.extension == "js") {
|
} else if (rootFile.extension == "js") {
|
||||||
target += rootFile
|
target += rootFile
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ dependencies {
|
|||||||
compile(project(":compiler:util"))
|
compile(project(":compiler:util"))
|
||||||
compile(project(":js:js.ast"))
|
compile(project(":js:js.ast"))
|
||||||
compile(project(":js:js.translator"))
|
compile(project(":js:js.translator"))
|
||||||
|
compileOnly(project(":js:js.sourcemap"))
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
compileOnly(intellijDep()) { includeJars("guava", rootProject = rootProject) }
|
compileOnly(intellijDep()) { includeJars("guava", rootProject = rootProject) }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.dce
|
package org.jetbrains.kotlin.js.dce
|
||||||
@@ -24,7 +13,7 @@ import org.jetbrains.kotlin.js.backend.ast.JsGlobalBlock
|
|||||||
import org.jetbrains.kotlin.js.backend.ast.JsNode
|
import org.jetbrains.kotlin.js.backend.ast.JsNode
|
||||||
import org.jetbrains.kotlin.js.backend.ast.JsProgram
|
import org.jetbrains.kotlin.js.backend.ast.JsProgram
|
||||||
import org.jetbrains.kotlin.js.dce.Context.Node
|
import org.jetbrains.kotlin.js.dce.Context.Node
|
||||||
import org.jetbrains.kotlin.js.facade.SourceMapBuilderConsumer
|
import org.jetbrains.kotlin.js.sourceMap.SourceMapBuilderConsumer
|
||||||
import org.jetbrains.kotlin.js.inline.util.collectDefinedNames
|
import org.jetbrains.kotlin.js.inline.util.collectDefinedNames
|
||||||
import org.jetbrains.kotlin.js.inline.util.fixForwardNameReferences
|
import org.jetbrains.kotlin.js.inline.util.fixForwardNameReferences
|
||||||
import org.jetbrains.kotlin.js.parser.parse
|
import org.jetbrains.kotlin.js.parser.parse
|
||||||
@@ -159,4 +148,4 @@ class DeadCodeElimination(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.inline
|
package org.jetbrains.kotlin.js.inline
|
||||||
@@ -29,6 +18,7 @@ import org.jetbrains.kotlin.js.inline.util.*
|
|||||||
import org.jetbrains.kotlin.js.parser.OffsetToSourceMapping
|
import org.jetbrains.kotlin.js.parser.OffsetToSourceMapping
|
||||||
import org.jetbrains.kotlin.js.parser.parseFunction
|
import org.jetbrains.kotlin.js.parser.parseFunction
|
||||||
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
import org.jetbrains.kotlin.js.parser.sourcemaps.*
|
||||||
|
import org.jetbrains.kotlin.js.sourceMap.RelativePathCalculator
|
||||||
import org.jetbrains.kotlin.js.translate.context.Namer
|
import org.jetbrains.kotlin.js.translate.context.Namer
|
||||||
import org.jetbrains.kotlin.js.translate.expression.InlineMetadata
|
import org.jetbrains.kotlin.js.translate.expression.InlineMetadata
|
||||||
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
import org.jetbrains.kotlin.js.translate.utils.JsAstUtils
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("jps-compatible")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compileOnly(project(":js:js.ast"))
|
||||||
|
compileOnly(project(":js:js.parser")) // TODO remove, required for JSON AST
|
||||||
|
compileOnly(project(":js:js.frontend")) // TODO remove
|
||||||
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
|
compileOnly(intellijDep()) { includeJars("trove4j") }
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets {
|
||||||
|
"main" { projectDefault() }
|
||||||
|
"test" {}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* 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.kotlin.js.sourceMap;
|
||||||
|
|
||||||
|
import com.intellij.openapi.editor.Document;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.PsiFile;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.kotlin.js.backend.ast.JsLocation;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public final class PsiUtils {
|
||||||
|
|
||||||
|
private PsiUtils() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JsLocation extractLocationFromPsi(@NotNull PsiElement element, @NotNull SourceFilePathResolver pathResolver)
|
||||||
|
throws IOException {
|
||||||
|
PsiFile psiFile = element.getContainingFile();
|
||||||
|
int offset = element.getNode().getStartOffset();
|
||||||
|
Document document = psiFile.getViewProvider().getDocument();
|
||||||
|
assert document != null;
|
||||||
|
int sourceLine = document.getLineNumber(offset);
|
||||||
|
int sourceColumn = offset - document.getLineStartOffset(sourceLine);
|
||||||
|
|
||||||
|
File file = new File(psiFile.getViewProvider().getVirtualFile().getPath());
|
||||||
|
return new JsLocation(pathResolver.getPathRelativeToSourceRoots(file), sourceLine, sourceColumn);
|
||||||
|
}
|
||||||
|
}
|
||||||
+4
-15
@@ -1,20 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.inline.util
|
package org.jetbrains.kotlin.js.sourceMap
|
||||||
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
@@ -38,4 +27,4 @@ class RelativePathCalculator(baseDir: File) {
|
|||||||
|
|
||||||
return sb.toString()
|
return sb.toString()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+2
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.sourceMap;
|
package org.jetbrains.kotlin.js.sourceMap;
|
||||||
@@ -21,7 +10,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.js.config.JSConfigurationKeys;
|
import org.jetbrains.kotlin.js.config.JSConfigurationKeys;
|
||||||
import org.jetbrains.kotlin.js.config.JsConfig;
|
import org.jetbrains.kotlin.js.config.JsConfig;
|
||||||
import org.jetbrains.kotlin.js.inline.util.RelativePathCalculator;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
+2
-13
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.sourceMap;
|
package org.jetbrains.kotlin.js.sourceMap;
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* 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.kotlin.js.sourceMap;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public interface SourceMapBuilder extends SourceMapMappingConsumer {
|
||||||
|
void skipLinesAtBeginning(int count);
|
||||||
|
|
||||||
|
void addLink();
|
||||||
|
|
||||||
|
File getOutFile();
|
||||||
|
|
||||||
|
String build();
|
||||||
|
}
|
||||||
+3
-17
@@ -1,20 +1,9 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.facade;
|
package org.jetbrains.kotlin.js.sourceMap;
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
import com.intellij.psi.PsiFile;
|
import com.intellij.psi.PsiFile;
|
||||||
@@ -23,9 +12,6 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.kotlin.js.backend.SourceLocationConsumer;
|
import org.jetbrains.kotlin.js.backend.SourceLocationConsumer;
|
||||||
import org.jetbrains.kotlin.js.backend.ast.JsLocation;
|
import org.jetbrains.kotlin.js.backend.ast.JsLocation;
|
||||||
import org.jetbrains.kotlin.js.backend.ast.JsLocationWithSource;
|
import org.jetbrains.kotlin.js.backend.ast.JsLocationWithSource;
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver;
|
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceMapMappingConsumer;
|
|
||||||
import org.jetbrains.kotlin.js.translate.utils.PsiUtils;
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
import org.jetbrains.kotlin.resolve.calls.callUtil.CallUtilKt;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* 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.kotlin.js.sourceMap;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.Reader;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public interface SourceMapMappingConsumer {
|
||||||
|
void newLine();
|
||||||
|
|
||||||
|
void addMapping(
|
||||||
|
@NotNull String source, @Nullable Object sourceIdentity, @NotNull Supplier<Reader> sourceSupplier,
|
||||||
|
int sourceLine, int sourceColumn
|
||||||
|
);
|
||||||
|
|
||||||
|
void addEmptyMapping();
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -41,6 +41,7 @@ import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapParser
|
|||||||
import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapSuccess
|
import org.jetbrains.kotlin.js.parser.sourcemaps.SourceMapSuccess
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
||||||
|
import org.jetbrains.kotlin.js.sourceMap.SourceMapBuilderConsumer
|
||||||
import org.jetbrains.kotlin.js.test.utils.*
|
import org.jetbrains.kotlin.js.test.utils.*
|
||||||
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
||||||
import org.jetbrains.kotlin.metadata.DebugProtoBuf
|
import org.jetbrains.kotlin.metadata.DebugProtoBuf
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ dependencies {
|
|||||||
compile(project(":js:js.ast"))
|
compile(project(":js:js.ast"))
|
||||||
compile(project(":js:js.frontend"))
|
compile(project(":js:js.frontend"))
|
||||||
compile(project(":js:js.parser"))
|
compile(project(":js:js.parser"))
|
||||||
|
compileOnly(project(":js:js.sourcemap"))
|
||||||
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
compileOnly(intellijCoreDep()) { includeJars("intellij-core") }
|
||||||
compileOnly(intellijDep()) { includeJars("trove4j", "guava", rootProject = rootProject) }
|
compileOnly(intellijDep()) { includeJars("trove4j", "guava", rootProject = rootProject) }
|
||||||
}
|
}
|
||||||
@@ -30,4 +31,4 @@ configure<IdeaModel> {
|
|||||||
module {
|
module {
|
||||||
excludeDirs = excludeDirs + files("testData/out", "testData/out-min")
|
excludeDirs = excludeDirs + files("testData/out", "testData/out-min")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.facade
|
package org.jetbrains.kotlin.js.facade
|
||||||
@@ -31,6 +20,7 @@ import org.jetbrains.kotlin.js.config.JsConfig
|
|||||||
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
|
import org.jetbrains.kotlin.js.config.SourceMapSourceEmbedding
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
import org.jetbrains.kotlin.js.sourceMap.SourceMap3Builder
|
||||||
|
import org.jetbrains.kotlin.js.sourceMap.SourceMapBuilderConsumer
|
||||||
import org.jetbrains.kotlin.js.util.TextOutput
|
import org.jetbrains.kotlin.js.util.TextOutput
|
||||||
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
import org.jetbrains.kotlin.js.util.TextOutputImpl
|
||||||
import org.jetbrains.kotlin.name.FqName
|
import org.jetbrains.kotlin.name.FqName
|
||||||
@@ -185,4 +175,4 @@ abstract class TranslationResult protected constructor(val diagnostics: Diagnost
|
|||||||
return SimpleOutputFileCollection(metadataFiles(outputFile))
|
return SimpleOutputFileCollection(metadataFiles(outputFile))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.sourceMap;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
public interface SourceMapBuilder extends SourceMapMappingConsumer {
|
|
||||||
void skipLinesAtBeginning(int count);
|
|
||||||
|
|
||||||
void addLink();
|
|
||||||
|
|
||||||
File getOutFile();
|
|
||||||
|
|
||||||
String build();
|
|
||||||
}
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.sourceMap;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.Reader;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public interface SourceMapMappingConsumer {
|
|
||||||
void newLine();
|
|
||||||
|
|
||||||
void addMapping(
|
|
||||||
@NotNull String source, @Nullable Object sourceIdentity, @NotNull Supplier<Reader> sourceSupplier,
|
|
||||||
int sourceLine, int sourceColumn
|
|
||||||
);
|
|
||||||
|
|
||||||
void addEmptyMapping();
|
|
||||||
}
|
|
||||||
+3
-14
@@ -1,17 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.translate.reference;
|
package org.jetbrains.kotlin.js.translate.reference;
|
||||||
@@ -29,9 +18,9 @@ import org.jetbrains.kotlin.js.inline.util.RewriteUtilsKt;
|
|||||||
import org.jetbrains.kotlin.js.parser.ParserUtilsKt;
|
import org.jetbrains.kotlin.js.parser.ParserUtilsKt;
|
||||||
import org.jetbrains.kotlin.js.resolve.BindingContextSlicesJsKt;
|
import org.jetbrains.kotlin.js.resolve.BindingContextSlicesJsKt;
|
||||||
import org.jetbrains.kotlin.js.resolve.diagnostics.JsCallChecker;
|
import org.jetbrains.kotlin.js.resolve.diagnostics.JsCallChecker;
|
||||||
|
import org.jetbrains.kotlin.js.sourceMap.PsiUtils;
|
||||||
import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator;
|
import org.jetbrains.kotlin.js.translate.callTranslator.CallTranslator;
|
||||||
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
import org.jetbrains.kotlin.js.translate.context.TranslationContext;
|
||||||
import org.jetbrains.kotlin.js.translate.utils.PsiUtils;
|
|
||||||
import org.jetbrains.kotlin.name.Name;
|
import org.jetbrains.kotlin.name.Name;
|
||||||
import org.jetbrains.kotlin.psi.KtCallExpression;
|
import org.jetbrains.kotlin.psi.KtCallExpression;
|
||||||
import org.jetbrains.kotlin.psi.KtExpression;
|
import org.jetbrains.kotlin.psi.KtExpression;
|
||||||
|
|||||||
@@ -1,38 +1,20 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2017 JetBrains s.r.o.
|
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
*
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.js.translate.utils;
|
package org.jetbrains.kotlin.js.translate.utils;
|
||||||
|
|
||||||
import com.intellij.openapi.editor.Document;
|
|
||||||
import com.intellij.psi.PsiElement;
|
|
||||||
import com.intellij.psi.PsiFile;
|
|
||||||
import com.intellij.psi.tree.IElementType;
|
import com.intellij.psi.tree.IElementType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
|
||||||
import org.jetbrains.kotlin.js.backend.ast.JsLocation;
|
|
||||||
import org.jetbrains.kotlin.js.sourceMap.SourceFilePathResolver;
|
|
||||||
import org.jetbrains.kotlin.lexer.KtToken;
|
import org.jetbrains.kotlin.lexer.KtToken;
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
import org.jetbrains.kotlin.psi.*;
|
import org.jetbrains.kotlin.psi.*;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -120,18 +102,4 @@ public final class PsiUtils {
|
|||||||
|
|
||||||
return resolvedCall.getCandidateDescriptor();
|
return resolvedCall.getCandidateDescriptor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
|
||||||
public static JsLocation extractLocationFromPsi(@NotNull PsiElement element, @NotNull SourceFilePathResolver pathResolver)
|
|
||||||
throws IOException {
|
|
||||||
PsiFile psiFile = element.getContainingFile();
|
|
||||||
int offset = element.getNode().getStartOffset();
|
|
||||||
Document document = psiFile.getViewProvider().getDocument();
|
|
||||||
assert document != null;
|
|
||||||
int sourceLine = document.getLineNumber(offset);
|
|
||||||
int sourceColumn = offset - document.getLineStartOffset(sourceLine);
|
|
||||||
|
|
||||||
File file = new File(psiFile.getViewProvider().getVirtualFile().getPath());
|
|
||||||
return new JsLocation(pathResolver.getPathRelativeToSourceRoots(file), sourceLine, sourceColumn);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ include ":benchmarks",
|
|||||||
":compiler:tests-for-compiler-generator",
|
":compiler:tests-for-compiler-generator",
|
||||||
":dukat",
|
":dukat",
|
||||||
":js:js.ast",
|
":js:js.ast",
|
||||||
|
":js:js.sourcemap",
|
||||||
":js:js.serializer",
|
":js:js.serializer",
|
||||||
":js:js.parser",
|
":js:js.parser",
|
||||||
":js:js.config",
|
":js:js.config",
|
||||||
|
|||||||
Reference in New Issue
Block a user