@NotNull @Override public PsiJavaCodeReferenceElement createReferenceElementByFQClassName( @NotNull final String qName, @NotNull final GlobalSearchScope resolveScope) { final String shortName = PsiNameHelper.getShortClassName(qName); return new LightClassReference(myManager, shortName, qName, resolveScope); }
@NotNull @Override public PsiKeyword createKeyword(@NotNull final String text) throws IncorrectOperationException { if (!PsiNameHelper.getInstance(myManager.getProject()).isKeyword(text)) { throw new IncorrectOperationException("\"" + text + "\" is not a keyword."); } return new LightKeyword(myManager, text); }
@NotNull @Override public PsiImportStatement createImportStatementOnDemand(@NotNull final String packageName) throws IncorrectOperationException { if (packageName.isEmpty()) { throw new IncorrectOperationException("Cannot create import statement for default package."); } if (!PsiNameHelper.getInstance(myManager.getProject()).isQualifiedName(packageName)) { throw new IncorrectOperationException("Incorrect package name: \"" + packageName + "\"."); } final PsiJavaFile aFile = createDummyJavaFile("import " + packageName + ".*;"); final PsiImportStatementBase statement = extractImport(aFile, false); return (PsiImportStatement) CodeStyleManager.getInstance(myManager.getProject()).reformat(statement); }
private boolean isIdentifier(@NotNull String name) { return PsiNameHelper.getInstance(myManager.getProject()).isIdentifier(name); }