use of org.jetbrains.kotlin.resolve.diagnostics.Diagnostics in project kotlin by JetBrains.
the class K2JSTranslator method translate.
@NotNull
public TranslationResult translate(@NotNull List<KtFile> files, @NotNull MainCallParameters mainCallParameters, @Nullable JsAnalysisResult analysisResult) throws TranslationException {
if (analysisResult == null) {
analysisResult = TopDownAnalyzerFacadeForJS.analyzeFiles(files, config);
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
}
BindingTrace bindingTrace = analysisResult.getBindingTrace();
TopDownAnalyzerFacadeForJS.checkForErrors(files, bindingTrace.getBindingContext());
ModuleDescriptor moduleDescriptor = analysisResult.getModuleDescriptor();
Diagnostics diagnostics = bindingTrace.getBindingContext().getDiagnostics();
TranslationContext context = Translation.generateAst(bindingTrace, files, mainCallParameters, moduleDescriptor, config);
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
if (hasError(diagnostics))
return new TranslationResult.Fail(diagnostics);
JsProgram program = JsInliner.process(context);
ResolveTemporaryNamesKt.resolveTemporaryNames(program);
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
if (hasError(diagnostics))
return new TranslationResult.Fail(diagnostics);
CoroutineTransformer coroutineTransformer = new CoroutineTransformer(program);
coroutineTransformer.accept(program);
RemoveUnusedImportsKt.removeUnusedImports(program);
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
if (hasError(diagnostics))
return new TranslationResult.Fail(diagnostics);
expandIsCalls(program, context);
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
List<String> importedModules = new ArrayList<String>();
for (StaticContext.ImportedModule module : context.getImportedModules()) {
importedModules.add(module.getExternalName());
}
return new TranslationResult.Success(config, files, program, diagnostics, importedModules, moduleDescriptor, bindingTrace.getBindingContext());
}
use of org.jetbrains.kotlin.resolve.diagnostics.Diagnostics in project kotlin by JetBrains.
the class DuplicateJvmSignatureAnnotator method annotate.
@Override
public void annotate(@NotNull PsiElement element, @NotNull AnnotationHolder holder) {
if (!(element instanceof KtFile) && !(element instanceof KtDeclaration))
return;
if (!ProjectRootsUtil.isInProjectSource(element))
return;
PsiFile file = element.getContainingFile();
if (!(file instanceof KtFile) || TargetPlatformDetector.getPlatform((KtFile) file) != JvmPlatform.INSTANCE)
return;
Diagnostics otherDiagnostics = ResolutionUtils.analyzeFully((KtElement) element).getDiagnostics();
GlobalSearchScope moduleScope = GetModuleInfoKt.getModuleInfo(element).contentScope();
Diagnostics diagnostics = DuplicateJvmSignatureUtilKt.getJvmSignatureDiagnostics(element, otherDiagnostics, moduleScope);
if (diagnostics == null)
return;
new KotlinPsiChecker().annotateElement(element, holder, diagnostics);
}
Aggregations