Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Overbey2008-04-14 20:32:49 +0000
committerJeffrey Overbey2008-04-14 20:32:49 +0000
commit90f20bd2d48aa79ccffd2723ca37e8d7b87c31ef (patch)
tree550ef1ba5fbc6fdebd792d86011b5c0db870a700
parent78079c8fbd3d374e5f38c6e5353ccc65b549b292 (diff)
downloadorg.eclipse.photran-90f20bd2d48aa79ccffd2723ca37e8d7b87c31ef.tar.gz
org.eclipse.photran-90f20bd2d48aa79ccffd2723ca37e8d7b87c31ef.tar.xz
org.eclipse.photran-90f20bd2d48aa79ccffd2723ca37e8d7b87c31ef.zip
Open Declaration is now an IFortranEditorASTTask which uses a DefinitionMap
-rw-r--r--org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/actions/OpenDeclaration.java120
-rw-r--r--org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/DefinitionMap.java43
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranEditorVPGTasks.java171
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGReconcilingStrategy.java131
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGSourceViewerConfigurationFactory.java13
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorASTTask.java7
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorVPGTask.java3
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/OldExperimentalFreeFormFortranEditor.java11
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorASTTask.java12
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorVPGTask.java2
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorASTTask.java45
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorMappingTask.java78
-rwxr-xr-xorg.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorVPGTask.java34
-rw-r--r--org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/views/DeclarationView.java45
-rw-r--r--org.eclipse.photran.ui/src/org/eclipse/photran/internal/ui/editor/AbstractFortranEditor.java21
15 files changed, 321 insertions, 415 deletions
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/actions/OpenDeclaration.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/actions/OpenDeclaration.java
index f479ce4e..df8854c3 100644
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/actions/OpenDeclaration.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/actions/OpenDeclaration.java
@@ -11,17 +11,21 @@
package org.eclipse.photran.internal.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import java.util.List;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.photran.core.IFortranAST;
-import org.eclipse.photran.core.vpg.PhotranVPG;
+import org.eclipse.jface.text.TextSelection;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
-import org.eclipse.photran.internal.core.lexer.Terminal;
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.ui.PartInitException;
+import org.eclipse.photran.internal.core.lexer.TokenList;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
+import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
+import org.eclipse.photran.internal.ui.editor_vpg.DefinitionMap;
+import org.eclipse.photran.internal.ui.editor_vpg.FortranEditorVPGTasks;
+import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorASTTask;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.ide.IDE;
/**
@@ -38,53 +42,73 @@ public class OpenDeclaration extends FortranEditorASTActionDelegate
{
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException
{
- try
- {
- progressMonitor.beginTask("Waiting for background work to complete (synchronizing Fortran virtual program graph)", IProgressMonitor.UNKNOWN);
-
- List<Definition> defs = resolveBinding();
-
- if (defs == null || defs.isEmpty())
- MessageDialog.openError(getFortranEditor().getShell(), "Error", "Unable to locate declaration");
- else if (defs.size() == 1)
- openEditorOn(defs.get(0));
- else
- openEditorOn(openSelectionDialog(defs));
- }
- catch (Exception e)
- {
- String message = e.getMessage();
- if (message == null) message = e.getClass().getName();
- MessageDialog.openError(getFortranEditor().getShell(), "Error", message);
- }
- finally
- {
- progressMonitor.done();
- }
+ AbstractFortranEditor editor = getFortranEditor();
+ TextSelection selection = (TextSelection)editor.getSelection();
+ Shell shell = editor.getShell();
+ IWorkbenchPage page = editor.getEditorSite().getPage();
+
+ FortranEditorVPGTasks tasks = FortranEditorVPGTasks.instance(editor);
+ tasks.addASTTask(new OpenDeclarationASTTask(editor, selection, shell, page));
+ tasks.getRunner().runTasks(false);
}
- private List<Definition> resolveBinding() throws Exception
+ private static class OpenDeclarationASTTask implements IFortranEditorASTTask
{
- // TODO: No need to parse; this is all in VPG edges
-
- IFortranAST ast = getAST();
+ private AbstractFortranEditor editor;
+ private TextSelection selection;
+ private Shell shell;
+ private IWorkbenchPage page;
+
+ public OpenDeclarationASTTask(AbstractFortranEditor editor, TextSelection selection, Shell shell, IWorkbenchPage page)
+ {
+ this.editor = editor;
+ this.selection = selection;
+ this.shell = shell;
+ this.page = page;
+ }
- Token token = findEnclosingToken(ast, getFortranEditor().getSelection());
- if (token == null || token.getTerminal() != Terminal.T_IDENT)
- throw new Exception("Please select an identifier.");
+ // This runs outside the UI thread
+ public boolean handle(ASTExecutableProgramNode ast,
+ TokenList tokenList,
+ DefinitionMap<Definition> defMap)
+ {
+ final Definition def = defMap.lookup(selection, tokenList);
- return token.resolveBinding();
- }
+ // Run this in the UI thread
+ Display.getDefault().asyncExec(new Runnable()
+ {
+ public void run()
+ {
+ if (def == null)
+ MessageDialog.openError(shell, "Error", "Unable to locate declaration");
+ else
+ openEditorOn(def);
+ }
+ });
- private void openEditorOn(Definition def) throws PartInitException
- {
- if (def == null) return; // Dialog canceled
-
- IMarker marker = def.createMarker();
- if (marker == null) return;
- if (marker == null)
- MessageDialog.openError(getFortranEditor().getShell(), "Error", "Unable to create marker");
- else
- IDE.openEditor(getFortranEditor().getEditorSite().getPage(), marker, true);
+ // Remove this task
+ return false;
+ }
+
+ private void openEditorOn(Definition def)
+ {
+ if (def == null) return; // Selection dialog canceled
+
+ try
+ {
+ IMarker marker = def.createMarker();
+ if (marker == null) return;
+ if (marker == null)
+ MessageDialog.openError(shell, "Error", "Unable to create marker");
+ else
+ IDE.openEditor(page, marker, true);
+ }
+ catch (Exception e)
+ {
+ String message = e.getMessage();
+ if (message == null) message = e.getClass().getName();
+ MessageDialog.openError(shell, "Error", message);
+ }
+ }
}
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/DefinitionMap.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/DefinitionMap.java
index 33ed73aa..1932cc37 100644
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/DefinitionMap.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/DefinitionMap.java
@@ -4,11 +4,13 @@ import java.util.HashMap;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.photran.core.IFortranAST;
+import org.eclipse.photran.core.vpg.util.IterableWrapper;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.analysis.binding.Intrinsics;
import org.eclipse.photran.internal.core.analysis.binding.ScopingNode;
import org.eclipse.photran.internal.core.lexer.Terminal;
import org.eclipse.photran.internal.core.lexer.Token;
+import org.eclipse.photran.internal.core.lexer.TokenList;
import org.eclipse.photran.internal.core.parser.ASTBlockDataNameNode;
import org.eclipse.photran.internal.core.parser.ASTBlockDataSubprogramNode;
import org.eclipse.photran.internal.core.parser.ASTDerivedTypeDefNode;
@@ -16,7 +18,6 @@ import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
import org.eclipse.photran.internal.core.parser.ASTFunctionSubprogramNode;
import org.eclipse.photran.internal.core.parser.ASTGenericNameNode;
import org.eclipse.photran.internal.core.parser.ASTInterfaceBlockNode;
-import org.eclipse.photran.internal.core.parser.ASTInterfaceStmtNode;
import org.eclipse.photran.internal.core.parser.ASTMainProgramNode;
import org.eclipse.photran.internal.core.parser.ASTModuleNode;
import org.eclipse.photran.internal.core.parser.ASTProgramStmtNode;
@@ -24,7 +25,6 @@ import org.eclipse.photran.internal.core.parser.ASTSubroutineSubprogramNode;
import org.eclipse.photran.internal.core.parser.ASTVisitor;
import org.eclipse.photran.internal.core.parser.GenericParseTreeVisitor;
import org.eclipse.photran.internal.core.parser.Parser.InteriorNode;
-import org.eclipse.photran.internal.core.parser.Parser.Nonterminal;
public abstract class DefinitionMap<T>
{
@@ -32,39 +32,52 @@ public abstract class DefinitionMap<T>
public DefinitionMap(IFortranAST ast)
{
+ this(ast.getRoot());
+ }
+
+ public DefinitionMap(ASTExecutableProgramNode ast)
+ {
ast.visitUsing(new GenericParseTreeVisitor()
{
@Override public void visitParseTreeNode(InteriorNode node)
{
if (ScopingNode.isScopingNode(node))
for (Definition def : ((ScopingNode)node).getAllDefinitions())
- // Qualify definitions imported from modules in the *importing* scope
- definitions.put(qualify(def.getTokenRef().findToken(), (ScopingNode)node),
- map(def));
+ {
+ String qualifiedName = qualify(def.getTokenRef().findToken(), (ScopingNode)node);
+ definitions.put(qualifiedName, map(qualifiedName, def));
+ }
}
});
// for (String def : definitions.keySet())
// System.out.println(def);
}
+
+ public DefinitionMap(DefinitionMap<Definition> other)
+ {
+ for (String key : other.definitions.keySet())
+ definitions.put(key, map(key, other.definitions.get(key)));
+ }
+
- protected abstract T map(Definition def);
+ protected abstract T map(String qualifiedName, Definition def);
- public T lookup(TextSelection selection, IFortranAST ast)
+ public T lookup(TextSelection selection, TokenList tokenList)
{
- return lookup(findTokenEnclosing(selection, ast));
+ return lookup(findTokenEnclosing(selection, tokenList));
}
- public static Token findTokenEnclosing(TextSelection sel, IFortranAST ast)
+ public static Token findTokenEnclosing(TextSelection sel, TokenList tokenList)
{
- return findTokenEnclosing(sel.getOffset(), ast);
+ return findTokenEnclosing(sel.getOffset(), tokenList);
}
- public static Token findTokenEnclosing(int offset, IFortranAST ast)
+ public static Token findTokenEnclosing(int offset, TokenList tokenList)
{
- for (Token t : ast)
- if (t.containsFileOffset(offset))
- return t;
+ for (int i = 0, size = tokenList.size(); i < size; i++)
+ if (tokenList.get(i).containsFileOffset(offset))
+ return tokenList.get(i);
return null;
}
@@ -84,7 +97,7 @@ public abstract class DefinitionMap<T>
{
Definition intrinsic = Intrinsics.resolveIntrinsic(token);
if (intrinsic != null)
- return map(intrinsic);
+ return map(intrinsic.getCanonicalizedName(), intrinsic);
else
return null;
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranEditorVPGTasks.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranEditorVPGTasks.java
index b69751c8..58ace39e 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranEditorVPGTasks.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranEditorVPGTasks.java
@@ -1,10 +1,30 @@
package org.eclipse.photran.internal.ui.editor_vpg;
+import java.io.ByteArrayInputStream;
import java.util.HashSet;
import java.util.Set;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.photran.core.IFortranAST;
+import org.eclipse.photran.core.vpg.PhotranVPG;
+import org.eclipse.photran.internal.core.analysis.binding.Definition;
+import org.eclipse.photran.internal.core.lexer.IAccumulatingLexer;
+import org.eclipse.photran.internal.core.lexer.IncludeLoaderCallback;
+import org.eclipse.photran.internal.core.lexer.LexerFactory;
+import org.eclipse.photran.internal.core.lexer.SourceForm;
+import org.eclipse.photran.internal.core.lexer.Token;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
+import org.eclipse.photran.internal.core.parser.Parser;
+import org.eclipse.photran.internal.core.properties.SearchPathProperties;
import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
+import bz.over.vpg.eclipse.VPGJob;
+
public class FortranEditorVPGTasks
{
/**
@@ -21,21 +41,28 @@ public class FortranEditorVPGTasks
private FortranEditorVPGTasks(AbstractFortranEditor editor)
{
+ this.editor = editor;
editor.reconcilerTasks = this;
+
+ this.runner = new Runner();
}
+ private AbstractFortranEditor editor;
+
+ private Runner runner;
+
/**
- * These jobs will be run (in order) if the contents of the editor parses successfully. The VPG will probably
+ * These jobs will be run if the contents of the editor parses successfully. The VPG will probably
* <i>not</i> be up to date, but token positions will correspond to the contents of the editor.
*/
- final Set<IFortranEditorASTTask> astTasks = new HashSet<IFortranEditorASTTask>();
+ private final Set<IFortranEditorASTTask> astTasks = new HashSet<IFortranEditorASTTask>();
/**
- * These jobs will be run (in order) when the VPG is more-or-less up-to-date and an AST is available for the
+ * These jobs will be run when the VPG is more-or-less up-to-date and an AST is available for the
* file in the editor.
*/
- final Set<IFortranEditorVPGTask> vpgTasks = new HashSet<IFortranEditorVPGTask>();
-
+ private final Set<IFortranEditorVPGTask> vpgTasks = new HashSet<IFortranEditorVPGTask>();
+
public synchronized void addASTTask(IFortranEditorASTTask task)
{
astTasks.add(task);
@@ -55,4 +82,138 @@ public class FortranEditorVPGTasks
{
vpgTasks.remove(task);
}
+
+ public Runner getRunner()
+ {
+ return runner;
+ }
+
+ public class Runner
+ {
+ protected DefinitionMap<Definition> defMap = null;
+
+ protected PhotranVPG vpg = PhotranVPG.getInstance();
+ protected Job dispatchASTTasksJob = null;
+ protected VPGJob<IFortranAST, Token> updateVPGJob = null;
+ protected Job dispatchVPGTasksJob = null;
+ protected IFortranAST vpgAST = null;
+
+ private Parser parser = new Parser();
+
+ public void runTasks()
+ {
+ runTasks(true);
+ }
+
+ public void runTasks(boolean runVPGTasks)
+ {
+ if (editor == null) return;
+
+ if (SearchPathProperties.getProperty(editor.getIFile().getProject(),
+ SearchPathProperties.ENABLE_VPG_PROPERTY_NAME).equals("true"))
+ {
+ runASTTasks();
+ if (runVPGTasks) runVPGTasks();
+ }
+ }
+
+ private void runASTTasks()
+ {
+ if (dispatchASTTasksJob != null) return; // Already running an update
+
+ dispatchASTTasksJob = new Job("Updating editor")
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ ASTExecutableProgramNode astRootNode = null;
+ try
+ {
+ String editorContents = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
+ IAccumulatingLexer lexer = LexerFactory.createLexer(new ByteArrayInputStream(editorContents.getBytes()),
+ null,
+ SourceForm.preprocessedFreeForm(new IncludeLoaderCallback(editor.getIFile().getProject())));
+ astRootNode = parser.parse(lexer);
+ if (astRootNode == null) return Status.OK_STATUS;
+
+ HashSet<IFortranEditorASTTask> tasksToRemove = new HashSet<IFortranEditorASTTask>();
+ synchronized (FortranEditorVPGTasks.instance(editor))
+ {
+ for (IFortranEditorASTTask task : FortranEditorVPGTasks.instance(editor).astTasks)
+ if (!task.handle(astRootNode, lexer.getTokenList(), defMap))
+ tasksToRemove.add(task);
+ }
+ FortranEditorVPGTasks.instance(editor).astTasks.removeAll(tasksToRemove);
+ }
+ catch (Exception e)
+ {
+ ;
+ }
+
+ dispatchASTTasksJob = null;
+ return Status.OK_STATUS;
+ }
+ };
+ dispatchASTTasksJob.setPriority(Job.DECORATE);
+ dispatchASTTasksJob.schedule();
+ }
+
+ private void runVPGTasks()
+ {
+ if (updateVPGJob != null || dispatchVPGTasksJob != null) return; // Already running an update
+
+ if (vpgAST == null || vpg.db.isOutOfDate(PhotranVPG.getFilenameForIFile(editor.getIFile())))
+ {
+ vpgAST = null;
+ updateVPGJob = new VPGJob<IFortranAST, Token>("Updating editor model")
+ {
+ @Override
+ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
+ {
+ vpgAST = vpg.acquireTransientAST(PhotranVPG.getFilenameForIFile(editor.getIFile()));
+ updateVPGJob = null;
+ scheduleVPGTaskDispatchJob();
+ return Status.OK_STATUS;
+ }
+ };
+ updateVPGJob.setPriority(Job.DECORATE);
+ updateVPGJob.schedule();
+ }
+ }
+
+ private void scheduleVPGTaskDispatchJob()
+ {
+ dispatchVPGTasksJob = new Job("Updating editor")
+ {
+ @Override
+ protected IStatus run(IProgressMonitor monitor)
+ {
+ if (vpgAST != null) // Parse might have failed
+ {
+ synchronized (FortranEditorVPGTasks.instance(editor))
+ {
+ defMap = createDefMap();
+ for (IFortranEditorVPGTask task : FortranEditorVPGTasks.instance(editor).vpgTasks)
+ task.handle(editor.getIFile(), vpgAST, defMap);
+ }
+ }
+ dispatchVPGTasksJob = null;
+ return Status.OK_STATUS;
+ }
+
+ private DefinitionMap<Definition> createDefMap()
+ {
+ return new DefinitionMap<Definition>(vpgAST)
+ {
+ @Override protected Definition map(String qualifiedName, Definition def)
+ {
+ return def;
+ }
+ };
+ }
+ };
+ dispatchVPGTasksJob.setPriority(Job.DECORATE);
+ dispatchVPGTasksJob.schedule();
+ }
+ }
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGReconcilingStrategy.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGReconcilingStrategy.java
index 55b8f9ae..81d4b061 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGReconcilingStrategy.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGReconcilingStrategy.java
@@ -1,43 +1,14 @@
package org.eclipse.photran.internal.ui.editor_vpg;
-import java.io.ByteArrayInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-
import org.eclipse.cdt.internal.ui.text.CReconcilingStrategy;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.text.IRegion;
-import org.eclipse.photran.core.FortranAST;
-import org.eclipse.photran.core.IFortranAST;
-import org.eclipse.photran.core.vpg.PhotranTokenRef;
-import org.eclipse.photran.core.vpg.PhotranVPG;
-import org.eclipse.photran.internal.core.lexer.IAccumulatingLexer;
-import org.eclipse.photran.internal.core.lexer.IncludeLoaderCallback;
-import org.eclipse.photran.internal.core.lexer.LexerFactory;
-import org.eclipse.photran.internal.core.lexer.SourceForm;
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
-import org.eclipse.photran.internal.core.parser.Parser;
-import org.eclipse.photran.internal.core.properties.SearchPathProperties;
import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
import org.eclipse.ui.texteditor.ITextEditor;
-import bz.over.vpg.VPGDependency;
-import bz.over.vpg.eclipse.VPGJob;
-
@SuppressWarnings("restriction")
public class FortranVPGReconcilingStrategy extends CReconcilingStrategy
{
protected final AbstractFortranEditor editor;
- protected PhotranVPG vpg = PhotranVPG.getInstance();
- protected VPGJob<IFortranAST, Token> dispatchASTTasksJob = null;
- protected VPGJob<IFortranAST, Token> updateVPGJob = null, dispatchVPGTasksJob = null;
- protected IFortranAST vpgAST = null;
-
- private Parser parser = new Parser();
public FortranVPGReconcilingStrategy(ITextEditor editor)
{
@@ -45,13 +16,6 @@ public class FortranVPGReconcilingStrategy extends CReconcilingStrategy
if (editor instanceof AbstractFortranEditor)
{
this.editor = (AbstractFortranEditor)editor;
-
-// astTasks.add(new SampleEditorASTTask(this.editor));
-// vpgTasks.add(new SampleEditorVPGTask(this.editor));
-
-// SampleEditorMappingTask t = new SampleEditorMappingTask(this.editor);
-// astTasks.add(t.astTask);
-// vpgTasks.add(t.vpgTask);
}
else
{
@@ -62,103 +26,12 @@ public class FortranVPGReconcilingStrategy extends CReconcilingStrategy
@Override public void initialReconcile()
{
super.initialReconcile();
- runTasks();
+ FortranEditorVPGTasks.instance(editor).getRunner().runTasks();
}
@Override public void reconcile(IRegion region)
{
super.reconcile(region);
- runTasks();
- }
-
- private void runTasks()
- {
- if (editor == null) return;
-
- if (SearchPathProperties.getProperty(editor.getIFile().getProject(),
- SearchPathProperties.ENABLE_VPG_PROPERTY_NAME).equals("true"))
- {
- runASTTasks();
- runVPGTasks();
- }
- }
-
- private void runASTTasks()
- {
- if (dispatchASTTasksJob != null) return; // Already running an update
-
- dispatchASTTasksJob = new VPGJob<IFortranAST, Token>("Updating editor")
- {
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
- {
- ASTExecutableProgramNode astRootNode = null;
- try
- {
- String editorContents = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();
- IAccumulatingLexer lexer = LexerFactory.createLexer(new ByteArrayInputStream(editorContents.getBytes()),
- null,
- SourceForm.preprocessedFreeForm(new IncludeLoaderCallback(editor.getIFile().getProject())));
- astRootNode = parser.parse(lexer);
- if (astRootNode == null) return Status.OK_STATUS;
-
- synchronized (FortranEditorVPGTasks.instance(editor))
- {
- for (IFortranEditorASTTask task : FortranEditorVPGTasks.instance(editor).astTasks)
- task.handle(new FortranAST(editor.getIFile(),
- astRootNode,
- lexer.getTokenList()));
- }
- }
- catch (Exception e)
- {
- ;
- }
-
- dispatchASTTasksJob = null;
- return Status.OK_STATUS;
- }
- };
- dispatchASTTasksJob.schedule();
- }
-
- private void runVPGTasks()
- {
- if (updateVPGJob != null || dispatchVPGTasksJob != null) return; // Already running an update
-
- if (vpgAST == null || vpg.db.isOutOfDate(PhotranVPG.getFilenameForIFile(editor.getIFile())))
- {
- vpgAST = null;
- updateVPGJob = new VPGJob<IFortranAST, Token>("Updating editor model")
- {
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
- {
- vpgAST = vpg.acquireTransientAST(PhotranVPG.getFilenameForIFile(editor.getIFile()));
- updateVPGJob = null;
- return Status.OK_STATUS;
- }
- };
- updateVPGJob.schedule();
- }
-
- dispatchVPGTasksJob = new VPGJob<IFortranAST, Token>("Updating editor")
- {
- @Override
- public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException
- {
- if (vpgAST != null) // Parse might have failed
- {
- synchronized (FortranEditorVPGTasks.instance(editor))
- {
- for (IFortranEditorVPGTask task : FortranEditorVPGTasks.instance(editor).vpgTasks)
- task.handle(editor.getIFile(), vpgAST);
- }
- }
- dispatchVPGTasksJob = null;
- return Status.OK_STATUS;
- }
- };
- dispatchVPGTasksJob.schedule();
+ FortranEditorVPGTasks.instance(editor).getRunner().runTasks();
}
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGSourceViewerConfigurationFactory.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGSourceViewerConfigurationFactory.java
index 28e090c7..c04adc89 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGSourceViewerConfigurationFactory.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/FortranVPGSourceViewerConfigurationFactory.java
@@ -1,17 +1,16 @@
package org.eclipse.photran.internal.ui.editor_vpg;
import org.eclipse.cdt.internal.ui.text.CReconciler;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
import org.eclipse.photran.internal.ui.editor.IFortranSourceViewerConfigurationFactory;
import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor.FortranModelReconcilingSourceViewerConfiguration;
import org.eclipse.photran.internal.ui.editor_vpg.contentassist.FortranCompletionProcessor;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
public class FortranVPGSourceViewerConfigurationFactory implements IFortranSourceViewerConfigurationFactory
{
@@ -22,9 +21,13 @@ public class FortranVPGSourceViewerConfigurationFactory implements IFortranSourc
private final FortranCompletionProcessor fortranCompletionProcessor =
new FortranCompletionProcessor();
- @Override protected IReconciler loadReconciler()
+ @Override public IReconciler getReconciler(ISourceViewer sourceViewer)
{
- return new CReconciler(editor, new FortranVPGReconcilingStrategy(editor));
+ MonoReconciler r = new CReconciler(editor, new FortranVPGReconcilingStrategy(editor));
+ r.setIsIncrementalReconciler(false);
+ r.setProgressMonitor(new NullProgressMonitor());
+ r.setDelay(500);
+ return r;
}
@Override public IContentAssistant getContentAssistant(ISourceViewer sourceViewer)
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorASTTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorASTTask.java
index 62de2049..2055719b 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorASTTask.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorASTTask.java
@@ -1,6 +1,8 @@
package org.eclipse.photran.internal.ui.editor_vpg;
-import org.eclipse.photran.core.IFortranAST;
+import org.eclipse.photran.internal.core.analysis.binding.Definition;
+import org.eclipse.photran.internal.core.lexer.TokenList;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
/**
* An <code>IFortranEditorASTTask</code> can be run if an AST for the file in the editor is available but the VPG is not
@@ -15,5 +17,6 @@ import org.eclipse.photran.core.IFortranAST;
*/
public interface IFortranEditorASTTask
{
- void handle(IFortranAST ast);
+ /** @return true to run this task again the next time the editor is updated, or false to run it only once */
+ boolean handle(ASTExecutableProgramNode ast, TokenList tokenList, DefinitionMap<Definition> defMap);
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorVPGTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorVPGTask.java
index 345ce3e6..2b63eaeb 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorVPGTask.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/IFortranEditorVPGTask.java
@@ -2,6 +2,7 @@ package org.eclipse.photran.internal.ui.editor_vpg;
import org.eclipse.core.resources.IFile;
import org.eclipse.photran.core.IFortranAST;
+import org.eclipse.photran.internal.core.analysis.binding.Definition;
/**
* An <code>IFortranEditorVPGTask</code> can be run only after the VPG has been updated for the file in the editor.
@@ -16,5 +17,5 @@ import org.eclipse.photran.core.IFortranAST;
*/
public interface IFortranEditorVPGTask
{
- void handle(IFile file, IFortranAST ast);
+ void handle(IFile file, IFortranAST ast, DefinitionMap<Definition> defMap);
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/OldExperimentalFreeFormFortranEditor.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/OldExperimentalFreeFormFortranEditor.java
index cc4d401f..8ff7ea78 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/OldExperimentalFreeFormFortranEditor.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/OldExperimentalFreeFormFortranEditor.java
@@ -1,10 +1,12 @@
package org.eclipse.photran.internal.ui.editor_vpg;
import org.eclipse.cdt.internal.ui.text.CReconciler;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jface.text.IPaintPositionManager;
import org.eclipse.jface.text.IPainter;
import org.eclipse.jface.text.ITextViewerExtension2;
import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
@@ -38,10 +40,13 @@ public class OldExperimentalFreeFormFortranEditor extends FreeFormFortranEditor
super(editor);
}
- @Override protected IReconciler loadReconciler()
+ @Override public IReconciler getReconciler(ISourceViewer sourceViewer)
{
- return new CReconciler(OldExperimentalFreeFormFortranEditor.this,
- new FortranVPGReconcilingStrategy(OldExperimentalFreeFormFortranEditor.this));
+ MonoReconciler r = new CReconciler(editor, new FortranVPGReconcilingStrategy(OldExperimentalFreeFormFortranEditor.this));
+ r.setIsIncrementalReconciler(false);
+ r.setProgressMonitor(new NullProgressMonitor());
+ r.setDelay(2000);
+ return r;
}
}
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorASTTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorASTTask.java
index afcbb4f0..4160c5ce 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorASTTask.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorASTTask.java
@@ -2,8 +2,11 @@ package org.eclipse.photran.internal.ui.editor_vpg.contentassist;
import java.util.ArrayList;
-import org.eclipse.photran.core.IFortranAST;
+import org.eclipse.photran.core.vpg.util.IterableWrapper;
+import org.eclipse.photran.internal.core.analysis.binding.Definition;
import org.eclipse.photran.internal.core.lexer.Token;
+import org.eclipse.photran.internal.core.lexer.TokenList;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
import org.eclipse.photran.internal.ui.editor_vpg.DefinitionMap;
import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorASTTask;
@@ -17,7 +20,9 @@ final class FortranCompletionProcessorASTTask implements IFortranEditorASTTask
}
// Will be run <i>outside</i> the UI thread
- public void handle(IFortranAST ast)
+ public boolean handle(ASTExecutableProgramNode ast,
+ TokenList tokenList,
+ DefinitionMap<Definition> defMap)
{
synchronized (fortranCompletionProcessor)
{
@@ -26,7 +31,7 @@ final class FortranCompletionProcessorASTTask implements IFortranEditorASTTask
try
{
int lastLine = 0;
- for (Token token : ast)
+ for (Token token : new IterableWrapper<Token>(tokenList))
{
int line = token.getLine();
if (line > lastLine)
@@ -43,6 +48,7 @@ final class FortranCompletionProcessorASTTask implements IFortranEditorASTTask
{
// Ignore
}
+ return true;
}
}
} \ No newline at end of file
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorVPGTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorVPGTask.java
index 20850110..d0b902dd 100755
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorVPGTask.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/contentassist/FortranCompletionProcessorVPGTask.java
@@ -22,7 +22,7 @@ final class FortranCompletionProcessorVPGTask implements IFortranEditorVPGTask
}
// IFortranEditorVPGTask - Will be run <i>outside</i> the UI thread
- public void handle(IFile file, IFortranAST ast)
+ public void handle(IFile file, IFortranAST ast, DefinitionMap<Definition> defMap)
{
synchronized (fortranCompletionProcessor)
{
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorASTTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorASTTask.java
deleted file mode 100755
index 333589db..00000000
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorASTTask.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.eclipse.photran.internal.ui.editor_vpg.sampletasks;
-
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.photran.core.IFortranAST;
-import org.eclipse.photran.internal.core.lexer.Terminal;
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
-import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorASTTask;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-final class SampleEditorASTTask implements IFortranEditorASTTask
-{
- private final AbstractFortranEditor freeFormVPGEditor;
- private Color LIGHT_YELLOW = new Color(null, new RGB(240, 240, 128));
-
- SampleEditorASTTask(AbstractFortranEditor freeFormVPGEditor)
- {
- this.freeFormVPGEditor = freeFormVPGEditor;
- }
-
- public void handle(IFortranAST ast)
- {
- // Sample Action: Highlight all identifiers (and destroy most of the rest of the highlighting)
-
- final TextPresentation presentation = new TextPresentation();
- for (Token token : ast)
- {
- if (token.getTerminal() == Terminal.T_IDENT)
- presentation.addStyleRange(new StyleRange(token.getFileOffset(),
- token.getLength(),
- null,
- LIGHT_YELLOW));
- }
-
- this.freeFormVPGEditor.getSite().getShell().getDisplay().asyncExec(new Runnable()
- {
- public void run()
- {
- freeFormVPGEditor.getSourceViewerx().changeTextPresentation(presentation, true);
- }
- });
- }
-} \ No newline at end of file
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorMappingTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorMappingTask.java
deleted file mode 100755
index d4899456..00000000
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorMappingTask.java
+++ /dev/null
@@ -1,78 +0,0 @@
-package org.eclipse.photran.internal.ui.editor_vpg.sampletasks;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.photran.core.IFortranAST;
-import org.eclipse.photran.internal.core.analysis.binding.Definition;
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
-import org.eclipse.photran.internal.ui.editor_vpg.DefinitionMap;
-import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorASTTask;
-import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorVPGTask;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-final class SampleEditorMappingTask
-{
- IFortranEditorVPGTask vpgTask = new VPGTask();
- IFortranEditorASTTask astTask = new ASTTask();
-
- private final AbstractFortranEditor freeFormVPGEditor;
- private DefinitionMap<Definition> defMap = null;
-
- private Color LIGHT_YELLOW = new Color(null, new RGB(240, 240, 128));
-
- SampleEditorMappingTask(AbstractFortranEditor freeFormVPGEditor)
- {
- this.freeFormVPGEditor = freeFormVPGEditor;
- }
-
- private class VPGTask implements IFortranEditorVPGTask
- {
- public void handle(IFile file, IFortranAST ast)
- {
- defMap = new DefinitionMap<Definition>(ast)
- {
- @Override protected Definition map(Definition def)
- {
- return def;
- }
- };
- }
- }
-
- private class ASTTask implements IFortranEditorASTTask
- {
- public void handle(final IFortranAST ast)
- {
- if (defMap == null) return;
-
- freeFormVPGEditor.getSite().getShell().getDisplay().syncExec(new Runnable()
- {
- public void run()
- {
- ITextSelection sel = freeFormVPGEditor.getSelection();
- if (sel == null) return;
-
- Token current = null;
- for (Token t : ast)
- {
- if (t.containsFileOffset(sel.getOffset()))
- {
- current = t;
- break;
- }
- }
- if (current == null) return;
-
- Definition def = defMap.lookup(current);
- if (def != null)
- System.err.println("The identifier under the cursor is bound to "
- + def.toString());
- else
- System.err.println("No definition found for the identifier under the cursor");
- }
- });
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorVPGTask.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorVPGTask.java
deleted file mode 100755
index 696aca16..00000000
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/editor_vpg/sampletasks/SampleEditorVPGTask.java
+++ /dev/null
@@ -1,34 +0,0 @@
-package org.eclipse.photran.internal.ui.editor_vpg.sampletasks;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.photran.core.IFortranAST;
-import org.eclipse.photran.internal.core.analysis.binding.Definition;
-import org.eclipse.photran.internal.core.lexer.Terminal;
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
-import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorVPGTask;
-
-final class SampleEditorVPGTask implements IFortranEditorVPGTask
-{
- SampleEditorVPGTask(AbstractFortranEditor freeFormVPGEditor)
- {
- }
-
- public void handle(IFile file, IFortranAST ast)
- {
- // Sample Action: Highlight all identifiers (and destroy most of the rest of the highlighting)
- // THIS IS ONLY AN EXAMPLE. Try it, and notice how incredibly broken it is.
-
- for (Token t : ast)
- {
- if (t.getTerminal() != Terminal.T_IDENT) continue;
-
- List<Definition> bindings = t.resolveBinding();
- if (bindings.isEmpty()) continue;
-
- System.out.println(bindings.get(0));
- }
- }
-} \ No newline at end of file
diff --git a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/views/DeclarationView.java b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/views/DeclarationView.java
index fd276c55..056af7a7 100644
--- a/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/views/DeclarationView.java
+++ b/org.eclipse.photran.ui.vpg/src/org/eclipse/photran/internal/ui/views/DeclarationView.java
@@ -1,47 +1,29 @@
-
package org.eclipse.photran.internal.ui.views;
-import java.io.ByteArrayOutputStream;
-import java.io.PrintStream;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.jface.resource.JFaceResources;
import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.presentation.PresentationReconciler;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.FastPartitioner;
import org.eclipse.jface.text.rules.ITokenScanner;
import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
-import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.photran.core.IFortranAST;
import org.eclipse.photran.internal.core.analysis.binding.Definition;
-import org.eclipse.photran.internal.core.analysis.binding.ScopingNode;
-import org.eclipse.photran.internal.core.analysis.types.DerivedType;
-import org.eclipse.photran.internal.core.analysis.types.FunctionType;
-import org.eclipse.photran.internal.core.analysis.types.Type;
-import org.eclipse.photran.internal.core.analysis.types.TypeProcessor;
-import org.eclipse.photran.internal.core.lexer.Token;
-import org.eclipse.photran.internal.core.parser.Parser.InteriorNode;
+import org.eclipse.photran.internal.core.lexer.TokenList;
+import org.eclipse.photran.internal.core.parser.ASTExecutableProgramNode;
import org.eclipse.photran.internal.core.properties.SearchPathProperties;
-import org.eclipse.photran.internal.core.refactoring.infrastructure.FortranRefactoring;
import org.eclipse.photran.internal.ui.editor.AbstractFortranEditor;
import org.eclipse.photran.internal.ui.editor.FortranKeywordRuleBasedScanner;
import org.eclipse.photran.internal.ui.editor_vpg.DefinitionMap;
-import org.eclipse.photran.internal.ui.editor_vpg.FortranVPGReconcilingStrategy;
+import org.eclipse.photran.internal.ui.editor_vpg.FortranEditorVPGTasks;
import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorASTTask;
import org.eclipse.photran.internal.ui.editor_vpg.IFortranEditorVPGTask;
-import org.eclipse.photran.internal.ui.editor_vpg.FortranEditorVPGTasks;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
@@ -67,8 +49,9 @@ public class DeclarationView extends ViewPart
IFortranEditorASTTask
{
private AbstractFortranEditor activeEditor = null;
- private IFortranAST activeAST = null;
- private DefinitionMap<String> activeDefMap = null;
+ private ASTExecutableProgramNode activeAST = null;
+ private TokenList activeTokenList = null;
+ private DefinitionMap<String> activeDefinitions = null;
private SourceViewer viewer = null;
private Document document = new Document();
@@ -232,13 +215,11 @@ public class DeclarationView extends ViewPart
* IFortranEditorVPGTask - Callback run when the VPG is more-or-less up-to-date.
* This method is run <i>outside</i> the UI thread.
*/
- public synchronized void handle(IFile file, IFortranAST ast)
+ public synchronized void handle(IFile file, IFortranAST ast, DefinitionMap<Definition> defMap)
{
- if (activeEditor == null || activeAST == null) return;
-
- activeDefMap = new DefinitionMap<String>(ast)
+ activeDefinitions = new DefinitionMap<String>(defMap)
{
- @Override protected String map(Definition def)
+ @Override protected String map(String qualifiedName, Definition def)
{
return def.describe();
}
@@ -250,9 +231,11 @@ public class DeclarationView extends ViewPart
* is available. May be newer than the information available in the VPG.
* This method is run <i>outside</i> the UI thread.
*/
- public synchronized void handle(final IFortranAST ast)
+ public synchronized boolean handle(ASTExecutableProgramNode ast, TokenList tokenList, DefinitionMap<Definition> defMap)
{
activeAST = ast;
+ activeTokenList = tokenList;
+ return true;
}
/**
@@ -260,9 +243,9 @@ public class DeclarationView extends ViewPart
*/
public synchronized void selectionChanged(SelectionChangedEvent event)
{
- if (event.getSelection() instanceof TextSelection && activeAST != null && activeDefMap != null)
+ if (event.getSelection() instanceof TextSelection && activeAST != null && activeDefinitions != null)
{
- String description = activeDefMap.lookup((TextSelection)event.getSelection(), activeAST);
+ String description = activeDefinitions.lookup((TextSelection)event.getSelection(), activeTokenList);
update(description == null ? "" : description);
}
else
diff --git a/org.eclipse.photran.ui/src/org/eclipse/photran/internal/ui/editor/AbstractFortranEditor.java b/org.eclipse.photran.ui/src/org/eclipse/photran/internal/ui/editor/AbstractFortranEditor.java
index 97de4fb9..4c283223 100644
--- a/org.eclipse.photran.ui/src/org/eclipse/photran/internal/ui/editor/AbstractFortranEditor.java
+++ b/org.eclipse.photran.ui/src/org/eclipse/photran/internal/ui/editor/AbstractFortranEditor.java
@@ -112,7 +112,7 @@ public abstract class AbstractFortranEditor extends TextEditor implements ISelec
// Public Fields - Custom Reconciler Task Support
///////////////////////////////////////////////////////////////////////////////////////////////
- /** @see org.eclipse.photran.internal.ui.editor_vpg.FortranReconcilingStrategy */
+ /** @see org.eclipse.photran.internal.ui.editor_vpg.FortranVPGReconcilingStrategy */
public Object reconcilerTasks = null;
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -390,20 +390,11 @@ public abstract class AbstractFortranEditor extends TextEditor implements ISelec
*/
public IReconciler getReconciler(ISourceViewer sourceViewer)
{
- IReconciler reconciler = loadReconciler();
- if (reconciler instanceof MonoReconciler)
- {
- MonoReconciler r = (MonoReconciler)reconciler;
- r.setIsIncrementalReconciler(false);
- r.setProgressMonitor(new NullProgressMonitor());
- r.setDelay(500);
- }
- return reconciler;
- }
-
- protected IReconciler loadReconciler()
- {
- return new CReconciler(editor, new CReconcilingStrategy(editor));
+ MonoReconciler r = new CReconciler(editor, new CReconcilingStrategy(editor));
+ r.setIsIncrementalReconciler(false);
+ r.setProgressMonitor(new NullProgressMonitor());
+ r.setDelay(500);
+ return r;
}
protected ITokenScanner getTokenScanner()

Back to the top