ipnb target expression stub based

This commit is contained in:
Ekaterina Tuzova
2015-11-17 15:23:38 +03:00
parent 3e9fe2898c
commit 15fe93e6ca
5 changed files with 56 additions and 1 deletions
@@ -4,6 +4,7 @@ import com.intellij.lang.ASTNode;
import com.intellij.openapi.editor.Editor;
import com.intellij.util.ui.UIUtil;
import com.jetbrains.python.psi.impl.PyTargetExpressionImpl;
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
import org.jetbrains.plugins.ipnb.editor.IpnbFileEditor;
import org.jetbrains.plugins.ipnb.editor.panels.IpnbFilePanel;
import org.jetbrains.plugins.ipnb.editor.panels.code.IpnbCodePanel;
@@ -15,6 +16,10 @@ public class IpnbPyTargetExpression extends PyTargetExpressionImpl {
super(astNode);
}
public IpnbPyTargetExpression(final PyTargetExpressionStub stub) {
super(stub, IpnbPyTokenTypes.IPNB_TARGET);
}
@Override
public void navigate(boolean requestFocus) {
final IpnbCodeSourcePanel sourcePanel = ((IpnbPyFragment)getContainingFile()).getCodeSourcePanel();
@@ -0,0 +1,38 @@
/*
* 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.plugins.ipnb.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import com.jetbrains.python.psi.PyTargetExpression;
import com.jetbrains.python.psi.impl.stubs.PyTargetExpressionElementType;
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
import org.jetbrains.annotations.NotNull;
public class IpnbPyTargetExpressionElementType extends PyTargetExpressionElementType {
public IpnbPyTargetExpressionElementType() {
super("IPNB_TARGET_EXPRESSION");
}
public PsiElement createElement(@NotNull final ASTNode node) {
return new IpnbPyTargetExpression(node);
}
public PyTargetExpression createPsi(@NotNull final PyTargetExpressionStub stub) {
return new IpnbPyTargetExpression(stub);
}
}
@@ -1,11 +1,14 @@
package org.jetbrains.plugins.ipnb.psi;
import com.jetbrains.python.psi.PyElementType;
import com.jetbrains.python.psi.PyStubElementType;
import com.jetbrains.python.psi.PyTargetExpression;
import com.jetbrains.python.psi.impl.stubs.PyFunctionElementType;
import com.jetbrains.python.psi.stubs.PyTargetExpressionStub;
public class IpnbPyTokenTypes {
public static final PyElementType IPNB_REFERENCE = new PyElementType("IPNB_REFERENCE", IpnbPyReferenceExpression.class);
public static final PyElementType IPNB_TARGET = new PyElementType("IPNB_TARGET", IpnbPyTargetExpression.class);
public static final PyStubElementType<PyTargetExpressionStub, PyTargetExpression> IPNB_TARGET = new IpnbPyTargetExpressionElementType();
public static final PyFunctionElementType IPNB_FUNCTION = new IpnbFunctionElementType();
private IpnbPyTokenTypes() {
@@ -27,6 +27,7 @@ import com.intellij.psi.ResolveResult;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.psi.search.LocalSearchScope;
import com.intellij.psi.search.SearchScope;
import com.intellij.psi.stubs.IStubElementType;
import com.intellij.psi.stubs.StubElement;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.util.QualifiedName;
@@ -75,6 +76,10 @@ public class PyTargetExpressionImpl extends PyBaseElementImpl<PyTargetExpression
super(stub, PyElementTypes.TARGET_EXPRESSION);
}
public PyTargetExpressionImpl(final PyTargetExpressionStub stub, IStubElementType nodeType) {
super(stub, nodeType);
}
@Override
protected void acceptPyVisitor(PyElementVisitor pyVisitor) {
pyVisitor.visitPyTargetExpression(this);
@@ -47,6 +47,10 @@ public class PyTargetExpressionElementType extends PyStubElementType<PyTargetExp
super("TARGET_EXPRESSION");
}
public PyTargetExpressionElementType(String debugName) {
super(debugName);
}
private CustomTargetExpressionStubType[] getCustomStubTypes() {
if (myCustomStubTypes == null) {
myCustomStubTypes = Extensions.getExtensions(CustomTargetExpressionStubType.EP_NAME);