/// <summary> /// Common internal implementation for all 4 constructors above /// </summary> private FileCompiler(string libraryName, string textName, CobolFile loadedCobolFile, SourceFileProvider sourceFileProvider, IProcessedTokensDocumentProvider documentProvider, ColumnsLayout columnsLayout, ITextDocument textDocument, TypeCobolOptions compilerOptions, SymbolTable customSymbols, bool isCopyFile, [CanBeNull] MultilineScanState scanState) { // 1.a Find the Cobol source file CobolFile sourceFile = null; if (textName != null) { if (sourceFileProvider.TryGetFile(libraryName, textName, out sourceFile)) { CobolFile = sourceFile; } else { throw new Exception(String.Format("Could not find a Cobol source file named {0} in {1}", textName, libraryName)); } } // 1.b Register a Cobol source file which was already loaded else if(loadedCobolFile != null) { CobolFile = loadedCobolFile; } // 2.a Load it in a new text document in memory if (textDocument == null) { TextDocument = new ReadOnlyTextDocument(sourceFile.Name, sourceFile.Encoding, columnsLayout, sourceFile.ReadChars()); } // 2.b Load it in an existing text document in memory else if (sourceFile != null) { TextDocument = textDocument; textDocument.LoadChars(sourceFile.ReadChars()); } // 2.c Use a pre-existing text document // - not yet associated with a Cobol source file // - with a Cobol source file already loaded else if (sourceFile == null || loadedCobolFile != null) { TextDocument = textDocument; } // 3. Prepare the data structures used by the different steps of the compiler if (isCopyFile) { CompilationResultsForCopy = new CompilationDocument(TextDocument.Source, TextDocument.Lines, compilerOptions, documentProvider, scanState); CompilationResultsForCopy.CustomSymbols = customSymbols; } else { CompilationResultsForProgram = new CompilationUnit(TextDocument.Source, TextDocument.Lines, compilerOptions, documentProvider); CompilationResultsForProgram.CustomSymbols = customSymbols; } CompilerOptions = compilerOptions; }
/// <summary> /// Returns an object representing a local or remote Cobol file /// </summary> public bool TryGetFile(string textName, out CobolFile cobolFile) { string absoluteFilePath = FindFirstMatchingFilePath(textName); if (absoluteFilePath != null) { cobolFile = new LocalCobolFile(textName, absoluteFilePath, encoding, endOfLineDelimiter, fixedLineLength); return(true); } else { cobolFile = null; return(false); } }
/// <summary> /// Returns an object representing a local or remote Cobol file /// if a library named librayName contains a file for the specified textName /// (COPY textName OF libraryName) /// </summary> public bool TryGetFile(string libraryName, string textName, out CobolFile cobolFile) { if (libraryName == null) { libraryName = DEFAULT_LIBRARY_NAME; } foreach (ICobolLibrary cobolLibrary in CobolLibraries) { if (cobolLibrary.Name == libraryName && cobolLibrary.TryGetFile(textName, out cobolFile)) { return(true); } } cobolFile = null; return(false); }
/// <summary> /// Returns an object representing a local or remote Cobol file /// </summary> public bool TryGetFile(string textName, out CobolFile cobolFile) { string absoluteFilePath = FindFirstMatchingFilePath(textName); if(absoluteFilePath != null) { cobolFile = new LocalCobolFile(textName, absoluteFilePath, encoding, endOfLineDelimiter, fixedLineLength); return true; } else { cobolFile = null; return false; } }
/// <summary> /// Returns an object representing a local or remote Cobol file /// if a library named librayName contains a file for the specified textName /// (COPY textName OF libraryName) /// </summary> public bool TryGetFile(string libraryName, string textName, out CobolFile cobolFile) { if (libraryName == null) libraryName = DEFAULT_LIBRARY_NAME; foreach (ICobolLibrary cobolLibrary in CobolLibraries) { if (cobolLibrary.Name == libraryName && cobolLibrary.TryGetFile(textName, out cobolFile)) { return true; } } cobolFile = null; return false; }
/// <summary> /// Returns an object representing a local or remote Cobol file /// if the default library contains a file for the specified textName /// (COPY textName) /// </summary> public bool TryGetFile(string textName, out CobolFile cobolFile) { return TryGetFile(DEFAULT_LIBRARY_NAME, textName, out cobolFile); }
/// <summary> /// Use a pre-existing text document, already initialized from a Cobol file /// </summary> public FileCompiler(ITextDocument textDocument, CobolFile loadedCobolFile, SourceFileProvider sourceFileProvider, IProcessedTokensDocumentProvider documentProvider, TypeCobolOptions compilerOptions, bool isCopyFile) : this(null, null, null, sourceFileProvider, documentProvider, default(ColumnsLayout), textDocument, compilerOptions, null, isCopyFile) { }
public ObserverTextDocument(CobolFile cobolFile, ITextDocument textDocument) { this.cobolFile = cobolFile; this.textDocument = textDocument; }
/// <summary> /// Remove a file from the project /// </summary> public void RemoveFile(CobolFile cobolFile) { if (rootDirectoryLibrary.ContainsFile(cobolFile.Name)) { rootDirectoryLibrary.RemoveFile(cobolFile.Name, cobolFile.FullPath); } CobolFiles.Remove(cobolFile.Name); }
/// <summary> /// Returns an object representing a local or remote Cobol file /// if the default library contains a file for the specified textName /// (COPY textName) /// </summary> public bool TryGetFile(string textName, out CobolFile cobolFile) { return(TryGetFile(DEFAULT_LIBRARY_NAME, textName, out cobolFile)); }
/// <summary> /// Loads the content of a source file in the editor /// </summary> public TypeCobolEditor(CobolFile sourceFile) { TextView textView = TextArea.TextView; // Default text style FontFamily = new FontFamily("Consolas"); FontSize = 13; // Show line numbers ShowLineNumbers = true; // Activate search box SearchPanel.Install(this); // Plug in TypeCobol syntax highlighting syntaxHighlighter = new SyntaxHighlighter(); textView.LineTransformers.Add(syntaxHighlighter); // Plug in TypeCobol error marker errorMarker = new ErrorMarker(this); textView.BackgroundRenderers.Add(errorMarker); textView.LineTransformers.Add(errorMarker); // Tooltip management tooltipManager = new TooltipManager(this, errorMarker); textView.MouseHover += tooltipManager.MouseHover; textView.MouseHoverStopped += tooltipManager.MouseHoverStopped; textView.VisualLinesChanged += tooltipManager.VisualLinesChanged; // Initial load of the cobol file if necessary if (sourceFile != null) { Document = new ICSharpCode.AvalonEdit.Document.TextDocument(sourceFile.ReadChars()); } // Wrap the AvalonEdit.Document in a ITextDocument interface textDocument = new AvalonEditTextDocument(Document, IBMCodePages.GetDotNetEncodingFromIBMCCSID(1147), ColumnsLayout.CobolReferenceFormat); }