public class JavaRearranger extends java.lang.Object implements Rearranger<JavaElementArrangementEntry>, ArrangementSectionRuleAwareSettings, ArrangementStandardSettingsAware, ArrangementColorsAware
EXTENSION
Constructor and Description |
---|
JavaRearranger() |
Modifier and Type | Method and Description |
---|---|
ArrangementEntryMatcher |
buildMatcher(ArrangementMatchCondition condition)
This method is assumed to be used only by third-party developers.
|
int |
getBlankLines(CodeStyleSettings settings,
JavaElementArrangementEntry parent,
JavaElementArrangementEntry previous,
JavaElementArrangementEntry target)
Allows to answer how many blank lines should be inserted before the target arrangement entry which position is changed.
|
java.awt.Color |
getBorderColor(EditorColorsScheme scheme,
boolean selected) |
StdArrangementSettings |
getDefaultSettings() |
java.util.Collection<java.util.Set<ArrangementSettingsToken>> |
getMutexes() |
ArrangementSettingsSerializer |
getSerializer() |
java.util.List<CompositeArrangementSettingsToken> |
getSupportedGroupingTokens() |
java.util.List<CompositeArrangementSettingsToken> |
getSupportedMatchingTokens() |
TextAttributes |
getTextAttributes(EditorColorsScheme scheme,
ArrangementSettingsToken token,
boolean selected) |
boolean |
isEnabled(ArrangementSettingsToken token,
ArrangementMatchCondition current)
Allows to answer if given token is enabled in combination with other conditions specified by the given condition object.
|
java.util.List<JavaElementArrangementEntry> |
parse(PsiElement root,
Document document,
java.util.Collection<TextRange> ranges,
ArrangementSettings settings)
Allows to build rearranger-interested data for the given element.
|
Pair<JavaElementArrangementEntry,java.util.List<JavaElementArrangementEntry>> |
parseWithNew(PsiElement root,
Document document,
java.util.Collection<TextRange> ranges,
PsiElement element,
ArrangementSettings settings)
Tries to wrap given element into arrangement entry at the target context.
|
void |
setupFieldInitializationDependencies(java.util.List<? extends ArrangementEntryDependencyInfo> fieldDependencyRoots,
ArrangementSettings settings,
JavaArrangementParseInfo parseInfo) |
public Pair<JavaElementArrangementEntry,java.util.List<JavaElementArrangementEntry>> parseWithNew(PsiElement root, Document document, java.util.Collection<TextRange> ranges, PsiElement element, ArrangementSettings settings)
Rearranger
parseWithNew
in interface Rearranger<JavaElementArrangementEntry>
element
- element to wrap into format eligible for further processing by arrangement enginesettings
- arrangement settings to use. The primary idea is to make the rearranger aware about
grouping rules
(if any). E.g. it's not worth to process java method bodies
in order to build method dependency graph if no such grouping rule is definednull
otherwisepublic java.util.List<JavaElementArrangementEntry> parse(PsiElement root, Document document, java.util.Collection<TextRange> ranges, ArrangementSettings settings)
Rearranger
parse
in interface Rearranger<JavaElementArrangementEntry>
root
- root element which children should be parsed for the rearrangementdocument
- document which corresponds to the target PSI treeranges
- target offsets ranges to use for filtering given root's childrensettings
- arrangement settings to use. The primary idea is to make the rearranger aware about
grouping rules
(if any). E.g. it's not worth to process java method bodies
in order to build method dependency graph if no such grouping rule is definedpublic void setupFieldInitializationDependencies(java.util.List<? extends ArrangementEntryDependencyInfo> fieldDependencyRoots, ArrangementSettings settings, JavaArrangementParseInfo parseInfo)
public int getBlankLines(CodeStyleSettings settings, JavaElementArrangementEntry parent, JavaElementArrangementEntry previous, JavaElementArrangementEntry target)
Rearranger
getBlankLines
in interface Rearranger<JavaElementArrangementEntry>
settings
- code style settings to use (it's assumed that returned result is derived from 'blank lines' code style settings)parent
- target entry's parent (if available)previous
- previous entry (if available)target
- target entry which blank lines number the caller is interested inpublic ArrangementSettingsSerializer getSerializer()
getSerializer
in interface Rearranger<JavaElementArrangementEntry>
arrangement settings
.
Serializer is expected to be lazy and don't save
default settings
.
DefaultArrangementSettingsSerializer
public StdArrangementSettings getDefaultSettings()
getDefaultSettings
in interface ArrangementStandardSettingsAware
null
as an indication that no default settings are availablepublic java.util.List<CompositeArrangementSettingsToken> getSupportedGroupingTokens()
getSupportedGroupingTokens
in interface ArrangementStandardSettingsAware
public java.util.List<CompositeArrangementSettingsToken> getSupportedMatchingTokens()
getSupportedMatchingTokens
in interface ArrangementStandardSettingsAware
public boolean isEnabled(ArrangementSettingsToken token, ArrangementMatchCondition current)
ArrangementStandardSettingsAware
false
for token 'volatile' (because it can be applied only to fields) but true
for token 'abstract' (a java class can be abstract).isEnabled
in interface ArrangementStandardSettingsAware
token
- target token to checkcurrent
- an object which represents currently chosen tokens; null
if no other token is selectedtrue
if given token is enabled with the given condition; false
otherwisepublic ArrangementEntryMatcher buildMatcher(ArrangementMatchCondition condition) throws java.lang.IllegalArgumentException
ArrangementStandardSettingsAware
StdArrangementTokens
.buildMatcher
in interface ArrangementStandardSettingsAware
condition
- target conditionjava.lang.IllegalArgumentException
- if current rearranger doesn't know how to build a matcher from the given conditionpublic java.util.Collection<java.util.Set<ArrangementSettingsToken>> getMutexes()
getMutexes
in interface ArrangementStandardSettingsAware
public TextAttributes getTextAttributes(EditorColorsScheme scheme, ArrangementSettingsToken token, boolean selected)
getTextAttributes
in interface ArrangementColorsAware
public java.awt.Color getBorderColor(EditorColorsScheme scheme, boolean selected)
getBorderColor
in interface ArrangementColorsAware