use of com.intellij.psi.PsiThrowStatement in project intellij-community by JetBrains.
the class ThrowsUsageTargetProvider method getTargets.
@Override
@Nullable
public UsageTarget[] getTargets(Editor editor, final PsiFile file) {
if (editor == null || file == null)
return null;
PsiElement element = file.findElementAt(TargetElementUtil.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset()));
if (element == null)
return null;
if (element instanceof PsiKeyword && PsiKeyword.THROWS.equals(element.getText())) {
return new UsageTarget[] { new PsiElement2UsageTargetAdapter(element) };
}
final PsiElement parent = element.getParent();
if (parent instanceof PsiThrowStatement) {
return new UsageTarget[] { new PsiElement2UsageTargetAdapter(parent) };
}
return null;
}
use of com.intellij.psi.PsiThrowStatement in project intellij-community by JetBrains.
the class MissingThrowExpressionFixer method apply.
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
if (psiElement instanceof PsiThrowStatement) {
PsiThrowStatement throwStatement = (PsiThrowStatement) psiElement;
if (throwStatement.getException() != null && startLine(editor, throwStatement) == startLine(editor, throwStatement.getException())) {
return;
}
final int startOffset = throwStatement.getTextRange().getStartOffset();
if (throwStatement.getException() != null) {
editor.getDocument().insertString(startOffset + "throw".length(), ";");
}
processor.registerUnresolvedError(startOffset + "throw".length());
}
}
Aggregations