mirror of
https://github.com/1C-Company/v8-code-style.git
synced 2025-01-06 08:40:15 +02:00
Merge pull request #25 from DoublesunRUS/bugfix/checkstyle
Ошибки checkstyle
This commit is contained in:
commit
4c7009cb52
@ -191,13 +191,17 @@ public class AutoSortPropertyPage
|
||||
{
|
||||
prefs.remove(AutoSortPreferences.KEY_TOP_NODE);
|
||||
if (prefs.nodeExists(AutoSortPreferences.KEY_TOP_NODE))
|
||||
{
|
||||
prefs.node(AutoSortPreferences.KEY_TOP_NODE).removeNode();
|
||||
}
|
||||
}
|
||||
if (buttons.get(AutoSortPreferences.KEY_SUBORDINATE_OBJECTS).getSelection())
|
||||
{
|
||||
prefs.remove(AutoSortPreferences.KEY_SUBORDINATE_NODE);
|
||||
if (prefs.nodeExists(AutoSortPreferences.KEY_SUBORDINATE_NODE))
|
||||
{
|
||||
prefs.node(AutoSortPreferences.KEY_SUBORDINATE_NODE).removeNode();
|
||||
}
|
||||
}
|
||||
prefs.flush();
|
||||
}
|
||||
@ -487,7 +491,9 @@ public class AutoSortPropertyPage
|
||||
public boolean isChecked(Object element)
|
||||
{
|
||||
if (element instanceof EReference)
|
||||
{
|
||||
return AutoSortPropertyPage.this.topObjects.getOrDefault(((EReference)element).getName(), false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -116,10 +116,14 @@ public final class AutoSortPreferences
|
||||
public static boolean isAllowedToSort(IProject project, EReference listRef)
|
||||
{
|
||||
if (ListConstants.TOP_OPBJECT_LISTS.contains(listRef))
|
||||
{
|
||||
return isSortAllTop(project) || isSortTopList(project, listRef);
|
||||
}
|
||||
|
||||
if (ListConstants.SUBORDINATE_OBJECT_LISTS.contains(listRef))
|
||||
{
|
||||
return isSortSubOrdinateObjects(project) || isSortSubordinateList(project, listRef);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
@ -64,25 +64,35 @@ public class SortBmTask
|
||||
for (SortItem item : items)
|
||||
{
|
||||
if (monitor.isCanceled())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!item.getListRef().isMany())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
EObject parent = transaction.getTopObjectByFqn(item.getFqn());
|
||||
if (parent != null)
|
||||
{
|
||||
Object value = parent.eGet(item.getListRef());
|
||||
if (!(value instanceof List))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
List<?> elements = (List<?>)value;
|
||||
if (elements.size() < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
SortCommand command = new SortCommand(parent, item.getListRef(), item.getSorter());
|
||||
if (command.canExecute())
|
||||
{
|
||||
command.execute();
|
||||
}
|
||||
command.dispose();
|
||||
|
||||
}
|
||||
|
@ -73,7 +73,9 @@ public class SortJob
|
||||
protected IStatus run(IProgressMonitor monitor)
|
||||
{
|
||||
if (dtProject.getWorkspaceProject() == null)
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
Object handler = workspaceOrchestrator.beginBackgroundOperation("Sort-MD-objects", //$NON-NLS-1$
|
||||
Arrays.asList(dtProject), ProjectPipelineJob.BUILD);
|
||||
@ -85,7 +87,9 @@ public class SortJob
|
||||
execute(monitor);
|
||||
}
|
||||
if (monitor.isCanceled())
|
||||
{
|
||||
queue.clear();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
@ -151,7 +151,9 @@ public class SortService
|
||||
{
|
||||
IBmAsyncEventListener listener = projectListeners.get(project);
|
||||
if (listener != null)
|
||||
{
|
||||
model.removeAsyncEventListener(listener);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,13 +163,17 @@ public class SortService
|
||||
{
|
||||
IBmModel model = modelManager.getModel(dtProject);
|
||||
if (model == null)
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
IProject project = dtProject.getWorkspaceProject();
|
||||
Collection<SortItem> items = readAllObjectsToSort(model, project, monitor);
|
||||
|
||||
if (monitor.isCanceled())
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
if (project != null)
|
||||
{
|
||||
@ -197,12 +203,18 @@ public class SortService
|
||||
{
|
||||
IBmModel model = modelManager.getModel(dtProject);
|
||||
if (model == null || model.isDisposed())
|
||||
{
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
if (monitor.isCanceled() || items == null)
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
if (items.isEmpty())
|
||||
{
|
||||
return Status.OK_STATUS;
|
||||
}
|
||||
|
||||
model.getGlobalContext().execute(new SortBmTask(items));
|
||||
return Status.OK_STATUS;
|
||||
@ -215,12 +227,16 @@ public class SortService
|
||||
|
||||
IBmModel model = modelManager.getModel(project);
|
||||
if (model == null)
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
Collection<SortItem> items = readAllObjectsToSort(model, project, monitor);
|
||||
|
||||
if (monitor.isCanceled())
|
||||
{
|
||||
return Status.CANCEL_STATUS;
|
||||
}
|
||||
|
||||
startSortObject(project, items);
|
||||
return Status.OK_STATUS;
|
||||
@ -233,7 +249,9 @@ public class SortService
|
||||
{
|
||||
IDtProject dtProject = dtProjectManager.getDtProject(project);
|
||||
if (dtProject == null || items.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SortJob job = jobs.computeIfAbsent(project, p -> new SortJob(dtProject, this, workspaceOrchestrator));
|
||||
job.getQueue().addAll(items);
|
||||
@ -276,7 +294,9 @@ public class SortService
|
||||
{
|
||||
IBmLongMap<BmChangeEvent> change = event.getChangeEvents();
|
||||
if (change == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Set<EReference>> changedItems = new HashMap<>();
|
||||
|
||||
@ -344,7 +364,9 @@ public class SortService
|
||||
}
|
||||
if (!(parent instanceof IBmObject) || listRef == null
|
||||
|| !AutoSortPreferences.isAllowedToSort(project, listRef))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
changedItems.computeIfAbsent(((IBmObject)parent).bmGetFqn(), k -> new HashSet<>()).add(listRef);
|
||||
}
|
||||
@ -370,7 +392,9 @@ public class SortService
|
||||
}
|
||||
|
||||
if (!items.isEmpty())
|
||||
{
|
||||
startSortObject(project, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -380,7 +404,9 @@ public class SortService
|
||||
{
|
||||
if (!feature.isMany() || feature.equals(MdClassPackage.Literals.CONFIGURATION__CONTENT)
|
||||
|| !feature.getEType().isInstance(mdObject))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return feature;
|
||||
}
|
||||
return null;
|
||||
@ -417,7 +443,9 @@ public class SortService
|
||||
|| project == null && AutoSortPreferences.DEFAULT_SORT)
|
||||
{
|
||||
if (monitor.isCanceled() || m.isCanceled())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
Iterable<EClass> eClassIterator = transaction.getTopObjectEClasses();
|
||||
Map<EClass, List<EReference>> sortListRefs = getSubordinateListsToSort(eClassIterator, project);
|
||||
@ -436,7 +464,9 @@ public class SortService
|
||||
.hasNext();)
|
||||
{
|
||||
if (monitor.isCanceled() || m.isCanceled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IBmObject object = iterator.next();
|
||||
String fqn = object.bmGetFqn();
|
||||
@ -452,13 +482,17 @@ public class SortService
|
||||
for (EClass topObjectEClass : eClassIterator)
|
||||
{
|
||||
if (topObjectEClass.equals(CONFIGURATION) || !MD_OBJECT.isSuperTypeOf(topObjectEClass))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (EReference feature : topObjectEClass.getEAllReferences())
|
||||
{
|
||||
if (!feature.isMany() || project != null && !AutoSortPreferences.isAllowedToSort(project, feature)
|
||||
|| project == null && !AutoSortPreferences.DEFAULT_SORT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
sortListRefs.computeIfAbsent(topObjectEClass, e -> new ArrayList<>()).add(feature);
|
||||
}
|
||||
@ -474,15 +508,21 @@ public class SortService
|
||||
for (EReference feature : CONFIGURATION.getEAllReferences())
|
||||
{
|
||||
if (monitor.isCanceled() || m.isCanceled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!feature.isMany() || feature.equals(MdClassPackage.Literals.CONFIGURATION__CONTENT)
|
||||
|| project != null && !AutoSortPreferences.isAllowedToSort(project, feature)
|
||||
|| project == null && !AutoSortPreferences.DEFAULT_SORT)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
EList<?> collection = (EList<?>)top.eGet(feature, false);
|
||||
if (collection.size() > 1)
|
||||
{
|
||||
result.add(new SortItem(CONFIGURATION_FQN, feature, sorter));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,13 +181,17 @@ public class EventDataExchangeLoadCheck
|
||||
Conditional conditional = statementMethod.getIfPart();
|
||||
Expression predicate = conditional.getPredicate();
|
||||
if (predicate instanceof DynamicFeatureAccess)
|
||||
{
|
||||
return checkDynamicFeatureAccess((DynamicFeatureAccess)predicate, checkCalls);
|
||||
}
|
||||
else if (predicate instanceof Invocation)
|
||||
{
|
||||
FeatureAccess expression = ((Invocation)predicate).getMethodAccess();
|
||||
if (expression instanceof DynamicFeatureAccess
|
||||
&& checkDynamicFeatureAccess((DynamicFeatureAccess)expression, checkCalls))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (predicate instanceof BinaryExpression)
|
||||
{
|
||||
@ -197,10 +201,14 @@ public class EventDataExchangeLoadCheck
|
||||
{
|
||||
Expression expression = temp.getKey();
|
||||
if (expression instanceof Invocation)
|
||||
{
|
||||
expression = ((Invocation)expression).getMethodAccess();
|
||||
}
|
||||
if (expression instanceof DynamicFeatureAccess
|
||||
&& checkDynamicFeatureAccess((DynamicFeatureAccess)expression, checkCalls))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +269,9 @@ public class EventDataExchangeLoadCheck
|
||||
|
||||
BinaryExpression currentExpression = null;
|
||||
if (binaryLeft instanceof BinaryExpression)
|
||||
{
|
||||
currentExpression = (BinaryExpression)binaryLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
mapOperatorOperand.put(binaryLeft, tempOperation);
|
||||
@ -275,9 +285,13 @@ public class EventDataExchangeLoadCheck
|
||||
tempOperation = currentExpression.getOperation();
|
||||
mapOperatorOperand.put(temp, tempOperation);
|
||||
if (binaryLeft instanceof BinaryExpression)
|
||||
{
|
||||
currentExpression = (BinaryExpression)binaryLeft;
|
||||
}
|
||||
else
|
||||
{
|
||||
currentExpression = null;
|
||||
}
|
||||
}
|
||||
|
||||
mapOperatorOperand.put(binaryLeft, tempOperation);
|
||||
|
@ -70,7 +70,9 @@ public class StructureCtorTooManyKeysCheck
|
||||
IProgressMonitor monitor)
|
||||
{
|
||||
if (monitor.isCanceled() || !(object instanceof OperatorStyleCreator))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
OperatorStyleCreator osc = (OperatorStyleCreator)object;
|
||||
if (IEObjectTypeNames.STRUCTURE.equals(McoreUtil.getTypeName(osc.getType())) && !osc.getParams().isEmpty()
|
||||
|
@ -61,7 +61,9 @@ public class TempTableHasIndex
|
||||
{
|
||||
QuerySchemaSelectQuery selectQuery = (QuerySchemaSelectQuery)object;
|
||||
if (selectQuery.getPlacementTable() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectQuery.getIndexes() == null || selectQuery.getIndexes().isEmpty())
|
||||
{
|
||||
|
@ -156,7 +156,9 @@ public class RoleRightHasRls
|
||||
{
|
||||
Assert.isNotNull(project);
|
||||
if (mdObject == null)
|
||||
{
|
||||
return "Unknown"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (project.getScriptVariant() == ScriptVariant.RUSSIAN)
|
||||
{
|
||||
|
@ -186,7 +186,9 @@ public abstract class RoleRightSetCheck
|
||||
private String getMdObjectName(MdObject mdObject, IV8Project project)
|
||||
{
|
||||
if (mdObject == null)
|
||||
{
|
||||
return "Unknown"; //$NON-NLS-1$
|
||||
}
|
||||
|
||||
if (project != null && project.getScriptVariant() == ScriptVariant.RUSSIAN)
|
||||
{
|
||||
|
@ -108,7 +108,7 @@
|
||||
<module name="MethodParamPad" />
|
||||
<module name="NoLineWrap" />
|
||||
<module name="NoWhitespaceAfter">
|
||||
<property name="tokens" value="ARRAY_INIT, INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, ARRAY_DECLARATOR, INDEX_OP, METHOD_REF" />
|
||||
<property name="tokens" value="INC, DEC, UNARY_MINUS, UNARY_PLUS, BNOT, LNOT, DOT, INDEX_OP, METHOD_REF" />
|
||||
</module>
|
||||
<module name="NoWhitespaceBefore">
|
||||
<property name="tokens" value="DOT" />
|
||||
@ -169,5 +169,13 @@
|
||||
<module name="SuperFinalize" />
|
||||
<module name="FallThrough" />
|
||||
<module name="MissingSwitchDefault" />
|
||||
<module name="NeedBraces" />
|
||||
|
||||
<!-- var -->
|
||||
<module name="IllegalType">
|
||||
<property name="illegalClassNames" value="var"/>
|
||||
<property name="tokens" value="VARIABLE_DEF"/>
|
||||
<property name="id" value="IllegalVar"/>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
||||
</module>
|
@ -45,7 +45,7 @@ import com.google.inject.Inject;
|
||||
/**
|
||||
* Tests for {@link ISortService}
|
||||
*/
|
||||
@RunWith(value = JUnitGuiceRunner.class)
|
||||
@RunWith(JUnitGuiceRunner.class)
|
||||
@GuiceModules(modules = { ExternalDependenciesModule.class })
|
||||
public class SortServiceTest
|
||||
{
|
||||
|
@ -1,6 +1,15 @@
|
||||
/**
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021, 1C-Soft LLC and others.
|
||||
*
|
||||
*/
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* 1C-Soft LLC - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.e1c.v8codestyle.md.itests;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
@ -1,6 +1,15 @@
|
||||
/**
|
||||
/*******************************************************************************
|
||||
* Copyright (C) 2021, 1C-Soft LLC and others.
|
||||
*
|
||||
*/
|
||||
* This program and the accompanying materials are made
|
||||
* available under the terms of the Eclipse Public License 2.0
|
||||
* which is available at https://www.eclipse.org/legal/epl-2.0/
|
||||
*
|
||||
* SPDX-License-Identifier: EPL-2.0
|
||||
*
|
||||
* Contributors:
|
||||
* 1C-Soft LLC - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.e1c.v8codestyle.md.itests;
|
||||
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
Loading…
Reference in New Issue
Block a user