use of com.intellij.openapi.vfs.VirtualFile in project freeline by alibaba.
the class FreelineUtil method installFreeline.
private static void installFreeline(final Project project, final FreelineStatus status, final PsiFile psiFile, final GradleDependencyEntity dependencyEntity) {
needReformatCode = false;
CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
@Override
public void run() {
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
if (!status.isExistClasspath()) {
Collection<VirtualFile> collection = status.getGradleBuildFiles();
if (dependencyEntity != null) {
for (VirtualFile file : collection) {
GradleBuildModel model = GradleBuildModel.parseBuildFile(file, project);
List<ArtifactDependencyModel> artifactDependencyModels = model.buildscript().dependencies().artifacts();
for (ArtifactDependencyModel model1 : artifactDependencyModels) {
ArtifactDependencyModelWrapper wrapper = new ArtifactDependencyModelWrapper(model1);
if (wrapper.group().equals(Constant.ANDROID_GRADLE_TOOL_GROUP_NAME)) {
ArtifactDependencySpec spec = new ArtifactDependencySpec(dependencyEntity.getArtifactId(), dependencyEntity.getGroupId(), dependencyEntity.getNewestReleaseVersion());
model.buildscript().dependencies().addArtifact("classpath", spec);
model.applyChanges();
needReformatCode = true;
status.setClasspathFile(file);
break;
}
}
if (status.isExistClasspath()) {
break;
}
}
}
}
if (!status.isExistPlugin()) {
if (psiFile != null && psiFile instanceof GroovyFile) {
GradleUtil.applyPlugin(project, (GroovyFile) psiFile, Constant.FREELINE_PLUGIN_ID);
}
}
}
});
}
});
if (needReformatCode && status.getClasspathFile() != null) {
DocumentUtil.reformatCode(project, status.getClasspathFile());
}
LogUtil.d("Sync Project Finish, start download freeline.zip.");
initFreeline(project);
}
use of com.intellij.openapi.vfs.VirtualFile in project plugins by kiteco.
the class KiteProjectComponent method sendEvent.
// -----sendEvent-----
private void sendEvent(String action, Editor editor) {
try {
if (editor == null) {
return;
}
VirtualFile file = FileDocumentManager.getInstance().getFile(editor.getDocument());
if (file == null) {
log(" -> null file, skipping event");
return;
}
if (!file.isInLocalFileSystem()) {
log(" -> non-local file, skipping event");
return;
}
m_kiteConnection.sendEvent(action, file.getCanonicalPath(), editor.getDocument().getText(), editor.getSelectionModel().getSelectionStart(), editor.getSelectionModel().getSelectionEnd());
} catch (Exception e) {
logException("Exception sending event", e);
}
}
use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoPathLibraryTest method testExcludeChildContentRootFromLibrary.
/**
* src <content root>
* goPath <gopath>
* - src
* -- contentRoot <content root>
* -- notContentRoot
*/
public void testExcludeChildContentRootFromLibrary() throws IOException {
VirtualFile goPath = createGoPath();
VirtualFile src = goPath.createChildDirectory(this, "src");
VirtualFile contentRoot = src.createChildDirectory(this, "contentRoot");
VirtualFile notContentRoot = src.createChildDirectory(this, "notContentRoot");
addContentRoot(contentRoot);
GoApplicationLibrariesService.getInstance().setLibraryRootUrls(goPath.getUrl());
assertLibrary(Collections.singletonList(notContentRoot.getUrl()), "temp:///src", contentRoot.getUrl());
}
use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoRunConfigurationTestCase method doTestProducedConfigurations.
protected void doTestProducedConfigurations() {
VirtualFile file = myFixture.copyFileToProject(getTestName(true) + ".go", "import/path/" + getTestName(true) + ".go");
myFixture.configureFromExistingVirtualFile(file);
doTestProducedConfigurations(myFixture.getFile().findElementAt(myFixture.getCaretOffset()));
}
use of com.intellij.openapi.vfs.VirtualFile in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoPathLibraryTest method testAddGoPathAsLibrary.
/**
* src <content root>
* goPath <gopath>
* - src
* -- test
*/
public void testAddGoPathAsLibrary() throws IOException {
VirtualFile goPath = createGoPath();
VirtualFile goPathContent = goPath.createChildDirectory(this, "src").createChildDirectory(this, "test");
GoApplicationLibrariesService.getInstance().setLibraryRootUrls(goPath.getUrl());
assertLibrary(Collections.singletonList(goPathContent.getUrl()), "temp:///src");
}
Aggregations