Tabnine Logo
com.intellij.codeInsight
Code IndexAdd Tabnine to your IDE (free)

How to use com.intellij.codeInsight

Best Java code snippets using com.intellij.codeInsight (Showing top 20 results out of 315)

origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public void invoke(@NotNull Project project, @NotNull PsiFile file, @Nullable("is null when called from inspection") Editor editor,
          @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
 if (!FileModificationService.getInstance().prepareFileForWrite(file)) return;
 perform(getImportPathVariantsToImport(startElement), file, editor);
}
origin: go-lang-plugin-org/go-lang-idea-plugin

 @Override
 public void visitElement(@NotNull PsiElement element) {
  if (PsiEquivalenceUtil.areElementsEquivalent(element, pattern)) {
   occurrences.add(element);
   return;
  }
  super.visitElement(element);
 }
};
origin: go-lang-plugin-org/go-lang-idea-plugin

 private void doInsert(InsertionContext context, @NotNull LookupElement item, @Nullable GoSignature signature) {
  int paramsCount = signature != null ? signature.getParameters().getParameterDeclarationList().size() : 0;
  InsertHandler<LookupElement> handler = paramsCount == 0 ? ParenthesesInsertHandler.NO_PARAMETERS : ParenthesesInsertHandler.WITH_PARAMETERS;
  handler.handleInsert(context, item);
  if (signature != null) {
   AutoPopupController.getInstance(context.getProject()).autoPopupParameterInfo(context.getEditor(), null);
  }
 }
};
origin: ballerina-platform/ballerina-lang

public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  char completionChar = context.getCompletionChar();
  if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
    return;
  }
  Project project = editor.getProject();
  if (project != null) {
    int completionCharOffset = getCompletionCharOffset(editor);
    if (completionCharOffset == -1) {
      EditorModificationUtil.insertStringAtCaret(editor, "()", false, 1);
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
    } else {
      editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
    }
    if (myTriggerAutoPopup) {
      AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
    }
  }
}
origin: go-lang-plugin-org/go-lang-idea-plugin

 @Override
 public void handleInsert(@NotNull InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  int tailOffset = context.getTailOffset();
  Document document = editor.getDocument();
  context.commitDocument();
  boolean staysAtChar = document.getTextLength() > tailOffset &&
             document.getCharsSequence().charAt(tailOffset) == myChar;

  context.setAddCompletionChar(false);
  if (!staysAtChar) {
   document.insertString(tailOffset, String.valueOf(myChar));
  }
  editor.getCaretModel().moveToOffset(tailOffset + 1);

  AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(editor);
 }
}
origin: ballerina-platform/ballerina-lang

ApplicationManager.getApplication().invokeLater(() -> {
  CommandProcessor.getInstance().runUndoTransparentAction(() -> {
    PsiElement element = item.getPsiElement();
    if (element == null) {
      return;
    PsiFile file = context.getFile();
    if (!(file instanceof BallerinaFile)) {
      return;
    Editor editor = context.getEditor();
    Project project = editor.getProject();
    if (suggestAlias) {
      if (suggestAlias) {
        PsiElement currentPackageName = file.findElementAt(context.getStartOffset());
        if (currentPackageName != null) {
          if (alias == null || alias.isEmpty()) {
          () -> AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null)
      );
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public void invoke(@NotNull Project project,
          @NotNull PsiFile file,
          @Nullable("is null when called from inspection") Editor editor,
          @NotNull PsiElement startElement,
          @NotNull PsiElement endElement) {
 if (editor == null) {
  LOG.error("Cannot run quick fix without editor: " + getClass().getSimpleName(),
       AttachmentFactory.createAttachment(file.getVirtualFile()));
  return;
 }
 if (!(startElement instanceof GoType)) return;
 GoType type = (GoType)startElement;
 PsiElement anchor = PsiTreeUtil.findPrevParent(file, type);
 String name = "TypeName";
 GoTypeDeclaration decl = (GoTypeDeclaration)file.addBefore(GoElementFactory.createTypeDeclaration(project, name, type), anchor);
 if (decl == null) return;
 decl = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(decl);
 if (decl == null) return;
 GoTypeSpec spec = ContainerUtil.getFirstItem(decl.getTypeSpecList());
 if (spec == null) return;
 TemplateBuilderImpl builder = new TemplateBuilderImpl(file);
 builder.replaceElement(type, OTHER_NAME, INPUT_NAME, false);
 builder.replaceElement(spec.getIdentifier(), INPUT_NAME, new ConstantNode(name), true);
 editor.getCaretModel().moveToOffset(file.getTextRange().getStartOffset());
 Template template = builder.buildInlineTemplate();
 editor.getCaretModel().moveToOffset(file.getTextRange().getStartOffset());
 TemplateManager.getInstance(project).startTemplate(editor, template);
}
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
protected void tearDown() throws Exception {
 try {
  updateSettings(defaultGoOnTheFly);
  CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
  codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY = defaultJavaMemberOnTheFly;
  codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = defaultJavaOnTheFly;
 }
 finally {
  //noinspection ThrowFromFinallyBlock
  super.tearDown();
 }
}
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public void invoke(@NotNull Project project, @NotNull Editor editor, @NotNull PsiFile file) {
 if (!(file instanceof GoFile)) {
  return;
 }
 String testingQualifier = null;
 if (myType.getParamType() != null) {
  testingQualifier = importTestingPackageIfNeeded((GoFile)file);
  PsiDocumentManager.getInstance(file.getProject()).doPostponedOperationsAndUnblockDocument(editor.getDocument());
 }
 String functionText = "func " + myType.getPrefix();
 int offset = functionText.length();
 functionText += "(" + myType.getSignature(testingQualifier) + ") {\n\t\n}";
 EditorModificationUtil.insertStringAtCaret(editor, functionText, false, offset);
 AutoPopupController.getInstance(project).scheduleAutoPopup(editor);
}
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
public void invoke(@NotNull Project project,
          @NotNull PsiFile file,
          @NotNull PsiElement startElement,
          @NotNull PsiElement endElement) {
 if (!FileModificationService.getInstance().preparePsiElementsForWrite(startElement)) return;
 Runnable runnable = () -> {
  AsyncResult<DataContext> dataContextContainer = DataManager.getInstance().getDataContextFromFocus();
  dataContextContainer.doWhenDone(new Consumer<DataContext>() {
   @Override
   public void consume(DataContext dataContext) {
    RenameHandler renameHandler = RenameHandlerRegistry.getInstance().getRenameHandler(dataContext);
    if (renameHandler != null) {
     renameHandler.invoke(project, new PsiElement[]{startElement}, dataContext);
    }
    else {
     RefactoringActionHandler renameRefactoringHandler = RefactoringActionHandlerFactory.getInstance().createRenameHandler();
     renameRefactoringHandler.invoke(project, new PsiElement[]{startElement}, dataContext);
    }
   }
  });
 };
 if (ApplicationManager.getApplication().isUnitTestMode()) {
  runnable.run();
 }
 else {
  ApplicationManager.getApplication().invokeLater(runnable, project.getDisposed());
 }
}
origin: mapstruct/mapstruct-idea

/**
 * Checks of the {@code psiClass} is annotated with {@link Mapper}.
 *
 * @param psiClass the class that needs to be checked
 *
 * @return {@code true} if the {@code psiClass} is annotated with {@link Mapper}, {@code false} otherwise
 */
public static boolean isMapper(PsiClass psiClass) {
  return isAnnotated( psiClass, MAPPER_ANNOTATION_FQN, false );
}
origin: go-lang-plugin-org/go-lang-idea-plugin

builder.append(CodeInsightBundle.message("parameter.info.no.parameters"));
origin: ballerina-platform/ballerina-lang

public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  char completionChar = context.getCompletionChar();
  if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
    return;
  }
  Project project = editor.getProject();
  if (project != null) {
    int completionCharOffset = getCompletionCharOffset(editor);
    if (completionCharOffset == -1) {
      EditorModificationUtil.insertStringAtCaret(editor, "();", false, 1);
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
    } else {
      editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
    }
    if (myTriggerAutoPopup) {
      AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
    }
  }
}
origin: ballerina-platform/ballerina-lang

  @Override
  public void handleInsert(@NotNull InsertionContext context, LookupElement item) {
    Editor editor = context.getEditor();
    int tailOffset = context.getTailOffset();
    Document document = editor.getDocument();
    context.commitDocument();
    boolean staysAtChar = (document.getTextLength() > tailOffset) &&
        (document.getCharsSequence().charAt(tailOffset) == myCharacter);
    context.setAddCompletionChar(false);
    if (!staysAtChar) {
      document.insertString(tailOffset, String.valueOf(myCharacter));
    }
    editor.getCaretModel().moveToOffset(tailOffset + 1);
    AutoPopupController.getInstance(context.getProject()).scheduleAutoPopup(editor);
  }
}
origin: ballerina-platform/ballerina-lang

@Override
public void invoke(@NotNull Project project, @NotNull PsiFile file,
          @Nullable("is null when called from inspection") Editor editor,
          @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
  if (!FileModificationService.getInstance().prepareFileForWrite(file)) {
    return;
  }
  if (!(file instanceof BallerinaFile)) {
    return;
  }
  BallerinaFile ballerinaFile = ((BallerinaFile) file);
  PsiReference reference = startElement.getReference();
  if (reference != null && reference.resolve() != null) {
    return;
  }
  List<String> importPathVariantsToImport = getImportPathVariantsToImport(startElement);
  if (importPathVariantsToImport.size() == 1) {
    Runnable addImport = () -> BallerinaFile.addImport(ballerinaFile, importPathVariantsToImport.get(0), null);
    CommandProcessor.getInstance().runUndoTransparentAction(
        () -> ApplicationManager.getApplication().runWriteAction(addImport)
    );
  } else {
    performImport(importPathVariantsToImport, ballerinaFile, editor);
  }
}
origin: go-lang-plugin-org/go-lang-idea-plugin

@Override
protected void setUp() throws Exception {
 super.setUp();
 myFixture.enableInspections(GoUnresolvedReferenceInspection.class);
 ((CodeInsightTestFixtureImpl)myFixture).canChangeDocumentDuringHighlighting(true);
 CodeInsightSettings codeInsightSettings = CodeInsightSettings.getInstance();
 defaultJavaOnTheFly = codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY;
 defaultJavaMemberOnTheFly = codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY;
 defaultGoOnTheFly = GoCodeInsightSettings.getInstance().isAddUnambiguousImportsOnTheFly();
 codeInsightSettings.ADD_UNAMBIGIOUS_IMPORTS_ON_THE_FLY = true;
 codeInsightSettings.ADD_MEMBER_IMPORTS_ON_THE_FLY = true;
}
origin: ballerina-platform/ballerina-lang

public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  char completionChar = context.getCompletionChar();
  if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
    return;
  }
  Project project = editor.getProject();
  if (project != null) {
    int completionCharOffset = getCompletionCharOffset(editor);
    if (completionCharOffset == -1) {
      EditorModificationUtil.insertStringAtCaret(editor, ";", false, 1);
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
    } else {
      editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
    }
    if (myTriggerAutoPopup) {
      AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
    }
  }
}
origin: ballerina-platform/ballerina-lang

public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  char completionChar = context.getCompletionChar();
  if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
    return;
  }
  Project project = editor.getProject();
  if (project != null) {
    int completionCharOffset = getCompletionCharOffset(editor);
    if (completionCharOffset == -1) {
      EditorModificationUtil.insertStringAtCaret(editor, " {}", false, 2);
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
    } else {
      editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
    }
    if (myTriggerAutoPopup) {
      AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
    }
  }
}
origin: ballerina-platform/ballerina-lang

public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  char completionChar = context.getCompletionChar();
  if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
    return;
  }
  Project project = editor.getProject();
  if (project != null) {
    int completionCharOffset = getCompletionCharOffset(editor);
    if (completionCharOffset == -1) {
      EditorModificationUtil.insertStringAtCaret(editor, ":", false, 1);
      if (myWithSpace) {
        EditorModificationUtil.insertStringAtCaret(editor, " ", false, 1);
      }
      PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
    } else {
      editor.getCaretModel().moveToOffset(editor.getCaretModel().getOffset() + completionCharOffset + 1);
    }
    if (myTriggerAutoPopup) {
      AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
    }
  }
}
origin: ballerina-platform/ballerina-lang

public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  char completionChar = context.getCompletionChar();
  if (completionChar == ' ' || StringUtil.containsChar(myIgnoreOnChars, completionChar)) {
    return;
    int completionCharOffset = getCompletionCharOffset(editor);
    if (completionCharOffset == -1) {
      PsiElement psiElement = item.getPsiElement();
      if (psiElement != null) {
        String hasAReturnValue = psiElement.getUserData(HAS_A_RETURN_VALUE);
      AutoPopupController.getInstance(project).autoPopupMemberLookup(editor, null);
com.intellij.codeInsight

Most used classes

  • LookupElementBuilder
  • CompletionParameters
  • CompletionResultSet
  • LookupElement
  • LookupElementPresentation
  • DaemonCodeAnalyzer,
  • TypedHandlerDelegate,
  • PrefixMatcher,
  • CamelHumpMatcher,
  • LineMarkerInfo,
  • HintManager,
  • LookupManager,
  • NavigationGutterIconBuilder,
  • CodeInsightSettings,
  • TargetElementUtil,
  • CodeCompletionHandlerBase,
  • PrioritizedLookupElement,
  • DocumentationManager,
  • Template
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now