• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Location类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.execution.Location的典型用法代码示例。如果您正苦于以下问题:Java Location类的具体用法?Java Location怎么用?Java Location使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Location类属于com.intellij.execution包,在下文中一共展示了Location类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: testInnerClass

import com.intellij.execution.Location; //导入依赖的package包/类
public void testInnerClass() throws Exception {
  myFixture.addClass("public class TestClass {\n" +
                     "    public static class Tests extends junit.framework.TestCase {\n" +
                     "        public void testFoo() throws Exception {}\n" +
                     "    }\n" +
                     "}");

  final SMTestProxy testProxy = new SMTestProxy("testFoo", false, "java:test://TestClass$Tests.testFoo");
  final Project project = getProject();
  final GlobalSearchScope searchScope = GlobalSearchScope.projectScope(project);
  testProxy.setLocator(JavaTestLocator.INSTANCE);
  Location location = testProxy.getLocation(project, searchScope);
  assertNotNull(location);
  PsiElement element = location.getPsiElement();
  assertTrue(element instanceof PsiMethod);
  String name = ((PsiMethod)element).getName();
  assertEquals(name, "testFoo");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:JUnitRerunFailedTestsTest.java


示例2: update

import com.intellij.execution.Location; //导入依赖的package包/类
@Override
public void update(AnActionEvent e) {
  final Presentation presentation = e.getPresentation();
  presentation.setVisible(false);
  final DataContext dataContext = e.getDataContext();
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project != null) {
    final RunConfiguration configuration = RunConfiguration.DATA_KEY.getData(dataContext);
    if (isPatternBasedConfiguration(configuration)) {
      final AbstractTestProxy testProxy = AbstractTestProxy.DATA_KEY.getData(dataContext);
      if (testProxy != null) {
        final Location location = testProxy.getLocation(project, ((T)configuration).getConfigurationModule().getSearchScope());
        if (location != null) {
          final PsiElement psiElement = location.getPsiElement();
          if (psiElement instanceof PsiClass && getPattern((T)configuration).contains(((PsiClass)psiElement).getQualifiedName())) {
            presentation.setVisible(true);
          }
        }
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:AbstractExcludeFromRunAction.java


示例3: getTargetName

import com.intellij.execution.Location; //导入依赖的package包/类
@Nullable
private static String getTargetName(Location location) {
  PsiElement parent = location.getPsiElement();
  while (!(parent.getParent() instanceof PsiFile) && parent.getParent() != null) {
    parent = parent.getParent();
  }
  if (parent instanceof GrMethodCallExpression && PsiUtil.isMethodCall((GrMethodCallExpression)parent, "target")) {
    final GrNamedArgument[] args = ((GrMethodCallExpression)parent).getNamedArguments();
    if (args.length == 1) {
      final GrArgumentLabel label = args[0].getLabel();
      if (label != null) {
        return label.getName();
      }
    }
    return null;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GantScriptType.java


示例4: getAncestors

import com.intellij.execution.Location; //导入依赖的package包/类
@NotNull
public <T extends PsiElement> Iterator<Location<T>> getAncestors(final Class<T> ancestorClass, final boolean strict) {
  final Iterator<Location<T>> fromClass = myClassLocation.getAncestors(ancestorClass, false);
  if (strict) return fromClass;
  return new Iterator<Location<T>>() {
    private boolean myFirstStep = ancestorClass.isInstance(myMethod);
    public boolean hasNext() {
      return myFirstStep || fromClass.hasNext();
    }

    public Location<T> next() {
      final Location<T> location = myFirstStep ? (Location<T>)(Location)MethodLocation.this : fromClass.next();
      myFirstStep = false;
      return location;
    }

    public void remove() {
      LOG.assertTrue(false);
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MethodLocation.java


示例5: getParameterizedLocation

import com.intellij.execution.Location; //导入依赖的package包/类
public static Location getParameterizedLocation(PsiClass psiClass,
                                                String paramSetName,
                                                String parameterizedClassName) {
  final PsiAnnotation annotation = AnnotationUtil.findAnnotationInHierarchy(psiClass, Collections.singleton(JUnitUtil.RUN_WITH));
  if (annotation != null) {
    final PsiAnnotationMemberValue attributeValue = annotation.findAttributeValue("value");
    if (attributeValue instanceof PsiClassObjectAccessExpression) {
      final PsiTypeElement operand = ((PsiClassObjectAccessExpression)attributeValue).getOperand();
      if (InheritanceUtil.isInheritor(operand.getType(), parameterizedClassName)) {
        return new PsiMemberParameterizedLocation(psiClass.getProject(), 
                                                  psiClass,
                                                  null,
                                                  paramSetName);
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiMemberParameterizedLocation.java


示例6: findExistingByElement

import com.intellij.execution.Location; //导入依赖的package包/类
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location,
                                                               @NotNull List<RunnerAndConfigurationSettings> existingConfigurations,
                                                               ConfigurationContext context) {
  for (RunnerAndConfigurationSettings existingConfiguration : existingConfigurations) {
    final RunConfiguration configuration = existingConfiguration.getConfiguration();
    final GroovyScriptRunConfiguration existing = (GroovyScriptRunConfiguration)configuration;
    final String path = existing.getScriptPath();
    if (path != null) {
      final PsiFile file = location.getPsiElement().getContainingFile();
      if (file instanceof GroovyFile) {
        final VirtualFile vfile = file.getVirtualFile();
        if (vfile != null && FileUtil.toSystemIndependentName(path).equals(ScriptFileUtil.getScriptFilePath(vfile))) {
          if (!((GroovyFile)file).isScript() ||
              GroovyScriptUtil.getScriptType((GroovyFile)file).isConfigurationByLocation(existing, location)) {
            return existingConfiguration;
          }
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:GroovyScriptRunConfigurationProducer.java


示例7: getDescriptor

import com.intellij.execution.Location; //导入依赖的package包/类
public Navigatable getDescriptor(final Location<?> location) {
  if (location == null) return super.getDescriptor(location);
  //navigate to the first stack trace
  final String[] stackTrace = new LineTokenizer(myStackTraces.get(0)).execute();
  final PsiLocation<?> psiLocation = location.toPsiLocation();
  final PsiClass containingClass = psiLocation.getParentElement(PsiClass.class);
  if (containingClass == null) return super.getDescriptor(location);
  String containingMethod = null;
  for (Iterator<Location<PsiMethod>> iterator = psiLocation.getAncestors(PsiMethod.class, false); iterator.hasNext();) {
    final PsiMethod psiMethod = iterator.next().getPsiElement();
    if (containingClass.equals(psiMethod.getContainingClass())) containingMethod = psiMethod.getName();
  }
  if (containingMethod == null) return super.getDescriptor(location);
  final String qualifiedName = containingClass.getQualifiedName();
  StackTraceLine lastLine = null;
  for (String aStackTrace : stackTrace) {
    final StackTraceLine line = new StackTraceLine(containingClass.getProject(), aStackTrace);
    if (containingMethod.equals(line.getMethodName()) && qualifiedName.equals(line.getClassName())) {
      lastLine = line;
      break;
    }
  }
  return lastLine != null ?
      lastLine.getOpenFileDescriptor(containingClass.getContainingFile().getVirtualFile()) :
      super.getDescriptor(location);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:FaultyState.java


示例8: getMethodLocation

import com.intellij.execution.Location; //导入依赖的package包/类
public Location<PsiMethod> getMethodLocation(final Project project) {
  String className = getClassName();
  final String methodName = getMethodName();
  if (className == null || methodName == null) return null;
  final int lineNumber;
  try {
    lineNumber = getLineNumber();
  } catch(NumberFormatException e) {
    return null;
  }
  final int dollarIndex = className.indexOf('$');
  if (dollarIndex != -1) className = className.substring(0, dollarIndex);
  PsiClass psiClass = findClass(project, className, lineNumber);
  if (psiClass == null || (psiClass.getNavigationElement() instanceof PsiCompiledElement)) return null;
  psiClass = (PsiClass)psiClass.getNavigationElement();
  final PsiMethod psiMethod = getMethodAtLine(psiClass, methodName, lineNumber);
  if (psiMethod != null) {
    return new MethodLineLocation(project, psiMethod, PsiLocation.fromPsiElement(psiClass), lineNumber);
  }
  else {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:StackTraceLine.java


示例9: testParameterizedMethodLocationResolves

import com.intellij.execution.Location; //导入依赖的package包/类
@Test
public void testParameterizedMethodLocationResolves() {
  PsiFile javaFile =
      workspace.createPsiFile(
          new WorkspacePath("java/com/google/lib/JavaClass.java"),
          "package com.google.lib;",
          "public class JavaClass {",
          "  public void testMethod() {}",
          "}");
  PsiClass javaClass = ((PsiClassOwner) javaFile).getClasses()[0];
  PsiMethod method = javaClass.findMethodsByName("testMethod", false)[0];
  assertThat(method).isNotNull();

  String url =
      handler.testLocationUrl(
          null, "testMethod", "[0] true (testMethod)", "com.google.lib.JavaClass");
  Location<?> location = getLocation(url);
  assertThat(location.getPsiElement()).isEqualTo(method);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:20,代码来源:BlazeJavaTestEventsHandlerTest.java


示例10: setLocator

import com.intellij.execution.Location; //导入依赖的package包/类
/** @deprecated use {@link #setLocator(SMTestLocator)} (to be removed in IDEA 16) */
@SuppressWarnings("deprecation")
public void setLocator(@NotNull final TestLocationProvider locator) {
  class Adapter implements SMTestLocator, PossiblyDumbAware {
    @NotNull
    @Override
    public List<Location> getLocation(@NotNull String protocol, @NotNull String path, @NotNull Project project, @NotNull GlobalSearchScope scope) {
      return locator.getLocation(protocol, path, project);
    }

    @Override
    public boolean isDumbAware() {
      return DumbService.isDumbAware(locator);
    }
  }

  myLocator = new Adapter();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SMTestProxy.java


示例11: getDescriptor

import com.intellij.execution.Location; //导入依赖的package包/类
@Nullable
public Navigatable getDescriptor(@Nullable Location location, @NotNull TestConsoleProperties properties) {
  // by location gets navigatable element.
  // It can be file or place in file (e.g. when OPEN_FAILURE_LINE is enabled)
  if (location == null) return null;

  String stacktrace = myStacktrace;
  if (stacktrace != null && properties instanceof SMStacktraceParser && isLeaf()) {
    Navigatable result = properties instanceof SMStacktraceParserEx ?
                         ((SMStacktraceParserEx)properties).getErrorNavigatable(location, stacktrace) :
                           ((SMStacktraceParser)properties).getErrorNavigatable(location.getProject(), stacktrace);
    if (result != null) {
      return result;
    }
  }

  return EditSourceUtil.getDescriptor(location.getPsiElement());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SMTestProxy.java


示例12: selectSubCoverage

import com.intellij.execution.Location; //导入依赖的package包/类
private void selectSubCoverage() {
  final CoverageDataManager coverageDataManager = CoverageDataManager.getInstance(myProperties.getProject());
  final CoverageSuitesBundle currentSuite = coverageDataManager.getCurrentSuitesBundle();
  if (currentSuite != null) {
    final AbstractTestProxy test = myModel.getTreeView().getSelectedTest();
    List<String> testMethods = new ArrayList<String>();
    if (test != null && !test.isInProgress()) {
      final List<? extends AbstractTestProxy> list = test.getAllTests();
      for (AbstractTestProxy proxy : list) {
        final Location location = proxy.getLocation(myProperties.getProject(), myProperties.getScope());
        if (location != null) {
          final PsiElement element = location.getPsiElement();
          final String name = currentSuite.getCoverageEngine().getTestMethodName(element, proxy);
          if (name != null) {
            testMethods.add(name);
          }
        }
      }
    }
    coverageDataManager.selectSubCoverage(currentSuite, testMethods);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TrackCoverageAction.java


示例13: ConfigurationContext

import com.intellij.execution.Location; //导入依赖的package包/类
private ConfigurationContext(final DataContext dataContext) {
  myRuntimeConfiguration = RunConfiguration.DATA_KEY.getData(dataContext);
  myContextComponent = PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext);
  myModule = LangDataKeys.MODULE.getData(dataContext);
  @SuppressWarnings({"unchecked"})
  final Location<PsiElement> location = (Location<PsiElement>)Location.DATA_KEY.getData(dataContext);
  if (location != null) {
    myLocation = location;
    return;
  }
  final Project project = CommonDataKeys.PROJECT.getData(dataContext);
  if (project == null) {
    myLocation = null;
    return;
  }
  final PsiElement element = getSelectedPsiElement(dataContext, project);
  if (element == null) {
    myLocation = null;
    return;
  }
  myLocation = new PsiLocation<PsiElement>(project, myModule, element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ConfigurationContext.java


示例14: findExistingByElement

import com.intellij.execution.Location; //导入依赖的package包/类
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location,
                                                               @NotNull List<RunnerAndConfigurationSettings> existingConfigurations,
                                                               ConfigurationContext context) {
  final XmlFile file = PsiTreeUtil.getParentOfType(location.getPsiElement(), XmlFile.class, false);
  if (file != null && file.isPhysical() && XsltSupport.isXsltFile(file)) {
    for (RunnerAndConfigurationSettings existingConfiguration : existingConfigurations) {
      final RunConfiguration configuration = existingConfiguration.getConfiguration();
      if (configuration instanceof XsltRunConfiguration) {
        if (file.getVirtualFile().getPath().replace('/', File.separatorChar)
          .equals(((XsltRunConfiguration)configuration).getXsltFile())) {
          return existingConfiguration;
        }
      }
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:XsltConfigurationProducer.java


示例15: findAllProducers

import com.intellij.execution.Location; //导入依赖的package包/类
private static List<RuntimeConfigurationProducer> findAllProducers(Location location, ConfigurationContext context) {
  //todo load configuration types if not already loaded
  Extensions.getExtensions(ConfigurationType.CONFIGURATION_TYPE_EP);
  final RuntimeConfigurationProducer[] configurationProducers =
    ApplicationManager.getApplication().getExtensions(RuntimeConfigurationProducer.RUNTIME_CONFIGURATION_PRODUCER);
  final ArrayList<RuntimeConfigurationProducer> producers = new ArrayList<RuntimeConfigurationProducer>();
  for (final RuntimeConfigurationProducer prototype : configurationProducers) {
    final RuntimeConfigurationProducer producer;
    try {
      producer = prototype.createProducer(location, context);
    }
    catch (AbstractMethodError e) {
      LOG.error(new ExtensionException(prototype.getClass()));
      continue;
    }
    if (producer.getConfiguration() != null) {
      LOG.assertTrue(producer.getSourceElement() != null, producer);
      producers.add(producer);
    }
  }
  return producers;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PreferredProducerFind.java


示例16: testFunctionWithoutMainPrefixResolves

import com.intellij.execution.Location; //导入依赖的package包/类
@Test
public void testFunctionWithoutMainPrefixResolves() {
  PsiFile file =
      workspace.createPsiFile(
          new WorkspacePath("lib/app/app_unittest.py"),
          "class AppUnitTest:",
          "  def testApp(self):",
          "    return");
  PyClass pyClass = PsiUtils.findFirstChildOfClassRecursive(file, PyClass.class);
  PyFunction function = pyClass.findMethodByName("testApp", false, null);
  assertThat(function).isNotNull();

  String url = handler.testLocationUrl(null, null, "lib.app.AppUnitTest.testApp", null);
  Location<?> location = getLocation(url);
  assertThat(location.getPsiElement()).isEqualTo(function);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:BlazePythonTestEventsHandlerTest.java


示例17: findExistingByElement

import com.intellij.execution.Location; //导入依赖的package包/类
@Nullable
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location,
                                                               @NotNull List<RunnerAndConfigurationSettings> existingConfigurations,
                                                               ConfigurationContext context) {
  PsiFile script = location.getPsiElement().getContainingFile();
  if (script == null) {
    return null;
  }
  final VirtualFile vFile = script.getVirtualFile();
  if (vFile == null) {
    return null;
  }
  String path = vFile.getPath();
  for (RunnerAndConfigurationSettings configuration : existingConfigurations) {
    final String scriptName = ((RestRunConfiguration)configuration.getConfiguration()).getInputFile();
    if (FileUtil.toSystemIndependentName(scriptName).equals(FileUtil.toSystemIndependentName(path))) {
      return configuration;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DocutilsConfigurationProducer.java


示例18: findExistingByElement

import com.intellij.execution.Location; //导入依赖的package包/类
@Nullable
@Override
protected RunnerAndConfigurationSettings findExistingByElement(Location location,
                                                               @NotNull List<RunnerAndConfigurationSettings> existingConfigurations,
                                                               ConfigurationContext context) {
  PsiElement element = location.getPsiElement();
  if (!(element instanceof PsiDirectory)) return null;
  final VirtualFile vFile = ((PsiDirectory)element).getVirtualFile();
  String path = vFile.getPath();
  for (RunnerAndConfigurationSettings configuration : existingConfigurations) {
    final String scriptName = ((RestRunConfiguration)configuration.getConfiguration()).getInputFile();
    if (FileUtil.toSystemIndependentName(scriptName).equals(FileUtil.toSystemIndependentName(path))) {
      return configuration;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:SphinxConfigurationProducer.java


示例19: getItems

import com.intellij.execution.Location; //导入依赖的package包/类
@NotNull
@Override
public List<? extends GotoRelatedItem> getItems(@NotNull DataContext context) {
  final Editor editor = CommonDataKeys.EDITOR.getData(context);
  final Project project = CommonDataKeys.PROJECT.getData(context);
  final VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(context);
  if (editor == null || file == null || project == null) {
    return Collections.emptyList();
  }

  final List<Location> locations = TestLocationDataRule.collectRelativeLocations(project, file);
  if (locations.isEmpty()) {
    return Collections.emptyList();
  }
  
  return ContainerUtil.map(locations, new Function<Location, GotoRelatedItem>() {
    @Override
    public GotoRelatedItem fun(Location location) {
      return new GotoRelatedItem(location.getPsiElement());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TestCaseAsRelatedFileProvider.java


示例20: getState

import com.intellij.execution.Location; //导入依赖的package包/类
@Nullable
@Override
public RunProfileState getState(@NotNull Executor executor, @NotNull ExecutionEnvironment env) throws ExecutionException {
  final AbstractPythonRunConfiguration configuration = ((AbstractPythonRunConfiguration)getPeer());

  // If configuration wants to take care about rerun itself
  if (configuration instanceof TestRunConfigurationReRunResponsible) {
    // TODO: Extract method
    final Set<PsiElement> failedTestElements = new HashSet<PsiElement>();
    for (final AbstractTestProxy proxy : getFailedTests(getProject())) {
      final Location<?> location = proxy.getLocation(getProject(), GlobalSearchScope.allScope(getProject()));
      if (location != null) {
        failedTestElements.add(location.getPsiElement());
      }
    }
    return ((TestRunConfigurationReRunResponsible)configuration).rerunTests(executor, env, failedTestElements);
  }
  return new FailedPythonTestCommandLineStateBase(configuration, env,
                                                  (PythonTestCommandLineStateBase)configuration.getState(executor, env));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:PyRerunFailedTestsAction.java



注:本文中的com.intellij.execution.Location类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StandardPatterns类代码示例发布时间:2022-05-21
下一篇:
Java Picture类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap