当前位置: 首页>>代码示例>>Java>>正文


Java ExceptionWorker类代码示例

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


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

示例1: findMethodRange

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private static List<TextRange> findMethodRange(final ExceptionWorker worker,
                                               final Document document,
                                               final Trinity<PsiClass, PsiFile, String> previousLineResult) {
  return ApplicationManager.getApplication().runReadAction(new Computable<List<TextRange>>() {
    @Override
    public List<TextRange> compute() {
      List<TextRange> ranges = getTextRangeForMethod(worker, previousLineResult);
      if (ranges == null) return null;
      final List<TextRange> result = new ArrayList<TextRange>();
      for (TextRange range : ranges) {
        result.add(new TextRange(document.getLineNumber(range.getStartOffset()),
                                     document.getLineNumber(range.getEndOffset())));
      }
      return result;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:VcsContentAnnotationExceptionFilter.java

示例2: getDocumentForFile

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private static Document getDocumentForFile(final ExceptionWorker worker)
{
	return ApplicationManager.getApplication().runReadAction(new Computable<Document>()
	{
		@Override
		public Document compute()
		{
			final Document document = FileDocumentManager.getInstance().getDocument(worker.getFile().getVirtualFile());
			if(document == null)
			{
				LOG.info("can not get document for file: " + worker.getFile().getVirtualFile());
				return null;
			}
			return document;
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:18,代码来源:VcsContentAnnotationExceptionFilter.java

示例3: findMethodRange

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private static List<TextRange> findMethodRange(final ExceptionWorker worker, final Document document, final Trinity<PsiClass, PsiFile, String> previousLineResult)
{
	return ApplicationManager.getApplication().runReadAction(new Computable<List<TextRange>>()
	{
		@Override
		public List<TextRange> compute()
		{
			List<TextRange> ranges = getTextRangeForMethod(worker, previousLineResult);
			if(ranges == null)
			{
				return null;
			}
			final List<TextRange> result = new ArrayList<TextRange>();
			for(TextRange range : ranges)
			{
				result.add(new TextRange(document.getLineNumber(range.getStartOffset()), document.getLineNumber(range.getEndOffset())));
			}
			return result;
		}
	});
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:VcsContentAnnotationExceptionFilter.java

示例4: getDocumentForFile

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private static Document getDocumentForFile(final ExceptionWorker worker) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Document>() {
    @Override
    public Document compute() {
      final Document document = FileDocumentManager.getInstance().getDocument(worker.getFile().getVirtualFile());
      if (document == null) {
        LOG.info("can not get document for file: " + worker.getFile().getVirtualFile());
        return null;
      }
      return document;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:VcsContentAnnotationExceptionFilter.java

示例5: getTextRangeForMethod

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private static List<TextRange> getTextRangeForMethod(final ExceptionWorker worker, Trinity<PsiClass, PsiFile, String> previousLineResult) {
  String method = worker.getMethod();
  PsiClass psiClass = worker.getPsiClass();
  PsiMethod[] methods;
  if (method.contains("<init>")) {
    // constructor
    methods = psiClass.getConstructors();
  } else if (method.contains("$")) {
    // access$100
    return null;
  } else {
    methods = psiClass.findMethodsByName(method, false);
  }
  if (methods.length > 0) {
    if (methods.length == 1) {
      final TextRange range = methods[0].getTextRange();
      return Collections.singletonList(range);
    } else {
      List<PsiMethod> selectedMethods = selectMethod(methods, previousLineResult);
      final List<PsiMethod> toIterate = selectedMethods == null ? Arrays.asList(methods) : selectedMethods;
      final List<TextRange> result = new ArrayList<TextRange>();
      for (PsiMethod psiMethod : toIterate) {
        result.add(psiMethod.getTextRange());
      }
      return result;
    }
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:VcsContentAnnotationExceptionFilter.java

示例6: getDocumentForFile

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private Document getDocumentForFile(final ExceptionWorker worker) {
  return ApplicationManager.getApplication().runReadAction(new Computable<Document>() {
    @Override
    public Document compute() {
      final Document document = FileDocumentManager.getInstance().getDocument(worker.getFile().getVirtualFile());
      if (document == null) {
        LOG.info("can not get document for file: " + worker.getFile().getVirtualFile());
        return null;
      }
      return document;
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:VcsContentAnnotationExceptionFilter.java

示例7: findMethodRange

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private List<TextRange> findMethodRange(final ExceptionWorker worker, final Document document, final Trinity<PsiClass, PsiFile, String> previousLineResult) {
  return ApplicationManager.getApplication().runReadAction(new Computable<List<TextRange>>() {
    @Override
    public List<TextRange> compute() {
      List<TextRange> ranges = getTextRangeForMethod(worker, previousLineResult);
      if (ranges == null) return null;
      final List<TextRange> result = new ArrayList<TextRange>();
      for (TextRange range : ranges) {
        result.add(new TextRange(document.getLineNumber(range.getStartOffset()),
                                     document.getLineNumber(range.getEndOffset())));
      }
      return result;
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:VcsContentAnnotationExceptionFilter.java

示例8: getTextRangeForMethod

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private List<TextRange> getTextRangeForMethod(final ExceptionWorker worker, Trinity<PsiClass, PsiFile, String> previousLineResult) {
  String method = worker.getMethod();
  PsiClass psiClass = worker.getPsiClass();
  PsiMethod[] methods;
  if (method.contains("<init>")) {
    // constructor
    methods = psiClass.getConstructors();
  } else if (method.contains("$")) {
    // access$100
    return null;
  } else {
    methods = psiClass.findMethodsByName(method, false);
  }
  if (methods.length > 0) {
    if (methods.length == 1) {
      final TextRange range = methods[0].getTextRange();
      return Collections.singletonList(range);
    } else {
      List<PsiMethod> selectedMethods = selectMethod(methods, previousLineResult);
      final List<PsiMethod> toIterate = selectedMethods == null ? Arrays.asList(methods) : selectedMethods;
      final List<TextRange> result = new ArrayList<TextRange>();
      for (PsiMethod psiMethod : toIterate) {
        result.add(psiMethod.getTextRange());
      }
      return result;
    }
  }
  return null;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:VcsContentAnnotationExceptionFilter.java

示例9: getTextRangeForMethod

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
private static List<TextRange> getTextRangeForMethod(final ExceptionWorker worker, Trinity<PsiClass, PsiFile, String> previousLineResult)
{
	String method = worker.getMethod();
	PsiClass psiClass = worker.getPsiClass();
	PsiMethod[] methods;
	if(method.contains("<init>"))
	{
		// constructor
		methods = psiClass.getConstructors();
	}
	else if(method.contains("$"))
	{
		// access$100
		return null;
	}
	else
	{
		methods = psiClass.findMethodsByName(method, false);
	}
	if(methods.length > 0)
	{
		if(methods.length == 1)
		{
			final TextRange range = methods[0].getTextRange();
			return Collections.singletonList(range);
		}
		else
		{
			List<PsiMethod> selectedMethods = selectMethod(methods, previousLineResult);
			final List<PsiMethod> toIterate = selectedMethods == null ? Arrays.asList(methods) : selectedMethods;
			final List<TextRange> result = new ArrayList<TextRange>();
			for(PsiMethod psiMethod : toIterate)
			{
				result.add(psiMethod.getTextRange());
			}
			return result;
		}
	}
	return null;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:41,代码来源:VcsContentAnnotationExceptionFilter.java

示例10: applyHeavyFilter

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
@Override
public void applyHeavyFilter(final Document copiedFragment,
                             int startOffset,
                             int startLineNumber,
                             Consumer<AdditionalHighlight> consumer) {
  VcsContentAnnotation vcsContentAnnotation = VcsContentAnnotationImpl.getInstance(myProject);
  final LocalChangesCorrector localChangesCorrector = new LocalChangesCorrector(myProject);
  Trinity<PsiClass, PsiFile, String> previousLineResult = null;

  for (int i = 0; i < copiedFragment.getLineCount(); i++) {
    final int lineStartOffset = copiedFragment.getLineStartOffset(i);
    final int lineEndOffset = copiedFragment.getLineEndOffset(i);
    final ExceptionWorker worker = new ExceptionWorker(myCache);
    final String[] lineText = new String[1];
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        lineText[0] = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
        worker.execute(lineText[0], lineEndOffset);
      }
    });
    if (worker.getResult() != null) {
      VirtualFile vf = worker.getFile().getVirtualFile();
      if (vf.getFileSystem().isReadOnly()) continue;

      VcsRevisionNumber recentChangeRevision = myRevNumbersCache.get(vf);
      if (recentChangeRevision == null) {
        recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf);
        if (recentChangeRevision == null) {
          myRevNumbersCache.put(vf, VcsRevisionNumber.NULL);
        } else {
          myRevNumbersCache.put(vf, recentChangeRevision);
        }
      }
      if (VcsRevisionNumber.NULL.equals(recentChangeRevision)) {
        recentChangeRevision = null;
      }
      if (localChangesCorrector.isFileAlreadyIdentifiedAsChanged(vf) || ChangeListManager.isFileChanged(myProject, vf) ||
          recentChangeRevision != null) {
        final Document document = getDocumentForFile(worker);
        if (document == null) return;

        int startFileOffset = worker.getInfo().getThird().getStartOffset();
        int idx = lineText[0].indexOf(':', startFileOffset);
        int endIdx = idx == -1 ? worker.getInfo().getThird().getEndOffset() : idx;
        consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + startFileOffset + 1, startOffset + lineStartOffset + endIdx));

        if (worker.getPsiClass() != null) {
          // also check method
          final List<TextRange> ranges = findMethodRange(worker, document, previousLineResult);
          if (ranges != null) {
            boolean methodChanged = false;
            for (TextRange range : ranges) {
              if (localChangesCorrector.isRangeChangedLocally(vf, document, range)) {
                methodChanged = true;
                break;
              }
              final TextRange correctedRange = localChangesCorrector.getCorrectedRange(vf, document, range);
              if (vcsContentAnnotation.intervalRecentlyChanged(vf, correctedRange, recentChangeRevision)) {
                methodChanged = true;
                break;
              }
            }
            if (methodChanged) {
              consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + worker.getInfo().getSecond().getStartOffset(),
                                                         startOffset + lineStartOffset + worker.getInfo().getSecond().getEndOffset()));
            }
          }
        }
      }
    }
    previousLineResult = worker.getResult() == null ? null :
                         new Trinity<PsiClass, PsiFile, String>(worker.getPsiClass(), worker.getFile(), worker.getMethod());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:76,代码来源:VcsContentAnnotationExceptionFilter.java

示例11: applyHeavyFilter

import com.intellij.execution.filters.ExceptionWorker; //导入依赖的package包/类
@Override
public void applyHeavyFilter(final Document copiedFragment,
                             int startOffset,
                             int startLineNumber,
                             Consumer<AdditionalHighlight> consumer) {
  VcsContentAnnotation vcsContentAnnotation = VcsContentAnnotationImpl.getInstance(myProject);
  final LocalChangesCorrector localChangesCorrector = new LocalChangesCorrector(myProject);
  Trinity<PsiClass, PsiFile, String> previousLineResult = null;

  for (int i = 0; i < copiedFragment.getLineCount(); i++) {
    final int lineStartOffset = copiedFragment.getLineStartOffset(i);
    final int lineEndOffset = copiedFragment.getLineEndOffset(i);
    final ExceptionWorker worker = new ExceptionWorker(myProject, myScope);
    final String[] lineText = new String[1];
    ApplicationManager.getApplication().runReadAction(new Runnable() {
      @Override
      public void run() {
        lineText[0] = copiedFragment.getText(new TextRange(lineStartOffset, lineEndOffset));
        worker.execute(lineText[0], lineEndOffset);
      }
    });
    if (worker.getResult() != null) {
      VirtualFile vf = worker.getFile().getVirtualFile();
      if (vf.getFileSystem().isReadOnly()) continue;

      VcsRevisionNumber recentChangeRevision = myRevNumbersCache.get(vf);
      if (recentChangeRevision == null) {
        recentChangeRevision = vcsContentAnnotation.fileRecentlyChanged(vf);
        if (recentChangeRevision == null) {
          myRevNumbersCache.put(vf, VcsRevisionNumber.NULL);
        } else {
          myRevNumbersCache.put(vf, recentChangeRevision);
        }
      }
      if (VcsRevisionNumber.NULL.equals(recentChangeRevision)) {
        recentChangeRevision = null;
      }
      if (localChangesCorrector.isFileAlreadyIdentifiedAsChanged(vf) || ChangeListManager.isFileChanged(myProject, vf) ||
          recentChangeRevision != null) {
        final Document document = getDocumentForFile(worker);
        if (document == null) return;

        int startFileOffset = worker.getInfo().getThird().getStartOffset();
        int idx = lineText[0].indexOf(':', startFileOffset);
        int endIdx = idx == -1 ? worker.getInfo().getThird().getEndOffset() : idx;
        consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + startFileOffset + 1, startOffset + lineStartOffset + endIdx));

        if (worker.getPsiClass() != null) {
          // also check method
          final List<TextRange> ranges = findMethodRange(worker, document, previousLineResult);
          if (ranges != null) {
            boolean methodChanged = false;
            for (TextRange range : ranges) {
              if (localChangesCorrector.isRangeChangedLocally(vf, document, range)) {
                methodChanged = true;
                break;
              }
              final TextRange correctedRange = localChangesCorrector.getCorrectedRange(vf, document, range);
              if (vcsContentAnnotation.intervalRecentlyChanged(vf, correctedRange, recentChangeRevision)) {
                methodChanged = true;
                break;
              }
            }
            if (methodChanged) {
              consumer.consume(new MyAdditionalHighlight(startOffset + lineStartOffset + worker.getInfo().getSecond().getStartOffset(),
                                                         startOffset + lineStartOffset + worker.getInfo().getSecond().getEndOffset()));
            }
          }
        }
      }
    }
    previousLineResult = worker.getResult() == null ? null :
                         new Trinity<PsiClass, PsiFile, String>(worker.getPsiClass(), worker.getFile(), worker.getMethod());
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:76,代码来源:VcsContentAnnotationExceptionFilter.java


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