org.jetbrains.kotlin.psi.KtFile Java Examples
The following examples show how to use
org.jetbrains.kotlin.psi.KtFile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: KotlinSyncStatusContributor.java From intellij with Apache License 2.0 | 6 votes |
@Nullable @Override public PsiFileAndName toPsiFileAndName(BlazeProjectData projectData, ProjectViewNode<?> node) { if (!projectData.getWorkspaceLanguageSettings().isLanguageActive(LanguageClass.KOTLIN)) { return null; } if (node instanceof KtFileTreeNode) { KtFile file = ((KtFileTreeNode) node).getKtFile(); return new PsiFileAndName(file, file.getName()); } if (node instanceof KtClassOrObjectTreeNode) { KtClassOrObject kt = ((KtClassOrObjectTreeNode) node).getValue(); return kt != null ? new PsiFileAndName(kt.getContainingKtFile(), kt.getName()) : null; } return null; }
Example #2
Source File: KotlinSdkAliasReader.java From jig with Apache License 2.0 | 5 votes |
@Override public TypeAliases readAlias(KotlinSources sources) { KotlinSourceVisitor visitor = new KotlinSourceVisitor(); for (KotlinSource kotlinSource : sources.list()) { KtFile ktFile = readKotlinSource(kotlinSource); if (ktFile == null) { continue; } ktFile.accept(visitor); } return new TypeAliases(visitor.typeJapaneseAliases, visitor.methodList); }
Example #3
Source File: KotlinSdkAliasReader.java From jig with Apache License 2.0 | 5 votes |
private KtFile sourceToKtFile(KotlinSource kotlinSource, String source) { CompilerConfiguration configuration = new CompilerConfiguration(); configuration.put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, MessageCollector.Companion.getNONE()); KotlinCoreEnvironment environment = KotlinCoreEnvironment.createForProduction(() -> { }, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES); Project project = environment.getProject(); LightVirtualFile virtualFile = new LightVirtualFile(kotlinSource.sourceFilePath().fineName(), KotlinFileType.INSTANCE, source); return (KtFile) PsiManager.getInstance(project).findFile(virtualFile); }
Example #4
Source File: KotlinSdkAliasReader.java From jig with Apache License 2.0 | 5 votes |
private KtFile readKotlinSource(KotlinSource source) { try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(source.toInputStream(), Charset.forName("utf8")))) { String sourceCode = bufferedReader.lines().collect(Collectors.joining("\n")); return sourceToKtFile(source, sourceCode); } catch (IOException e) { e.printStackTrace(); } return null; }
Example #5
Source File: LoggingFileProcessor.java From sputnik with Apache License 2.0 | 4 votes |
@Override public void onStart(List<? extends KtFile> list) { log.debug("Found {} files for review", list.size()); }
Example #6
Source File: LoggingFileProcessor.java From sputnik with Apache License 2.0 | 4 votes |
@Override public void onProcess(KtFile ktFile) { log.debug("Processing {}", ktFile.getName()); }
Example #7
Source File: LoggingFileProcessor.java From sputnik with Apache License 2.0 | 4 votes |
@Override public void onProcessComplete(KtFile ktFile, Map<String, ? extends List<? extends Finding>> map) { log.debug("Processed {} and found {} problems", ktFile.getName(), countProblems(map)); }
Example #8
Source File: LoggingFileProcessor.java From sputnik with Apache License 2.0 | 4 votes |
@Override public void onFinish(List<? extends KtFile> list, Detektion detektion) { log.debug("Processed {} files and found {} problems", list.size(), countProblems(detektion)); }