@Test public void getMethodTemplate() { ApplicationManager.getApplication() .invokeAndWait( () -> { final Project project = testHelper.getFixture().getProject(); final PsiMethod onAttached = ServiceManager.getService(project, TemplateService.class) .getMethodTemplate("OnAttached", project); assertThat(onAttached).isNotNull(); }); }
@Nullable public PsiMethod getMethodTemplate(String targetName, Project project) { final PsiMethod savedTemplate = templates.get(targetName); if (savedTemplate != null) return savedTemplate; final PsiMethod template = readMethodTemplate(targetName, project); if (template != null) { templates.putIfAbsent(targetName, template); } return template; }
TemplateService implements Disposable { @Nullable public PsiMethod getMethodTemplate(String targetName, Project project) { final PsiMethod savedTemplate = templates.get(targetName); if (savedTemplate != null) return savedTemplate; final PsiMethod template = readMethodTemplate(targetName, project); if (template != null) { templates.putIfAbsent(targetName, template); } return template; } }
TemplateService implements Disposable { @Nullable public PsiMethod getMethodTemplate(String targetName, Project project) { final PsiMethod savedTemplate = templates.get(targetName); if (savedTemplate != null) return savedTemplate; final PsiMethod template = readMethodTemplate(targetName, project); if (template != null) { templates.putIfAbsent(targetName, template); } return template; }  }
TemplateService implements Disposable { @Nullable public PsiMethod getMethodTemplate(String targetName, Project project) { final PsiMethod savedTemplate = templates.get(targetName); if (savedTemplate != null) return savedTemplate; final PsiMethod template = readMethodTemplate(targetName, project); if (template != null) { templates.putIfAbsent(targetName, template); } return template; }  @Nullable PsiMethod getMethodTemplate(String targetName, Project project); @Override void dispose(); }
TemplateService implements Disposable { @Nullable public PsiMethod getMethodTemplate(String targetName, Project project) { final PsiMethod savedTemplate = templates.get(targetName); if (savedTemplate != null) return savedTemplate; final PsiMethod template = readMethodTemplate(targetName, project); if (template != null) { templates.putIfAbsent(targetName, template); } return template; }  @Nullable PsiMethod getMethodTemplate(String targetName, Project project); @Override void dispose();  }