以上就是给各位分享com.intellij.ui.TextFieldWithHistoryWithBrowseButton的实例源码,其中也会对源代码案例进行解释,同时本文还将给你拓展com.inte
以上就是给各位分享com.intellij.ui.TextFieldWithHistoryWithBrowseButton的实例源码,其中也会对源代码案例进行解释,同时本文还将给你拓展com.intellij.openapi.actionSystem.impl.ActionButtonWithText的实例源码、com.intellij.openapi.editor.colors.TextAttributesKey的实例源码、com.intellij.openapi.editor.colors.TextAttributesScheme的实例源码、com.intellij.openapi.editor.EditorGutterAction的实例源码等相关知识,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:- com.intellij.ui.TextFieldWithHistoryWithBrowseButton的实例源码(源代码案例)
- com.intellij.openapi.actionSystem.impl.ActionButtonWithText的实例源码
- com.intellij.openapi.editor.colors.TextAttributesKey的实例源码
- com.intellij.openapi.editor.colors.TextAttributesScheme的实例源码
- com.intellij.openapi.editor.EditorGutterAction的实例源码
com.intellij.ui.TextFieldWithHistoryWithBrowseButton的实例源码(源代码案例)
@NotNull public static TextFieldWithHistoryWithbrowseButton createTextFieldWithHistoryWithbrowseButton(@Nullable Project project,@NotNull String browseDialogTitle,@NotNull FileChooserDescriptor fileChooserDescriptor,@Nullable NotNullProducer<List<String>> historyProvider) { TextFieldWithHistoryWithbrowseButton textFieldWithHistoryWithbrowseButton = new TextFieldWithHistoryWithbrowseButton(); TextFieldWithHistory textFieldWithHistory = textFieldWithHistoryWithbrowseButton.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); if (historyProvider != null) { addHistoryOnExpansion(textFieldWithHistory,historyProvider); } installFileCompletionAndbrowseDialog( project,textFieldWithHistoryWithbrowseButton,browseDialogTitle,fileChooserDescriptor ); return textFieldWithHistoryWithbrowseButton; }
public static void resizeDialogToFitTextFor(@NotNull final JComponent... components) { if (components.length == 0) return; doWithDialogWrapper(components[0],new Consumer<DialogWrapper>() { @Override public void consume(final DialogWrapper dialogWrapper) { if (dialogWrapper instanceof SettingsDialog || dialogWrapper instanceof SingleConfigurableEditor) { for (Component component : components) { if (component instanceof TextFieldWithHistoryWithbrowseButton) { setPreferredWidthToFitText((TextFieldWithHistoryWithbrowseButton)component); } else if (component instanceof TextFieldWithbrowseButton) { setPreferredWidthToFitText((TextFieldWithbrowseButton)component); } else if (component instanceof JTextField) { setPreferredWidthToFitText((JTextField)component); } } ApplicationManager.getApplication().invokelater(new Runnable() { @Override public void run() { adjustDialogSizetoFitPreferredSize(dialogWrapper); } },ModalityState.any()); } } }); }
public static void installFileCompletionAndbrowseDialog(@Nullable Project project,@NotNull TextFieldWithHistoryWithbrowseButton textFieldWithHistoryWithbrowseButton,@NotNull @Nls(capitalization = Nls.Capitalization.Title) String browseDialogTitle,@NotNull FileChooserDescriptor fileChooserDescriptor) { doInstall(project,textFieldWithHistoryWithbrowseButton.getChildComponent().getTextEditor(),fileChooserDescriptor,TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); }
@Override protected JComponent createnorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); myTargetDirectoryField = new TextFieldWithHistoryWithbrowseButton(); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addbrowseFolderListener(RefactoringBundle.message("select.target.directory"),RefactoringBundle.message("the.file.will.be.moved.to.this.directory"),myProject,descriptor,TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); final JTextField textField = myTargetDirectoryField.getChildComponent().getTextEditor(); FileChooserFactory.getInstance().installFileCompletion(textField,true,getdisposable()); textField.getDocument().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); myTargetDirectoryField.setTextFieldPreferredWidth(copyFilesOrDirectoriesDialog.MAX_PATH_LENGTH); disposer.register(getdisposable(),myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"),myTargetDirectoryField,UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut",shortcutText)) .addComponentToRightColumn(myCbSearchForReferences,UIUtil.LARGE_VGAP).getPanel(); }
private void validateField(Validator validator,TextFieldWithHistoryWithbrowseButton field,boolean allowEmpty,String message) { if (!ValidationUtils.validatePath(project,field.getChildComponent().getText(),allowEmpty)) { validator.add(field.getChildComponent().getTextEditor(),message,FIX_IT); } }
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithbrowseButton field) { TextFieldWithHistory textFieldWithHistory = field.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); return textFieldWithHistory; }
private static boolean areEqual(TextFieldWithHistoryWithbrowseButton field,String value) { return field.getChildComponent().getText().equals(value); }
public static void setPreferredWidthToFitText(@NotNull TextFieldWithHistoryWithbrowseButton component) { int childWidth = calcWidthToFitText(component.getChildComponent().getTextEditor(),JBUI.scale(32)); setPreferredWidthForComponentWithbrowseButton(component,childWidth); }
@Override protected JComponent createnorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); myTargetDirectoryField = new TextFieldWithHistoryWithbrowseButton(); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addbrowseFolderListener(RefactoringBundle.message("select.target.directory"),myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); myOpenInEditorCb = new NonFocusableCheckBox("Open moved files in editor"); myOpenInEditorCb.setSelected(isOpenInEditor()); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"),UIUtil.LARGE_VGAP) .addComponentToRightColumn(myOpenInEditorCb,UIUtil.LARGE_VGAP) .getPanel(); }
@Override protected JComponent createnorthPanel() { myinformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myinformationLabel).addVerticalGap( UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { validateOKButton(); } }; if (myShowNewNameField) { myNewNameField = new JBTextField(); myNewNameField.getDocument().addDocumentListener(documentListener); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"),myNewNameField); } if (myShowDirectoryField) { myTargetDirectoryField = new TextFieldWithHistoryWithbrowseButton(); myTargetDirectoryField.setTextFieldPreferredWidth(MAX_PATH_LENGTH); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addbrowseFolderListener(RefactoringBundle.message("select.target.directory"),RefactoringBundle.message("the.file.will.be.copied.to.this.directory"),TextComponentAccessor.TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT); myTargetDirectoryField.getChildComponent().addDocumentListener(new DocumentAdapter() { @Override protected void textChanged(DocumentEvent e) { validateOKButton(); } }); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.to.directory.label"),myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); formBuilder.addTooltip(RefactoringBundle.message("path.completion.shortcut",shortcutText)); } final JPanel wrapper = new JPanel(new BorderLayout()); wrapper.add(myOpenFilesInEditor,BorderLayout.EAST); formBuilder.addComponent(wrapper); return formBuilder.getPanel(); }
private void validateField(Validator validator,allowEmpty)) { ValidationInfo error = new ValidationInfo(field.getChildComponent().getTextEditor(),FIX_IT); validator.errors.add(error); } }
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithbrowseButton field) { TextFieldWithHistory textFieldWithHistory = field.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); return textFieldWithHistory; }
private static boolean areEqual(TextFieldWithHistoryWithbrowseButton field,String value) { return field.getChildComponent().getText().equals(value); }
private void validateField(List<ValidationInfo> errors,FIX_IT); errors.add(error); } }
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithbrowseButton field) { TextFieldWithHistory textFieldWithHistory = field.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); return textFieldWithHistory; }
private static boolean areEqual(TextFieldWithHistoryWithbrowseButton field,String value) { return field.getChildComponent().getText().equals(value); }
private void validateField(List<ValidationInfo> errors,String message) { if (!validatePath(field.getChildComponent().getText(),FIX_IT); errors.add(error); } }
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithbrowseButton field) { TextFieldWithHistory textFieldWithHistory = field.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); return textFieldWithHistory; }
private static boolean areEqual(TextFieldWithHistoryWithbrowseButton field,String value) { return field.getChildComponent().getText().equals(value); }
private void addDocumentListenerToComp(TextFieldWithHistoryWithbrowseButton field,DocumentAdapter docAdp) { field.getChildComponent().getTextEditor().getDocument().addDocumentListener(docAdp); }
private void validateField(List<ValidationInfo> errors,FIX_IT); errors.add(error); } }
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithbrowseButton field) { TextFieldWithHistory textFieldWithHistory = field.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); return textFieldWithHistory; }
private static boolean areEqual(TextFieldWithHistoryWithbrowseButton field,String value) { return field.getChildComponent().getText().equals(value); }
private void validateField(Validator validator,String message) { if (!validatePath(field.getChildComponent().getText(),allowEmpty)) { validator.add(field.getChildComponent().getTextEditor(),FIX_IT); // addError(validator,field.getChildComponent().getTextEditor(),FIX_IT); } }
private static TextFieldWithHistory configWithDefaults(TextFieldWithHistoryWithbrowseButton field) { TextFieldWithHistory textFieldWithHistory = field.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); return textFieldWithHistory; }
private static boolean areEqual(TextFieldWithHistoryWithbrowseButton field,String value) { return field.getChildComponent().getText().equals(value); }
public TextFieldWithHistoryWithbrowseButton getControllerNameBox() { return controllerNameBox; }
@Override protected JComponent createnorthPanel() { myinformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myinformationLabel).addVerticalGap( UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { validateOKButton(); } }; if (myShowNewNameField) { myNewNameField = new JTextField(); myNewNameField.getDocument().addDocumentListener(documentListener); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"),BorderLayout.EAST); formBuilder.addComponent(wrapper); return formBuilder.getPanel(); }
@Override protected JComponent createnorthPanel() { myNameLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); myTargetDirectoryField = new TextFieldWithHistoryWithbrowseButton(); final List<String> recentEntries = RecentsManager.getInstance(myProject).getRecentEntries(RECENT_KEYS); if (recentEntries != null) { myTargetDirectoryField.getChildComponent().setHistory(recentEntries); } final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFolderDescriptor(); myTargetDirectoryField.addbrowseFolderListener(RefactoringBundle.message("select.target.directory"),myTargetDirectoryField); String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_CODE_COMPLETION)); myCbSearchForReferences = new NonFocusableCheckBox(RefactoringBundle.message("search.for.references")); myCbSearchForReferences.setSelected(RefactoringSettings.getInstance().MOVE_SEARCH_FOR_REFERENCES_FOR_FILE); myOpenInEditorCb = new NonFocusableCheckBox("Open moved files in editor"); myOpenInEditorCb.setSelected(isOpenInEditor()); return FormBuilder.createFormBuilder().addComponent(myNameLabel) .addLabeledComponent(RefactoringBundle.message("move.files.to.directory.label"),UIUtil.LARGE_VGAP) .addTooltip(RefactoringBundle.message("path.completion.shortcut",shortcutText)) .addComponentToRightColumn(myCbSearchForReferences,UIUtil.LARGE_VGAP) .addComponentToRightColumn(myOpenInEditorCb,UIUtil.LARGE_VGAP) .getPanel(); }
@Override protected JComponent createnorthPanel() { myinformationLabel = JBLabelDecorator.createJBLabelDecorator().setBold(true); final FormBuilder formBuilder = FormBuilder.createFormBuilder().addComponent(myinformationLabel).addVerticalGap( UIUtil.LARGE_VGAP - UIUtil.DEFAULT_VGAP); DocumentListener documentListener = new DocumentAdapter() { @Override public void textChanged(DocumentEvent event) { validateOKButton(); } }; if (myShowNewNameField) { myNewNameField = new JTextField(); myNewNameField.getDocument().addDocumentListener(documentListener); formBuilder.addLabeledComponent(RefactoringBundle.message("copy.files.new.name.label"),BorderLayout.EAST); formBuilder.addComponent(wrapper); return formBuilder.getPanel(); }
com.intellij.openapi.actionSystem.impl.ActionButtonWithText的实例源码
@Override public void paint(Graphics g,JComponent c) { if(c instanceof ActionButtonWithText) { paintTextButton(g,(ActionButtonWithText)c); } else { paintDefaultButton(g,(ActionButton)c); } }
private void paintTextButton(Graphics g,ActionButtonWithText c) { AnAction action = c.getAction(); Icon icon = c.getIcon(); FontMetrics fm = SwingUtilities2.getFontMetrics(c,g,c.getFont()); Rectangle viewRect = new Rectangle(c.getSize()); Insets i = c.getInsets(); viewRect.x += i.left; viewRect.y += i.top; viewRect.width -= (i.right + viewRect.x); viewRect.height -= (i.bottom + viewRect.y); Rectangle iconRect = new Rectangle(); Rectangle textRect = new Rectangle(); String text = SwingUtilities .layoutCompoundLabel(c,fm,c.getText(),icon,SwingConstants.CENTER,c.horizontalTextAlignment(),SwingConstants.TRAILING,viewRect,iconRect,textRect,c.iconTextSpace()); int state = c.getPopState(); if (state != ActionButtonComponent.norMAL) { paintBackground(c,c.getSize(),state); } icon.paintIcon(null,iconRect.x,iconRect.y); UIUtil.applyRenderingHints(g); g.setColor(c.isButtonEnabled() ? c.getForeground() : UIUtil.getInactiveTextColor()); SwingUtilities2.drawStringUnderlineCharat(c,text,getMnemonicCharIndex(c,action,text),textRect.x,textRect.y + fm.getAscent()); }
public static JComponent createCustomComponentImpl(final AnAction action,final Presentation presentation) { return new ActionButtonWithText(action,presentation,ActionPlaces.UNKNowN,ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); }
public static JComponent createCustomComponentImpl(final AnAction action,ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); }
@Override public JComponent createCustomComponent(Presentation presentation) { return new ActionButtonWithText(this,ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE); }
public static JComponent createCustomComponentImpl(final AnAction action,JBUI.size(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE)); }
@Override public JComponent createCustomComponent(Presentation presentation) { return new ActionButtonWithText(this,JBUI.size(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE)); }
com.intellij.openapi.editor.colors.TextAttributesKey的实例源码
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(CptTypes.SEParaTOR) || tokenType.equals(CptTypes.MAP)) { return SEParaTOR_KEYS; } else if (tokenType.equals(CptTypes.TEMPLATE_NAME)) { return TEMPLATE_NAME_KEYS; } else if (tokenType.equals(CptTypes.CLASS_NAME)) { return CLASS_NAME_KEYS; } else if (tokenType.equals(CptTypes.TEMPLATE_DESCRIPTION)) { return TEMPLATE_DESCRIPTION_KEYS; } else if (tokenType.equals(CptTypes.TEMPLATE_CODE)) { return TEMPLATE_CODE_KEYS; } else if (TEMPLATE_VARIABLE_PARTS.contains(tokenType)) { return TEMPLATE_VARIABLE_KEYS; } else if (tokenType.equals(CptTypes.TEMPLATE_ESCAPE)) { return TEMPLATE_ESCAPE_KEYS; } else if (tokenType.equals(CptTypes.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(CrystalTypes.SEParaTOR)) { return SEParaTOR_KEYS; } else if (tokenType.equals(CrystalTypes.KEY)) { return KEY_KEYS; } else if (tokenType.equals(CrystalTypes.VALUE)) { return VALUE_KEYS; } else if (tokenType.equals(CrystalTypes.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(CapnpTypes.SEParaTOR)) { return SEParaTOR_KEYS; } else if (tokenType.equals(CapnpTypes.IDENTIFIER)){ return IDENTIFIER_KEYS; } else if (tokenType.equals(CapnpTypes.KEYWORD)) { return KEY_KEYS; } else if (tokenType.equals(CapnpTypes.TYPE)) { return TYPE_KEYS; } else if (tokenType.equals(CapnpTypes.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(CsvTypes.COMMA)) { return COMMA_KEYS; } else if (tokenType.equals(CsvTypes.QUOTE)) { return QUOTE_KEYS; } else if (tokenType.equals(CsvTypes.TEXT)) { return TEXT_KEYS; } else if (tokenType.equals(CsvTypes.ESCAPED_TEXT)) { return ESCAPED_TEXT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHAR_KEYS; } else { return EMPTY_KEYS; } }
public boolean isInherited(TextAttributesKey key) { TextAttributesKey fallbackKey = key.getFallbackAttributeKey(); if (fallbackKey != null) { if (myParentScheme instanceof AbstractColoRSScheme) { TextAttributes ownAttrs = ((AbstractColoRSScheme)myParentScheme).getDirectlyDefinedAttributes(key); if (ownAttrs != null) { return ownAttrs.isFallbackEnabled(); } } TextAttributes attributes = getAttributes(key); if (attributes != null) { TextAttributes fallbackAttributes = getAttributes(fallbackKey); return attributes == fallbackAttributes; } } return false; }
@Override @NotNull public SyntaxHighlighter getSyntaxHighlighter(final Project project,final VirtualFile virtualFile) { return new SyntaxHighlighterBase() { @NotNull @Override public Lexer getHighlightingLexer() { return createPlainTextLexer(); } @NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { return EMPTY; } }; }
@Override public void visitDocTag(LuaDocTag e) { super.visitDocTag(e); LuaDocSyntaxHighlighter Highlighter = new LuaDocSyntaxHighlighter(); PsiElement element = e.getFirstChild(); while (element != null) { if (element instanceof ASTNode) { ASTNode astNode = (ASTNode) element; TextAttributesKey[] keys = Highlighter.getTokenHighlights(astNode.getElementType()); for (TextAttributesKey key : keys) { final Annotation a = myHolder.createInfoAnnotation(element,null); a.setTextAttributes(key); } } element = element.getNextSibling(); } }
@Nullable private static TextAttributesKey getDeclarationAttribute(PsiElement element) { if (element.getParent() instanceof GrAnnotation && element.getNode().getElementType() == GroovyTokenTypes.mAT) { return GroovySyntaxHighlighter.ANNOTATION; } PsiElement parent = element.getParent(); if (!(parent instanceof GrNamedElement) || ((GrNamedElement)parent).getNameIdentifierGroovy() != element) { return null; } //don't highlight local vars and parameters here because their highlighting needs index. if (PsiUtil.isLocalVariable(parent) || parent instanceof GrParameter) return null; return GrHighlightUtil.getDeclarationHighlightingAttribute(parent,null); }
private SchemeTextAttributesDescription(String name,String group,@NotNull TextAttributesKey key,@NotNull MyColorScheme scheme,Icon icon,String toolTip) { super(name,group,getinitialAttributes(scheme,key).clone(),key,scheme,icon,toolTip); this.key = key; myInitialAttributes = getinitialAttributes(scheme,key); TextAttributesKey fallbackKey = key.getFallbackAttributeKey(); if (fallbackKey != null) { myFallbackAttributes = scheme.getAttributes(fallbackKey); myBaseAttributeDescriptor = ColorSettingsPages.getInstance().getAttributeDescriptor(fallbackKey); if (myBaseAttributeDescriptor == null) { myBaseAttributeDescriptor = new Pair<ColorSettingsPage,AttributesDescriptor>(null,new AttributesDescriptor(fallbackKey.getExternalName(),fallbackKey)); } } myIsInheritedInitial = scheme.isInherited(key); setInherited(myIsInheritedInitial); if (myIsInheritedInitial) { setInheritedAttributes(getTextAttributes()); } initCheckedStatus(); }
@Override public ItemPresentation getPresentation(@NotNull final PsiPackage aPackage) { return new ColoredItemPresentation() { @Override public TextAttributesKey getTextAttributesKey() { return null; } @Override public String getPresentableText() { return aPackage.getName(); } @Override public String getLocationString() { return aPackage.getQualifiedname(); } @Override public Icon getIcon(boolean open) { return PlatformIcons.PACKAGE_ICON; } }; }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { // Return the appropriate text attributes depending on the type of token. if (tokenType.equals(ProguardTypes.LINE_CMT)) { return COMMENTS_KEY; } if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHARS_KEY; } if (tokenType.equals(ProguardTypes.JAVA_DECL)) { return CLASS_SPEC_KEY; } if (tokenType.equals(ProguardTypes.CLOSE_BRACE) || tokenType.equals(ProguardTypes.OPEN_BRACE)) { return OPERATOR_KEY; } if (tokenType.equals(ProguardTypes.FLAG_NAME)) { return FLAG_NAME_KEY; } if (tokenType.equals(ProguardTypes.FLAG_ARG)) { return FLAG_ARG_KEY; } return EMPTY_KEY; }
private static TextAttributes getScopeAttributes(@NotNull PsiElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiFile file = element.getContainingFile(); if (file == null) return null; TextAttributes result = null; DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(file.getProject()); List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes(); for (Pair<NamedScope,NamedScopesHolder> scope : scopes) { final NamedScope namedScope = scope.getFirst(); final TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName()); final TextAttributes attributes = coloRSScheme.getAttributes(scopeKey); if (attributes == null || attributes.isEmpty()) { continue; } final PackageSet packageSet = namedScope.getValue(); if (packageSet != null && packageSet.contains(file,scope.getSecond())) { result = TextAttributes.merge(attributes,result); } } return result; }
@NotNull public ItemPresentation getPresentation() { return new ColoredItemPresentation() { @Nullable @Override public TextAttributesKey getTextAttributesKey() { return (myPresentableName != null && myPresentableName.isEmpty()) ? GROUP_KEY :null; } public String getPresentableText() { return myPresentableName == null ? myProperty.getUnescapedKey() : (myPresentableName.isEmpty() ? ResourceBundlePropertyStructureViewElement.PROPERTY_GROUP_KEY_TEXT : myPresentableName); } public String getLocationString() { return null; } public Icon getIcon(boolean open) { return myProperty.getIcon(0); } }; }
public void testScopeBased() throws Exception { NamedScope xScope = new NamedScope("xxx",new PatternPackageSet("x..*",PatternPackageSet.ScopE_SOURCE,null)); NamedScope utilScope = new NamedScope("util",new PatternPackageSet("java.util.*",PatternPackageSet.ScopE_LIBRARY,null)); NamedScopeManager scopeManager = NamedScopeManager.getInstance(getProject()); scopeManager.addScope(xScope); scopeManager.addScope(utilScope); EditorColorsManager manager = EditorColorsManager.getInstance(); EditorColoRSScheme scheme = (EditorColoRSScheme)manager.getGlobalScheme().clone(); manager.addColoRSScheme(scheme); EditorColorsManager.getInstance().setGlobalScheme(scheme); TextAttributesKey xKey = ScopeAttributesUtil.getScopeTextAttributeKey(xScope.getName()); TextAttributes xAttributes = new TextAttributes(Color.cyan,Color.darkGray,Color.blue,EffectType.BoxED,Font.ITALIC); scheme.setAttributes(xKey,xAttributes); TextAttributesKey utilKey = ScopeAttributesUtil.getScopeTextAttributeKey(utilScope.getName()); TextAttributes utilAttributes = new TextAttributes(Color.gray,Color.magenta,Color.orange,EffectType.STRIKEOUT,Font.BOLD); scheme.setAttributes(utilKey,utilAttributes); try { testFile(BASE_PATH + "/scopeBased/x/X.java").projectRoot(BASE_PATH + "/scopeBased").checkSymbolNames().test(); } finally { scopeManager.removeAllSets(); } }
/** * Returns the text attribute key used for highlighting the annotation. If not specified * explicitly,the key is determined automatically based on the problem highlight type and * the annotation severity. * * @return the text attribute key used for highlighting */ @NotNull public TextAttributesKey getTextAttributes() { if (myEnforcedAttributesKey != null) return myEnforcedAttributesKey; if (myHighlightType == ProblemHighlightType.GENERIC_ERROR_OR_WARNING) { if (mySeverity == HighlightSeverity.ERROR) return CodeInsightColors.ERRORS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WARNING) return CodeInsightColors.WARNINGS_ATTRIBUTES; if (mySeverity == HighlightSeverity.WEAK_WARNING) return CodeInsightColors.WEAK_WARNING_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.GENERIC_ERROR) { return CodeInsightColors.ERRORS_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_DEPRECATED) { return CodeInsightColors.DEPRECATED_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNUSED_SYMBOL) { return CodeInsightColors.NOT_USED_ELEMENT_ATTRIBUTES; } if (myHighlightType == ProblemHighlightType.LIKE_UNKNowN_SYMBOL || myHighlightType == ProblemHighlightType.ERROR) { return CodeInsightColors.WRONG_REFERENCES_ATTRIBUTES; } return HighlighterColors.NO_HIGHLIGHTING; }
@Override public void updateOptionsList() { myOptionsModel.clear(); myDescriptions.clear(); Map<TextAttributesKey,TextDiffType> typesByKey = ContainerUtil.newMapFromValues(TextDiffType.MERGE_TYPES.iterator(),TextDiffType.ATTRIBUTES_KEY); for (int i = 0; i < myOptions.getCurrentDescriptions().length; i++) { EditorSchemeAttributeDescriptor description = myOptions.getCurrentDescriptions()[i]; TextAttributesKey type = TextAttributesKey.find(description.getType()); if (description.getGroup() == ColorAndFontOptions.DIFF_GROUP && typesByKey.keySet().contains(type)) { myOptionsModel.add(typesByKey.get(type)); myDescriptions.put(type.getExternalName(),(MyColorAndFontDescription)description); } } ScrollingUtil.ensureSelectionExists(myOptionsList); }
@Override public Set<String> processListOptions() { Set<String> result = ContainerUtil.newHashSet(); Map<TextAttributesKey,TextDiffType.ATTRIBUTES_KEY); for (int i = 0; i < myOptions.getCurrentDescriptions().length; i++) { EditorSchemeAttributeDescriptor description = myOptions.getCurrentDescriptions()[i]; TextAttributesKey type = TextAttributesKey.find(description.getType()); if (description.getGroup() == ColorAndFontOptions.DIFF_GROUP && typesByKey.keySet().contains(type)) { result.add(type.getExternalName()); } } return result; }
public static boolean isHighlightedAsComment(TextAttributesKey... keys) { for (TextAttributesKey key : keys) { if (key == DefaultLanguageHighlighterColors.DOC_COMMENT || key == SyntaxHighlighterColors.DOC_COMMENT || key == DefaultLanguageHighlighterColors.LINE_COMMENT || key == SyntaxHighlighterColors.LINE_COMMENT || key == DefaultLanguageHighlighterColors.BLOCK_COMMENT || key == SyntaxHighlighterColors.JAVA_BLOCK_COMMENT ) { return true; } if (key == null) continue; final TextAttributesKey fallbackAttributeKey = key.getFallbackAttributeKey(); if (fallbackAttributeKey != null && isHighlightedAsComment(fallbackAttributeKey)) { return true; } } return false; }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (KEYS.containsKey(tokenType)) { return KEYS.get(tokenType); } return EMPTY_KEYS; }
private static void createInfoAnnotation(final @NotNull AnnotationHolder holder,final @Nullable PsiElement element,final @Nullable TextAttributesKey attributeKey) { if (element != null && attributeKey != null) { holder.createInfoAnnotation(element,null).setTextAttributes(attributeKey); } }
@NotNull @Override public final TextAttributesKey[] getTokenHighlights(IElementType tokenType) { /* Entities OPERATIONS */ if (KEYWORD_SET.contains(tokenType)) { return KEYWORD_KEYS; } if (SEParaTOR_SET.contains(tokenType)) { return SEParaTOR_KEYS; } /* Basic elem */ if (tokenType.equals(GCMTypes.ANNOTATION)) { return ANNOTATION_KEYS; } if (tokenType.equals(GCMTypes.IDENT)) { return IDENT_KEYS; } if (tokenType.equals(GCMTypes.NUMBER)) { return NUMBER_KEYS; } if (tokenType.equals(GCMTypes.LINE_COMMENT) | tokenType.equals(GCMTypes.BLOCK_COMMENT)) { return COMMENT_KEYS; } if (tokenType.equals(GCMTypes.STRING)) { return STRING_KEYS; } if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHAR_KEYS; } return EMPTY_KEYS; }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType type) { if (textAttrMap.containsKey(type)) { return textAttrMap.get(type); } return EMPTY_KEYS; }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (KEYWORD_TOKEN_SET.contains(tokenType)) { return KEYWORD_KEYS; } else if (tokenType.equals(FlexibleSearchTypes.STRING)) { return STRING_KEYS; } else if (SYMBOL_TOKEN_SET.contains(tokenType)) { return SYMBOL_KEYS; } else if (COLUMN_TOKEN_SET.contains(tokenType)) { return COLUMN_KEYS; } else if (TABLE_NAME_TOKEN_SET.contains(tokenType)) { return TABLE_KEYS; } else if (BRACES_TOKEN_SET.contains(tokenType)) { return BRACES_KEYS; } else if (BRACKETS_TOKEN_SET.contains(tokenType)) { return BRACKETS_KEYS; } else if (PARENTHESES_TOKEN_SET.contains(tokenType)) { return PARENTHESES_KEYS; } else if (tokenType.equals(FlexibleSearchTypes.NUMBER)) { return NUMBER_KEYS; } else if (tokenType.equals(FlexibleSearchParserDeFinition.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHaraCTER_KEYS; } else { return EMPTY_KEYS; } }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType iElementType) { if (iElementType.equals(OnescriptTypes.COMMENT)) { return COMMENT_KEYS; } else if (iElementType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHAR_KEYS; } else if (iElementType.equals(OnescriptTypes.STRING) || iElementType.equals(OnescriptTypes.STRINGSTART) || iElementType.equals(OnescriptTypes.STRINGPART) || iElementType.equals(OnescriptTypes.STRINGTAIL)) { return STRING_KEYS; } else if (iElementType.equals(OnescriptTypes.DATETIME)) { return DATETIME_KEYS; } else if (iElementType.equals(OnescriptTypes.COMPILER_DIRECTIVE)) { return COMPILER_DIRECTIVE_KEYS; } else if (iElementType.equals(OnescriptTypes.USING)) { return USING_DIRECTIVE_KEYS; } else if (iElementType.equals(OnescriptTypes.PREPROCESSOR)) { return PREPROCESSOR_DIRECTIVE_KEYS; } else if (iElementType.equals(OnescriptTypes.BOOLEAN_TRUE) || iElementType.equals(OnescriptTypes.BOOLEAN_FALSE) || iElementType.equals(OnescriptTypes.UNDEFINED) || iElementType.equals(OnescriptTypes.NULL)) { return LIteraL_CONSTANT_KEYS; } else if (iElementType.toString().endsWith("_KEYWORD")) { return KEYWORD_KEYS; } else { return new TextAttributesKey[0]; } }
@Override @NotNull public TextAttributesKey[] getTokenHighlights(final IElementType tokenType) { if (tokenType == BAD_CHaraCTER) { return new TextAttributesKey[0]; } return myHighlighter.getTokenHighlights(tokenType); }
@NotNull public Map<String,TextAttributesKey> getAdditionalHighlightingTagToDescriptorMap() { log.info("Returning additional highlighting tags."); if (_keyMap != null) { return _keyMap; } return new HashMap<>(); }
@NotNull public static HighlightInfoType highlightTypeFromDescriptor(@NotNull ProblemDescriptor problemDescriptor,@NotNull HighlightSeverity severity,@NotNull SeverityRegistrar severityRegistrar) { final ProblemHighlightType highlightType = problemDescriptor.getHighlightType(); switch (highlightType) { case GENERIC_ERROR_OR_WARNING: return severityRegistrar.getHighlightInfoTypeBySeverity(severity); case LIKE_DEPRECATED: return new HighlightInfoType.HighlightInfoTypeImpl(severity,HighlightInfoType.DEPRECATED.getAttributesKey()); case LIKE_UNKNowN_SYMBOL: if (severity == HighlightSeverity.ERROR) { return new HighlightInfoType.HighlightInfoTypeImpl(severity,HighlightInfoType.WRONG_REF.getAttributesKey()); } if (severity == HighlightSeverity.WARNING) { return new HighlightInfoType.HighlightInfoTypeImpl(severity,CodeInsightColors.WEAK_WARNING_ATTRIBUTES); } return severityRegistrar.getHighlightInfoTypeBySeverity(severity); case LIKE_UNUSED_SYMBOL: return new HighlightInfoType.HighlightInfoTypeImpl(severity,HighlightInfoType.UNUSED_SYMBOL.getAttributesKey()); case INFO: return HighlightInfoType.INFO; case WEAK_WARNING: return HighlightInfoType.WEAK_WARNING; case ERROR: return HighlightInfoType.WRONG_REF; case GENERIC_ERROR: return HighlightInfoType.ERROR; case informatION: final TextAttributesKey attributes = ((ProblemDescriptorBase)problemDescriptor).getEnforcedTextAttributes(); if (attributes != null) { return new HighlightInfoType.HighlightInfoTypeImpl(HighlightSeverity.informatION,attributes); } return HighlightInfoType.informatION; } throw new RuntimeException("Cannot map " + highlightType); }
/** * Tries to update the map by associating given keys with a given value. * Throws error if the map already contains different mapping for one of given keys. */ protected static void safeMap(@NotNull final Map<IElementType,TextAttributesKey> map,@NotNull final TokenSet keys,@NotNull final TextAttributesKey value) { for (final IElementType type : keys.getTypes()) { safeMap(map,type,value); } }
@Nullable protected TextAttributes getNavigationItemAttributes(Object value) { TextAttributes attributes = null; if (value instanceof NavigationItem) { TextAttributesKey attributesKey = null; final ItemPresentation presentation = ((NavigationItem)value).getPresentation(); if (presentation instanceof ColoredItemPresentation) attributesKey = ((ColoredItemPresentation) presentation).getTextAttributesKey(); if (attributesKey != null) { attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey); } } return attributes; }
@NotNull public static TextAttributesKey[] pack(@NotNull TextAttributesKey[] base,@Nullable TextAttributesKey t1,@Nullable TextAttributesKey t2) { int add = 0; if (t1 != null) add++; if (t2 != null) add++; if (add == 0) return base; TextAttributesKey[] result = new TextAttributesKey[base.length + add]; add = base.length; System.arraycopy(base,result,base.length); if (t1 != null) result[add++] = t1; if (t2 != null) result[add] = t2; return result; }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(GraphQLElementTypes.NAME)) { return IDENTIFIER_KEYS; } else if (tokenType.equals(GraphQLElementTypes.KEYWORD)) { return KEYWORD_KEYS; } else if (tokenType.equals(GraphQLElementTypes.NUMBER)) { return NUMBER_KEYS; } else if (tokenType.equals(GraphQLElementTypes.STRING)) { return STRING_KEYS; } else if (tokenType.equals(GraphQLElementTypes.COMMENT)) { return COMMENT_KEYS; } else if (tokenType.equals(GraphQLElementTypes.BRACE_L) || tokenType.equals(GraphQLElementTypes.BRACE_R)) { return BRACES_KEYS; } else if (tokenType.equals(GraphQLElementTypes.PAREN_L) || tokenType.equals(GraphQLElementTypes.PAREN_R)) { return PARENTHESES_KEYS; } else if (tokenType.equals(GraphQLElementTypes.BRACKET_L) || tokenType.equals(GraphQLElementTypes.BRACKET_R)) { return BRACKETS_KEYS; } else if (tokenType.equals(GraphQLElementTypes.SPREAD)) { return SPREAD_KEYS; } else if (tokenType.equals(TokenType.BAD_CHaraCTER)) { return BAD_CHaraCTER_KEYS; } else { return EMPTY_KEYS; } }
@NotNull public static TextAttributesKey[] pack(@NotNull TextAttributesKey[] base,@Nullable TextAttributesKey key) { if (key == null) return base; TextAttributesKey[] result = new TextAttributesKey[base.length + 1]; System.arraycopy(base,base.length); result[base.length] = key; return result; }
private AttributeWrapper getAttributeWrapper(RadComponent component) { AttributeWrapper wrapper = AttributeWrapper.DEFAULT; final HighlightdisplayLevel level = getHighlightdisplayLevel(myDesigner.getProject(),component); if (level != null) { TextAttributesKey attributesKey = SeverityRegistrar.getSeverityRegistrar(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()) .getAttributesKey(); final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey); wrapper = new AttributeWrapper() { @Override public SimpleTextAttributes getAttribute(SimpleTextAttributes attributes) { Color bgColor = textAttributes.getBackgroundColor(); try { textAttributes.setBackgroundColor(null); return SimpleTextAttributes.fromTextAttributes(TextAttributes.merge(attributes.toTextAttributes(),textAttributes)); } finally { textAttributes.setBackgroundColor(bgColor); } } }; } return wrapper; }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(RythmTypes.RYTHM_ARGS)) { return RYTHM_ARGS_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_EXTENDS)) { return RYTHM_EXTENDS_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_SECTION)) { return RYTHM_SECTION_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_IMPORT)) { return RYTHM_IMPORT_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_INVOKE)) { return RYTHM_INVOKE_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_RENDER)) { return RYTHM_RENDER_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_IF)) { return RYTHM_IF_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_FOR)) { return RYTHM_FOR_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_I_18_N)) { return RYTHM_I_18_N_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_PREFIX)) { return RYTHM_PREFIX_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_METHOD)) { return RYTHM_METHOD_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_KEY)) { return RYTHM_KEY_KEYS; } else if (tokenType.equals(RythmTypes.RYTHM_COMMENT)) { return RYTHM_COMMENT_KEYS; } else if(tokenType.equals(RythmTypes.FUNCTION)){ return FUNCTION_KEYS; } /*if (tokenType.equals(RythmTypes.ParaM)) { return RYTHM_ParaM_KEYS; } */else if (tokenType.equals(RythmTypes.RYTHM_ELSE)){ return RYTHM_ELSE_KEYS; } else { return EMPTY_KEYS; } }
@NotNull public TextAttributesScheme getColoRSScheme() { return new TextAttributesScheme() { @Override public TextAttributes getAttributes(TextAttributesKey key) { return key.getDefaultAttributes(); } }; }
@Nullable @Override public TextAttributesKey getKeyForNamespace(String namespace,XmlElement context) { if (!(context instanceof XmlTag)) return null; if (XsltSupport.XSLT_NS.equals(((XmlTag)context).getNamespace())) return XsltSupport.XSLT_DIRECTIVE; return null; }
private void visit(GrReferenceElement element) { ProgressManager.checkCanceled(); final PsiElement resolved = element.resolve(); final TextAttributesKey attribute = GrHighlightUtil.getDeclarationHighlightingAttribute(resolved,element); if (attribute != null) { final PsiElement refNameElement = GrHighlightUtil.getElementToHighlight(element); addInfo(attribute,refNameElement); } }
@NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (!(tokenType instanceof TokenIElementType)) { return EMPTY_KEYS; } TokenIElementType myType = (TokenIElementType) tokenType; int antlrTokenType = myType.getAntlrTokenType(); TextAttributesKey attrKey; switch (antlrTokenType) { case ProtoLexer.INTEGER_VALUE: case ProtoLexer.FLOAT_VALUE: attrKey = NUMBER; break; case ProtoLexer.STRING_VALUE: attrKey = STRING; break; case ProtoLexer.COMMENT: attrKey = BLOCK_COMMENT; break; case ProtoLexer.LINE_COMMENT: attrKey = LINE_COMMENT; break; case ProtoLexer.PLUGIN_DEV_MARKER: attrKey = MetaDATA; break; default: return EMPTY_KEYS; } return new TextAttributesKey[]{attrKey}; }
/** * The methods determines the text attributes for the token provided as arg * @param tokenType * @return text attributes required to highlight the corresponding token */ @NotNull @Override public TextAttributesKey[] getTokenHighlights(IElementType tokenType) { if (tokenType.equals(Dottypes.EXTENDED_ID)| tokenType.equals(Dottypes.SIMPLE_ID)) { return VARS_KEYS; } else if (tokenType.equals(Dottypes.NUMERAL_ID)){ return NUMERIC_KEYS; } else if (tokenType.equals(Dottypes.GRAPH_) | tokenType.equals(Dottypes.NODE_) | tokenType.equals(Dottypes.EDGE_) | tokenType.equals(Dottypes.STRICT_) | tokenType.equals(Dottypes.DIGRAPH_)) { return KEYWORD_KEYS; } else if (tokenType.equals(Dottypes.COMPASS)) { return COMPASS_KEYS; } else if(tokenType.equals(Dottypes.BRACHET_LEFT)| tokenType.equals(Dottypes.BRACKET_RIGHT)| tokenType.equals(Dottypes.CURLY_BRACHET_LEFT)| tokenType.equals(Dottypes.CURLY_BRACKET_RIGHT)){ return BRACKET_KEYS; } else if (tokenType.equals(Dottypes.EDGE_OP)) { return EDGE_OP_KEYS; } else if (tokenType.equals(Dottypes.COMMENT) | tokenType.equals(Dottypes.MULTILINE_COMMENT)) { return COMMENT_KEYS; } else { return EMPTY_KEYS; } }
protected static Annotation setHighlighting( @NotNull PsiElement element,@NotNull AnnotationHolder holder,@NotNull TextAttributesKey key) { Annotation annotation = holder.createInfoAnnotation(element,null); annotation.setEnforcedTextAttributes(EditorColorsManager.getInstance().getGlobalScheme().getAttributes(key)); return annotation; }
com.intellij.openapi.editor.colors.TextAttributesScheme的实例源码
@Nullable static HighlightInfo highlightvariableName(final PsiVariable variable,final PsiElement elementToHighlight,@NotNull TextAttributesScheme coloRSScheme) { HighlightInfoType varType = getvariableNameHighlightType(variable); if (varType != null) { if (variable instanceof PsiField) { TextAttributes attributes = mergeWithScopeAttributes(variable,varType,coloRSScheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(varType).range(elementToHighlight.getTextRange()); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return HighlightInfo.newHighlightInfo(varType).range(elementToHighlight).create(); } return null; }
private static TextAttributes getScopeAttributes(@NotNull PsiElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiFile file = element.getContainingFile(); if (file == null) return null; TextAttributes result = null; DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl)DependencyValidationManager.getInstance(file.getProject()); List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes(); for (Pair<NamedScope,NamedScopesHolder> scope : scopes) { final NamedScope namedScope = scope.getFirst(); final TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName()); final TextAttributes attributes = coloRSScheme.getAttributes(scopeKey); if (attributes == null || attributes.isEmpty()) { continue; } final PackageSet packageSet = namedScope.getValue(); if (packageSet != null && packageSet.contains(file,scope.getSecond())) { result = TextAttributes.merge(attributes,result); } } return result; }
@Nullable public static HighlightInfo highlightMethodName(@NotNull PsiMethod method,TextRange range,@NotNull TextAttributesScheme coloRSScheme,final boolean isDeclaration) { boolean isInherited = false; if (!isDeclaration) { if (isCalledOnThis(elementToHighlight)) { PsiClass enclosingClass = PsiTreeUtil.getParentOfType(elementToHighlight,PsiClass.class); isInherited = enclosingClass != null && enclosingClass.isInheritor(method.getContainingClass(),true); } } HighlightInfoType type = getmethodNameHighlightType(method,isDeclaration,isInherited); if (type != null && elementToHighlight != null) { TextAttributes attributes = mergeWithScopeAttributes(method,type,coloRSScheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return null; }
@Nullable public static HighlightInfo highlightvariableName(final PsiVariable variable,coloRSScheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(varType).range(elementToHighlight.getTextRange()); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return HighlightInfo.newHighlightInfo(varType).range(elementToHighlight).create(); } return null; }
private static TextAttributes getScopeAttributes(@NotNull PsiElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiFile file = element.getContainingFile(); if (file == null) return null; TextAttributes result = null; final DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(file.getProject()); List<Pair<NamedScope,NamedScopesHolder>> scopes = daemonCodeAnalyzer.getScopeBasedHighlightingCachedScopes(); for (Pair<NamedScope,NamedScopesHolder> scope : scopes) { NamedScope namedScope = scope.getFirst(); NamedScopesHolder scopesHolder = scope.getSecond(); PackageSet packageSet = namedScope.getValue(); if (packageSet != null && packageSet.contains(file,scopesHolder)) { TextAttributesKey scopeKey = ColorAndFontOptions.getScopeTextAttributeKey(namedScope.getName()); TextAttributes attributes = coloRSScheme.getAttributes(scopeKey); if (attributes == null || attributes.isEmpty()) { continue; } result = TextAttributes.merge(attributes,result); } } return result; }
@Override public void visitDocTagValue(PsiDocTagValue value) { PsiReference reference = value.getReference(); if(reference != null) { PsiElement element = reference.resolve(); final TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); if(element instanceof PsiMethod) { PsiElement nameElement = ((PsiDocmethodorFieldRef) value).getNameElement(); if(nameElement != null) { myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod) element,nameElement,false,coloRSScheme)); } } else if(element instanceof PsiParameter) { myHolder.add(HighlightNamesUtil.highlightvariableName((PsiVariable) element,value.getNavigationElement(),coloRSScheme)); } } }
@Nullable static HighlightInfo highlightMethodName(@NotNull PsiMethod method,final boolean isDeclaration,@NotNull TextAttributesScheme coloRSScheme) { return highlightMethodName(method,elementToHighlight,elementToHighlight.getTextRange(),coloRSScheme,isDeclaration); }
@Nullable static HighlightInfo highlightMethodName(@NotNull PsiMethod method,final boolean isDeclaration) { boolean isInherited = false; if (!isDeclaration) { if (isCalledOnThis(elementToHighlight)) { final PsiClass containingClass = method.getContainingClass(); PsiClass enclosingClass = containingClass == null ? null : PsiTreeUtil.getParentOfType(elementToHighlight,PsiClass.class); while (enclosingClass != null) { isInherited = enclosingClass.isInheritor(containingClass,true); if (isInherited) break; enclosingClass = PsiTreeUtil.getParentOfType(enclosingClass,PsiClass.class,true); } } } HighlightInfoType type = getmethodNameHighlightType(method,coloRSScheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return null; }
private static TextAttributes mergeWithScopeAttributes(final PsiElement element,@NotNull HighlightInfoType type,@NotNull TextAttributesScheme coloRSScheme) { TextAttributes regularattributes = HighlightInfo.getAttributesByType(element,coloRSScheme); if (element == null) return regularattributes; TextAttributes scopeAttributes = getScopeAttributes(element,coloRSScheme); return TextAttributes.merge(scopeAttributes,regularattributes); }
@Nullable static HighlightInfo highlightClassName(PsiClass aClass,PsiElement elementToHighlight,@NotNull TextAttributesScheme coloRSScheme) { HighlightInfoType type = getClassNameHighlightType(aClass,elementToHighlight); if (elementToHighlight != null) { TextAttributes attributes = mergeWithScopeAttributes(aClass,coloRSScheme); TextRange range = elementToHighlight.getTextRange(); if (elementToHighlight instanceof PsiJavaCodeReferenceElement) { final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement)elementToHighlight; PsiReferenceParameterList parameterList = referenceElement.getParameterList(); if (parameterList != null) { final TextRange paramListRange = parameterList.getTextRange(); if (paramListRange.getEndOffset() > paramListRange.getStartOffset()) { range = new TextRange(range.getStartOffset(),paramListRange.getStartOffset()); } } } // This will highlight @ sign in annotation as well. final PsiElement parent = elementToHighlight.getParent(); if (parent instanceof PsiAnnotation) { final PsiAnnotation psiAnnotation = (PsiAnnotation)parent; range = new TextRange(psiAnnotation.getTextRange().getStartOffset(),range.getEndOffset()); } HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return null; }
@Nullable static HighlightInfo highlightClassNameInQualifier(final PsiJavaCodeReferenceElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiElement qualifierExpression = element.getQualifier(); if (qualifierExpression instanceof PsiJavaCodeReferenceElement) { PsiElement resolved = ((PsiJavaCodeReferenceElement)qualifierExpression).resolve(); if (resolved instanceof PsiClass) { return highlightClassName((PsiClass)resolved,qualifierExpression,coloRSScheme); } } return null; }
@Override public void visitDocTagValue(PsiDocTagValue value) { PsiReference reference = value.getReference(); if (reference != null) { PsiElement element = reference.resolve(); final TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); if (element instanceof PsiMethod) { myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod)element,((PsiDocmethodorFieldRef)value).getNameElement(),coloRSScheme)); } else if (element instanceof PsiParameter) { myHolder.add(HighlightNamesUtil.highlightvariableName((PsiVariable)element,coloRSScheme)); } } }
@Override public void visitMethod(PsiMethod method) { super.visitMethod(method); if (!myHolder.hasErrorResults()) myHolder.add(HighlightControlFlowUtil.checkUnreachableStatement(method.getBody())); if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkConstructorHandleSuperClassExceptions(method)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkRecursiveConstructorInvocation(method)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkSafeVarargsAnnotation(method,myLanguageLevel)); PsiClass aClass = method.getContainingClass(); if (!myHolder.hasErrorResults() && method.isConstructor()) { myHolder.add(HighlightClassUtil.checkThingNotAllowedInInterface(method,aClass)); } if (!myHolder.hasErrorResults() && method.hasModifierProperty(PsiModifier.DEFAULT)) { myHolder.add(checkFeature(method,Feature.EXTENSION_METHODS)); } if (!myHolder.hasErrorResults() && aClass != null && aClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC)) { myHolder.add(checkFeature(method,Feature.EXTENSION_METHODS)); } if (!myHolder.hasErrorResults() && aClass != null) { myHolder.add(HighlightMethodUtil.checkDuplicateMethod(aClass,method,getDuplicateMethods(aClass))); } // method params are highlighted in visitMethod since we should make sure the method body was visited before PsiParameter[] parameters = method.getParameterList().getParameters(); final TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); for (PsiParameter parameter : parameters) { int info = myReassignedParameters.get(parameter); if (info == 0) continue; // out of this file if (info == 2) {// reassigned myHolder.add(HighlightNamesUtil.highlightReassignedVariable(parameter,parameter.getNameIdentifier())); } else { myHolder.add(HighlightNamesUtil.highlightvariableName(parameter,parameter.getNameIdentifier(),coloRSScheme)); } } }
@NotNull public TextAttributesScheme getColoRSScheme() { return new TextAttributesScheme() { @Override public TextAttributes getAttributes(TextAttributesKey key) { return key.getDefaultAttributes(); } }; }
@Override @NotNull public TextAttributesScheme getColoRSScheme() { if (myCustomColoRSScheme != null) { return myCustomColoRSScheme; } return EditorColorsManager.getInstance().getGlobalScheme(); }
@Nullable public static HighlightInfo highlightMethodName(@NotNull PsiMethod method,isDeclaration); }
private static TextAttributes mergeWithScopeAttributes(final PsiElement element,regularattributes); }
@Nullable public static HighlightInfo highlightClassName(PsiClass aClass,range.getEndOffset()); } HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if (attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return null; }
@Nullable public static HighlightInfo highlightClassNameInQualifier(final PsiJavaCodeReferenceElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiExpression qualifierExpression = null; if (element instanceof PsiReferenceExpression) { qualifierExpression = ((PsiReferenceExpression)element).getQualifierExpression(); } if (qualifierExpression instanceof PsiJavaCodeReferenceElement) { PsiElement resolved = ((PsiJavaCodeReferenceElement)qualifierExpression).resolve(); if (resolved instanceof PsiClass) { return highlightClassName((PsiClass)resolved,coloRSScheme); } } return null; }
@Override public void visitDocTagValue(PsiDocTagValue value) { PsiReference reference = value.getReference(); if (reference != null) { PsiElement element = reference.resolve(); final TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); if (element instanceof PsiMethod) { myHolder.add(HighlightNamesUtil.highlightMethodName((PsiMethod)element,coloRSScheme)); } } }
@Override public void visitMethod(PsiMethod method) { super.visitMethod(method); if (!myHolder.hasErrorResults()) myHolder.add(HighlightControlFlowUtil.checkUnreachableStatement(method.getBody())); if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkConstructorHandleSuperClassExceptions(method)); if (!myHolder.hasErrorResults()) myHolder.add(HighlightMethodUtil.checkRecursiveConstructorInvocation(method)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkOverrideAnnotation(method,myLanguageLevel)); if (!myHolder.hasErrorResults()) myHolder.add(GenericsHighlightUtil.checkSafeVarargsAnnotation(method)); if (!myHolder.hasErrorResults() && method.isConstructor()) { myHolder.add(HighlightClassUtil.checkThingNotAllowedInInterface(method,method.getContainingClass())); } // method params are highlighted in visitMethod since we should make sure the method body was visited before PsiParameter[] parameters = method.getParameterList().getParameters(); final TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); for (PsiParameter parameter : parameters) { int info = myReassignedParameters.get(parameter); if (info == 0) continue; // out of this file if (info == 2) {// reassigned myHolder.add(HighlightNamesUtil.highlightReassignedVariable(parameter,coloRSScheme)); } } }
@NotNull public TextAttributesScheme getColoRSScheme() { return new TextAttributesScheme() { @Override public TextAttributes getAttributes(TextAttributesKey key) { return key.getDefaultAttributes(); } }; }
@Override @NotNull public TextAttributesScheme getColoRSScheme() { if (myCustomColoRSScheme != null) { return myCustomColoRSScheme; } return EditorColorsManager.getInstance().getGlobalScheme(); }
@Nonnull public TextAttributesScheme getColoRSScheme() { return new TextAttributesScheme() { @Override public TextAttributes getAttributes(TextAttributesKey key) { return key.getDefaultAttributes(); } }; }
@Override @Nonnull public TextAttributesScheme getColoRSScheme() { if (myCustomColoRSScheme != null) { return myCustomColoRSScheme; } return EditorColorsManager.getInstance().getGlobalScheme(); }
@Nullable @Contract("_,null -> !null") public static Boolean isRainbowEnabled(@Nullable TextAttributesScheme coloRSScheme,@Nullable Language language) { if (coloRSScheme instanceof SchemeMetaInfo) { String value = ((SchemeMetaInfo)coloRSScheme).getMetaProperties().getProperty(getKey(language),INHERITED); if (String.valueOf(true).equals(value)) return Boolean.TRUE; if (String.valueOf(false).equals(value)) return Boolean.FALSE; return language == null ? DEFAULT_RAINBOW_ON : null; } return false; }
@Nonnull private static Color[] generateColorSequence(@Nonnull TextAttributesScheme coloRSScheme) { String colorDump = ApplicationManager.getApplication().isUnitTestMode() ? UNIT_TEST_COLORS : Registry.get("rainbow.Highlighter.colors").asstring(); final List<String> registryColors = StringUtil.split(colorDump,","); if (!registryColors.isEmpty()) { return registryColors.stream().map(s -> ColorUtil.fromHex(s.trim())).toArray(Color[]::new); } List<Color> stopColors = ContainerUtil.map(RAINBOW_COLOR_KEYS,key -> coloRSScheme.getAttributes(key).getForegroundColor()); List<Color> colors = ColorGenerator.generateLinearColorSequence(stopColors,RAINBOW_COLORS_BETWEEN); return colors.toArray(new Color[colors.size()]); }
private static TextAttributes mergeWithScopeAttributes(@Nullable PsiElement element,@NotNull TextAttributesScheme coloRSScheme) { TextAttributes regularattributes = HighlightInfo.getAttributesByType(element,coloRSScheme); if(element == null) { return regularattributes; } TextAttributes scopeAttributes = getScopeAttributes(element,coloRSScheme); return TextAttributes.merge(scopeAttributes,regularattributes); }
@NotNull static HighlightInfo highlightClassName(@Nullable PsiClass aClass,@NotNull PsiElement elementToHighlight,@NotNull TextAttributesScheme coloRSScheme) { TextRange range = elementToHighlight.getTextRange(); if(elementToHighlight instanceof PsiJavaCodeReferenceElement) { final PsiJavaCodeReferenceElement referenceElement = (PsiJavaCodeReferenceElement) elementToHighlight; PsiElement identifier = referenceElement.getReferenceNameElement(); if(identifier != null) { range = identifier.getTextRange(); } } // This will highlight @ sign in annotation as well. final PsiElement parent = elementToHighlight.getParent(); if(parent instanceof PsiAnnotation) { final PsiAnnotation psiAnnotation = (PsiAnnotation) parent; range = new TextRange(psiAnnotation.getTextRange().getStartOffset(),range.getEndOffset()); } HighlightInfoType type = getClassNameHighlightType(aClass,elementToHighlight); TextAttributes attributes = mergeWithScopeAttributes(aClass,coloRSScheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if(attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); }
@Nullable static HighlightInfo highlightClassNameInQualifier(@NotNull PsiJavaCodeReferenceElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiElement qualifierExpression = element.getQualifier(); if(qualifierExpression instanceof PsiJavaCodeReferenceElement) { PsiElement resolved = ((PsiJavaCodeReferenceElement) qualifierExpression).resolve(); if(resolved instanceof PsiClass) { return highlightClassName((PsiClass) resolved,coloRSScheme); } } return null; }
private static TextAttributes getScopeAttributes(@NotNull PsiElement element,@NotNull TextAttributesScheme coloRSScheme) { PsiFile file = element.getContainingFile(); if(file == null) { return null; } TextAttributes result = null; DependencyValidationManagerImpl validationManager = (DependencyValidationManagerImpl) DependencyValidationManager.getInstance(file.getProject()); List<Pair<NamedScope,NamedScopesHolder>> scopes = validationManager.getScopeBasedHighlightingCachedScopes(); for(Pair<NamedScope,NamedScopesHolder> scope : scopes) { final NamedScope namedScope = scope.getFirst(); final TextAttributesKey scopeKey = ScopeAttributesUtil.getScopeTextAttributeKey(namedScope.getName()); final TextAttributes attributes = coloRSScheme.getAttributes(scopeKey); if(attributes == null || attributes.isEmpty()) { continue; } final PackageSet packageSet = namedScope.getValue(); if(packageSet != null && packageSet.contains(file,scope.getSecond())) { result = TextAttributes.merge(attributes,result); } } return result; }
static HighlightInfo highlightPackage(@NotNull PsiElement resolved,@NotNull PsiJavaCodeReferenceElement elementToHighlight,@NotNull TextAttributesScheme scheme) { PsiElement referenceNameElement = elementToHighlight.getReferenceNameElement(); TextRange range; if(referenceNameElement == null) { range = elementToHighlight.getTextRange(); } else { PsiElement nextSibling = PsiTreeUtil.nextLeaf(referenceNameElement); if(nextSibling != null && nextSibling.getTextRange().isEmpty()) { // empty PsiReferenceParameterList nextSibling = PsiTreeUtil.nextLeaf(nextSibling); } if(nextSibling instanceof PsiJavaToken && ((PsiJavaToken) nextSibling).getTokenType() == JavaTokenType.DOT) { range = new TextRange(referenceNameElement.getTextRange().getStartOffset(),nextSibling.getTextRange().getEndOffset()); } else { range = referenceNameElement.getTextRange(); } } HighlightInfoType type = JavaHighlightInfoTypes.PACKAGE_NAME; TextAttributes attributes = mergeWithScopeAttributes(resolved,scheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if(attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); }
@NotNull @Override public TextAttributesScheme getColoRSScheme() { return myHolder.getColoRSScheme(); }
@Override public void visitIdentifier(final PsiIdentifier identifier) { TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); PsiElement parent = identifier.getParent(); if (parent instanceof PsiVariable) { PsiVariable variable = (PsiVariable)parent; myHolder.add(HighlightUtil.checkVariableAlreadyDefined(variable)); if (variable.getinitializer() == null) { final PsiElement child = variable.getLastChild(); if (child instanceof PsiErrorElement && child.getPrevSibling() == identifier) return; } boolean isMethodParameter = variable instanceof PsiParameter && ((PsiParameter)variable).getDeclarationScope() instanceof PsiMethod; if (!isMethodParameter) { // method params are highlighted in visitMethod since we should make sure the method body was visited before if (HighlightControlFlowUtil.isReassigned(variable,myFinalVarProblems)) { myHolder.add(HighlightNamesUtil.highlightReassignedVariable(variable,identifier)); } else { myHolder.add(HighlightNamesUtil.highlightvariableName(variable,identifier,coloRSScheme)); } } else { myReassignedParameters.put((PsiParameter)variable,1); // mark param as present in current file } myHolder.add(HighlightUtil.checkUnderscore(identifier,variable)); } else if (parent instanceof PsiClass) { PsiClass aClass = (PsiClass)parent; if (aClass.isAnnotationType()) { myHolder.add(HighlightUtil.checkAnnotationFeature(identifier,myLanguageLevel,myFile)); } myHolder.add(HighlightClassUtil.checkClassAlreadyImported(aClass,identifier)); if (!(parent instanceof PsiAnonymousClass) && aClass.getNameIdentifier() == identifier) { myHolder.add(HighlightNamesUtil.highlightClassName(aClass,coloRSScheme)); } } else if (parent instanceof PsiMethod) { PsiMethod method = (PsiMethod)parent; if (method.isConstructor()) { myHolder.add(HighlightMethodUtil.checkConstructorName(method)); } myHolder.add(HighlightNamesUtil.highlightMethodName(method,true,coloRSScheme)); } else { visitParentReference(parent); } super.visitIdentifier(identifier); }
@Nonnull @Override public TextAttributesScheme getColoRSScheme() { return myHolder.getColoRSScheme(); }
public RainbowHighlighter(@Nullable TextAttributesScheme coloRSScheme) { myColoRSScheme = coloRSScheme != null ? coloRSScheme : EditorColorsManager.getInstance().getGlobalScheme(); myRainbowColors = generateColorSequence(myColoRSScheme); }
public static boolean isRainbowEnabledWithInheritance(@Nullable TextAttributesScheme coloRSScheme,@Nullable Language language) { Boolean rainbowEnabled = isRainbowEnabled(coloRSScheme,language); return rainbowEnabled != null ? rainbowEnabled : isRainbowEnabled(coloRSScheme,null); }
@Nullable static HighlightInfo highlightMethodName(@NotNull PsiMethod method,@NotNull TextAttributesScheme coloRSScheme) { return highlightMethodName(method,isDeclaration); }
/** * @param methodorClass method to highlight; class is passed instead of implicit constructor */ @Nullable static HighlightInfo highlightMethodName(@NotNull PsiMember methodorClass,@NotNull TextRange range,final boolean isDeclaration) { boolean isInherited = false; if(!isDeclaration) { if(isCalledOnThis(elementToHighlight)) { final PsiClass containingClass = methodorClass instanceof PsiMethod ? methodorClass.getContainingClass() : null; PsiClass enclosingClass = containingClass == null ? null : PsiTreeUtil.getParentOfType(elementToHighlight,PsiClass.class); while(enclosingClass != null) { isInherited = enclosingClass.isInheritor(containingClass,true); if(isInherited) { break; } enclosingClass = PsiTreeUtil.getParentOfType(enclosingClass,true); } } } LOG.assertTrue(methodorClass instanceof PsiMethod || !isDeclaration); HighlightInfoType type = methodorClass instanceof PsiMethod ? getmethodNameHighlightType((PsiMethod) methodorClass,isInherited) : JavaHighlightInfoTypes.CONSTRUCTOR_CALL; if(type != null) { TextAttributes attributes = mergeWithScopeAttributes(methodorClass,coloRSScheme); HighlightInfo.Builder builder = HighlightInfo.newHighlightInfo(type).range(range); if(attributes != null) { builder.textAttributes(attributes); } return builder.createUnconditionally(); } return null; }
@Override public void visitMethod(PsiMethod method) { super.visitMethod(method); if(!myHolder.hasErrorResults()) { myHolder.add(HighlightControlFlowUtil.checkUnreachableStatement(method.getBody())); } if(!myHolder.hasErrorResults()) { myHolder.add(HighlightMethodUtil.checkConstructorHandleSuperClassExceptions(method)); } if(!myHolder.hasErrorResults()) { myHolder.add(HighlightMethodUtil.checkRecursiveConstructorInvocation(method)); } if(!myHolder.hasErrorResults()) { myHolder.add(GenericsHighlightUtil.checkSafeVarargsAnnotation(method,myLanguageLevel)); } PsiClass aClass = method.getContainingClass(); if(!myHolder.hasErrorResults() && method.isConstructor()) { myHolder.add(HighlightClassUtil.checkThingNotAllowedInInterface(method,aClass)); } if(!myHolder.hasErrorResults() && method.hasModifierProperty(PsiModifier.DEFAULT)) { myHolder.add(checkFeature(method,Feature.EXTENSION_METHODS)); } if(!myHolder.hasErrorResults() && aClass != null && aClass.isInterface() && method.hasModifierProperty(PsiModifier.STATIC)) { myHolder.add(checkFeature(method,Feature.EXTENSION_METHODS)); } if(!myHolder.hasErrorResults() && aClass != null) { myHolder.add(HighlightMethodUtil.checkDuplicateMethod(aClass,getDuplicateMethods(aClass))); } // method params are highlighted in visitMethod since we should make sure the method body was visited before PsiParameter[] parameters = method.getParameterList().getParameters(); final TextAttributesScheme coloRSScheme = myHolder.getColoRSScheme(); for(PsiParameter parameter : parameters) { int info = myReassignedParameters.get(parameter); if(info == 0) { continue; // out of this file } PsiIdentifier nameIdentifier = parameter.getNameIdentifier(); if(nameIdentifier != null) { if(info == 2) { // reassigned myHolder.add(HighlightNamesUtil.highlightReassignedVariable(parameter,nameIdentifier)); } else { myHolder.add(HighlightNamesUtil.highlightvariableName(parameter,nameIdentifier,coloRSScheme)); } } } }
com.intellij.openapi.editor.EditorGutterAction的实例源码
AnnotationFieldGutter(FileAnnotation annotation,LineAnnotationAspect aspect,final TextAnnotationPresentation presentation,Couple<Map<VcsRevisionNumber,Color>> colorScheme) { myAnnotation = annotation; myAspect = aspect; myPresentation = presentation; myIsGutteraction = myAspect instanceof EditorGutteraction; myColorScheme = colorScheme; }
public Cursor getCursor(final int line) { if (myIsGutteraction) { return ((EditorGutteraction)myAspect).getCursor(line); } else { return Cursor.getDefaultCursor(); } }
AnnotationFieldGutter(FileAnnotation annotation,Editor editor,Map<String,Color> colorScheme) { myAnnotation = annotation; myEditor = editor; myAspect = aspect; myPresentation = presentation; myIsGutteraction = myAspect instanceof EditorGutteraction; myColorScheme = colorScheme; }
public Cursor getCursor(final int line) { if (myIsGutteraction) { return ((EditorGutteraction)myAspect).getCursor(line); } else { return Cursor.getDefaultCursor(); } }
public AspectAnnotationFieldGutter(@Nonnull FileAnnotation annotation,@Nonnull LineAnnotationAspect aspect,@Nonnull TextAnnotationPresentation presentation,@Nullable Couple<Map<VcsRevisionNumber,Color>> colorScheme) { super(annotation,presentation,colorScheme); myAspect = aspect; myIsGutteraction = myAspect instanceof EditorGutteraction; }
@Override public Cursor getCursor(final int line) { if (myIsGutteraction) { return ((EditorGutteraction)myAspect).getCursor(line); } return super.getCursor(line); }
public void doAction(int line) { if (myIsGutteraction) { ((EditorGutteraction)myAspect).doAction(line); } }
public void doAction(int line) { if (myIsGutteraction) { ((EditorGutteraction)myAspect).doAction(line); } }
@Override public void doAction(int line) { if (myIsGutteraction) { ((EditorGutteraction)myAspect).doAction(line); } }
今天关于com.intellij.ui.TextFieldWithHistoryWithBrowseButton的实例源码和源代码案例的讲解已经结束,谢谢您的阅读,如果想了解更多关于com.intellij.openapi.actionSystem.impl.ActionButtonWithText的实例源码、com.intellij.openapi.editor.colors.TextAttributesKey的实例源码、com.intellij.openapi.editor.colors.TextAttributesScheme的实例源码、com.intellij.openapi.editor.EditorGutterAction的实例源码的相关知识,请在本站搜索。
本文标签: