Java Code Examples for com.intellij.openapi.actionSystem.CommonDataKeys#PSI_ELEMENT
The following examples show how to use
com.intellij.openapi.actionSystem.CommonDataKeys#PSI_ELEMENT .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestsUIUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nullable @SuppressWarnings("unchecked") public static <T> T getData(final AbstractTestProxy testProxy, final Key<T> dataId, final TestFrameworkRunningModel model) { final TestConsoleProperties properties = model.getProperties(); final Project project = properties.getProject(); if (testProxy == null) return null; if (AbstractTestProxy.DATA_KEY == dataId) return (T)testProxy; if (CommonDataKeys.NAVIGATABLE == dataId) return (T)getOpenFileDescriptor(testProxy, model); if (CommonDataKeys.PSI_ELEMENT == dataId) { final Location location = testProxy.getLocation(project, properties.getScope()); if (location != null) { final PsiElement element = location.getPsiElement(); return element.isValid() ? (T)element : null; } else { return null; } } if (Location.DATA_KEY == dataId) return (T)testProxy.getLocation(project, properties.getScope()); if (RunConfiguration.DATA_KEY == dataId) { final RunProfile configuration = properties.getConfiguration(); if (configuration instanceof RunConfiguration) { return (T)configuration; } } return null; }
Example 2
Source File: PsiElementUsageGroupBase.java From consulo with Apache License 2.0 | 5 votes |
public void calcData(final Key<?> key, final DataSink sink) { if (!isValid()) return; if (CommonDataKeys.PSI_ELEMENT == key) { sink.put(CommonDataKeys.PSI_ELEMENT, getElement()); } if (UsageView.USAGE_INFO_KEY == key) { T element = getElement(); if (element != null) { sink.put(UsageView.USAGE_INFO_KEY, new UsageInfo(element)); } } }
Example 3
Source File: FileGroupingRule.java From consulo with Apache License 2.0 | 5 votes |
@Override public void calcData(final Key<?> key, final DataSink sink) { if (!isValid()) return; if (key == CommonDataKeys.VIRTUAL_FILE) { sink.put(CommonDataKeys.VIRTUAL_FILE, myFile); } if (key == CommonDataKeys.PSI_ELEMENT) { sink.put(CommonDataKeys.PSI_ELEMENT, getPsiFile()); } }
Example 4
Source File: AbstractMemberSelectionTable.java From consulo with Apache License 2.0 | 5 votes |
@Override public void calcData(final Key key, final DataSink sink) { if (key == CommonDataKeys.PSI_ELEMENT) { final Collection<M> memberInfos = getSelectedMemberInfos(); if (memberInfos.size() > 0) { sink.put(CommonDataKeys.PSI_ELEMENT, memberInfos.iterator().next().getMember()); } } }
Example 5
Source File: PsiElementFromSelectionRule.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Key<PsiElement> getKey() { return CommonDataKeys.PSI_ELEMENT; }
Example 6
Source File: PsiElementDataValidator.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull @Override public Key<PsiElement> getKey() { return CommonDataKeys.PSI_ELEMENT; }