Commit 4c26a9a1 authored by Sebastian Pretscher's avatar Sebastian Pretscher

Merge branch 'master' of git@github.com:jroith/cup-eclipse.git

parents b4c025d5 d3d9926e
......@@ -3,20 +3,36 @@ package de.tum.in.www2.cupplugin.editors;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.javaeditor.JavaSourceViewer;
import org.eclipse.jdt.internal.ui.text.ContentAssistPreference;
import org.eclipse.jdt.internal.ui.text.java.ContentAssistProcessor;
import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProcessor;
import org.eclipse.jdt.internal.ui.text.javadoc.JavadocCompletionProcessor;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DefaultInformationControl;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IInformationControl;
import org.eclipse.jface.text.IInformationControlCreator;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ContentAssistant;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.texteditor.ITextEditor;
import de.in.tum.www2.cup.CupSymbol;
import de.in.tum.www2.cup.Declarations;
import de.in.tum.www2.cup.ast.ParserResult;
import de.tum.in.www2.cupplugin.IDisposable;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.model.*;
public class CupContentAssistProcessor implements IContentAssistProcessor,
......@@ -27,16 +43,33 @@ public class CupContentAssistProcessor implements IContentAssistProcessor,
/*
* TODO: Find the way to get the Java Code assistant here
*/
private IContentAssistProcessor javaProcessor = null;
public CupContentAssistProcessor(IDocument doc) {
this.decls = new Declarations();
this.doc = doc;
Model model = Model.getInstanceForDocument(doc);
updateFromParserResult(model.getAstModel());
model.registerModelObserver(this);
this.javaProcessor = getJavaContentAssistProcessor();
}
@SuppressWarnings("restriction")
private IContentAssistProcessor getJavaContentAssistProcessor() {
JavaCompletionProcessor r = null;
return r;
}
public void dispose() {
Model.getInstanceForDocument(doc).unregisterModelObserver(this);
}
......
......@@ -13,6 +13,7 @@ import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
......@@ -62,10 +63,9 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
class ConflictPanel extends Composite {
private static final int BASE_HEIGHT = 90;
private static final int BASE_HEIGHT = 60;
private static final int COLUMNS = 3;
private static final int HEADING_FONT_SIZE = 14;
private static final int SIZE_INCREASE_PER_LINE = 11;
private Conflict conflict;
......@@ -200,6 +200,7 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
public void update(ConflictResolutionManager crm, Conflict conflict) {
this.conflict = conflict;
gridData.heightHint = BASE_HEIGHT;
links.clear();
int linkCounter = 0;
......@@ -207,7 +208,9 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
lalr_state state = conflict.getState();
Pair<String,Integer> hint = makeConflictResolutionHint(crm, state);
resolutionHint.setText(hint.getFirst());
gridData.heightHint = BASE_HEIGHT + hint.getSecond() * SIZE_INCREASE_PER_LINE;
gridData.heightHint += resolutionHint.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
System.err.println(gridData.heightHint);
int cindex = state.index();
stateLabel.setText("<a href=\"" + cindex + "\">State: " + cindex + "</a>");
......@@ -310,11 +313,14 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
builder.append("</a>");
if (i != size - 1)
builder.append(", ");
gridData.heightHint += SIZE_INCREASE_PER_LINE;
// gridData.heightHint += SIZE_INCREASE_PER_LINE;
}
detailText.setText(builder.toString());
gridData.heightHint += detailText.computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
} else {
throw new RuntimeException("unexpected conflict type.");
}
......
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