diff --git a/org.eclipse.titan.designer/plugin.xml b/org.eclipse.titan.designer/plugin.xml index 67c0ebf76bbb47876731ec13bcb200debde96ed1..55dea4491fb44a4f7c359ca0df6444c3fc3d8207 100644 --- a/org.eclipse.titan.designer/plugin.xml +++ b/org.eclipse.titan.designer/plugin.xml @@ -1646,21 +1646,10 @@ - - - - - - - - + diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Assignment.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Assignment.java index 46574ec0ba3113787072cc370e5e85c63a4318be..3170cdf220e4c35837d99056736ca90b363b3925 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Assignment.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/Assignment.java @@ -425,6 +425,6 @@ public abstract class Assignment extends ASTNode implements IOutlineElement, ILo } protected void removeMining() { - CodeMiningMaps.removeHeaderMining(location); + CodeMiningMaps.removeCodeMining(location); } } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/definitions/Definition.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/definitions/Definition.java index 47576fe6c29e204dcc95d2ce8fab7c5c4224a322..be660a225f6e1d764656356e34e930fb9cd3e396 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/definitions/Definition.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/AST/TTCN3/definitions/Definition.java @@ -62,6 +62,7 @@ import org.eclipse.titan.designer.compiler.JavaGenData; import org.eclipse.titan.designer.editors.AstSyntaxHighlightTokens; import org.eclipse.titan.designer.editors.AstSyntaxHighlightTokens.SyntaxDecoration; import org.eclipse.titan.designer.editors.CodeMiningMaps; +import org.eclipse.titan.designer.editors.CodeMiningMaps.CodeMiningType; import org.eclipse.titan.designer.editors.ProposalCollector; import org.eclipse.titan.designer.editors.actions.DeclarationCollector; import org.eclipse.titan.designer.editors.controls.PeekSource; @@ -524,11 +525,7 @@ public abstract class Definition extends Assignment implements IAppendableSyntax AstSyntaxHighlightTokens.addSyntaxDecoration(getIdentifier().getLocation(), SyntaxDecoration.Unused); } if (this instanceof IFunctionBase) { - CodeMiningMaps.addHeaderMining(getLocation(), "[Function definition]", null); - } - if (this instanceof Def_Const) { -// CodeMiningMaps.addContentMining(getLocation(), new Position(getLocation().getEndOffset()), "[Hello world]", -// PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_ELCL_STOP)); + CodeMiningMaps.addCodeMining(CodeMiningType.Header, getLocation(), "[Function definition]", null); } } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/CodeMiningMaps.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/CodeMiningMaps.java index b43b55ee3f826b03e798f4ecff1a0a08872ead84..7473a24308e277f78d349a1face5db88fd000f0d 100755 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/CodeMiningMaps.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/CodeMiningMaps.java @@ -10,7 +10,7 @@ package org.eclipse.titan.designer.editors; import java.util.HashMap; import java.util.Map; -import org.eclipse.collections.api.tuple.Pair; +import org.eclipse.collections.api.tuple.Triple; import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; import org.eclipse.collections.impl.tuple.Tuples; import org.eclipse.core.resources.IFile; @@ -28,135 +28,79 @@ import org.eclipse.titan.designer.AST.NULL_Location; * */ public final class CodeMiningMaps { + public enum CodeMiningType { Header, Content, LineEnd } + //* file based map of code minings - private static Map>> headerMinings; - private static Map>> contentMinings; + private static Map>> codeMinings; static { - headerMinings = new HashMap<>(); - contentMinings = new HashMap<>(); - } - - /** - * Gets the existing code mining map for the given filename. If it does not exist, - * a new empty map is created. - * - * @param key - * @return - */ - private static synchronized IntObjectHashMap> getHeaderMiningMap(String key) { - final IntObjectHashMap> existing = headerMinings.get(key); - if (existing != null) { - return existing; - } - IntObjectHashMap> newmap = new IntObjectHashMap>(); - headerMinings.put(key, newmap); - return newmap; + codeMinings = new HashMap<>(); } - - private static synchronized IntObjectHashMap> getContentMiningMap(String key) { - final IntObjectHashMap> existing = contentMinings.get(key); + + private static synchronized IntObjectHashMap> getCodeMiningMap(String key) { + final IntObjectHashMap> existing = codeMinings.get(key); if (existing != null) { return existing; } - IntObjectHashMap> newmap = new IntObjectHashMap>(); - contentMinings.put(key, newmap); + IntObjectHashMap> newmap = + new IntObjectHashMap>(); + codeMinings.put(key, newmap); return newmap; } - /** - * Associates a code mining map with the given filename - * - * @param filename - * @param newmap - */ - private static synchronized void setHeaderMiningMap(String filename, IntObjectHashMap> newmap) { - headerMinings.put(filename, newmap); - } - - private static synchronized void setContentMiningMap(String filename, IntObjectHashMap> newmap) { - contentMinings.put(filename, newmap); + private static synchronized void setCodeMiningMap(String filename, IntObjectHashMap> newmap) { + codeMinings.put(filename, newmap); } - public static synchronized void addContentMining(Location location, Position position, String text, Image image) { + public static synchronized void addCodeMining(CodeMiningType type, Location location, Position position, String text, Image image) { if (location == NULL_Location.INSTANCE) { return; } String file = location.getFile().getFullPath().toOSString(); - addContentMining(file, position, text, image); + addCodeMining(type, file, position, text, image); } - public static synchronized void addContentMining(Location location, Position position, String text) { + public static synchronized void addCodeMining(CodeMiningType type, Location location, Position position, String text) { if (location == NULL_Location.INSTANCE) { return; } String file = location.getFile().getFullPath().toOSString(); - addContentMining(file, position, text); - } - - public static synchronized void addContentMining(String key, Position position, String text, Image image) { - final IntObjectHashMap> miningMap = getContentMiningMap(key); - if (miningMap == null) { - return; - } - miningMap.asSynchronized().put(position.offset, Tuples.pair(text, image)); - } - - public static synchronized void addContentMining(String key, Position position, String text) { - addContentMining(key, position, text, null); + addCodeMining(type, file, position, text); } - public static synchronized void addHeaderMining(Location location, String text, Image image) { + public static synchronized void addCodeMining(CodeMiningType type, Location location, String text, Image image) { if (location == NULL_Location.INSTANCE) { return; } String file = location.getFile().getFullPath().toOSString(); - addHeaderMining(file, location.getLine(), text, image); - } - - /** - * Adds a code mining entry to the map based on the location. - * - * @param location Location of the object to be annotated - * @param text Code mining text - */ - public static synchronized void addHeaderMining(Location location, String text) { - if (location == NULL_Location.INSTANCE) { + final IntObjectHashMap> miningMap = getCodeMiningMap(file); + if (miningMap == null) { return; } - String file = location.getFile().getFullPath().toOSString(); - addHeaderMining(file, location.getLine(), text); - } - - public static void addHeaderMining(String key, int offset, String text) { - addHeaderMining(key, offset, text, null); + if (type == CodeMiningType.Header) { + miningMap.asSynchronized().put(location.getLine(), Tuples.triple(type, text, image)); + } else { + miningMap.asSynchronized().put(location.getOffset(), Tuples.triple(type, text, image)); + } } - public static void addHeaderMining(String key, int offset, String text, Image image) { - final IntObjectHashMap> miningMap = getHeaderMiningMap(key); + public static synchronized void addCodeMining(CodeMiningType type, String key, Position position, String text, Image image) { + final IntObjectHashMap> miningMap = getCodeMiningMap(key); if (miningMap == null) { return; } - miningMap.asSynchronized().put(offset, Tuples.pair(text, image)); + miningMap.asSynchronized().put(position.offset, Tuples.triple(type, text, image)); } - /** - * Gets the mining map for the given file - * @param file - * @return - */ - public static synchronized IntObjectHashMap> getHeaderMinings(final IFile file) { - if (file == null) { - return null; - } - return getHeaderMiningMap(file.getFullPath().toOSString()); + public static synchronized void addCodeMining(CodeMiningType type, String key, Position position, String text) { + addCodeMining(type, key, position, text, null); } - public static synchronized IntObjectHashMap> getContentMinings(final IFile file) { + public static synchronized IntObjectHashMap> getCodeMinings(final IFile file) { if (file == null) { return null; } - return getContentMiningMap(file.getFullPath().toOSString()); + return getCodeMiningMap(file.getFullPath().toOSString()); } /** @@ -167,7 +111,7 @@ public final class CodeMiningMaps { * @param removedNL number of newline characters removed by the update */ public static synchronized void update(String filename, DocumentEvent event, int removedNL) { - final IntObjectHashMap> existing = headerMinings.get(filename); + final IntObjectHashMap> existing = codeMinings.get(filename); if (existing == null) { return; } @@ -177,70 +121,42 @@ public final class CodeMiningMaps { replCount -= removedNL; } int intCount = (int)replCount; - final IntObjectHashMap> tempMap = new IntObjectHashMap>(); - existing.forEachKeyValue((int key, Pair value) -> { - try { - if (event.fDocument.getLineOfOffset(event.fOffset) < key) { - tempMap.put(key + intCount, value); - } else { - tempMap.put(key, value); - } - } catch (BadLocationException e) { - e.printStackTrace(); - } - }); - CodeMiningMaps.setHeaderMiningMap(filename, tempMap); - - final IntObjectHashMap> existingContent = contentMinings.get(filename); - if (existingContent == null) { - return; - } - final IntObjectHashMap> tempContentMap = new IntObjectHashMap>(); final int change = event.getText().length() - event.fLength; - existingContent.forEachKeyValue((int key, Pair value) -> { - if (key < event.fOffset || key > event.fOffset + event.fLength) { - tempContentMap.put(key < event.fOffset ? key : key + change, value); + final IntObjectHashMap> tempMap = + new IntObjectHashMap>(); + existing.forEachKeyValue((int key, Triple value) -> { + switch (value.getOne()) { + case Header: + try { + if (event.fDocument.getLineOfOffset(event.fOffset) < key) { + tempMap.put(key + intCount, value); + } else { + tempMap.put(key, value); + } + } catch (BadLocationException e) { } + break; + case Content: + case LineEnd: + if (key < event.fOffset || key > event.fOffset + event.fLength) { + tempMap.put(key < event.fOffset ? key : key + change, value); + } + break; } }); - CodeMiningMaps.setContentMiningMap(filename, tempContentMap); - } - - /** - * Removes the given mining from the map - * @param location - */ - public static void removeHeaderMining(Location location) { - if (location == NULL_Location.INSTANCE) { - return; - } - final String file = location.getFile().getFullPath().toOSString(); - removeHeaderMining(file, location.getLine()); - } - - /** - * Removes the given mining from the map - * @param key - * @param line - */ - public static void removeHeaderMining(String key, int line) { - final IntObjectHashMap> miningMap = getHeaderMiningMap(key); - if (miningMap == null) { - return; - } - miningMap.asSynchronized().remove(line); + CodeMiningMaps.setCodeMiningMap(filename, tempMap); } - public static void removeContentMining(Location location) { + public static void removeCodeMining(Location location) { if (location == NULL_Location.INSTANCE) { return; } final String file = location.getFile().getFullPath().toOSString(); - removeContentMining(file, location.getLine()); + removeCodeMining(file, location.getLine()); } - public static void removeContentMining(String key, int line) { - final IntObjectHashMap> miningMap = getContentMiningMap(key); + public static void removeCodeMining(String key, int line) { + final IntObjectHashMap> miningMap = getCodeMiningMap(key); if (miningMap == null) { return; } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/GitUtilities.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/GitUtilities.java index 1c748258d0a39f5de2511e9a2bae4ab4df8a3862..ff388c17d17900fe16930dcbb096d612e7e9e0d5 100755 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/GitUtilities.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/GitUtilities.java @@ -37,6 +37,9 @@ import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.treewalk.AbstractTreeIterator; import org.eclipse.jgit.treewalk.FileTreeIterator; import org.eclipse.jgit.util.io.DisabledOutputStream; +import org.eclipse.swt.graphics.Image; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; /** * Git helper utilities @@ -45,6 +48,8 @@ import org.eclipse.jgit.util.io.DisabledOutputStream; * */ public class GitUtilities { + private static Image historyIcon = null; + /** * Gets commit information for a given file/line (using 'git blame') * @@ -111,7 +116,7 @@ public class GitUtilities { RevCommit commit = lines.getSourceCommit(line); return "[" + modifiedBy + ", " + timeAgo(author.getWhen()) + " " + commit.getShortMessage() + "]"; } catch (IOException | GitAPIException e) { - e.printStackTrace(); + } return null; } @@ -141,4 +146,12 @@ public class GitUtilities { final long untilYears = localDate.until(now, ChronoUnit.YEARS); return untilYears + (untilYears == 1 ? " year" : " years") + " ago "; } + + public static Image getHistoryIconImage() { + if (historyIcon != null) { + return historyIcon; + } + historyIcon = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY); + return historyIcon; + } } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/HeaderCodeMiningProvider.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/CodeMiningProvider.java similarity index 70% rename from org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/HeaderCodeMiningProvider.java rename to org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/CodeMiningProvider.java index 81f1381f532fdd8c254bf202fc2e6ffc5d8c78d8..f3026d5e134d3799d20f06c083f047cd27019977 100755 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/HeaderCodeMiningProvider.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/CodeMiningProvider.java @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.CompletableFuture; -import org.eclipse.collections.api.tuple.Pair; +import org.eclipse.collections.api.tuple.Triple; import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IProgressMonitor; @@ -20,25 +20,19 @@ import org.eclipse.core.runtime.preferences.IPreferencesService; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; +import org.eclipse.jface.text.Position; import org.eclipse.jface.text.codemining.AbstractCodeMiningProvider; import org.eclipse.jface.text.codemining.ICodeMining; import org.eclipse.swt.graphics.Image; import org.eclipse.titan.designer.editors.CodeMiningMaps; +import org.eclipse.titan.designer.editors.CodeMiningMaps.CodeMiningType; import org.eclipse.titan.designer.editors.DocumentTracker; import org.eclipse.titan.designer.preferences.PreferenceConstants; import org.eclipse.titan.designer.productUtilities.ProductConstants; import org.eclipse.ui.texteditor.ITextEditor; -/** - * - * @author Miklos Magyari - * - */ -public class HeaderCodeMiningProvider extends AbstractCodeMiningProvider { - public HeaderCodeMiningProvider() { - - } - +public class CodeMiningProvider extends AbstractCodeMiningProvider { + @Override public CompletableFuture> provideCodeMinings(ITextViewer viewer, IProgressMonitor monitor) { @@ -55,27 +49,26 @@ public class HeaderCodeMiningProvider extends AbstractCodeMiningProvider { if (textEditor instanceof TTCN3Editor) { final IFile file = DocumentTracker.getFile(document); if (file != null) { - final IntObjectHashMap> collectedMinings = CodeMiningMaps.getHeaderMinings(file); - if (collectedMinings == null) { - return null; - } - collectedMinings.forEachKeyValue((int key, Pair value) -> { + final IntObjectHashMap> collectedMinings = CodeMiningMaps.getCodeMinings(file); + collectedMinings.forEachKeyValue((int key, Triple value) -> { + final Position pos = new Position(key, value.getTwo().length()); + switch (value.getOne()) { + case Content: + minings.add(new ContentCodeMining(pos, this, value.getTwo(), value.getThree())); + break; + case LineEnd: + minings.add(new LineEndCodeMining(pos, this, value.getTwo(), value.getThree())); + break; + case Header: try { - minings.add(new HeaderCodeMining(key, document, this, value.getOne(), value.getTwo())); - } catch (BadLocationException e) { - e.printStackTrace(); - } - }); - } - return minings; + minings.add(new HeaderCodeMining(key, document, this, value.getTwo(), value.getThree())); + } catch (BadLocationException e) { } + } + }); } + return minings; + } return null; }); } - - @Override - public void dispose() { - // TODO Auto-generated method stub - } - } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMining.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMining.java index bf0fa8e93d5f827e5e086793e680ac8d775fb83d..978f8dd4876baaef35eb7b3c653c7bedb84be4f6 100755 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMining.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMining.java @@ -23,10 +23,13 @@ import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.widgets.Display; +import org.eclipse.titan.designer.editors.ColorManager; +import org.eclipse.titan.designer.editors.ColorManager.Theme; +import org.eclipse.ui.PlatformUI; public class ContentCodeMining extends LineContentCodeMining { - private final String text; - private final Image image; + protected String text; + protected Image image; public ContentCodeMining(Position position, ICodeMiningProvider provider) { super(position, provider); @@ -65,22 +68,37 @@ public class ContentCodeMining extends LineContentCodeMining { */ @Override public Point draw(GC gc, StyledText textWidget, Color color, int x, int y) { - FontData fontData = JFaceResources.getDefaultFont().getFontData()[0]; - fontData.setHeight(8); - final Font miningFont = new Font(Display.getDefault(), fontData); - gc.setFont(miningFont); - String title= getLabel() != null ? getLabel() : "no command"; - if (image != null) { - gc.drawImage(image, x + 10, y + 4); + final Theme theme = ColorManager.getColorTheme(); + final Display display = PlatformUI.getWorkbench().getDisplay(); + if (theme == Theme.Dark) { + gc.setForeground(new Color(display, 200, 200, 200)); + } else { + gc.setForeground(new Color(display, 50, 50, 50)); } - gc.drawString(title, image != null ? x + 40 : x, y, true); - Point extent = gc.stringExtent(title); + final String title= getLabel() != null ? getLabel() : ""; + final Point extent = gc.stringExtent(title); extent.x += 20; if (image != null) { extent.x += image.getBounds().width; - extent.y += image.getBounds().height; + if (image.getBounds().height > extent.y) { + extent.y = image.getBounds().height; + } + } + + final FontData fontData = JFaceResources.getDefaultFont().getFontData()[0]; + fontData.setHeight(8); + final Font miningFont = new Font(Display.getDefault(), fontData); + gc.setFont(miningFont); + final int leftmargin = getLeftMargin(); + if (image != null) { + gc.drawImage(image, x + leftmargin, y + 4); } + gc.drawString(title, image != null ? x + leftmargin + 20 : x + leftmargin + 10, y, true); return extent; } + + protected int getLeftMargin() { + return 0; + } } diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMiningProvider.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMiningProvider.java deleted file mode 100755 index 72a3f219df639fc9fdce8ea8768bc1960989c5fc..0000000000000000000000000000000000000000 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/ContentCodeMiningProvider.java +++ /dev/null @@ -1,61 +0,0 @@ -/****************************************************************************** - * Copyright (c) 2000-2022 Ericsson Telecom AB - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v2.0 - * which accompanies this distribution, and is available at - * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html - ******************************************************************************/ -package org.eclipse.titan.designer.editors.ttcn3editor; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CompletableFuture; - -import org.eclipse.collections.api.tuple.Pair; -import org.eclipse.collections.impl.map.mutable.primitive.IntObjectHashMap; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.Platform; -import org.eclipse.core.runtime.preferences.IPreferencesService; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.ITextViewer; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.text.codemining.AbstractCodeMiningProvider; -import org.eclipse.jface.text.codemining.ICodeMining; -import org.eclipse.swt.graphics.Image; -import org.eclipse.titan.designer.editors.CodeMiningMaps; -import org.eclipse.titan.designer.editors.DocumentTracker; -import org.eclipse.titan.designer.preferences.PreferenceConstants; -import org.eclipse.titan.designer.productUtilities.ProductConstants; -import org.eclipse.ui.texteditor.ITextEditor; - -public class ContentCodeMiningProvider extends AbstractCodeMiningProvider { - - @Override - public CompletableFuture> provideCodeMinings(ITextViewer viewer, - IProgressMonitor monitor) { - return CompletableFuture.supplyAsync(() -> { - List minings = new ArrayList<>(); - final IPreferencesService prefs = Platform.getPreferencesService(); - final boolean isMiningsEnabled = prefs.getBoolean(ProductConstants.PRODUCT_ID_DESIGNER, - PreferenceConstants.ENABLE_CODE_MININGS, false, null); - if (!isMiningsEnabled) { - return minings; - } - final IDocument document = viewer.getDocument(); - final ITextEditor textEditor = super.getAdapter(ITextEditor.class); - if (textEditor instanceof TTCN3Editor) { - final IFile file = DocumentTracker.getFile(document); - if (file != null) { - final IntObjectHashMap> collectedMinings = CodeMiningMaps.getContentMinings(file); - collectedMinings.forEachKeyValue((int key, Pair value) -> { - final Position pos = new Position(key, value.getOne().length()); - minings.add(new ContentCodeMining(pos, this, value.getOne(), value.getTwo())); - }); - } - return minings; - } - return null; - }); - } -} diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/LineEndCodeMining.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/LineEndCodeMining.java new file mode 100755 index 0000000000000000000000000000000000000000..eedb6d749938bc01089c842d8b516fa1f09bd7e3 --- /dev/null +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/LineEndCodeMining.java @@ -0,0 +1,33 @@ +/****************************************************************************** + * Copyright (c) 2000-2022 Ericsson Telecom AB + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html + ******************************************************************************/ +package org.eclipse.titan.designer.editors.ttcn3editor; + +import org.eclipse.jface.text.Position; +import org.eclipse.jface.text.codemining.ICodeMiningProvider; +import org.eclipse.swt.graphics.Image; + +public class LineEndCodeMining extends ContentCodeMining { + private static int LINEENDMARGIN = 20; + + public LineEndCodeMining(Position position, ICodeMiningProvider provider, String text) { + super(position, provider); + this.text = text; + this.image = null; + } + + public LineEndCodeMining(Position position, ICodeMiningProvider provider, String text, Image image) { + super(position, provider); + this.text = text; + this.image = image; + } + + @Override + protected int getLeftMargin() { + return LINEENDMARGIN; + } +} diff --git a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/TTCN3Editor.java b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/TTCN3Editor.java index 7b566e35225e84303b4b0d5d85f6e473d40ed5a7..b1d019a2e5a10f59193ab5730edaad558e161170 100644 --- a/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/TTCN3Editor.java +++ b/org.eclipse.titan.designer/src/org/eclipse/titan/designer/editors/ttcn3editor/TTCN3Editor.java @@ -7,13 +7,9 @@ ******************************************************************************/ package org.eclipse.titan.designer.editors.ttcn3editor; -import java.io.File; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.resources.WorkspaceJob; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; @@ -46,14 +42,6 @@ import org.eclipse.jface.viewers.SelectionChangedEvent; import org.eclipse.jface.viewers.StructuredSelection; import org.eclipse.jface.viewers.TreePath; import org.eclipse.jface.viewers.TreeSelection; -import org.eclipse.jgit.api.BlameCommand; -import org.eclipse.jgit.api.errors.GitAPIException; -import org.eclipse.jgit.blame.BlameResult; -import org.eclipse.jgit.lib.ObjectId; -import org.eclipse.jgit.lib.PersonIdent; -import org.eclipse.jgit.lib.Repository; -import org.eclipse.jgit.revwalk.RevCommit; -import org.eclipse.jgit.storage.file.FileRepositoryBuilder; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.titan.designer.Activator; @@ -64,6 +52,7 @@ import org.eclipse.titan.designer.declarationsearch.Declaration; import org.eclipse.titan.designer.declarationsearch.IdentifierFinderVisitor; import org.eclipse.titan.designer.editors.AstSyntaxHighlightTokens; import org.eclipse.titan.designer.editors.CodeMiningMaps; +import org.eclipse.titan.designer.editors.CodeMiningMaps.CodeMiningType; import org.eclipse.titan.designer.editors.ColorManager; import org.eclipse.titan.designer.editors.EditorTracker; import org.eclipse.titan.designer.editors.FoldingSupport; @@ -82,7 +71,6 @@ import org.eclipse.titan.designer.productUtilities.ProductConstants; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IPartListener; -import org.eclipse.ui.ISharedImages; import org.eclipse.ui.IViewPart; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchActionConstants; @@ -503,7 +491,7 @@ public final class TTCN3Editor extends AbstractDecoratedTextEditor implements IS if (lastLine != line) { if (lastLine != -1) { final IRegion region = getDocument().getLineInformation(lastLine); - CodeMiningMaps.removeContentMining(file.getFullPath().toOSString(), region.getOffset() + region.getLength()); + CodeMiningMaps.removeCodeMining(file.getFullPath().toOSString(), region.getOffset() + region.getLength()); } if (miningRefreshJob != null) { @@ -531,8 +519,8 @@ public final class TTCN3Editor extends AbstractDecoratedTextEditor implements IS return; } final Position position = new Position(miningRegion.getOffset() + miningRegion.getLength(), text.length()); - CodeMiningMaps.addContentMining(file.getFullPath().toOSString(), position, text, - PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_TOOL_COPY)); + CodeMiningMaps.addCodeMining(CodeMiningType.LineEnd, file.getFullPath().toOSString(), position, text, + GitUtilities.getHistoryIconImage()); ((ISourceViewerExtension5)getSourceViewer()).updateCodeMinings(); lastLine = line; } catch (BadLocationException e) {