Package com._1c.g5.v8.dt.bsl.ui.outline
Class BslOutlineElementUtil
- java.lang.Object
-
- com._1c.g5.v8.dt.bsl.ui.outline.BslOutlineElementUtil
-
public final class BslOutlineElementUtil extends Object
Commons methods for working with Bsl outline elements
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static boolean
allElementsHasTheSameParent(List<?> elements)
Checks that all elements ofelements
have the same parentstatic int
computeElementLengthWithComment(org.eclipse.handly.ui.outline.ICommonOutlinePage outlinePage, int elementOffset, int elementLength)
Compute full length of the outline element.static void
createDeleteChanges(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 void
createInsertChanges(String content, int targetOffset, org.eclipse.text.edits.MultiTextEdit multiEdit)
static String
formatContent(String content, String formatStringTarget, String formatStringElement)
Formats content of moving element corresponding for format in target elementstatic List<IBslConstruct>
getBslElements(List<?> listOfElements)
Gets allIBslConstruct
elementsstatic String
getFormatString(String contents, int offset, IV8Element element)
Gets formating string for element of bsl outlinestatic String
getFormatTargetString(IBslConstruct target, org.eclipse.handly.snapshot.NonExpiringSnapshot snapshot, com._1c.g5.v8.dt.internal.bsl.ui.dnd.BslViewerDropAdapter.DropLocation location, String indent)
Gets format string for target element of bsl outlinestatic Object
getLowerNeighbor(Object target)
Gets the nearest lower neighbor of bsl outline elementstatic int
getTargetOffset(IBslConstruct target, com._1c.g5.v8.dt.internal.bsl.ui.dnd.BslViewerDropAdapter.DropLocation location, org.eclipse.handly.ui.outline.ICommonOutlinePage outlinePage)
Gets actual offset for moving by target elementstatic Object
getUpperNeighbor(Object target)
Gets the nearest upper neighbor of bsl outline elementstatic boolean
hasElementByType(List<?> elements, Class<?> clazz, boolean checkChildren)
Checks thatelements
contains elements of typeclazz
static boolean
isContainsType(Object target, Class<?> clazz)
Checks that class oftarget
in instance ofclazz
static boolean
isNestedElementsOfSelected(Object target, List<?> elements)
Checks thattarget
is parent element for one element fromelements
-
-
-
Method Detail
-
getBslElements
public static List<IBslConstruct> getBslElements(List<?> listOfElements)
Gets allIBslConstruct
elements- 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
-IBslConstruct
deleting element of Bsl outline, can't benull
snapshot
- actualNonExpiringSnapshot
for outline's editor, can't benull
elementOffset
- offset of deleting elementselementLength
- length of content of deleting elementsformatStringElement
- actual formatting string for deleting elements, can't benull
multiEdit
-MultiTextEdit
for 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 benull
offset
- offset of element of bsl outline, can't benull
element
- 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
public static Object getLowerNeighbor(Object target) throws org.eclipse.core.runtime.CoreException
Gets the nearest lower neighbor of bsl outline element- Parameters:
target
- bsl outline element- Returns:
- the nearest lower neighbor of bsl outline element or
null
iftarget
is not bsl outline element, or there is no lower neighbor - Throws:
org.eclipse.core.runtime.CoreException
- can be throw from methodIElement#getChildren()
-
getUpperNeighbor
public static Object getUpperNeighbor(Object target) throws org.eclipse.core.runtime.CoreException
Gets the nearest upper neighbor of bsl outline element- Parameters:
target
- bsl outline element- Returns:
- the nearest upper neighbor of bsl outline element or
null
iftarget
is 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 oftarget
in instance ofclazz
- Parameters:
target
- checking elements, can benull
clazz
- expected type, can't benull
- Returns:
true
if class oftarget
in instance ofclazz
or iftarget
instanceofIElement
and there is child instanceofclazz
,false
otherwise or iftarget
isnull
- 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 thatelements
contains elements of typeclazz
- Parameters:
elements
- checking elements, can't benull
clazz
- checking type, , can't benull
checkChildren
-true
if need to check and children of each element ofelements
,false
otherwise- Returns:
true
ifelements
contains elements of typeclazz
,false
otherwise 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, com._1c.g5.v8.dt.internal.bsl.ui.dnd.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 benull
location
- actualBslViewerDropAdapter.DropLocation
, cannot benull
outlinePage
- 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, com._1c.g5.v8.dt.internal.bsl.ui.dnd.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 benull
snapshot
- actualNonExpiringSnapshot
for outline's editor, can't benull
location
- actualBslViewerDropAdapter.DropLocation
indent
- 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 benull
formatStringTarget
- format of target bsl outline element, can't benull
formatStringElement
- 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
public static boolean allElementsHasTheSameParent(List<?> elements)
Checks that all elements ofelements
have the same parent- Parameters:
elements
- checking elements, can't benull
- Returns:
true
if all elements ofelements
have the same parent,false
otherwise
-
isNestedElementsOfSelected
public static boolean isNestedElementsOfSelected(Object target, List<?> elements) throws org.eclipse.core.runtime.CoreException
Checks thattarget
is parent element for one element fromelements
- Parameters:
target
- bsl outline element, can't benull
elements
- checking elements, can't benull
- Returns:
true
iftarget
is parent element for one element fromelements
,false
otherwise- 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 benull
elementOffset
- actual offset of the outline elementelementLength
- actual length of the outline element- Returns:
- full length of the outline element
-
-