use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-community by JetBrains.
the class ArrangementGroupingRulesControl method setRules.
public void setRules(@Nullable List<ArrangementGroupingRule> rules) {
for (ArrangementGroupingComponent component : myComponents.values()) {
component.setSelected(false);
}
if (rules == null) {
return;
}
DefaultTableModel model = getModel();
while (model.getRowCount() > 0) {
model.removeRow(model.getRowCount() - 1);
}
final Set<ArrangementSettingsToken> groupingTokens = ContainerUtilRt.newHashSet(myComponents.keySet());
for (ArrangementGroupingRule rule : rules) {
final ArrangementSettingsToken groupingType = rule.getGroupingType();
ArrangementGroupingComponent component = myComponents.get(groupingType);
component.setSelected(true);
component.setOrderType(rule.getOrderType());
model.addRow(new Object[] { component });
groupingTokens.remove(groupingType);
}
List<ArrangementSettingsToken> types = ContainerUtilRt.newArrayList(groupingTokens);
types = mySettingsManager.sort(types);
for (ArrangementSettingsToken type : types) {
model.addRow(new Object[] { myComponents.get(type) });
}
}
use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-plugins by JetBrains.
the class ActionScriptRearranger method getDefaultMatchRules.
public static List<StdArrangementMatchRule> getDefaultMatchRules() {
// more or less close to Coding Conventions at http://sourceforge.net/adobe/flexsdk/wiki/Coding%20Conventions/
final List<StdArrangementMatchRule> matchRules = new ArrayList<>();
final Set<ArrangementSettingsToken> visibility = VISIBILITY_MODIFIERS;
// static initialization blocks
addRule(matchRules, STATIC_INIT);
// constants
addRule(matchRules, CONST);
// static vars
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, VAR, modifier, STATIC);
}
// static properties
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, PROPERTY, modifier, STATIC);
}
// static methods
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, METHOD, modifier, STATIC);
}
// constructor
addRule(matchRules, CONSTRUCTOR);
// vars
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, VAR, modifier);
}
// properties
addRule(matchRules, PROPERTY, OVERRIDE);
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, PROPERTY, modifier);
}
// methods
addRule(matchRules, METHOD, OVERRIDE);
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, METHOD, modifier);
}
// event handlers
addRule(matchRules, EVENT_HANDLER, OVERRIDE);
for (ArrangementSettingsToken modifier : visibility) {
addRule(matchRules, EVENT_HANDLER, modifier);
}
return matchRules;
}
use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-plugins by JetBrains.
the class ActionScriptRearranger method detectModifiers.
@NotNull
protected Set<ArrangementSettingsToken> detectModifiers(@NotNull final JSAttributeListOwner fieldOrMethod) {
final Set<ArrangementSettingsToken> result = ContainerUtil.newHashSet();
final JSAttributeList attributes = fieldOrMethod.getAttributeList();
if (attributes != null) {
JSAttributeList.AccessType accessType = attributes.getExplicitAccessType();
if (accessType == null) {
final String namespace = attributes.getNamespace();
if (namespace == null) {
accessType = JSAttributeList.AccessType.PACKAGE_LOCAL;
}
}
if (accessType != null) {
switch(accessType) {
case PUBLIC:
result.add(PUBLIC);
break;
case PROTECTED:
result.add(PROTECTED);
break;
case PACKAGE_LOCAL:
result.add(PACKAGE_PRIVATE);
break;
case PRIVATE:
result.add(PRIVATE);
break;
}
}
if (attributes.hasModifier(JSAttributeList.ModifierType.STATIC))
result.add(STATIC);
if (attributes.hasModifier(JSAttributeList.ModifierType.FINAL))
result.add(FINAL);
if (attributes.hasModifier(JSAttributeList.ModifierType.OVERRIDE))
result.add(OVERRIDE);
}
return result;
}
use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-community by JetBrains.
the class JavaArrangementVisitor method visitMethod.
@Override
public void visitMethod(PsiMethod method) {
boolean isSectionCommentsDetected = registerSectionComments(method);
final TextRange range = isSectionCommentsDetected ? getElementRangeWithoutComments(method) : method.getTextRange();
ArrangementSettingsToken type = method.isConstructor() ? CONSTRUCTOR : METHOD;
JavaElementArrangementEntry entry = createNewEntry(method, range, type, method.getName(), true);
if (entry == null) {
return;
}
processEntry(entry, method, method.getBody());
parseProperties(method, entry);
myInfo.onMethodEntryCreated(method, entry);
MethodSignatureBackedByPsiMethod overridden = SuperMethodsSearch.search(method, null, true, false).findFirst();
if (overridden != null) {
entry.addModifier(OVERRIDDEN);
myInfo.onOverriddenMethod(overridden.getMethod(), method);
}
boolean reset = myMethodBodyProcessor.setBaseMethod(method);
try {
method.accept(myMethodBodyProcessor);
} finally {
if (reset) {
myMethodBodyProcessor.setBaseMethod(null);
}
}
}
use of com.intellij.psi.codeStyle.arrangement.std.ArrangementSettingsToken in project intellij-community by JetBrains.
the class JavaArrangementVisitor method visitClass.
@Override
public void visitClass(PsiClass aClass) {
boolean isSectionCommentsDetected = registerSectionComments(aClass);
TextRange range = isSectionCommentsDetected ? getElementRangeWithoutComments(aClass) : aClass.getTextRange();
ArrangementSettingsToken type = CLASS;
if (aClass.isEnum()) {
type = ENUM;
} else if (aClass.isInterface()) {
type = INTERFACE;
}
JavaElementArrangementEntry entry = createNewEntry(aClass, range, type, aClass.getName(), true);
processEntry(entry, aClass, aClass);
}
Aggregations