[SCM] Lisaac compiler branch, master, updated. lisaac-0.12-503-g8377b34
Damien Bouvarel
dams.bouvarel at wanadoo.fr
Thu Oct 1 14:46:23 UTC 2009
The following commit has been merged in the master branch:
commit 8377b346a18276c807266b17b4441edd25750316
Author: Damien Bouvarel <dams.bouvarel at wanadoo.fr>
Date: Thu Oct 1 16:45:10 2009 +0200
completion & navigation ok everywhere in lisaac code (normally)
diff --git a/editor/eclipse/eclisaac/META-INF/MANIFEST.MF b/editor/eclipse/eclisaac/META-INF/MANIFEST.MF
index 287772f..0fd949d 100644
--- a/editor/eclipse/eclisaac/META-INF/MANIFEST.MF
+++ b/editor/eclipse/eclisaac/META-INF/MANIFEST.MF
@@ -1,7 +1,7 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-SymbolicName: org.lisaac.ldt;singleton:=true
-Bundle-Version: 1.1.6
+Bundle-Version: 1.1.7
Bundle-Activator: org.lisaac.ldt.LisaacPlugin
Bundle-Vendor: %Bundle-Vendor.0
Require-Bundle: org.eclipse.ui,
@@ -23,86 +23,75 @@ Import-Package: org.eclipse.debug.core,
org.eclipse.ui.texteditor.templates,
org.eclipse.ui.views.contentoutline
Export-Package: org.lisaac.ldt;
- uses:="org.eclipse.jface.text.templates.persistence,
- org.eclipse.jface.text.templates,
- org.osgi.framework,
- org.eclipse.ui.plugin,
+ uses:="org.eclipse.core.runtime,
org.eclipse.jface.resource,
- org.eclipse.core.runtime",
+ org.eclipse.ui.plugin,
+ org.eclipse.jface.text.templates.persistence,
+ org.osgi.framework,
+ org.eclipse.jface.text.templates",
org.lisaac.ldt.actions;
- uses:="org.eclipse.jface.viewers,
- org.eclipse.ltk.ui.refactoring,
- org.eclipse.jface.text,
- org.lisaac.ldt.editors,
- org.eclipse.jface.action,
- org.eclipse.swt.widgets,
- org.eclipse.ui",
- org.lisaac.ldt.builder;uses:="org.lisaac.ldt.model,org.eclipse.core.resources,org.eclipse.core.runtime",
- org.lisaac.ldt.editors;
- uses:="org.eclipse.jface.util,
+ uses:="org.eclipse.jface.action,
+ org.eclipse.ui,
org.eclipse.jface.viewers,
- org.eclipse.jface.text.presentation,
- org.eclipse.swt.graphics,
- org.eclipse.jface.text,
- org.eclipse.core.resources,
- org.eclipse.ui.editors.text,
- org.eclipse.jface.text.source,
- org.eclipse.jface.preference,
- org.lisaac.ldt.model,
+ org.eclipse.swt.widgets",
+ org.lisaac.ldt.builder;uses:="org.lisaac.ldt.model,org.eclipse.core.runtime,org.eclipse.core.resources",
+ org.lisaac.ldt.editors;
+ uses:="org.eclipse.jface.text,
org.eclipse.jface.text.hyperlink,
+ org.eclipse.core.runtime,
+ org.eclipse.jface.text.source,
org.eclipse.jface.text.rules,
+ org.eclipse.jface.text.contentassist,
+ org.lisaac.ldt.model,
+ org.eclipse.jface.preference,
+ org.eclipse.jface.text.presentation,
+ org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.graphics,
+ org.eclipse.jface.util,
org.eclipse.swt.widgets,
- org.eclipse.jface.text.contentassist",
+ org.eclipse.ui.editors.text",
org.lisaac.ldt.launch;
- uses:="org.lisaac.ldt.model,
- org.eclipse.jface.viewers,
- org.eclipse.debug.core.model,
+ uses:="org.eclipse.debug.core,
org.eclipse.debug.ui,
- org.eclipse.core.resources,
- org.eclipse.swt.widgets,
org.eclipse.core.runtime,
org.eclipse.ui,
- org.eclipse.debug.core",
- org.lisaac.ldt.model;
- uses:="org.lisaac.ldt.model.items,
- org.lisaac.ldt.model.types,
- org.lisaac.ldt.editors,
+ org.eclipse.debug.core.model,
org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.graphics,
+ org.eclipse.swt.widgets",
+ org.lisaac.ldt.model;
+ uses:="org.lisaac.ldt.model.types,
+ org.lisaac.ldt.model.items,
org.lisaac.ldt.model.lip,
- org.lisaac.ldt.builder,
- org.eclipse.core.runtime",
- org.lisaac.ldt.model.items;
- uses:="org.lisaac.ldt.model,
- org.eclipse.jface.text,
- org.lisaac.ldt.model.types,
- org.eclipse.ltk.core.refactoring,
org.eclipse.core.resources,
- org.eclipse.core.runtime",
+ org.lisaac.ldt.builder",
+ org.lisaac.ldt.model.items;uses:="org.lisaac.ldt.model,org.lisaac.ldt.model.types",
org.lisaac.ldt.model.lip,
org.lisaac.ldt.model.types,
- org.lisaac.ldt.outline;uses:="org.eclipse.jface.viewers,org.lisaac.ldt.model.items,org.eclipse.swt.graphics",
+ org.lisaac.ldt.outline;uses:="org.lisaac.ldt.model.items,org.eclipse.jface.viewers,org.eclipse.swt.graphics",
org.lisaac.ldt.perspectives;uses:="org.eclipse.ui",
org.lisaac.ldt.preferences;
- uses:="org.eclipse.jface.preference,
- org.eclipse.core.runtime.preferences,
- org.eclipse.ui.texteditor.templates,
- org.eclipse.ui",
- org.lisaac.ldt.properties;uses:="org.eclipse.ui.dialogs,org.eclipse.swt.widgets",
- org.lisaac.ldt.templates;uses:="org.eclipse.swt.graphics,org.eclipse.jface.text.templates,org.eclipse.jface.text",
+ uses:="org.eclipse.ui.texteditor.templates,
+ org.eclipse.jface.preference,
+ org.eclipse.ui,
+ org.eclipse.core.runtime.preferences",
+ org.lisaac.ldt.properties;uses:="org.eclipse.core.resources,org.eclipse.ui.dialogs,org.eclipse.swt.widgets",
+ org.lisaac.ldt.templates;uses:="org.eclipse.jface.text,org.eclipse.swt.graphics,org.eclipse.jface.text.templates",
org.lisaac.ldt.views;
- uses:="org.eclipse.jface.viewers,
+ uses:="org.eclipse.jface.text,
+ org.eclipse.ui.texteditor,
org.eclipse.ui.console,
org.eclipse.ui.views.contentoutline,
- org.eclipse.jface.text,
- org.eclipse.ui.texteditor,
org.eclipse.core.resources,
+ org.eclipse.jface.viewers,
org.eclipse.swt.widgets",
org.lisaac.ldt.wizards;
- uses:="org.eclipse.jface.dialogs,
- org.eclipse.jface.viewers,
+ uses:="org.eclipse.jface.wizard,
+ org.eclipse.ui,
org.eclipse.core.resources,
- org.eclipse.jface.wizard,
- org.eclipse.swt.widgets,
- org.eclipse.ui"
+ org.eclipse.jface.viewers,
+ org.eclipse.swt.widgets"
Bundle-Localization: plugin
Bundle-Name: %Bundle-Name.0
diff --git a/editor/eclipse/eclisaac/build.properties b/editor/eclipse/eclisaac/build.properties
index efd7c19..329e511 100644
--- a/editor/eclipse/eclisaac/build.properties
+++ b/editor/eclipse/eclisaac/build.properties
@@ -1,13 +1,20 @@
+source.. = src/
+output.. = bin/
bin.includes = META-INF/,\
+ .,\
bin/,\
- help/,\
icons/,\
+ plugin.xml,\
plugin.properties,\
- plugin.xml
-src.includes = icons/,\
help/,\
+ build.properties
+bin.excludes = icons/Thumbs.db
+src.excludes = icons/Thumbs.db
+src.includes = META-INF/,\
+ README,\
build.properties,\
- META-INF/,\
- src/,\
+ help/,\
+ icons/,\
+ plugin.properties,\
plugin.xml,\
- plugin.properties
+ src/
diff --git a/editor/eclipse/eclisaac/plugin.xml b/editor/eclipse/eclisaac/plugin.xml
index cfadac6..3b853ce 100644
--- a/editor/eclipse/eclisaac/plugin.xml
+++ b/editor/eclipse/eclisaac/plugin.xml
@@ -509,5 +509,13 @@
</action>
</viewerContribution>
</extension>
+ <extension
+ id="product"
+ point="org.eclipse.core.runtime.products">
+ <product
+ application="eclisaac_product.application"
+ name="eclisaac">
+ </product>
+ </extension>
</plugin>
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/LisaacPlugin.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/LisaacPlugin.java
index 56d14fd..7dfb3fa 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/LisaacPlugin.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/LisaacPlugin.java
@@ -106,7 +106,7 @@ public class LisaacPlugin extends AbstractUIPlugin {
}
// clean all lisaac projects to get started
- projects[i].build(IncrementalProjectBuilder.CLEAN_BUILD, null);
+ projects[i].build(IncrementalProjectBuilder.FULL_BUILD, null);
} catch (Exception e) {
log(new Status(IStatus.ERROR,
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/ColorManager.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/ColorManager.java
index cef19a8..517e5cb 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/ColorManager.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/ColorManager.java
@@ -5,6 +5,7 @@ import java.util.Iterator;
import java.util.Map;
import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.jface.viewers.StyledString.Styler;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.jface.text.TextAttribute;
@@ -13,20 +14,38 @@ import org.eclipse.jface.text.rules.Token;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.TextStyle;
import org.eclipse.swt.widgets.Display;
public class ColorManager {
+ private static ColorManager instance;
+
protected Map<RGB,Color> fColorTable = new HashMap<RGB,Color>(10);
private Map<String,IToken> tokenTable = new HashMap<String,IToken>(10);
private Map<String,String> styleTable = new HashMap<String,String>(10);
private final IPreferenceStore preferenceStore;
+ private Styler operatorStyler;
+ private Styler prototypeStyler;
+ private Styler slotStyler;
+ private Styler variableStyler;
+
public ColorManager(IPreferenceStore preferenceStore) {
this.preferenceStore = preferenceStore;
+ instance = this;
+
+ operatorStyler = new DefaultStyler(ILisaacColor.PREF_OPERATOR, ILisaacColor.STYLE_OPERATOR);
+ prototypeStyler = new DefaultStyler(ILisaacColor.PREF_PROTOTYPE, ILisaacColor.STYLE_PROTOTYPE);
+ slotStyler = new DefaultStyler(ILisaacColor.PREF_SLOT, ILisaacColor.STYLE_SLOT);
+ variableStyler = new DefaultStyler(ILisaacColor.PREF_LOCAL_SLOT, ILisaacColor.STYLE_LOCAL_SLOT);
}
+ public static ColorManager getDefault() {
+ return instance;
+ }
+
public void dispose() {
Iterator<Color> e = fColorTable.values().iterator();
while (e.hasNext())
@@ -123,4 +142,34 @@ public class ColorManager {
}
return SWT.NORMAL;
}
+
+ public Styler getOperatorStyler() {
+ return operatorStyler;
+ }
+
+ public Styler getPrototypeStyler() {
+ return prototypeStyler;
+ }
+
+ public Styler getSlotStyler() {
+ return slotStyler;
+ }
+
+ public Styler getVariableStyler() {
+ return variableStyler;
+ }
+
+ private class DefaultStyler extends Styler {
+ String prefKey, styleKey;
+
+ public DefaultStyler(String prefKey, String styleKey) {
+ this.prefKey = prefKey;
+ this.styleKey = styleKey;
+ }
+ public void applyStyles(TextStyle textStyle) {
+ IToken token = getToken(prefKey, styleKey);
+ TextAttribute attrib = (TextAttribute) token.getData();
+ textStyle.foreground = attrib.getForeground();
+ }
+ }
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java
index 935351c..848452d 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacCompletionProcessor.java
@@ -1,6 +1,9 @@
package org.lisaac.ldt.editors;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.BadLocationException;
@@ -13,6 +16,7 @@ import org.eclipse.jface.text.contentassist.IContextInformationValidator;
import org.eclipse.jface.text.templates.TemplateProposal;
import org.lisaac.ldt.LisaacPlugin;
import org.lisaac.ldt.model.LisaacCompletionParser;
+import org.lisaac.ldt.model.LisaacParser;
import org.lisaac.ldt.preferences.PreferenceConstants;
import org.lisaac.ldt.templates.LisaacTemplateProcessor;
@@ -38,6 +42,13 @@ public class LisaacCompletionProcessor implements IContentAssistProcessor {
//
computeLisaacCompletion(document, offset, result);
+ if (result.size() > 1) {
+ Collections.sort(result, new Comparator<ICompletionProposal>() {
+ public int compare(ICompletionProposal o1, ICompletionProposal o2) {
+ return o1.getDisplayString().compareTo(o2.getDisplayString());
+ }
+ });
+ }
//
String prefix= extractPrefix(document, offset);
@@ -77,6 +88,9 @@ public class LisaacCompletionProcessor implements IContentAssistProcessor {
if (c == '-' && pos-1 > 0 && document.getChar(pos-1) == '<') {
break;
}
+ if (LisaacParser.isOperatorSymbol(c)) {
+ break;
+ }
if (c == '(' || c == '{' || c == '[') {
if (bracketLevel == 0) {
break;
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacConfiguration.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacConfiguration.java
index 437a03e..1e802e6 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacConfiguration.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacConfiguration.java
@@ -71,6 +71,7 @@ public class LisaacConfiguration extends SourceViewerConfiguration {
//
contentAssistant.setRepeatedInvocationMode(true);
contentAssistant.setStatusLineVisible(true);
+ contentAssistant.enableColoredLabels(true);
contentAssistant.setStatusMessage(LisaacMessages.getString("LisaacConfiguration_0")); //$NON-NLS-1$
//
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacTextHover.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacTextHover.java
index dbe977d..08bb85d 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacTextHover.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/LisaacTextHover.java
@@ -64,6 +64,12 @@ public class LisaacTextHover implements ITextHover, ITextHoverExtension {
IVariable variable = slot.getVariable(text, hoverRegion.getOffset());
if (variable != null) {
return variable.getHoverInformation();
+ } else {
+ // is 'text' a slot-call argument?
+ slot = prototype.lookupSlot(text);
+ if (slot != null) {
+ return "<I>Argument</I> : "+slot.getHoverInformation();
+ }
}
}
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/PrototypeHyperLink.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/PrototypeHyperLink.java
index 236dfcf..7fea1c5 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/PrototypeHyperLink.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/editors/PrototypeHyperLink.java
@@ -102,7 +102,14 @@ public class PrototypeHyperLink implements IHyperlink {
}
position = new Position(0, 0, p.offset-len, len);
} else {
- prototype = null;
+ // is 'text' a slot-call argument?
+ slot = prototype.lookupSlot(fPrototypeString);
+ if (slot != null) {
+ prototype = slot.getPrototype();
+ position = slot.getPosition();
+ } else {
+ prototype = null;
+ }
}
}
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacCompiler.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacCompiler.java
index a5029b7..fb3ef2a 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacCompiler.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacCompiler.java
@@ -4,6 +4,7 @@ import java.util.ArrayList;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
@@ -118,7 +119,10 @@ public class LisaacCompiler {
output.refreshLocal(IResource.DEPTH_INFINITE, null);
// move the generated files to bin/
- IContainer bin = project.getFolder("bin");
+ IFolder bin = project.getFolder("bin");
+ if (! bin.exists()) {
+ bin.create(false,true,null);
+ }
IPath generatedPath = new Path(outputName);
IFile executable = output.getFile(generatedPath);
if (! executable.exists()) {
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacLauncher.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacLauncher.java
index bb55953..cf76b22 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacLauncher.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/launch/LisaacLauncher.java
@@ -6,6 +6,7 @@ import java.io.IOException;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.IStreamListener;
@@ -18,7 +19,7 @@ import org.lisaac.ldt.views.LisaacConsole;
public class LisaacLauncher {
- public static boolean executeCommandInConsole(final ILaunch launch, final IProgressMonitor monitor,
+ public static boolean executeCommandInConsole(final ILaunch launch, IProgressMonitor monitorParent,
final IContainer container, final String[] commandLine, final LisaacCompiler compiler) throws CoreException {
// get & clear lisaac console
final LisaacConsole console = ConsoleFactory.getConsole();
@@ -27,6 +28,8 @@ public class LisaacLauncher {
if (compiler == null) {
console.activate();// show console
}
+ final IProgressMonitor monitor = new NullProgressMonitor();
+
Runnable getStandardOutput = new Runnable() {
public void run() {
monitor.beginTask("Executing... ", 100);
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/AbstractLisaacParser.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/AbstractLisaacParser.java
index f3fae9e..12b309b 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/AbstractLisaacParser.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/AbstractLisaacParser.java
@@ -32,6 +32,10 @@ public class AbstractLisaacParser {
public Position getPosition(int len) {
Position result=null;
+ if (position > source.length()) { // outline thread bug
+ return new Position(pos_line, pos_col, pos_cur, len);
+ }
+
while (pos_cur < position) {
if (source.charAt(pos_cur) == '\n') {
pos_col = 0;
@@ -137,7 +141,7 @@ public class AbstractLisaacParser {
}
public char lastCharacter() {
- if (position > source.length()-1) {
+ if (position >= source.length()) {
return 0;
}
return source.charAt(position);
@@ -798,9 +802,9 @@ public class AbstractLisaacParser {
return result;
}
- private final String operators = "!@#$%^&<|*-+=~/?\\>";
+ private static final String operators = "!@#$%^&<|*-+=~/?\\>";
- public boolean isOperatorSymbol(char c) {
+ public static boolean isOperatorSymbol(char c) {
return operators.indexOf(c) != -1;
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/LisaacCompletionParser.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/LisaacCompletionParser.java
index 1bfd610..6799c1f 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/LisaacCompletionParser.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/LisaacCompletionParser.java
@@ -12,10 +12,14 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.lisaac.ldt.LisaacPlugin;
import org.lisaac.ldt.editors.LisaacEditor;
import org.lisaac.ldt.model.items.ICode;
+import org.lisaac.ldt.model.items.ITMPrototype;
import org.lisaac.ldt.model.items.ITMRead;
import org.lisaac.ldt.model.items.Prototype;
import org.lisaac.ldt.model.items.Slot;
import org.lisaac.ldt.model.types.IType;
+import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeGeneric;
+import org.lisaac.ldt.model.types.TypeParameter;
import org.lisaac.ldt.model.types.TypeSelf;
import org.lisaac.ldt.outline.OutlineImages;
@@ -27,11 +31,25 @@ public class LisaacCompletionParser extends LisaacParser {
protected int endOffset;
+ protected TypeGeneric lastGenericType;
public LisaacCompletionParser(String contents, LisaacModel model) {
super(null,contents);
+
+ if (model == null) {
+ IWorkbenchWindow w = LisaacPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
+ if (w != null) {
+ IWorkbenchPart part = w.getPartService().getActivePart();
+ if (part instanceof LisaacEditor) {
+ model = LisaacModel.getModel(((LisaacEditor)part).getProject());
+ }
+ }
+ }
LisaacCompletionParser.model = model;
+ //
+ enableErrorReport(false); // turn off error reporting
+ //
}
/**
@@ -47,6 +65,7 @@ public class LisaacCompletionParser extends LisaacParser {
currentPrototype = LisaacModel.getCurrentPrototype();
currentSlot = currentPrototype.getSlot(startOffset);
+ lastGenericType = null;
endOffset = -1;
// keyword match
@@ -66,23 +85,34 @@ public class LisaacCompletionParser extends LisaacParser {
return;
}
setPosition(0);
-
+
// slot match
ICode code = readExpr();
if (code != null && currentPrototype != null) {
type = code.getType(currentSlot, currentPrototype);
if (type != null) {
- //if (! type.equals(TypeSimple.getTypeSelf())) {
- //if ("SELF".compareTo(type.toString()) != 0) {
- if (type instanceof TypeSelf) {
- currentPrototype = findPrototype(((TypeSelf) type).getStaticType());
- } else {
- currentPrototype = findPrototype(type.toString());
- }
- if (currentPrototype != null) {
- currentPrototype.getSlotProposals(proposals, baseOffset, 0);
- proposals.add(new CompletionProposal(""+type,baseOffset,0,0));
- } else {
+ if (source.charAt(position-1) == '.') {
+ //
+ // slot completion
+ //
+ if (type instanceof TypeSelf) {
+ currentPrototype = findPrototype(((TypeSelf) type).getStaticType());
+
+ } else if (type instanceof TypeParameter && lastGenericType != null) {
+ // genericity TypeParameter -> TypeSimple
+ int index = currentPrototype.getGenericIndex((TypeParameter) type);
+ if (index != -1) {
+ ITypeMono realType = lastGenericType.getGenericElt(index);
+ currentPrototype = findPrototype(realType.toString());
+ }
+ } else {
+ currentPrototype = findPrototype(type.toString());
+ }
+ if (currentPrototype != null) {
+ // compute completion result
+ currentPrototype.getSlotProposals(proposals, baseOffset, 0);
+ }
+ } else if (code instanceof ITMPrototype) {
// partial prototype name
String prefix = type.toString();
model.getPathManager().getPathMatch(prefix, proposals, baseOffset);
@@ -91,7 +121,7 @@ public class LisaacCompletionParser extends LisaacParser {
// partial name, search for matches
if (code instanceof ITMRead) {
String prefix = ((ITMRead) code).getName();
-
+
// partial local name
if (currentSlot != null) {
currentSlot.getArgumentMatchProposals(prefix, proposals, baseOffset, 0);
@@ -120,20 +150,34 @@ public class LisaacCompletionParser extends LisaacParser {
}
// update source of completion
IType type = lastResult.getType(currentSlot, currentPrototype);
- //if (type != null && ! type.equals(TypeSimple.getTypeSelf())) {
- if (type != null && "SELF".compareTo(type.toString()) != 0) {
- try {
- currentPrototype = findPrototype(type.toString());
- } catch(CoreException e) {
- return null;
- }
- if (currentPrototype == null) {
- return null;
- }
- if (result instanceof ITMRead) {
- currentSlot = currentPrototype.lookupSlot(((ITMRead) result).getName());
- } else {
- currentSlot = null;
+ if (type != null) {
+ String stringType = type.toString();
+ if (stringType != null && "SELF".compareTo(stringType) != 0) {
+ try {
+ if (type instanceof TypeParameter && lastGenericType != null) {
+ // genericity TypeParameter -> TypeSimple
+ int index = currentPrototype.getGenericIndex((TypeParameter) type);
+ if (index != -1) {
+ ITypeMono realType = lastGenericType.getGenericElt(index);
+ currentPrototype = findPrototype(realType.toString());
+ }
+ } else {
+ currentPrototype = findPrototype(stringType);
+ }
+ } catch(CoreException e) {
+ return null;
+ }
+ if (currentPrototype == null) {
+ return null;
+ }
+ if (type instanceof TypeGeneric) {
+ lastGenericType = (TypeGeneric) type;
+ }
+ if (result instanceof ITMRead) {
+ currentSlot = currentPrototype.lookupSlot(((ITMRead) result).getName());
+ } else {
+ currentSlot = null;
+ }
}
}
}
@@ -142,11 +186,11 @@ public class LisaacCompletionParser extends LisaacParser {
}
- public Prototype readReceiver(int startOffset, int endOffset, Prototype currentPrototype) throws CoreException {
+ public Prototype readReceiver(int startOffset, int endOffset, Prototype current) throws CoreException {
Prototype result=null;
IType type;
- this.currentPrototype = currentPrototype;//LisaacModel.getCurrentPrototype();
+ currentPrototype = current;
currentSlot = currentPrototype.getSlot(startOffset);
this.endOffset = endOffset;
@@ -165,6 +209,14 @@ public class LisaacCompletionParser extends LisaacParser {
currentPrototype = save;
}
}
+ // genericity TypeParameter -> TypeSimple
+ if (type instanceof TypeParameter && lastGenericType != null) {
+ int index = currentPrototype.getGenericIndex((TypeParameter) type);
+ if (index != -1) {
+ ITypeMono realType = lastGenericType.getGenericElt(index);
+ currentPrototype = findPrototype(realType.toString());
+ }
+ }
result = currentPrototype;
}
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/SectionContext.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/SectionContext.java
index 3596bdf..d58bf2e 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/SectionContext.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/SectionContext.java
@@ -1,8 +1,11 @@
package org.lisaac.ldt.model;
+import java.util.ArrayList;
+
import org.lisaac.ldt.model.items.Prototype;
import org.lisaac.ldt.model.items.Section;
import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeParameter;
public class SectionContext implements ILisaacContext {
@@ -135,24 +138,33 @@ public class SectionContext implements ILisaacContext {
//
// Generic loader.
//
- // TODO error for non generic object
if (parser.readIdentifier()) {
return false;
// TODO syntax identifier : PROTO
} else if (parser.readCapIdentifier()) {
- // TODO error Identifier parameter type is needed.
-
+ if (! parser.isParameterType) {
+ parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
+ }
+ ArrayList<TypeParameter> genlist = new ArrayList<TypeParameter>();
+ TypeParameter param = TypeParameter.get(parser.getLastString());
+ genlist.add(param);
+
while (parser.readCharacter(',')) {
- // TODO error Identifier parameter type is needed.
if (! parser.readCapIdentifier()) {
parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
return false;
}
+ if (! parser.isParameterType) {
+ parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
+ }
+ param = TypeParameter.get(parser.getLastString());
+ genlist.add(param);
}
if (! parser.readCharacter(')')) {
parser.getReporter().syntaxError("Added ')'.", parser.getLine());
return false;
}
+ prototype.setGenericList(genlist.toArray(new TypeParameter[genlist.size()]));
} else {
parser.getReporter().syntaxError("Identifier parameter type is needed.", parser.getLine());
return false;
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/IArgument.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/IArgument.java
index 1b05e87..cf8a283 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/IArgument.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/IArgument.java
@@ -3,6 +3,7 @@ package org.lisaac.ldt.model.items;
import java.util.ArrayList;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
import org.lisaac.ldt.model.types.IType;
public interface IArgument extends IVariable {
@@ -14,7 +15,8 @@ public interface IArgument extends IVariable {
boolean hasName(String word);
void printIn(StringBuffer buffer);
-
+ void styledPrintIn(StyledString buffer);
+
void getMatchProposals(String n, ArrayList<ICompletionProposal> matchList,
int offset, int length);
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgs.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgs.java
index 8097273..d03bada 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgs.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgs.java
@@ -4,7 +4,9 @@ import java.util.ArrayList;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
import org.lisaac.ldt.model.Position;
import org.lisaac.ldt.model.types.IType;
import org.lisaac.ldt.model.types.TypeMulti;
@@ -76,6 +78,22 @@ public class ITMArgs implements IArgument {
buffer.append(")");
}
+ public void styledPrintIn(StyledString buffer) {
+ ColorManager colors = ColorManager.getDefault();
+ buffer.append("(");
+ for (int i=0; i<name.length; i++) {
+ IType subType = type.getSubType(i);
+ buffer.append(name[i], colors.getVariableStyler());
+ buffer.append(" : ");
+ buffer.append(subType.toString(), colors.getPrototypeStyler());
+
+ if (i != name.length-1) {
+ buffer.append(", ");
+ }
+ }
+ buffer.append(")");
+ }
+
public String getHoverInformation() {
StringBuffer buffer = new StringBuffer();
buffer.append("<I>Arguments</I> : ");
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgument.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgument.java
index fa2a0ea..4731811 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgument.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/ITMArgument.java
@@ -4,7 +4,9 @@ import java.util.ArrayList;
import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
import org.lisaac.ldt.model.Position;
import org.lisaac.ldt.model.types.IType;
import org.lisaac.ldt.model.types.ITypeMono;
@@ -41,6 +43,13 @@ public class ITMArgument implements IArgument {
buffer.append(type);
}
+ public void styledPrintIn(StyledString buffer) {
+ ColorManager colors = ColorManager.getDefault();
+ buffer.append(name, colors.getVariableStyler());
+ buffer.append(':');
+ buffer.append(type.toString(), colors.getPrototypeStyler());
+ }
+
public String getHoverInformation() {
StringBuffer buffer = new StringBuffer();
buffer.append("<I>Argument</I> : <b>");
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Prototype.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Prototype.java
index 9874a60..adac394 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Prototype.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Prototype.java
@@ -25,6 +25,7 @@ import org.lisaac.ldt.model.LisaacParser;
import org.lisaac.ldt.model.Position;
import org.lisaac.ldt.model.types.IType;
import org.lisaac.ldt.model.types.ITypeMono;
+import org.lisaac.ldt.model.types.TypeParameter;
import org.lisaac.ldt.outline.OutlineItem;
import org.lisaac.ldt.outline.OutlinePrototype;
import org.lisaac.ldt.outline.OutlineSection;
@@ -41,6 +42,9 @@ public class Prototype {
protected HashMap<String, Slot> parentList;
protected HashMap<String, Slot> slotList;
+ // genericity
+ protected TypeParameter[] genericList;
+
// hover informations
protected String headerData;
protected String headerComment;
@@ -87,6 +91,21 @@ public class Prototype {
return name;
}
+ public int getGenericIndex(TypeParameter param) {
+ if (genericList != null) {
+ for (int i=0; i<genericList.length; i++) {
+ if (genericList[i].equals(param)) {
+ return i;
+ }
+ }
+ }
+ return -1;
+ }
+
+ public void setGenericList(TypeParameter[] list) {
+ genericList = list;
+ }
+
public void setHeaderComment(String comment) {
this.headerComment = comment;
}
@@ -107,7 +126,7 @@ public class Prototype {
}
}
-
+
public LisaacParser openParser() {
parser.initialize();
return parser;
@@ -359,7 +378,7 @@ public class Prototype {
break;
}
}
- if (parser.isOperatorSymbol(c)) {
+ if (LisaacParser.isOperatorSymbol(c)) {
if (c == '+' || c == '-') {
// slot definition
if (offset - 3 > 0 && source.charAt(offset - 1) == ' ' &&
@@ -454,7 +473,7 @@ public class Prototype {
break;
}
}
- if (parser.isOperatorSymbol(c)) {
+ if (LisaacParser.isOperatorSymbol(c)) {
break;
}
// strings
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Slot.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Slot.java
index de2ad20..2fc0c29 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Slot.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/items/Slot.java
@@ -1,12 +1,14 @@
package org.lisaac.ldt.model.items;
import java.util.ArrayList;
- import org.eclipse.jface.text.contentassist.CompletionProposal;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
import org.eclipse.text.edits.DeleteEdit;
import org.eclipse.text.edits.InsertEdit;
import org.eclipse.text.edits.TextEdit;
+import org.lisaac.ldt.editors.ColorManager;
+import org.lisaac.ldt.editors.LisaacCompletionProposal;
import org.lisaac.ldt.model.ILisaacModel;
import org.lisaac.ldt.model.LisaacParser;
import org.lisaac.ldt.model.Position;
@@ -277,11 +279,9 @@ import org.lisaac.ldt.outline.OutlineSlot;
}
public String getSignature(boolean isCall) {
-
if (name.startsWith("__")) {
return getOperatorName();
}
-
if (keywordList == null || keywordList.length < 1) {
return name;
}
@@ -307,9 +307,51 @@ import org.lisaac.ldt.outline.OutlineSlot;
if (!isCall && resultType.toString() != null) {
buffer.append(" : " + resultType);
}
+
return buffer.toString();
}
+
+ public StyledString getStyledSignature(boolean isCall, boolean showProto) {
+ ColorManager colors = ColorManager.getDefault();
+ StyledString result = new StyledString();
+
+ if (name.startsWith("__")) {
+ result.append(getOperatorName(), colors.getOperatorStyler());
+ return result;
+ }
+ if (keywordList == null || keywordList.length < 1) {
+ result.append(name, colors.getSlotStyler());
+ return result;
+ }
+ result.append(keywordList[0], colors.getSlotStyler());
+ result.append(" ");
+ int keywordIndex = 1;
+ for (int argIndex = 0; argIndex < argumentList.length; argIndex++) {
+ if (isCall) {
+ result.append(argumentList[argIndex].getName(), colors.getVariableStyler());
+ } else {
+ argumentList[argIndex].styledPrintIn(result);
+ }
+ result.append(" ");
+
+ if (keywordIndex < keywordList.length) {
+ result.append(keywordList[keywordIndex], colors.getSlotStyler());
+ result.append(" ");
+ keywordIndex++;
+ }
+ }
+ if (!isCall && resultType.toString() != null) {
+ result.append(" : ");
+ result.append(resultType.toString(), colors.getPrototypeStyler());
+ }
+ if (showProto) {
+ result.append(" - ", StyledString.QUALIFIER_STYLER);
+ result.append(getPrototype().getName(), StyledString.QUALIFIER_STYLER);
+ }
+ return result;
+ }
+
public void getSlotProposals(ArrayList<ICompletionProposal> proposals,
int offset, int length) {
@@ -317,11 +359,10 @@ import org.lisaac.ldt.outline.OutlineSlot;
String displayString = getSignature(true);
if (checkUnicity(proposals,displayString)) {
- proposals.add(new CompletionProposal(displayString, offset, length,
- displayString.length() - 1, image, getSignature(false),
- null, null));
+ proposals.add(new LisaacCompletionProposal(displayString, offset, length,
+ displayString.length() - 1, image, getStyledSignature(false, true)));
}
- }
+ }
public void getSlotMatchProposals(
ArrayList<ICompletionProposal> proposals, int offset,
@@ -332,9 +373,8 @@ import org.lisaac.ldt.outline.OutlineSlot;
if (checkUnicity(proposals,displayString)) {
displayString = displayString.substring(matchLength);
- proposals.add(new CompletionProposal(displayString, offset, length,
- displayString.length(), image, getSignature(false), null,
- null));
+ proposals.add(new LisaacCompletionProposal(displayString, offset, length,
+ displayString.length(), image, getStyledSignature(false, true)));
}
}
@@ -376,6 +416,7 @@ import org.lisaac.ldt.outline.OutlineSlot;
}
}
+ // FIXME cannot compare display string now... they're already unique, ex: "slot - SON" and "slot - FATHER"
public static boolean checkUnicity(ArrayList<ICompletionProposal> proposals, String str) {
for (int i=0; i<proposals.size(); i++) {
if (proposals.get(i).getDisplayString().compareTo(str) == 0) {
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeGeneric.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeGeneric.java
index be734f1..f3d9573 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeGeneric.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeGeneric.java
@@ -8,4 +8,8 @@ public class TypeGeneric extends TypeStyle {
super(name, style);
listType = lt;
}
+
+ public ITypeMono getGenericElt(int index) {
+ return listType[index];
+ }
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeParameter.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeParameter.java
index 9d2a1e1..4959067 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeParameter.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeParameter.java
@@ -1,5 +1,7 @@
package org.lisaac.ldt.model.types;
+import java.util.HashMap;
+
/**
* Parameter type for argument define.
*/
@@ -8,4 +10,16 @@ public class TypeParameter extends TypeSimple {
public TypeParameter(String name) {
super(name);
}
+
+ public static TypeParameter get(String n) {
+ TypeParameter result=null;
+
+ if (dico != null && dico.containsKey(n)) {
+ result = (TypeParameter) dico.get(n);
+ }
+ if (result == null) {
+ result = new TypeParameter(n);
+ }
+ return result;
+ }
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeSimple.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeSimple.java
index 3c91bbc..7198ef4 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeSimple.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/model/types/TypeSimple.java
@@ -6,7 +6,7 @@ import org.lisaac.ldt.model.ILisaacModel;
public class TypeSimple implements ITypeMono {
- private static HashMap<String,TypeSimple> dico;
+ protected static HashMap<String,TypeSimple> dico;
protected String name;
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineItem.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineItem.java
index bb520c2..7b4d9f2 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineItem.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineItem.java
@@ -1,6 +1,8 @@
package org.lisaac.ldt.outline;
import java.util.List;
+
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
public abstract class OutlineItem implements Comparable<Object> {
@@ -23,6 +25,8 @@ public abstract class OutlineItem implements Comparable<Object> {
*/
public abstract String getText();
+ public abstract StyledString getStyledText();
+
/**
* Returns the children of this element.
*/
@@ -35,5 +39,5 @@ public abstract class OutlineItem implements Comparable<Object> {
public int length() {
return fLength;
- }
+ }
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineLabelProvider.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineLabelProvider.java
index 51c96eb..b217a2e 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineLabelProvider.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineLabelProvider.java
@@ -1,41 +1,66 @@
package org.lisaac.ldt.outline;
import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StyledCellLabelProvider;
+import org.eclipse.jface.viewers.StyledString;
+import org.eclipse.jface.viewers.ViewerCell;
import org.eclipse.swt.graphics.Image;
-public class OutlineLabelProvider extends LabelProvider {
-
+public class OutlineLabelProvider extends StyledCellLabelProvider {
+
+ /**
+ * @see WorkbenchLabelProvider#getImage(Object)
+ * @param element the element for which an image is created
+ * @return the image associated to the element
+ */
+ public Image getImage(Object element) {
+ if (element instanceof OutlineItem) {
+ OutlineItem item = (OutlineItem) element;
+ Image image = item.getImage();
+
+ if (image != null) {
+ return image;
+ }
+ }
+ return OutlineImages.BLANK;
+ }
+
/**
- * @see WorkbenchLabelProvider#getImage(Object)
- * @param element the element for which an image is created
- * @return the image associated to the element
- */
- public Image getImage(Object element) {
- if (element instanceof OutlineItem) {
- OutlineItem item = (OutlineItem) element;
- Image image = item.getImage();
-
- if (image != null) {
- return image;
- }
- }
- return OutlineImages.BLANK;
- }
-
- /**
- * @see WorkbenchLabelProvider#getText(Object)
- * @param element the element for which a label is created
- * @return the label associated to the element
- */
- public String getText(Object element) {
- if (element instanceof OutlineItem) {
- OutlineItem item = (OutlineItem) element;
- return item.getText();
- }
- if (element != null) {
- return element.toString();
- } else {
- return new String();
- }
- }
+ * @see WorkbenchLabelProvider#getText(Object)
+ * @param element the element for which a label is created
+ * @return the label associated to the element
+ */
+ public String getText(Object element) {
+ if (element instanceof OutlineItem) {
+ OutlineItem item = (OutlineItem) element;
+ return item.getText();
+ }
+ if (element != null) {
+ return element.toString();
+ } else {
+ return new String();
+ }
+ }
+
+ public StyledString getStyledText(Object element) {
+ if (element instanceof OutlineItem) {
+ OutlineItem item = (OutlineItem) element;
+ return item.getStyledText();
+ }
+ if (element != null) {
+ return new StyledString(element.toString());
+ } else {
+ return new StyledString();
+ }
+ }
+
+ public void update(ViewerCell cell) {
+ Object obj = cell.getElement();
+ StyledString styledString = getStyledText(obj);
+
+ cell.setText(styledString.toString());
+ cell.setStyleRanges(styledString.getStyleRanges());
+ cell.setImage(getImage(obj));
+ super.update(cell);
+ }
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlinePrototype.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlinePrototype.java
index d55daff..d2e8bd0 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlinePrototype.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlinePrototype.java
@@ -3,7 +3,9 @@ package org.lisaac.ldt.outline;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
import org.lisaac.ldt.model.items.Prototype;
public class OutlinePrototype extends OutlineItem {
@@ -25,6 +27,11 @@ public class OutlinePrototype extends OutlineItem {
return name;
}
+ public StyledString getStyledText() {
+ ColorManager colors = ColorManager.getDefault();
+ return new StyledString(name, colors.getPrototypeStyler());
+ }
+
public String toString() {
return name;
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSection.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSection.java
index d45a4e1..84ea3a6 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSection.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSection.java
@@ -2,7 +2,9 @@ package org.lisaac.ldt.outline;
import java.util.List;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
+import org.lisaac.ldt.editors.ColorManager;
import org.lisaac.ldt.model.Position;
import org.lisaac.ldt.model.items.Section;
import org.lisaac.ldt.model.types.ITypeMono;
@@ -12,13 +14,13 @@ public class OutlineSection extends OutlineItem {
protected Section section;
protected List<OutlineItem> slots;
-
+
public OutlineSection(Section section) {
this.section = section;
this.slots = section.getOutlineItems();
-
+
Position position = section.getPosition();
-
+
fstartOffset = position.getStartOffset() - 7;
fLength = 7;
//fstartOffset = position.getStartOffset();
@@ -47,6 +49,26 @@ public class OutlineSection extends OutlineItem {
return result;
}
+ public StyledString getStyledText() {
+ StyledString result = new StyledString();
+ ColorManager colors = ColorManager.getDefault();
+
+ if (section != null) {
+ if (section.getName() != null) {
+ result.append(section.getName());
+ } else {
+ ITypeMono[] types = section.getTypeList();
+ for (int i=0; i<types.length; i++) {
+ result.append(types[i].toString(), colors.getPrototypeStyler());
+ if (i != types.length-1) {
+ result.append(", ");
+ }
+ }
+ }
+ }
+ return result;
+ }
+
public String toString() {
return getText();
}
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSlot.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSlot.java
index 62de449..69eb440 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSlot.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/outline/OutlineSlot.java
@@ -2,10 +2,10 @@ package org.lisaac.ldt.outline;
import java.util.List;
+import org.eclipse.jface.viewers.StyledString;
import org.eclipse.swt.graphics.Image;
import org.lisaac.ldt.model.Position;
import org.lisaac.ldt.model.items.Slot;
-import org.lisaac.ldt.model.types.IType;
public class OutlineSlot extends OutlineItem {
@@ -31,6 +31,13 @@ public class OutlineSlot extends OutlineItem {
}
return result;
}
+
+ public StyledString getStyledText() {
+ if (slot != null) {
+ return slot.getStyledSignature(false, false);
+ }
+ return null;
+ }
public String toString() {
return getText();
diff --git a/editor/eclipse/eclisaac/src/org/lisaac/ldt/views/LisaacOutlineView.java b/editor/eclipse/eclisaac/src/org/lisaac/ldt/views/LisaacOutlineView.java
index 17c08d3..4b84f2d 100644
--- a/editor/eclipse/eclisaac/src/org/lisaac/ldt/views/LisaacOutlineView.java
+++ b/editor/eclipse/eclisaac/src/org/lisaac/ldt/views/LisaacOutlineView.java
@@ -38,7 +38,7 @@ import org.lisaac.ldt.outline.OutlineLabelProvider;
public class LisaacOutlineView extends ContentOutlinePage implements IDocumentListener {
/** the delay before the outline view is updated. */
- private static final long UPDATE_DELAY = 2000;
+ private static final long UPDATE_DELAY = 1500;
/** the document provider. */
private IDocumentProvider documentProvider;
@@ -124,15 +124,6 @@ public class LisaacOutlineView extends ContentOutlinePage implements IDocumentLi
IToolBarManager toolbarManager = actionBars.getToolBarManager();
toolbarManager.add(sortByName);
toolbarManager.add(sortBySection);
-
- /* IMenuManager menuManager = actionBars.getMenuManager();
- menuManager.add(new OutlineHideCommentsAction(this, imageCache));
- menuManager.add(new OutlineHideImportsAction(this, imageCache));
- menuManager.add(new OutlineHideMagicObjectsAction(this, imageCache));
- menuManager.add(new OutlineHideFieldsAction(this, imageCache));
- menuManager.add(new OutlineHideNonPublicMembersAction(this, imageCache));
- menuManager.add(new OutlineHideStaticMethodsAction(this, imageCache));
- */
}
/**
--
Lisaac compiler
More information about the Lisaac-commits
mailing list