use of org.jetbrains.annotations.Nullable in project intellij-plugins by StepicOrg.
the class NavBarModelExtensionUtils method getPresentableText.
@Nullable
public static String getPresentableText(@Nullable final Object object) {
if (object instanceof Project) {
Project project = (Project) object;
StudyNode root = StepikProjectManager.getProjectRoot(project);
if (root == null) {
return null;
}
return root.getName();
}
if (object instanceof PsiDirectory) {
PsiDirectory psiDirectory = (PsiDirectory) object;
PresentationData data = new PresentationData();
updatePresentationData(data, psiDirectory);
String text = data.getPresentableText();
if (text != null)
return text;
}
return null;
}
use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.
the class GroovyHotSwapper method handleSpacesInPath.
@Nullable
private static String handleSpacesInPath(String agentPath) {
if (agentPath.contains(" ")) {
final File dir = new File(PathManager.getSystemPath(), "groovyHotSwap");
if (dir.getAbsolutePath().contains(" ")) {
LOG.info("Groovy hot-swap not used since the agent path contains spaces: " + agentPath + "\n" + "One can move the agent to a directory with no spaces in path," + " and specify its path in <IDEA dist>/bin/idea.properties as " + GROOVY_HOTSWAP_AGENT_PATH + "=<path>");
return null;
}
final File toFile = new File(dir, "gragent.jar");
try {
FileUtil.copy(new File(agentPath), toFile);
return toFile.getPath();
} catch (IOException e) {
LOG.info(e);
}
}
return agentPath;
}
use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.
the class GroovyPositionManager method findReferenceTypeSourceImage.
@Nullable
private static GroovyPsiElement findReferenceTypeSourceImage(SourcePosition position) {
PsiFile file = position.getFile();
if (!(file instanceof GroovyFileBase))
return null;
PsiElement element = file.findElementAt(position.getOffset());
if (element == null)
return null;
return PsiTreeUtil.getParentOfType(element, GrClosableBlock.class, GrTypeDefinition.class);
}
use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.
the class GroovyGenerateMethodMissingHandler method genMethod.
@Nullable
private static GrMethod genMethod(PsiClass aClass, FileTemplate template) {
Properties properties = FileTemplateManager.getInstance(aClass.getProject()).getDefaultProperties();
properties.setProperty(FileTemplate.ATTRIBUTE_RETURN_TYPE, "java.lang.Object");
properties.setProperty(FileTemplate.ATTRIBUTE_DEFAULT_RETURN_VALUE, "null");
properties.setProperty(FileTemplate.ATTRIBUTE_CALL_SUPER, "");
String fqn = aClass.getQualifiedName();
if (fqn != null)
properties.setProperty(FileTemplate.ATTRIBUTE_CLASS_NAME, fqn);
String className = aClass.getName();
if (className != null)
properties.setProperty(FileTemplate.ATTRIBUTE_SIMPLE_CLASS_NAME, className);
properties.setProperty(FileTemplate.ATTRIBUTE_METHOD_NAME, "methodMissing");
String bodyText;
try {
bodyText = StringUtil.replace(template.getText(properties), ";", "");
} catch (IOException e) {
return null;
}
return GroovyPsiElementFactory.getInstance(aClass.getProject()).createMethodFromText("def methodMissing(String name, def args) {\n" + bodyText + "\n}");
}
use of org.jetbrains.annotations.Nullable in project intellij-community by JetBrains.
the class GroovyGeneratePropertyMissingHandler method chooseOriginalMembers.
@Nullable
@Override
protected ClassMember[] chooseOriginalMembers(PsiClass aClass, Project project) {
final PsiMethod[] missings = aClass.findMethodsByName("propertyMissing", true);
PsiMethod getter = null;
PsiMethod setter = null;
for (PsiMethod missing : missings) {
final PsiParameter[] parameters = missing.getParameterList().getParameters();
if (parameters.length == 1) {
if (isNameParam(parameters[0])) {
getter = missing;
}
} else if (parameters.length == 2) {
if (isNameParam(parameters[0])) {
setter = missing;
}
}
}
if (setter != null && getter != null) {
String text = GroovyCodeInsightBundle.message("generate.property.missing.already.defined.warning");
if (Messages.showYesNoDialog(project, text, GroovyCodeInsightBundle.message("generate.property.missing.already.defined.title"), Messages.getQuestionIcon()) == Messages.YES) {
final PsiMethod finalGetter = getter;
final PsiMethod finalSetter = setter;
if (!ApplicationManager.getApplication().runWriteAction(new Computable<Boolean>() {
@Override
public Boolean compute() {
try {
finalSetter.delete();
finalGetter.delete();
return Boolean.TRUE;
} catch (IncorrectOperationException e) {
LOG.error(e);
return Boolean.FALSE;
}
}
}).booleanValue()) {
return null;
}
} else {
return null;
}
}
return new ClassMember[1];
}
Aggregations