use of com.intellij.psi.PsiFile in project buck by facebook.
the class BuckAutoDepsContributor method getVirtualFileFromClassname.
@Nullable
public VirtualFile getVirtualFileFromClassname(String classname) {
GlobalSearchScope scope = GlobalSearchScope.allScope(mProject);
PsiClass psiClass = JavaPsiFacade.getInstance(mProject).findClass(classname, scope);
if (psiClass == null) {
return null;
}
PsiFile psiFile = psiClass.getContainingFile();
if (psiFile == null) {
return null;
}
return psiFile.getVirtualFile();
}
use of com.intellij.psi.PsiFile in project android-parcelable-intellij-plugin by mcharmas.
the class ParcelableAction method getPsiClassFromContext.
private PsiClass getPsiClassFromContext(AnActionEvent e) {
PsiFile psiFile = e.getData(LangDataKeys.PSI_FILE);
Editor editor = e.getData(PlatformDataKeys.EDITOR);
if (psiFile == null || editor == null) {
return null;
}
int offset = editor.getCaretModel().getOffset();
PsiElement element = psiFile.findElementAt(offset);
return PsiTreeUtil.getParentOfType(element, PsiClass.class);
}
use of com.intellij.psi.PsiFile in project freeline by alibaba.
the class FreelineUtil method checkInstall.
/**
* 检查是否需要载入Freeline
*
* @param project
* @return
*/
public static boolean checkInstall(@NotNull final Project project) {
final FreelineStatus status = getFreelineStatus(project);
if (GradleUtil.isSyncInProgress(project)) {
NotificationUtils.errorMsgDialog("Waiting for sync project to complete");
return false;
}
if (status.hasInitFreeline()) {
return true;
}
if (status.getGradleBuildFiles().size() < 1) {
NotificationUtils.errorMsgDialog("It's not an Android Gradle project Currently?");
return false;
}
if (status.isExistClasspath() && status.isExistPlugin() && !status.isExistFreelineCore()) {
NotificationUtils.errorNotification("Execute task initFreeline and download freeline dependencies...");
initFreeline(project);
return false;
}
if (DialogUtil.createDialog("Detected that you did not installFreeline Freeline, Whether installFreeline Automatically?", "Install Freeline Automatically", "Cancel")) {
Module[] modules = ModuleManager.getInstance(project).getModules();
List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
for (Module module : modules) {
GradleBuildFile file = GradleBuildFile.get(module);
if (file != null && !GradleUtil.isLibrary(file)) {
selectModulesList.add(Pair.create(module, file.getPsiFile()));
}
}
// 多个app模块的情况
if (selectModulesList.size() > 1) {
final DialogBuilder builder = new DialogBuilder();
builder.setTitle("Install Freeline");
builder.resizable(false);
builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the module to be installed Freeline.", Messages.getInformationIcon(), SwingConstants.CENTER));
builder.addOkAction().setText("Cancel");
for (final Pair<Module, PsiFile> pair : selectModulesList) {
builder.addAction(new AbstractAction(":" + pair.first.getName()) {
@Override
public void actionPerformed(ActionEvent e) {
builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
installFreeline(project, status, pair.getSecond());
}
});
}
if (builder.show() > -1) {
return false;
}
} else if (selectModulesList.size() == 1) {
installFreeline(project, status, selectModulesList.get(0).getSecond());
} else {
NotificationUtils.errorMsgDialog("Can not found Application Module! Please Sync Project.");
return false;
}
}
return false;
}
use of com.intellij.psi.PsiFile in project freeline by alibaba.
the class UsingReportAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent event) {
final Project project = event.getProject();
Module[] modules = ModuleManager.getInstance(project).getModules();
List<Pair<Module, PsiFile>> selectModulesList = new ArrayList<Pair<Module, PsiFile>>();
for (Module module : modules) {
GradleBuildFile file = GradleBuildFile.get(module);
if (file != null && !GradleUtil.isLibrary(file)) {
selectModulesList.add(Pair.create(module, file.getPsiFile()));
}
}
if (selectModulesList.size() > 1) {
final DialogBuilder builder = new DialogBuilder();
builder.setTitle("Freeline Reporter");
builder.resizable(false);
builder.setCenterPanel(new JLabel("There are multiple application modules, Please select the exact one.", Messages.getInformationIcon(), SwingConstants.CENTER));
builder.addOkAction().setText("Cancel");
for (final Pair<Module, PsiFile> pair : selectModulesList) {
builder.addAction(new AbstractAction(":" + pair.first.getName()) {
@Override
public void actionPerformed(ActionEvent e) {
builder.getDialogWrapper().close(DialogWrapper.CANCEL_EXIT_CODE);
report(project, pair.getSecond());
}
});
}
if (builder.show() > -1) {
//return false;
}
} else if (selectModulesList.size() == 1) {
report(project, selectModulesList.get(0).getSecond());
}
}
use of com.intellij.psi.PsiFile in project go-lang-idea-plugin by go-lang-plugin-org.
the class GoStubTest method doTest.
private void doTest(boolean checkErrors) throws IOException {
String fileName = getTestName(true) + ".go";
String text = FileUtil.loadFile(new File(getTestDataPath(), fileName));
PsiFile file = myFixture.addFileToProject(fileName, text);
String s = buildStubTreeText(getProject(), file.getVirtualFile(), text, checkErrors);
ParsingTestCase.doCheckResult(getTestDataPath(), getTestName(true) + ".txt", s);
}
Aggregations