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


Java Editor.getProject方法代码示例

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


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

示例1: generateGherkinRunIcons

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
public void generateGherkinRunIcons(Document rootDocument, Editor rootEditor) {
    for (int i = 0; i < rootDocument.getLineCount(); i++) {
        int startOffset = rootDocument.getLineStartOffset(i);
        int endOffset = rootDocument.getLineEndOffset(i);

        String lineText = rootDocument.getText(new TextRange(startOffset, endOffset)).trim();

        Icon icon;
        if (lineText.matches(SCENARIO_REGEX)) {
            icon = GherkinIconRenderer.SCENARIO_ICON;
        } else if (lineText.matches(FEATURE_REGEX)) {
            icon = GherkinIconRenderer.FEATURE_ICON;
        } else {
            // System.out.println();
             continue;
        }
        GherkinIconRenderer gherkinIconRenderer = new GherkinIconRenderer(rootEditor.getProject(), fileName);
        gherkinIconRenderer.setLine(i);
        gherkinIconRenderer.setIcon(icon);

        RangeHighlighter rangeHighlighter = createRangeHighlighter(rootDocument, rootEditor, i, i, new TextAttributes());
        rangeHighlighter.setGutterIconRenderer(gherkinIconRenderer);
    }
}
 
开发者ID:KariiO,项目名称:Gherkin-TS-Runner,代码行数:25,代码来源:GherkinIconUtils.java

示例2: execute

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
public void execute(@NotNull Editor editor, char charTyped, @NotNull DataContext dataContext) {
  myOriginalHandler.execute(editor, charTyped, dataContext);
  if (isMatchForClosingTag(editor, charTyped)) {
    int offset = editor.getCaretModel().getOffset();
    PsiFile file = dataContext.getData(LangDataKeys.PSI_FILE);
    if (file == null) {
      return;
    }
    PsiElement el = file.findElementAt(offset - 1);
    TagBlockElement block = (TagBlockElement) PsiTreeUtil
        .findFirstParent(el,
            parent -> parent instanceof TagBlockElement && !(parent instanceof SoyChoiceClause));
    if (block == null) {
      return;
    }
    String closingTag = block.getOpeningTag().generateClosingTag();
    insertClosingTag(editor, offset, closingTag);
    if (editor.getProject() != null) {
      PsiDocumentManager.getInstance(editor.getProject()).commitDocument(editor.getDocument());
      CodeStyleManager.getInstance(editor.getProject()).reformat(block);
    }
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:24,代码来源:ClosingTagHandler.java

示例3: highlightCurrentColumn

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
@Override
@Contract
public void highlightCurrentColumn(@NotNull final Editor editor) {
    Validate.notNull(editor);

    final Project project = editor.getProject();

    if (null == project) {
        return;
    }

    if (project.isDisposed()) {
        return;
    }

    final Language languageInEditor = PsiUtilBase.getLanguageInEditor(editor, project);

    if (languageInEditor instanceof ImpexLanguage) {
        this.highlightColumnOfValueUnderCaret(editor);
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:DefaultImpexColumnHighlighterService.java

示例4: highlightCurrentHeader

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
@Override
@Contract(pure = false)
public void highlightCurrentHeader(@NotNull final Editor editor) {
    Validate.notNull(editor);

    final Project project = editor.getProject();

    if (null == project) {
        return;
    }

    if (project.isDisposed()) {
        return;
    }

    final Language languageInEditor = PsiUtilBase.getLanguageInEditor(editor, project);

    if (languageInEditor instanceof ImpexLanguage) {
        this.highlightHeaderOfValueUnderCaret(editor);
    }
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:22,代码来源:DefaultImpexHeaderNameHighlighterService.java

示例5: drawAllAnswerPlaceholders

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
public static void drawAllAnswerPlaceholders(Editor editor, TaskFile taskFile) {
  editor.getMarkupModel().removeAllHighlighters();
  final Project project = editor.getProject();
  if (project == null) return;
  final StudyTaskManager taskManager = StudyTaskManager.getInstance(project);
  for (AnswerPlaceholder answerPlaceholder : taskFile.getAnswerPlaceholders()) {
    final JBColor color = taskManager.getColor(answerPlaceholder);
    EduAnswerPlaceholderPainter.drawAnswerPlaceholder(editor, answerPlaceholder, color);
  }

  final Document document = editor.getDocument();
  EditorActionManager.getInstance()
    .setReadonlyFragmentModificationHandler(document, new EduAnswerPlaceholderDeleteHandler(editor));
  EduAnswerPlaceholderPainter.createGuardedBlocks(editor, taskFile);
  editor.getColorsScheme().setColor(EditorColors.READONLY_FRAGMENT_BACKGROUND_COLOR, null);
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:17,代码来源:StudyUtils.java

示例6: isClearHighlights

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
private static boolean isClearHighlights(@NotNull Editor editor) {
    if (editor instanceof EditorWindow) {
        editor = ((EditorWindow) editor).getDelegate();
    }
    
    final Project project = editor.getProject();
    if (project == null) {
        Log.error("isClearHighlights: editor.getProject() == null");
        return false;
    }
    
    int caretOffset = editor.getCaretModel().getOffset();
    final RangeHighlighter[] highlighters =
            ((HighlightManagerImpl) HighlightManager.getInstance(project)).getHighlighters(
                    editor);
    for (RangeHighlighter highlighter : highlighters) {
        if (TextRange.create(highlighter).grown(1).contains(caretOffset)) {
            return true;
        }
    }
    
    return false;
}
 
开发者ID:huoguangjin,项目名称:MultiHighlight,代码行数:24,代码来源:MultiHighlightHandler.java

示例7: handleInsert

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
public void handleInsert(InsertionContext context, LookupElement item) {
  Editor editor = context.getEditor();
  Project project = editor.getProject();

  if (project != null) {
    EditorModificationUtil.insertStringAtCaret(
        editor, closingTagBeforeCaret + closingTagAfterCaret);
    PsiDocumentManager.getInstance(project).commitDocument(editor.getDocument());
    EditorModificationUtil.moveCaretRelatively(editor, -closingTagAfterCaret.length());
  }
}
 
开发者ID:google,项目名称:bamboo-soy,代码行数:12,代码来源:PostfixInsertHandler.java

示例8: unfoldMethodsInCurrentFile

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
private void unfoldMethodsInCurrentFile(Editor editor) {
	Project project = editor.getProject();
	if (project != null) {
		PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
		methodFolder.unfoldMethods(editor, methodFinder.findMethodsCalledBy(psiFile));
	}
}
 
开发者ID:AWeinb,项目名称:IntellijMethodHierarchyHighlighter,代码行数:8,代码来源:MethodHighlighter.java

示例9: isInSameFile

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
private boolean isInSameFile(Editor editor, PsiElement psiElement) {
	Project project = editor.getProject();
	if (project != null) {
		PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
		return Objects.equals(psiFile, psiElement.getContainingFile());
	}
	return false;
}
 
开发者ID:AWeinb,项目名称:IntellijMethodHierarchyHighlighter,代码行数:9,代码来源:MethodHighlighter.java

示例10: modifyHighlightedArea

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
@Contract
protected void modifyHighlightedArea(
    @NotNull final Editor editor,
    @NotNull final List<PsiElement> column,
    final boolean clear
) {
    Validate.notNull(editor);
    Validate.notNull(column);

    if (null == editor.getProject()) {
        return;
    }

    if (editor.getProject().isDisposed()) {
        return;
    }

    // This list must be modifiable
    // https://bitbucket.org/AlexanderBartash/impex-editor-intellij-idea-plugin/issue/11/unsupportedoperationexception-null
    final List<TextRange> ranges = newArrayList();
    column.forEach((cell) -> ranges.add(cell.getTextRange()));

    HighlightUsagesHandler.highlightRanges(
        HighlightManager.getInstance(editor.getProject()),
        editor,
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES),
        clear,
        ranges
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:31,代码来源:DefaultImpexColumnHighlighterService.java

示例11: modifyHighlightedArea

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
@Contract(pure = false)
protected void modifyHighlightedArea(
    @NotNull final Editor editor,
    @NotNull final PsiElement impexFullHeaderParameter,
    final boolean clear
) {
    Validate.notNull(editor);
    Validate.notNull(impexFullHeaderParameter);

    if (null == editor.getProject()) {
        return;
    }

    if (editor.getProject().isDisposed()) {
        return;
    }

    // This list must be modifiable
    // https://bitbucket.org/AlexanderBartash/impex-editor-intellij-idea-plugin/issue/11/unsupportedoperationexception-null
    final List<TextRange> ranges = new ArrayList<TextRange>();
    ranges.add(impexFullHeaderParameter.getTextRange());

    HighlightUsagesHandler.highlightRanges(
        HighlightManager.getInstance(editor.getProject()),
        editor,
        EditorColorsManager.getInstance().getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES),
        clear,
        ranges
    );
}
 
开发者ID:AlexanderBartash,项目名称:hybris-integration-intellij-idea-plugin,代码行数:31,代码来源:DefaultImpexHeaderNameHighlighterService.java

示例12: navigateToFirstFailedAnswerPlaceholder

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
public static void navigateToFirstFailedAnswerPlaceholder(@NotNull final Editor editor, @NotNull final TaskFile taskFile) {
  final Project project = editor.getProject();
  if (project == null) return;
  for (AnswerPlaceholder answerPlaceholder : taskFile.getActivePlaceholders()) {
    if (answerPlaceholder.getStatus() != StudyStatus.Failed) {
      continue;
    }
    navigateToAnswerPlaceholder(editor, answerPlaceholder);
    break;
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:12,代码来源:StudyNavigator.java

示例13: editorCreated

import com.intellij.openapi.editor.Editor; //导入方法依赖的package包/类
@Override
public void editorCreated(@NotNull final EditorFactoryEvent event) {
  final Editor editor = event.getEditor();
  final Project project = editor.getProject();
  if (project == null) {
    return;
  }

  final Document document = editor.getDocument();
  final VirtualFile openedFile = FileDocumentManager.getInstance().getFile(document);
  if (openedFile != null) {
    final TaskFile taskFile = StudyUtils.getTaskFile(project, openedFile);
    if (taskFile != null) {
      WolfTheProblemSolver.getInstance(project).clearProblems(openedFile);
      final ToolWindow studyToolWindow = ToolWindowManager.getInstance(project).getToolWindow(StudyToolWindowFactory.STUDY_TOOL_WINDOW);
      if (studyToolWindow != null) {
        StudyUtils.updateToolWindows(project);
        studyToolWindow.show(null);
      }
      Course course = StudyTaskManager.getInstance(project).getCourse();
      if (course == null) {
        return;
      }

      StudyEditor.addDocumentListener(document, new EduDocumentListener(taskFile, true));

      if (!taskFile.getAnswerPlaceholders().isEmpty()) {
        StudyNavigator.navigateToFirstAnswerPlaceholder(editor, taskFile);
        boolean isStudyProject = EduNames.STUDY.equals(course.getCourseMode());
        StudyUtils.drawAllAnswerPlaceholders(editor, taskFile);
        if (isStudyProject) {
          editor.addEditorMouseListener(new WindowSelectionListener(taskFile));
        }
      }
    }
  }
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:38,代码来源:StudyEditorFactoryListener.java


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