本文整理汇总了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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
示例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;
}
});
}
示例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;
}
});
}
示例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;
}
示例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;
}
示例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());
}
}
示例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());
}
}