Package com._1c.g5.v8.dt.bsl.ui.outline
Class BslOutlineElementUtil
java.lang.Object
com._1c.g5.v8.dt.bsl.ui.outline.BslOutlineElementUtil
Commons methods for working with Bsl outline elements
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleanallElementsHasTheSameParent(List<?> elements) Checks that all elements ofelementshave the same parentstatic intcomputeElementLengthWithComment(org.eclipse.handly.ui.outline.ICommonOutlinePage outlinePage, int elementOffset, int elementLength) Compute full length of the outline element.static voidcreateDeleteChanges(IBslConstruct element, org.eclipse.handly.snapshot.NonExpiringSnapshot snapshot, int elementOffset, int elementLength, String formatStringElement, org.eclipse.text.edits.MultiTextEdit multiEdit) Creates change corresponding to the element of Bsl outlinestatic voidcreateInsertChanges(String content, int targetOffset, org.eclipse.text.edits.MultiTextEdit multiEdit) static StringformatContent(String content, String formatStringTarget, String formatStringElement) Formats content of moving element corresponding for format in target elementstatic List<IBslConstruct>getBslElements(List<?> listOfElements) Gets allIBslConstructelementsstatic StringgetFormatString(String contents, int offset, IV8Element element) Gets formating string for element of bsl outlinestatic StringgetFormatTargetString(IBslConstruct target, org.eclipse.handly.snapshot.NonExpiringSnapshot snapshot, BslViewerDropAdapter.DropLocation location, String indent) Gets format string for target element of bsl outlinestatic ObjectgetLowerNeighbor(Object target) Gets the nearest lower neighbor of bsl outline elementstatic intgetTargetOffset(IBslConstruct target, BslViewerDropAdapter.DropLocation location, org.eclipse.handly.ui.outline.ICommonOutlinePage outlinePage) Gets actual offset for moving by target elementstatic ObjectgetUpperNeighbor(Object target) Gets the nearest upper neighbor of bsl outline elementstatic booleanhasElementByType(List<?> elements, Class<?> clazz, boolean checkChildren) Checks thatelementscontains elements of typeclazzstatic booleanisContainsType(Object target, Class<?> clazz) Checks that class oftargetin instance ofclazzstatic booleanisNestedElementsOfSelected(Object target, List<?> elements) Checks thattargetis parent element for one element fromelements
-
Method Details
-
getBslElements
Gets allIBslConstructelements- Parameters:
listOfElements- filtered lists, can't benull- Returns:
- list of
IBslConstruct, nevernull
-
createDeleteChanges
public static void createDeleteChanges(IBslConstruct element, org.eclipse.handly.snapshot.NonExpiringSnapshot snapshot, int elementOffset, int elementLength, String formatStringElement, org.eclipse.text.edits.MultiTextEdit multiEdit) throws org.eclipse.core.runtime.CoreException Creates change corresponding to the element of Bsl outline- Parameters:
element-IBslConstructdeleting element of Bsl outline, can't benullsnapshot- actualNonExpiringSnapshotfor outline's editor, can't benullelementOffset- offset of deleting elementselementLength- length of content of deleting elementsformatStringElement- actual formatting string for deleting elements, can't benullmultiEdit-MultiTextEditfor accumulate creating changes, can't benull- Throws:
org.eclipse.core.runtime.CoreException- can be throw from method#getOffsetLowerNeighbourElement()
-
getFormatString
public static String getFormatString(String contents, int offset, IV8Element element) throws org.eclipse.core.runtime.CoreException Gets formating string for element of bsl outline- Parameters:
contents- string content of element of bsl outline, can't benulloffset- offset of element of bsl outline, can't benullelement- actual element of bsl outline, can't benull- Returns:
- formating string for element of bsl outline, never
null - Throws:
org.eclipse.core.runtime.CoreException
-
getLowerNeighbor
Gets the nearest lower neighbor of bsl outline element- Parameters:
target- bsl outline element- Returns:
- the nearest lower neighbor of bsl outline element or
nulliftargetis not bsl outline element, or there is no lower neighbor - Throws:
org.eclipse.core.runtime.CoreException- can be throw from methodIElement#getChildren()
-
getUpperNeighbor
Gets the nearest upper neighbor of bsl outline element- Parameters:
target- bsl outline element- Returns:
- the nearest upper neighbor of bsl outline element or
nulliftargetis not bsl outline element, or there is no upper neighbor - Throws:
org.eclipse.core.runtime.CoreException- can be throw from methodIElement#getChildren()
-
isContainsType
public static boolean isContainsType(Object target, Class<?> clazz) throws org.eclipse.core.runtime.CoreException Checks that class oftargetin instance ofclazz- Parameters:
target- checking elements, can benullclazz- expected type, can't benull- Returns:
trueif class oftargetin instance ofclazzor iftargetinstanceofIElementand there is child instanceofclazz,falseotherwise or iftargetisnull- Throws:
org.eclipse.core.runtime.CoreException- can be throw from methodIElement#getChildren()
-
hasElementByType
public static boolean hasElementByType(List<?> elements, Class<?> clazz, boolean checkChildren) throws org.eclipse.core.runtime.CoreException Checks thatelementscontains elements of typeclazz- Parameters:
elements- checking elements, can't benullclazz- checking type, , can't benullcheckChildren-trueif need to check and children of each element ofelements,falseotherwise- Returns:
trueifelementscontains elements of typeclazz,falseotherwise or if list of elements is empty- Throws:
org.eclipse.core.runtime.CoreException- CoreException can be throw from method#isContainsType()
-
getTargetOffset
public static int getTargetOffset(IBslConstruct target, BslViewerDropAdapter.DropLocation location, org.eclipse.handly.ui.outline.ICommonOutlinePage outlinePage) throws org.eclipse.core.runtime.CoreException Gets actual offset for moving by target element- Parameters:
target- moving element of bsl outline, cannot benulllocation- actualBslViewerDropAdapter.DropLocation, cannot benulloutlinePage- actual outline page, cannot benull- Returns:
- offset for moving by target element
- Throws:
org.eclipse.core.runtime.CoreException
-
getFormatTargetString
public static String getFormatTargetString(IBslConstruct target, org.eclipse.handly.snapshot.NonExpiringSnapshot snapshot, BslViewerDropAdapter.DropLocation location, String indent) throws org.eclipse.core.runtime.CoreException Gets format string for target element of bsl outline- Parameters:
target- bsl outline element, can't benullsnapshot- actualNonExpiringSnapshotfor outline's editor, can't benulllocation- actualBslViewerDropAdapter.DropLocationindent- actual indent of text editor, can't benull- Returns:
- format string for target element, never
null - Throws:
org.eclipse.core.runtime.CoreException
-
createInsertChanges
public static void createInsertChanges(String content, int targetOffset, org.eclipse.text.edits.MultiTextEdit multiEdit) -
formatContent
public static String formatContent(String content, String formatStringTarget, String formatStringElement) Formats content of moving element corresponding for format in target element- Parameters:
content- formatting content, can't benullformatStringTarget- format of target bsl outline element, can't benullformatStringElement- format of element of bsl outline which content is being formatted, can't benull- Returns:
- formatted content of moving element corresponding for format in target element, never
null
-
allElementsHasTheSameParent
Checks that all elements ofelementshave the same parent- Parameters:
elements- checking elements, can't benull- Returns:
trueif all elements ofelementshave the same parent,falseotherwise
-
isNestedElementsOfSelected
public static boolean isNestedElementsOfSelected(Object target, List<?> elements) throws org.eclipse.core.runtime.CoreException Checks thattargetis parent element for one element fromelements- Parameters:
target- bsl outline element, can't benullelements- checking elements, can't benull- Returns:
trueiftargetis parent element for one element fromelements,falseotherwise- Throws:
org.eclipse.core.runtime.CoreException
-
computeElementLengthWithComment
public static int computeElementLengthWithComment(org.eclipse.handly.ui.outline.ICommonOutlinePage outlinePage, int elementOffset, int elementLength) Compute full length of the outline element. Full length is sum of original element length and length of the comment node with leader whitespace at the same line that end of the outline element- Parameters:
outlinePage- actual outline page, cannot benullelementOffset- actual offset of the outline elementelementLength- actual length of the outline element- Returns:
- full length of the outline element
-