Commit 9ae22047 authored by Andrey Filippov's avatar Andrey Filippov

bug fixes (handling ports & parameters), also made Verilog parser to use

one of the editor windows instead of the file if it is open (possibly
dirty)
parent dde3f196
......@@ -28,7 +28,7 @@ package com.elphel.vdt;
import java.util.ArrayList;
import java.util.List;
import com.elphel.vdt.ui.variables.SelectedResourceManager;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.document.HdlDocument;
......@@ -40,12 +40,17 @@ import com.elphel.vdt.veditor.parser.OutlineDatabase;
import com.elphel.vdt.veditor.parser.OutlineElement;
import com.elphel.vdt.veditor.preference.PreferenceStrings;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.texteditor.ITextEditor;
/**
* Verilog file utilities.
......@@ -251,7 +256,39 @@ public class VerilogUtils {
} catch (CoreException e) {
}
} // getVerilogFiles()
/**
* Get the full text from one of the open editor windows or null (if there is none)
* @param file IFile for which we are looking for text
* @return full text of the current state of the file or null
*/
public static String getEditorText(IFile file){
try {
IEditorPart editor=org.eclipse.ui.ide.ResourceUtil.findEditor(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage(), file);
if (editor instanceof TextEditor) {
IDocument doc = ((ITextEditor)editor).getDocumentProvider().getDocument(editor.getEditorInput());
return doc.get();
}
} catch (Exception e) {
}
return null;
}
/*
*
IDocument doc =
((ITextEditor)editor).getDocumentProvider().getDocument(editor.getEditorInput());
String text = doc.get();
IWorkbench wb = PlatformUI.getWorkbench();
IWorkbenchWindow window = wb.getActiveWorkbenchWindow();
IWorkbenchPage page = window.getActivePage();
IEditorPart editor = page.getActiveEditor();
IEditorInput input = editor.getEditorInput();
IPath path = ((FileEditorInput)input).getPath();
*/
/*
private static SourceFile getSourceFile(IFile file) {
......
......@@ -31,6 +31,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
import com.elphel.vdt.VerilogUtils;
import com.elphel.vdt.veditor.VerilogPlugin;
import com.elphel.vdt.veditor.parser.HdlParserException;
import com.elphel.vdt.veditor.parser.OutlineContainer;
......@@ -63,10 +64,13 @@ public class VerilogParseMultipass {
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_EDITOR)) {
System.out.println ("parseMultiPass("+file+")");
}
String text= VerilogUtils.getEditorText(file);
try {
parser=null;
// VerilogParserReader handles verilog compiler directive
ParserReader reader = new VerilogParserReader(file.getContents(), file);
ParserReader reader = (text==null)?
(new VerilogParserReader(file.getContents(), file)): // use file
(new VerilogParserReader(text, file)); // use (possibly dirty) editor window
parser = (VerilogParser) ParserFactory.createVerilogParser(reader, project, file); // Creates file on outline database
//do we have parser
if(parser!= null){
......@@ -95,7 +99,11 @@ public class VerilogParseMultipass {
Map<String,VariableStore> variableStoreMap=parser.getVariableStoreMap();
ParserReader reader;
try {
reader = new VerilogParserReader(file.getContents(), file);
// reader = new VerilogParserReader(file.getContents(), file);
reader = (text==null)?
(new VerilogParserReader(file.getContents(), file)): // use file
(new VerilogParserReader(text, file)); // use (possibly dirty) editor window
} catch (CoreException e) {
System.out.println("BUG: parseMultiPass() could not create VerilogParserReader() e="+e);
return false;
......@@ -118,10 +126,10 @@ public class VerilogParseMultipass {
if (rank>=0) maxPass= rank+2;
}
if (VerilogPlugin.getPreferenceBoolean(PreferenceStrings.DEBUG_EDITOR)) {
System.out.println("getDepsResolved()= "+parser.getDepsResolved());
System.out.println("getParsResolved()= "+parser.getParsResolved());
System.out.println("getExpressionsValid()="+parser.getExpressionsValid());
System.out.println("getPortsValid()= "+parser.getPortsValid());
System.out.println("parseMultiPass: getDepsResolved()= "+parser.getDepsResolved()+" file:"+file);
System.out.println("parseMultiPass: getParsResolved()= "+parser.getParsResolved()+" file:"+file);
System.out.println("parseMultiPass: getExpressionsValid()="+parser.getExpressionsValid()+" file:"+file);
System.out.println("parseMultiPass: getPortsValid()= "+parser.getPortsValid()+" file:"+file);
}
if (parser.getExpressionsValid() || (numPass == maxPass)) {
parser.setParametricPorts();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment