use of com.intellij.psi.PsiElementFactory in project intellij-community by JetBrains.
the class CompoundTypeRenderer method getChildValueExpression.
protected final PsiElement getChildValueExpression(String text, DebuggerTreeNode node, DebuggerContext context) {
Project project = node.getProject();
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
return elementFactory.createExpressionFromText(text, getContext(project, context));
}
use of com.intellij.psi.PsiElementFactory in project intellij-community by JetBrains.
the class ArrayRenderer method getChildValueExpression.
public PsiExpression getChildValueExpression(DebuggerTreeNode node, DebuggerContext context) {
LOG.assertTrue(node.getDescriptor() instanceof ArrayElementDescriptorImpl, node.getDescriptor().getClass().getName());
ArrayElementDescriptorImpl descriptor = (ArrayElementDescriptorImpl) node.getDescriptor();
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(node.getProject()).getElementFactory();
try {
LanguageLevel languageLevel = LanguageLevelProjectExtension.getInstance(node.getProject()).getLanguageLevel();
return elementFactory.createExpressionFromText("this[" + descriptor.getIndex() + "]", elementFactory.getArrayClass(languageLevel));
} catch (IncorrectOperationException e) {
LOG.error(e);
return null;
}
}
use of com.intellij.psi.PsiElementFactory in project intellij-community by JetBrains.
the class ClassRenderer method getChildValueExpression.
@Override
public PsiElement getChildValueExpression(DebuggerTreeNode node, DebuggerContext context) throws EvaluateException {
FieldDescriptor fieldDescriptor = (FieldDescriptor) node.getDescriptor();
PsiElementFactory elementFactory = JavaPsiFacade.getInstance(node.getProject()).getElementFactory();
try {
return elementFactory.createExpressionFromText("this." + fieldDescriptor.getField().name(), DebuggerUtils.findClass(fieldDescriptor.getObject().referenceType().name(), context.getProject(), context.getDebugProcess().getSearchScope()));
} catch (IncorrectOperationException e) {
throw new EvaluateException(DebuggerBundle.message("error.invalid.field.name", fieldDescriptor.getField().name()), null);
}
}
use of com.intellij.psi.PsiElementFactory in project intellij-community by JetBrains.
the class PsiUtilTest method createClass.
private static PsiClass createClass(String text) throws IncorrectOperationException {
final PsiElementFactory factory = JavaPsiFacade.getInstance(ourProject).getElementFactory();
final PsiClass classA = factory.createClassFromText(text, null).getInnerClasses()[0];
return classA;
}
use of com.intellij.psi.PsiElementFactory in project intellij-community by JetBrains.
the class ChangeToEndOfLineCommentIntention method processIntention.
@Override
public void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
final PsiComment comment = (PsiComment) element;
final JavaPsiFacade manager = JavaPsiFacade.getInstance(comment.getProject());
final PsiElement parent = comment.getParent();
assert parent != null;
final PsiElementFactory factory = manager.getElementFactory();
final String commentText = comment.getText();
final PsiElement whitespace = comment.getNextSibling();
final String text = commentText.substring(2, commentText.length() - 2);
final String[] lines = text.split("\n");
for (int i = lines.length - 1; i >= 1; i--) {
final PsiComment nextComment = factory.createCommentFromText("//" + lines[i].trim() + '\n', parent);
parent.addAfter(nextComment, comment);
/* if (whitespace != null) {
final PsiElement newWhiteSpace =
factory.createWhiteSpaceFromText(whitespace.getText());
parent.addAfter(newWhiteSpace, comment);
} */
}
final PsiComment newComment = factory.createCommentFromText("//" + lines[0], parent);
comment.replace(newComment);
}
Aggregations