Search in sources :

Example 1 with Filter

use of com.intellij.execution.filters.Filter in project intellij-community by JetBrains.

the class StackTraceElementObjectRenderer method getFullValueEvaluator.

@Nullable
@Override
public XFullValueEvaluator getFullValueEvaluator(final EvaluationContextImpl evaluationContext, final ValueDescriptorImpl valueDescriptor) {
    return new JavaValue.JavaFullValueEvaluator(DebuggerBundle.message("message.node.navigate"), evaluationContext) {

        @Override
        public void evaluate(@NotNull XFullValueEvaluationCallback callback) {
            Value value = valueDescriptor.getValue();
            ClassType type = ((ClassType) value.type());
            Method toString = type.concreteMethodByName("toString", "()Ljava/lang/String;");
            if (toString != null) {
                try {
                    Value res = evaluationContext.getDebugProcess().invokeMethod(evaluationContext, (ObjectReference) value, toString, Collections.emptyList());
                    if (res instanceof StringReference) {
                        callback.evaluated("");
                        final String line = ((StringReference) res).value();
                        ApplicationManager.getApplication().runReadAction(() -> {
                            ExceptionFilter filter = new ExceptionFilter(evaluationContext.getDebugProcess().getSession().getSearchScope());
                            Filter.Result result = filter.applyFilter(line, line.length());
                            if (result != null) {
                                final HyperlinkInfo info = result.getFirstHyperlinkInfo();
                                if (info != null) {
                                    DebuggerUIUtil.invokeLater(() -> info.navigate(valueDescriptor.getProject()));
                                }
                            }
                        });
                    }
                } catch (EvaluateException e) {
                    LOG.info("Exception while getting stack info", e);
                }
            }
        }

        @Override
        public boolean isShowValuePopup() {
            return false;
        }
    };
}
Also used : ExceptionFilter(com.intellij.execution.filters.ExceptionFilter) NotNull(org.jetbrains.annotations.NotNull) HyperlinkInfo(com.intellij.execution.filters.HyperlinkInfo) EvaluateException(com.intellij.debugger.engine.evaluation.EvaluateException) ExceptionFilter(com.intellij.execution.filters.ExceptionFilter) Filter(com.intellij.execution.filters.Filter) JavaValue(com.intellij.debugger.engine.JavaValue) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with Filter

use of com.intellij.execution.filters.Filter in project intellij-community by JetBrains.

the class GradleConsoleFilterProvider method getDefaultFilters.

@NotNull
@Override
public Filter[] getDefaultFilters(@NotNull Project project) {
    return new Filter[] { new GradleConsoleFilter(project), new RegexpFilter(project, RegexpFilter.FILE_PATH_MACROS + ":" + RegexpFilter.LINE_MACROS) {

        private CachedValue<Boolean> myIsGradleProject = new CachedValueImpl<>(() -> CachedValueProvider.Result.create(isGradleProject(), ProjectRootModificationTracker.getInstance(project)));

        @Override
        public Result applyFilter(String line, int entireLength) {
            if (line == null || !FileUtil.isAbsolutePlatformIndependent(line))
                return null;
            if (Boolean.FALSE.equals(myIsGradleProject.getValue()))
                return null;
            Result result = super.applyFilter(line, entireLength);
            if (result == null)
                return null;
            Pattern pattern = getPattern();
            Matcher matcher = pattern.matcher(StringUtil.newBombedCharSequence(line, 100));
            if (!matcher.lookingAt())
                return result;
            int lineStart = entireLength - line.length();
            int start = lineStart + matcher.start();
            int end = lineStart + matcher.end();
            return new Result(start, end, result.getFirstHyperlinkInfo());
        }

        private boolean isGradleProject() {
            return !GradleSettings.getInstance(project).getLinkedProjectsSettings().isEmpty();
        }
    } };
}
Also used : Pattern(java.util.regex.Pattern) RegexpFilter(com.intellij.execution.filters.RegexpFilter) Filter(com.intellij.execution.filters.Filter) RegexpFilter(com.intellij.execution.filters.RegexpFilter) Matcher(java.util.regex.Matcher) CachedValue(com.intellij.psi.util.CachedValue) NotNull(org.jetbrains.annotations.NotNull)

Example 3 with Filter

use of com.intellij.execution.filters.Filter in project intellij-plugins by JetBrains.

the class RubyMotionUtilImpl method generateApp.

public void generateApp(final VirtualFile dir, final Module module, Sdk sdk, final ProjectType projectType) {
    final Project project = module.getProject();
    final String applicationHomePath = dir.getPath();
    final File tempDirectory;
    try {
        tempDirectory = FileUtil.createTempDirectory("RubyMotion", ".RubyMine");
    } catch (IOException e) {
        throw new Error(e);
    }
    final File generatedApp = new File(tempDirectory, module.getName());
    final Filter[] filters = null;
    final ProcessAdapter processListener = new ProcessAdapter() {

        public void processTerminated(ProcessEvent event) {
            FileUtil.moveDirWithContent(generatedApp, VfsUtilCore.virtualToIoFile(dir));
            tempDirectory.delete();
            if (module.isDisposed()) {
                return;
            }
            RModuleUtil.getInstance().refreshRubyModuleTypeContent(module);
            GeneratorsUtil.openFileInEditor(project, "app/app_delegate.rb", applicationHomePath);
            GeneratorsUtil.openFileInEditor(project, RakeUtilBase.RAKE_FILE, applicationHomePath);
            GeneratorsUtil.openFileInEditor(project, BundlerUtil.GEMFILE, applicationHomePath);
        }
    };
    final MergingCommandLineArgumentsProvider resultProvider = new MergingCommandLineArgumentsProvider(new String[] { getRubyMotionPath() + "/bin/motion", "create", "--template=" + projectType.name().toLowerCase(Locale.US), module.getName() }, null, null, null, sdk);
    ConsoleRunner.run(module, null, processListener, filters, null, ConsoleRunner.ProcessLaunchMode.BACKGROUND_TASK_WITH_PROGRESS, "Generating RubyMotion Application '" + module.getName() + "'...", tempDirectory.getAbsolutePath(), resultProvider, null, false);
}
Also used : Project(com.intellij.openapi.project.Project) MergingCommandLineArgumentsProvider(org.jetbrains.plugins.ruby.ruby.run.MergingCommandLineArgumentsProvider) ProcessAdapter(com.intellij.execution.process.ProcessAdapter) Filter(com.intellij.execution.filters.Filter) ProcessEvent(com.intellij.execution.process.ProcessEvent) IOException(java.io.IOException) VirtualFile(com.intellij.openapi.vfs.VirtualFile) RFile(org.jetbrains.plugins.ruby.ruby.lang.psi.RFile) PsiFile(com.intellij.psi.PsiFile) File(java.io.File)

Aggregations

Filter (com.intellij.execution.filters.Filter)3 NotNull (org.jetbrains.annotations.NotNull)2 JavaValue (com.intellij.debugger.engine.JavaValue)1 EvaluateException (com.intellij.debugger.engine.evaluation.EvaluateException)1 ExceptionFilter (com.intellij.execution.filters.ExceptionFilter)1 HyperlinkInfo (com.intellij.execution.filters.HyperlinkInfo)1 RegexpFilter (com.intellij.execution.filters.RegexpFilter)1 ProcessAdapter (com.intellij.execution.process.ProcessAdapter)1 ProcessEvent (com.intellij.execution.process.ProcessEvent)1 Project (com.intellij.openapi.project.Project)1 VirtualFile (com.intellij.openapi.vfs.VirtualFile)1 PsiFile (com.intellij.psi.PsiFile)1 CachedValue (com.intellij.psi.util.CachedValue)1 File (java.io.File)1 IOException (java.io.IOException)1 Matcher (java.util.regex.Matcher)1 Pattern (java.util.regex.Pattern)1 Nullable (org.jetbrains.annotations.Nullable)1 RFile (org.jetbrains.plugins.ruby.ruby.lang.psi.RFile)1 MergingCommandLineArgumentsProvider (org.jetbrains.plugins.ruby.ruby.run.MergingCommandLineArgumentsProvider)1