summaryrefslogtreecommitdiff
path: root/python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java
diff options
context:
space:
mode:
Diffstat (limited to 'python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java')
-rw-r--r--python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java24
1 files changed, 10 insertions, 14 deletions
diff --git a/python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java b/python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java
index d0bc9dcbc7ca..27522d6e7f53 100644
--- a/python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java
+++ b/python/src/com/jetbrains/python/codeInsight/highlighting/PyHighlightExitPointsHandlerFactory.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2000-2013 JetBrains s.r.o.
+ * Copyright 2000-2014 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,30 +15,26 @@
*/
package com.jetbrains.python.codeInsight.highlighting;
-import com.intellij.codeInsight.TargetElementUtilBase;
import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerBase;
-import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerFactory;
+import com.intellij.codeInsight.highlighting.HighlightUsagesHandlerFactoryBase;
import com.intellij.openapi.editor.Editor;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import com.intellij.psi.util.PsiTreeUtil;
import com.jetbrains.python.psi.PyExpression;
import com.jetbrains.python.psi.PyReturnStatement;
+import org.jetbrains.annotations.NotNull;
/**
* @author oleg
*/
-public class PyHighlightExitPointsHandlerFactory implements HighlightUsagesHandlerFactory {
- public HighlightUsagesHandlerBase createHighlightUsagesHandler(final Editor editor, final PsiFile file) {
- int offset = TargetElementUtilBase.adjustOffset(file, editor.getDocument(), editor.getCaretModel().getOffset());
- PsiElement target = file.findElementAt(offset);
- if (target != null) {
- final PyReturnStatement returnStatement = PsiTreeUtil.getParentOfType(target, PyReturnStatement.class);
- if (returnStatement != null) {
- final PyExpression returnExpr = returnStatement.getExpression();
- if (returnExpr == null || !PsiTreeUtil.isAncestor(returnExpr, target, false)) {
- return new PyHighlightExitPointsHandler(editor, file, target);
- }
+public class PyHighlightExitPointsHandlerFactory extends HighlightUsagesHandlerFactoryBase {
+ public HighlightUsagesHandlerBase createHighlightUsagesHandler(@NotNull Editor editor, @NotNull PsiFile file, @NotNull PsiElement target) {
+ final PyReturnStatement returnStatement = PsiTreeUtil.getParentOfType(target, PyReturnStatement.class);
+ if (returnStatement != null) {
+ final PyExpression returnExpr = returnStatement.getExpression();
+ if (returnExpr == null || !PsiTreeUtil.isAncestor(returnExpr, target, false)) {
+ return new PyHighlightExitPointsHandler(editor, file, target);
}
}
return null;