Commit 7f564867 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

Initial implementation for fix proposals


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 6669aacb
......@@ -21,6 +21,7 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.designer.GeneralConstants;
import org.eclipse.titan.designer.compiler.JavaGenData;
import org.eclipse.titan.designer.editors.controls.HoverProposal;
/**
* The Location class represents a location in the source code.
......@@ -235,6 +236,10 @@ public class Location {
public void reportSemanticError(final String reason) {
reportProblem(reason, IMarker.SEVERITY_ERROR, GeneralConstants.ONTHEFLY_SEMANTIC_MARKER);
}
public void reportSemanticError(final String reason, HoverProposal[] proposals) {
reportProblem(reason, IMarker.SEVERITY_ERROR, GeneralConstants.ONTHEFLY_SEMANTIC_MARKER, proposals);
}
/**
* Reports a semantic error to this location containing the supplied reason of error.
......@@ -343,8 +348,16 @@ public class Location {
protected void reportProblem(final String reason, final int severity, final String markerID) {
reportProblem(reason, severity, IMarker.PRIORITY_HIGH, markerID);
}
protected void reportProblem(final String reason, final int severity, final String markerID, HoverProposal[] proposals) {
reportProblem(reason, severity, IMarker.PRIORITY_HIGH, markerID, proposals);
}
protected void reportProblem(final String reason, final int severity, final int priority, final String markerID) {
reportProblem(reason, severity, IMarker.PRIORITY_HIGH, markerID, null);
}
protected void reportProblem(final String reason, final int severity, final int priority, final String markerID, HoverProposal[] proposals) {
final Map<String, Object> markerProperties = new HashMap<String, Object>();
final Integer lineNumber = Integer.valueOf(line);
......@@ -362,6 +375,9 @@ public class Location {
markerProperties.put(IMarker.PRIORITY, Integer.valueOf(priority));
markerProperties.put(IMarker.MESSAGE, reason);
markerProperties.put(IMarker.TRANSIENT, Boolean.TRUE);
if (proposals != null) {
markerProperties.put(HoverProposal.PROPOSAL, proposals);
}
try {
if (file != null && file.isAccessible()) {
final IMarker marker = MarkerHandler.hasMarker(markerID, file, line, offset, endOffset, severity, reason);
......
......@@ -63,6 +63,7 @@ import org.eclipse.titan.designer.editors.ProposalCollector;
import org.eclipse.titan.designer.editors.Stylers;
import org.eclipse.titan.designer.editors.T3Doc;
import org.eclipse.titan.designer.editors.actions.DeclarationCollector;
import org.eclipse.titan.designer.editors.controls.HoverProposal;
import org.eclipse.titan.designer.editors.controls.HoverContentType;
import org.eclipse.titan.designer.editors.controls.Ttcn3HoverContent;
import org.eclipse.titan.designer.editors.ttcn3editor.TTCN3CodeSkeletons;
......@@ -609,7 +610,10 @@ public final class Def_Function extends Definition implements IParameterisedAssi
switch (block.hasReturn(timestamp)) {
case RS_NO:
identifier.getLocation().reportSemanticError(
"The function has a return type, but it does not have any return statement");
"The function has a return type, but it does not have any return statement",
new HoverProposal[] {
new HoverProposal("Add return statement...")
});
break;
case RS_MAYBE:
identifier.getLocation()
......
......@@ -26,7 +26,6 @@ import org.eclipse.jface.text.source.LineRange;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.titan.common.logging.ErrorReporter;
import org.eclipse.titan.designer.editors.controls.MarkerHoverContent;
import org.eclipse.titan.designer.editors.controls.MarkerHoverInfoControl;
import org.eclipse.titan.designer.editors.controls.Ttcn3HoverInfoControl;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.texteditor.MarkerAnnotation;
......
/******************************************************************************
* Copyright (c) 2000-2021 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.controls;
import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.ui.IMarkerResolution;
public class HoverProposal implements IMarkerResolution {
public static String PROPOSAL = "proposal";
private String label;
public HoverProposal(String label) {
this.label = label;
}
@Override
public String getLabel() {
return label;
}
@Override
public void run(IMarker marker) {
MessageDialog.openInformation(null, "QuickFix Demo",
"This quick-fix is not yet implemented");
}
}
/******************************************************************************
* Copyright (c) 2000-2021 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.controls;
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment