use of com.intellij.execution.Location in project intellij-community by JetBrains.
the class JavaAwareTestConsoleProperties method getErrorNavigatable.
@Nullable
@Override
public Navigatable getErrorNavigatable(@NotNull Location<?> location, @NotNull String stacktrace) {
//navigate to the first stack trace
final String[] stackTrace = new LineTokenizer(stacktrace).execute();
final PsiLocation<?> psiLocation = location.toPsiLocation();
final PsiClass containingClass = psiLocation.getParentElement(PsiClass.class);
if (containingClass == null)
return null;
final String qualifiedName = containingClass.getQualifiedName();
if (qualifiedName == null)
return null;
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 null;
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()) : null;
}
use of com.intellij.execution.Location in project intellij-community by JetBrains.
the class JarApplicationConfigurationProducer method getJarFileFromContext.
@Nullable
private static VirtualFile getJarFileFromContext(ConfigurationContext context) {
Location location = context.getLocation();
if (location == null)
return null;
VirtualFile file = location.getVirtualFile();
return file != null && FileUtilRt.extensionEquals(file.getName(), "jar") ? file : null;
}
use of com.intellij.execution.Location in project intellij-community by JetBrains.
the class PythonRunConfigurationProducer method setupConfigurationFromContext.
@Override
protected boolean setupConfigurationFromContext(PythonRunConfiguration configuration, ConfigurationContext context, Ref<PsiElement> sourceElement) {
final Location location = context.getLocation();
if (location == null)
return false;
final PsiFile script = location.getPsiElement().getContainingFile();
if (!isAvailable(location, script))
return false;
final VirtualFile vFile = script.getVirtualFile();
if (vFile == null)
return false;
configuration.setScriptName(vFile.getPath());
final VirtualFile parent = vFile.getParent();
if (parent != null) {
configuration.setWorkingDirectory(parent.getPath());
}
final Module module = ModuleUtilCore.findModuleForPsiElement(script);
if (module != null) {
configuration.setUseModuleSdk(true);
configuration.setModule(module);
}
configuration.setName(configuration.suggestedName());
return true;
}
use of com.intellij.execution.Location in project intellij-community by JetBrains.
the class PythonRunConfigurationProducer method isConfigurationFromContext.
@Override
public boolean isConfigurationFromContext(PythonRunConfiguration configuration, ConfigurationContext context) {
final Location location = context.getLocation();
if (location == null)
return false;
final PsiFile script = location.getPsiElement().getContainingFile();
if (!isAvailable(location, script))
return false;
final VirtualFile virtualFile = script.getVirtualFile();
if (virtualFile == null)
return false;
if (virtualFile instanceof LightVirtualFile)
return false;
final String workingDirectory = configuration.getWorkingDirectory();
final String scriptName = configuration.getScriptName();
final String path = virtualFile.getPath();
return scriptName.equals(path) || path.equals(new File(workingDirectory, scriptName).getAbsolutePath());
}
use of com.intellij.execution.Location in project intellij-community by JetBrains.
the class PyStudyRunContextAction method update.
@Override
public void update(AnActionEvent event) {
final ConfigurationContext context = ConfigurationContext.getFromContext(event.getDataContext());
final Location location = context.getLocation();
if (location == null)
return;
super.update(event);
final InputEvent inputEvent = event.getInputEvent();
final Presentation presentation = event.getPresentation();
if (inputEvent == null && !(context.getDataContext().getData(PlatformDataKeys.CONTEXT_COMPONENT) instanceof EditorGutter)) {
presentation.setText("");
}
}
Aggregations