本文整理汇总了Java中com.intellij.openapi.progress.ProgressIndicatorProvider.checkCanceled方法的典型用法代码示例。如果您正苦于以下问题:Java ProgressIndicatorProvider.checkCanceled方法的具体用法?Java ProgressIndicatorProvider.checkCanceled怎么用?Java ProgressIndicatorProvider.checkCanceled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.progress.ProgressIndicatorProvider
的用法示例。
在下文中一共展示了ProgressIndicatorProvider.checkCanceled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findFilesWithoutAttrs
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@NotNull
private Collection<VirtualFile> findFilesWithoutAttrs(@NotNull VirtualFile root, @NotNull Collection<VirtualFile> files) {
GitRepository repository = myPlatformFacade.getRepositoryManager(myProject).getRepositoryForRoot(root);
if (repository == null) {
LOG.warn("Repository is null for " + root);
return Collections.emptyList();
}
Collection<String> interestingAttributes = Arrays.asList(GitAttribute.TEXT.getName(), GitAttribute.CRLF.getName());
GitCommandResult result = myGit.checkAttr(repository, interestingAttributes, files);
if (!result.success()) {
LOG.warn(String.format("Couldn't git check-attr. Attributes: %s, files: %s", interestingAttributes, files));
return Collections.emptyList();
}
GitCheckAttrParser parser = GitCheckAttrParser.parse(result.getOutput());
Map<String, Collection<GitAttribute>> attributes = parser.getAttributes();
Collection<VirtualFile> filesWithoutAttrs = new ArrayList<VirtualFile>();
for (VirtualFile file : files) {
ProgressIndicatorProvider.checkCanceled();
String relativePath = FileUtil.getRelativePath(root.getPath(), file.getPath(), '/');
Collection<GitAttribute> attrs = attributes.get(relativePath);
if (attrs == null || !attrs.contains(GitAttribute.TEXT) && !attrs.contains(GitAttribute.CRLF)) {
filesWithoutAttrs.add(file);
}
}
return filesWithoutAttrs;
}
示例2: findClass
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope) {
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
Map<String, PsiClass> map = myClassCache.get(scope);
if (map == null) {
map = ContainerUtil.createConcurrentWeakValueMap();
map = ConcurrencyUtil.cacheOrGet(myClassCache, scope, map);
}
PsiClass result = map.get(qualifiedName);
if (result == null) {
result = doFindClass(qualifiedName, scope);
if (result != null) {
map.put(qualifiedName, result);
}
}
return result;
}
示例3: findReplacement
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Nullable
private static PsiLocalVariable findReplacement(@NotNull PsiMethod method,
@NotNull PsiVariable castedVar,
@NotNull PsiTypeCastExpression expression) {
final TextRange expressionTextRange = expression.getTextRange();
for (PsiExpression occurrence : CodeInsightUtil.findExpressionOccurrences(method,expression)){
ProgressIndicatorProvider.checkCanceled();
final TextRange occurrenceTextRange = occurrence.getTextRange();
if (occurrence == expression || occurrenceTextRange.getEndOffset() >= expressionTextRange.getStartOffset()) {
continue;
}
final PsiLocalVariable variable = getVariable(occurrence);
final PsiCodeBlock methodBody = method.getBody();
if (variable != null && methodBody != null &&
!isChangedBetween(castedVar, methodBody, occurrence, expression) && !isChangedBetween(variable, methodBody, occurrence, expression)) {
return variable;
}
}
return null;
}
示例4: processChildren
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
checkValid();
ProgressIndicatorProvider.checkCanceled();
for (VirtualFile vFile : myFile.getChildren()) {
boolean isDir = vFile.isDirectory();
if (processor instanceof PsiFileSystemItemProcessor && !((PsiFileSystemItemProcessor)processor).acceptItem(vFile.getName(), isDir)) {
continue;
}
PsiFileSystemItem item = isDir ? myManager.findDirectory(vFile) : myManager.findFile(vFile);
if (item != null && !processor.execute(item)) {
return false;
}
}
return true;
}
示例5: insertLeaves
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
private int insertLeaves(int curToken, int lastIdx, final CompositeElement curNode) {
lastIdx = Math.min(lastIdx, myLexemeCount);
while (curToken < lastIdx) {
ProgressIndicatorProvider.checkCanceled();
final int start = myLexStarts[curToken];
final int end = myLexStarts[curToken + 1];
if (start < end || myLexTypes[curToken] instanceof ILeafElementType) { // Empty token. Most probably a parser directive like indent/dedent in Python
final IElementType type = myLexTypes[curToken];
final TreeElement leaf = createLeaf(type, start, end);
curNode.rawAddChildrenWithoutNotifications(leaf);
}
curToken++;
}
return curToken;
}
示例6: nextToken
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
/** Create an ANTLR Token from the current token type of the builder
* then advance the builder to next token (which ultimately calls an
* ANTLR lexer). The {@link ANTLRLexerAdaptor} creates tokens via
* an ANTLR lexer but converts to {@link TokenIElementType} and here
* we have to convert back to an ANTLR token using what info we
* can get from the builder. We lose info such as the original channel.
* So, whitespace and comments (typically hidden channel) will look like
* real tokens. Jetbrains uses {@link ParserDefinition#getWhitespaceTokens()}
* and {@link ParserDefinition#getCommentTokens()} to strip these before
* our ANTLR parser sees them.
*/
@Override
public Token nextToken() {
ProgressIndicatorProvider.checkCanceled();
TokenIElementType ideaTType = (TokenIElementType)builder.getTokenType();
int type = ideaTType!=null ? ideaTType.getANTLRTokenType() : Token.EOF;
int channel = Token.DEFAULT_CHANNEL;
Pair<TokenSource, CharStream> source = new Pair<TokenSource, CharStream>(this, null);
String text = builder.getTokenText();
int start = builder.getCurrentOffset();
int length = text != null ? text.length() : 0;
int stop = start + length - 1;
// PsiBuilder doesn't provide line, column info
int line = 0;
int charPositionInLine = 0;
Token t = tokenFactory.create(source, type, text, channel, start, stop, line, charPositionInLine);
builder.advanceLexer();
// System.out.println("TOKEN: "+t);
return t;
}
示例7: visitDeclarationStatement
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public void visitDeclarationStatement(PsiDeclarationStatement statement) {
startElement(statement);
int pc = myCurrentFlow.getSize();
PsiElement[] elements = statement.getDeclaredElements();
for (PsiElement element : elements) {
ProgressIndicatorProvider.checkCanceled();
if (element instanceof PsiClass) {
element.accept(this);
}
else if (element instanceof PsiVariable) {
processVariable((PsiVariable)element);
}
}
if (pc == myCurrentFlow.getSize()) {
// generate at least one instruction for declaration
emitEmptyInstruction();
}
finishElement(statement);
}
示例8: addUsedVariables
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
private void addUsedVariables(List<PsiVariable> array, PsiElement scope) {
if (scope instanceof PsiReferenceExpression) {
PsiVariable variable = getUsedVariable((PsiReferenceExpression)scope);
if (variable != null) {
if (!array.contains(variable)) {
array.add(variable);
}
}
}
PsiElement[] children = scope.getChildren();
for (PsiElement child : children) {
ProgressIndicatorProvider.checkCanceled();
addUsedVariables(array, child);
}
}
示例9: processChildren
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public boolean processChildren(PsiElementProcessor<PsiFileSystemItem> processor) {
checkValid();
ProgressIndicatorProvider.checkCanceled();
for (VirtualFile vFile : myFile.getChildren()) {
boolean isDir = vFile.isDirectory();
if (processor instanceof PsiFileSystemItemProcessor &&
!((PsiFileSystemItemProcessor)processor).acceptItem(vFile.getName(), isDir)) {
continue;
}
if (isDir) {
PsiDirectory dir = myManager.findDirectory(vFile);
if (dir != null) {
if (!processor.execute(dir)) return false;
}
}
else {
PsiFile file = myManager.findFile(vFile);
if (file != null) {
if (!processor.execute(file)) return false;
}
}
}
return true;
}
示例10: processClassesByNames
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
public static boolean processClassesByNames(Project project, final GlobalSearchScope scope, Collection<String> names, Processor<PsiClass> processor)
{
final PsiShortNamesCache cache = PsiShortNamesCache.getInstance(project);
for(final String name : names)
{
ProgressIndicatorProvider.checkCanceled();
final PsiClass[] classes = MethodUsagesSearcher.resolveInReadAction(project, new Computable<PsiClass[]>()
{
@Override
public PsiClass[] compute()
{
return cache.getClassesByName(name, scope);
}
});
for(PsiClass psiClass : classes)
{
ProgressIndicatorProvider.checkCanceled();
if(!processor.process(psiClass))
{
return false;
}
}
}
return true;
}
示例11: findClass
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public PsiClass findClass(@NotNull final String qualifiedName, @NotNull GlobalSearchScope scope)
{
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
if(DumbService.getInstance(getProject()).isDumb())
{
PsiClass[] classes = findClassesInDumbMode(qualifiedName, scope);
if(classes.length != 0)
{
return classes[0];
}
return null;
}
for(PsiElementFinder finder : finders())
{
PsiClass aClass = finder.findClass(qualifiedName, scope);
if(aClass != null)
{
return aClass;
}
}
return null;
}
示例12: treeWalkUp
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
public static boolean treeWalkUp(@NotNull final PsiScopeProcessor processor,
@NotNull final PsiElement entrance,
@Nullable final PsiElement maxScope,
@NotNull final ResolveState state) {
if (!entrance.isValid()) {
LOG.error(new PsiInvalidElementAccessException(entrance));
}
PsiElement prevParent = entrance;
PsiElement scope = entrance;
while (scope != null) {
ProgressIndicatorProvider.checkCanceled();
if (scope instanceof PsiClass) {
processor.handleEvent(JavaScopeProcessorEvent.SET_CURRENT_FILE_CONTEXT, scope);
}
if (!scope.processDeclarations(processor, state, prevParent, entrance)) {
return false; // resolved
}
if (scope instanceof PsiModifierListOwner && !(scope instanceof PsiParameter/* important for not loading tree! */)) {
PsiModifierList modifierList = ((PsiModifierListOwner)scope).getModifierList();
if (modifierList != null && modifierList.hasModifierProperty(PsiModifier.STATIC)) {
processor.handleEvent(JavaScopeProcessorEvent.START_STATIC, null);
}
}
if (scope == maxScope) break;
prevParent = scope;
scope = prevParent.getContext();
processor.handleEvent(JavaScopeProcessorEvent.CHANGE_LEVEL, null);
}
return true;
}
示例13: resolve
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Nullable
private <TRef extends PsiReference, TResult> TResult resolve(@NotNull final TRef ref,
@NotNull final AbstractResolver<TRef, TResult> resolver,
boolean needToPreventRecursion,
final boolean incompleteCode,
boolean isPoly,
boolean isPhysical) {
ProgressIndicatorProvider.checkCanceled();
if (isPhysical) {
ApplicationManager.getApplication().assertReadAccessAllowed();
}
int index = getIndex(isPhysical, incompleteCode, isPoly);
ConcurrentMap<TRef, TResult> map = getMap(index);
TResult result = map.get(ref);
if (result != null) {
return result;
}
RecursionGuard.StackStamp stamp = myGuard.markStack();
result = needToPreventRecursion ? myGuard.doPreventingRecursion(Trinity.create(ref, incompleteCode, isPoly), true, new Computable<TResult>() {
@Override
public TResult compute() {
return resolver.resolve(ref, incompleteCode);
}
}) : resolver.resolve(ref, incompleteCode);
PsiElement element = result instanceof ResolveResult ? ((ResolveResult)result).getElement() : null;
LOG.assertTrue(element == null || element.isValid(), result);
if (stamp.mayCacheNow()) {
cache(ref, map, result);
}
return result;
}
示例14: advanceLexer
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public void advanceLexer() {
ProgressIndicatorProvider.checkCanceled();
if (eof()) return;
if (!myTokenTypeChecked) {
LOG.error("Probably a bug: eating token without its type checking");
}
myTokenTypeChecked = false;
myCurrentLexeme++;
clearCachedTokenType();
}
示例15: getPsi
import com.intellij.openapi.progress.ProgressIndicatorProvider; //导入方法依赖的package包/类
@Override
public final PsiElement getPsi() {
ProgressIndicatorProvider.checkCanceled(); // We hope this method is being called often enough to cancel daemon processes smoothly
PsiElement wrapper = myWrapper;
if (wrapper != null) return wrapper;
synchronized (PsiLock.LOCK) {
wrapper = myWrapper;
if (wrapper != null) return wrapper;
return createAndStorePsi();
}
}