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


Java LookupImpl.performGuardedChange方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.lookup.impl.LookupImpl.performGuardedChange方法的典型用法代码示例。如果您正苦于以下问题:Java LookupImpl.performGuardedChange方法的具体用法?Java LookupImpl.performGuardedChange怎么用?Java LookupImpl.performGuardedChange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.lookup.impl.LookupImpl的用法示例。


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

示例1: restoreOldCaretPositionAndSelection

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
private void restoreOldCaretPositionAndSelection(final int offset) {
  //move to old offset
  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      myEditor.getCaretModel().moveToOffset(restoreCaretOffset(offset));
      restoreSelection();
    }
  };

  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null && lookup.getLookupStart() <= (restoreCaretOffset(offset))) {
    lookup.setFocusDegree(LookupImpl.FocusDegree.UNFOCUSED);
    lookup.performGuardedChange(runnable);
  }
  else {
    runnable.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:InplaceRefactoring.java

示例2: checkAutoPopup

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
@Override
public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
  LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);

  if (LOG.isDebugEnabled()) {
    LOG.debug("checkAutoPopup: character=" + charTyped + ";");
    LOG.debug("phase=" + CompletionServiceImpl.getCompletionPhase());
    LOG.debug("lookup=" + lookup);
    LOG.debug("currentCompletion=" + CompletionServiceImpl.getCompletionService().getCurrentCompletion());
  }

  if (lookup != null) {
    if (editor.getSelectionModel().hasSelection()) {
      lookup.performGuardedChange(() -> EditorModificationUtil.deleteSelectedText(editor));
    }
    return Result.STOP;
  }

  if (Character.isLetter(charTyped) || charTyped == '_') {
    AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
    return Result.STOP;
  }

  return Result.CONTINUE;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:CompletionAutoPopupHandler.java

示例3: perform

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
public void perform(final boolean generateFinal, final String modifier, final PsiVariable variable) {
  final Document document = myEditor.getDocument();
  LOG.assertTrue(variable != null);
  final PsiModifierList modifierList = variable.getModifierList();
  LOG.assertTrue(modifierList != null);
  final int textOffset = modifierList.getTextOffset();

  final Runnable runnable = new Runnable() {
    public void run() {
      if (generateFinal) {
        final PsiTypeElement typeElement = variable.getTypeElement();
        final int typeOffset = typeElement != null ? typeElement.getTextOffset() : textOffset;
        document.insertString(typeOffset, modifier + " ");
      }
      else {
        final int idx = modifierList.getText().indexOf(modifier);
        document.deleteString(textOffset + idx, textOffset + idx + modifier.length() + 1);
      }
    }
  };
  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null) {
    lookup.performGuardedChange(runnable);
  } else {
    runnable.run();
  }
  PsiDocumentManager.getInstance(variable.getProject()).commitDocument(document);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:FinalListener.java

示例4: checkAutoPopup

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
@Override
public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
  LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);

  if (LOG.isDebugEnabled()) {
    LOG.debug("checkAutoPopup: character=" + charTyped + ";");
    LOG.debug("phase=" + CompletionServiceImpl.getCompletionPhase());
    LOG.debug("lookup=" + lookup);
    LOG.debug("currentCompletion=" + CompletionServiceImpl.getCompletionService().getCurrentCompletion());
  }

  if (lookup != null) {
    if (editor.getSelectionModel().hasSelection()) {
      lookup.performGuardedChange(new Runnable() {
        @Override
        public void run() {
          EditorModificationUtil.deleteSelectedText(editor);
        }
      });
    }
    return Result.STOP;
  }

  if (Character.isLetter(charTyped) || charTyped == '_') {
    AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
    return Result.STOP;
  }

  return Result.CONTINUE;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:CompletionAutoPopupHandler.java

示例5: perform

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
public void perform(final boolean generateFinal, final String modifier, final GrVariable variable) {
  final Document document = myEditor.getDocument();
  LOG.assertTrue(variable != null);
  final GrModifierList modifierList = variable.getModifierList();
  LOG.assertTrue(modifierList != null);
  final int textOffset = modifierList.getTextOffset();

  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      if (generateFinal) {
        final GrTypeElement typeElement = variable.getTypeElementGroovy();
        final int typeOffset = typeElement != null ? typeElement.getTextOffset() : textOffset;
        document.insertString(typeOffset, modifier + " ");
      }
      else {
        final int idx = modifierList.getText().indexOf(modifier);
        document.deleteString(textOffset + idx, textOffset + idx + modifier.length() + 1);
      }
    }
  };
  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null) {
    lookup.performGuardedChange(runnable);
  } else {
    runnable.run();
  }
  PsiDocumentManager.getInstance(variable.getProject()).commitDocument(document);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:GrFinalListener.java

示例6: checkAutoPopup

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
@Override
public Result checkAutoPopup(char charTyped, final Project project, final Editor editor, final PsiFile file) {
  CompletionPhase oldPhase = CompletionServiceImpl.getCompletionPhase();
  if (oldPhase instanceof CompletionPhase.EmptyAutoPopup && ((CompletionPhase.EmptyAutoPopup)oldPhase).editor != editor) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  }


  if (oldPhase instanceof CompletionPhase.CommittingDocuments && ((CompletionPhase.CommittingDocuments)oldPhase).isRestartingCompletion()) {
    oldPhase.indicator.scheduleRestart();
    return Result.STOP;
  }

  LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(editor);
  if (lookup != null) {
    if (editor.getSelectionModel().hasSelection()) {
      lookup.performGuardedChange(new Runnable() {
        @Override
        public void run() {
          EditorModificationUtil.deleteSelectedText(editor);
        }
      });
    }
    return Result.STOP;
  }

  if (Character.isLetter(charTyped) || charTyped == '_') {
    AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
    return Result.STOP;
  }

  if (CompletionServiceImpl.isPhase(CompletionPhase.EmptyAutoPopup.class, CompletionPhase.CommittingDocuments.class)) {
    CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion);
  }
  return Result.CONTINUE;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:CompletionAutoPopupHandler.java

示例7: perform

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
public void perform(final boolean generateFinal, final String modifier, final GrVariable variable) {
  final Document document = myEditor.getDocument();
  LOG.assertTrue(variable != null);
  final GrModifierList modifierList = variable.getModifierList();
  LOG.assertTrue(modifierList != null);
  final int textOffset = modifierList.getTextOffset();

  final Runnable runnable = new Runnable() {
    public void run() {
      if (generateFinal) {
        final GrTypeElement typeElement = variable.getTypeElementGroovy();
        final int typeOffset = typeElement != null ? typeElement.getTextOffset() : textOffset;
        document.insertString(typeOffset, modifier + " ");
      }
      else {
        final int idx = modifierList.getText().indexOf(modifier);
        document.deleteString(textOffset + idx, textOffset + idx + modifier.length() + 1);
      }
    }
  };
  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null) {
    lookup.performGuardedChange(runnable);
  } else {
    runnable.run();
  }
  PsiDocumentManager.getInstance(variable.getProject()).commitDocument(document);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:29,代码来源:GrFinalListener.java

示例8: perform

import com.intellij.codeInsight.lookup.impl.LookupImpl; //导入方法依赖的package包/类
/**
 * to be performed in write action
 */
public void perform(final PsiVariable variable) {
  ApplicationManager.getApplication().assertWriteAccessAllowed();

  final Document document = myEditor.getDocument();
  LOG.assertTrue(variable != null);
  final PsiModifierList modifierList = variable.getModifierList();
  LOG.assertTrue(modifierList != null);
  int textOffset = modifierList.getTextOffset();
  final String modifierListText = modifierList.getText();

  int length = PsiModifier.PUBLIC.length();
  int idx = modifierListText.indexOf(PsiModifier.PUBLIC);

  if (idx == -1) {
    idx = modifierListText.indexOf(PsiModifier.PROTECTED);
    length = PsiModifier.PROTECTED.length();
  }

  if (idx == -1) {
    idx = modifierListText.indexOf(PsiModifier.PRIVATE);
    length = PsiModifier.PRIVATE.length();
  }

  String visibility = getVisibility();
  if (visibility == PsiModifier.PACKAGE_LOCAL) {
    visibility = "";
  }

  final boolean wasPackageLocal = idx == -1;
  final boolean isPackageLocal = visibility.isEmpty();

  final int startOffset = textOffset + (wasPackageLocal ? 0 : idx);
  final int endOffset;
  if (wasPackageLocal) {
    endOffset = startOffset;
  }
  else {
    endOffset = textOffset + length + (isPackageLocal ? 1 : 0);
  }

  final String finalVisibility = visibility + (wasPackageLocal ? " " : "");

  Runnable runnable = new Runnable() {
    @Override
    public void run() {
      document.replaceString(startOffset, endOffset, finalVisibility);
    }
  };

  final LookupImpl lookup = (LookupImpl)LookupManager.getActiveLookup(myEditor);
  if (lookup != null) {
    lookup.performGuardedChange(runnable);
  } else {
    runnable.run();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:60,代码来源:VisibilityListener.java


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