Beispiel #1
0
 public void ClearAllErrorsFrom(ProjectItemCodeDocument codeDocument, ErrorSource source)
 {
     foreach(var error in GetErrorsFromDocument(codeDocument)) {
         if(error.Source == source)
             this.Remove(error);
     }
 }
        protected override void UpdateDocumentIncludeFlow(ProjectItemCodeDocument document)
        {
            document.Project.Solution.ErrorService.ClearAllErrorsFrom(document);
            var directives = document.SegmentService.GetDirectiveSegments();

            // Update the code documents Include Flow.
            if(_codeDocuments.ContainsKey(document)){
                _codeDocuments[document].Clear();
                foreach(var d in directives) {
                    if(d.TokenString.Equals(INCLUDE_ONCE, StringComparison.InvariantCultureIgnoreCase)) {
                        var includedDoc = ParseIncludeDirective(d, document);
                        if(includedDoc != null) {
                            _codeDocuments[document].Add(includedDoc);
                        } else {

                            if(_project.StartUpCodeDocument == null) {
                                RegisterError(document, d, "This Include can't be analyzed because a start Script file is missing. Please define a Startup-Scriptfile!");
                            } else {
                                RegisterError(document, d, "This Include can't be analyzed because the Target it is not member of the current Project.");
                            }
                        }
                    }
                }
            }
        }
        public CurrentLineHighlightRenderer(TextEditor editor, ProjectItemCodeDocument projectitem)
        {
            _editor = editor;
            _projectitem = projectitem;

            _editor.TextArea.Caret.PositionChanged += (s, e) => Invalidate();
        }
        /// <summary>
        /// Generates the dependency hirarchy of the include files
        /// </summary>
        /// <param name="document"></param>
        /// <param name="parentNode"></param>
        /// <returns></returns>
        /// <exception cref="DependencyTreeException" />
        public List<ProjectItemCodeDocument> BuildHirarchy(Dictionary<ProjectItemCodeDocument, List<ProjectItemCodeDocument>> data, ProjectItemCodeDocument startDoc)
        {
            // init globals
            _codeDocuments = data;
            _treeRoot = new SimpleTree<ProjectItemCodeDocument>() { Value = startDoc };

            return GenerateDependcyHirarchy(startDoc, _treeRoot);
        }
        public ErrorBackgroundRenderer(TextEditor editor, ProjectItemCodeDocument projectitem)
        {
            _editor = editor;
            _codeitem = projectitem;
            _solution = projectitem.Project.Solution;

            //_editor.TextArea.Caret.PositionChanged += (s, e) => Invalidate();
        }
        public CompletionDataProviderAHK(TextEditor texteditor, ProjectItemCodeDocument projectitem) {
            ThrowUtil.ThrowIfNull(texteditor);
            ThrowUtil.ThrowIfNull(projectitem);

            _texteditor = texteditor;
            _projectitem = projectitem;

            _texteditor.TextArea.TextEntered += OnTextEntered;
        }
        public TreeViewProjectItemCodeFile(ProjectItemCodeDocument codeitem, TreeViewProjectItem parent)
            : base(codeitem, parent)
        {
            _codeitem = codeitem;
                ImageSource = @"../Images/ironAHK.ico";

            _codeitem.IsStartUpDocumentChanged += (s,e) => OnPropertyChanged(() => IsStartUpDocument);
            _codeitem.IsStartUpDocumentChanged += (s,e) => OnPropertyChanged(() => ItemFontWeight);
        }
Beispiel #8
0
        public void Remove(ProjectItemCodeDocument document) {
            _codeDocuments.Remove(document);
            OnCodeDocumentRemoved(document);

            if(UpdateAtWill && !_project.IsInUpdate) {
                UpdateAtWill = false;
                UpdateFullASTAndReleaseUpdateLock();
            }
        }
 /// <summary>
 /// Creates a new VM, or if there was already created it returns the cached VM
 /// </summary>
 /// <param name="projectitem"></param>
 /// <returns></returns>
 public static CodeFileViewModel Create(ProjectItemCodeDocument projectitem) {
     var viewModelPoolService = ServiceLocator.Instance.Resolve<IViewModelPoolService>();
     CodeFileViewModel vm;
     vm = viewModelPoolService.Resolve<CodeFileViewModel>(projectitem);
     if(vm == null) {
         vm = new CodeFileViewModel(projectitem);
         viewModelPoolService.Register(projectitem, vm);
     }
     return vm;
 }
Beispiel #10
0
 public CodeSegment(ProjectItemCodeDocument codeDocument, Token token, string tokenstr, SimpleSegment anchorsegment, int line, int colstart, CodeSegment previous)
 {
     _type = token;
     _tokenstring = tokenstr;
     _codesegment = anchorsegment;
     _line = line;
     _column = colstart;
     _previous = previous;
     _codeDocument = codeDocument;
 }
Beispiel #11
0
        public void Add(ProjectItemCodeDocument document) {
            if(!_codeDocuments.ContainsKey(document)) {
                _codeDocuments.Add(document, new List<ProjectItemCodeDocument>());
                OnCodeDocumentAdded(document);

                if(UpdateAtWill && !_project.IsInUpdate) {
                    UpdateAtWill = false;
                    UpdateFullASTAndReleaseUpdateLock();
                }
            } 
        }
        public override ProjectItem CreateNewItem(ProjectItem parent)
        {
            var doc = new ProjectItemCodeDocument(this.FileName, parent.Project.Language, parent);
            doc.Document.Text = string.Format(
            @"
            #NoEnv
            ; Empty Template

            ");
            parent.Add(doc);
            return doc;
        }
        public override ProjectItem CreateNewItem(ProjectItem parent)
        {
            var doc = new ProjectItemCodeDocument(parent.Project.Language, parent);
            doc.Name = this.FileName;

            doc.Document.Text = string.Format(
            @"
            class {0}
            {{

            }}", Path.GetFileNameWithoutExtension(this.FileName));
            parent.Add(doc);
            return doc;
        }
        public override SmartCodeProject Create(string displayname, string name, string location)
        {
            var p = new SmartCodeProjectAHK(name, location, this.Language) { DisplayName = displayname };
            p.BeginProjectUpdate();
            {
                // Create stdlib folder alias
                var stdlibdir = Path.GetDirectoryName(((CodeLanguageAHKv1)_language).Settings.InterpreterPath);
                p.StdLib = new ProjectItemFolderSTdLib("StdLib", stdlibdir, p);
                p.Add(p.StdLib);

                // Create local lib folder alias
                p.Add(new ProjectItemFolder("Lib", p));

                var dp = new ProjectItemCodeDocument(_language, p) { Name = "New.ahk" };
                p.Add(dp);
                dp.Document.Text = InitialEmptyFile();
                dp.QuickSave();
                dp.IsStartUpDocument = true;
                //dp.ShowInWorkSpace(); // present our demo file to the user
            } p.EndProjectUpdate();

            return p;
        }
        List<ProjectItemCodeDocument> GenerateDependcyHirarchy(ProjectItemCodeDocument document, SimpleTreeNode<ProjectItemCodeDocument> parentNode)
        {
            List<ProjectItemCodeDocument> hirarchy = new List<ProjectItemCodeDocument>();

            SimpleTreeNode<ProjectItemCodeDocument> currentNode;

            if(!_codeDocuments.ContainsKey(document))
                return hirarchy;

            // for each include in this document
            foreach(var doc in _codeDocuments[document]) {

                // Ignore Selfincludes
                if(document.Equals(doc)) {
                    continue;
                }

                SimpleTreeNode<ProjectItemCodeDocument> parent = parentNode;
                while((parent = parent.Parent) != null) {
                    if(parent.Value.Equals(doc)) {
                        throw new DependencyTreeException(
                            string.Format("Cyclyc reference flow detected in the dependency Tree. --> {0}", doc.Name), doc);
                    }
                }

                currentNode = new SimpleTreeNode<ProjectItemCodeDocument>(doc);
                parentNode.Children.Add(currentNode);

                foreach(var doctoAdd in GenerateDependcyHirarchy(doc, currentNode)) {
                    if(!hirarchy.Contains(doctoAdd))
                        hirarchy.Add(doctoAdd);
                }
                if(!hirarchy.Contains(doc))
                    hirarchy.Add(doc);
            }
            return hirarchy;
        }
        public InvokeCompletionViewModel(CodeFileViewModel documentVM, CodeSegment methodSegment, int startParam)
        {
            _document = documentVM.CodeDocument;
            _documentVM = documentVM;

            _toolTip = new ToolTip();
            _toolTip.Placement = PlacementMode.Custom;
            _toolTip.PlacementTarget = _documentVM.Editor.TextArea.TextView;
            _toolTip.Content = this;

            _toolTip.CustomPopupPlacementCallback = PopupPlacement;

            _documentVM.Editor.TextArea.KeyDown += (s, e) => {
                if(e.Key == Key.Escape)
                    this.CloseCommand.Execute(null);
            };

            //_documentVM.Editor.TextArea.TextEntered += OnTextEntered;
            _documentVM.Editor.TextArea.Caret.PositionChanged += OnCaretPositionChanged;

            AllParameters = new ObservableCollection<InvokeParameter>();
            SetMethod(methodSegment);
            SetCurrentParam(startParam);
        }
Beispiel #17
0
 public void ClearAllErrorsFrom(ProjectItemCodeDocument codeDocument)
 {
     foreach(var error in GetErrorsFromDocument(codeDocument)) {
         this.Remove(error);
     }
 }
 public override void GetHelpFor(ProjectItemCodeDocument document, Model.CodeContexts.CodeContext ctx)
 {
     if(File.Exists(_settings.HelpFilePath)) {
         Process p = new Process();
         p.StartInfo.FileName = _settings.HelpFilePath; // todo: run hh.exe and open correct theme if avaiable
         p.Start();
     } else
         _workbenchservice.MessageBox(string.Format("Missing Helpfile.\n{0}", _settings.HelpFilePath), "Help Error",
             MessageBoxType.Error);
 }
 public override Tokenizer CreateTokenizer(ProjectItemCodeDocument codeitem, ITextSource source)
 {
     return new SimpleTokinizerIA(codeitem, source);
 }
 public override IEnumerable<EditorDocumentExtension> CreateExtensionsForCodeDocument(TextEditor texteditor, ProjectItemCodeDocument projectitem)
 {
     var extes = new List<EditorDocumentExtension>();
     extes.Add(new CompletionDataProviderAHK(texteditor, projectitem));
     return extes;
 }
 public override CodeDocumentDOMService CreateDOMService(ProjectItemCodeDocument document)
 {
     return new CodeDOMDocumentServiceAHK(document);
 }
 public CodeMethodReferenceExpressionEx(ProjectItemCodeDocument codeDocumentItem, CodeExpression target, string methodName, CodeTypeDeclarationEx enclosingType)
     : base(target, methodName)
 {
     _enclosingType = enclosingType;
         _codeDocumentItem = codeDocumentItem;
 }
 protected void SetCurrentDocumentAsEditor(ProjectItemCodeDocument doc)
 {
     var docVM =  CodeFileViewModel.Create(doc);
         CurrentEditor = docVM;
         docVM.ShowCommand.Execute(null);
 }
Beispiel #24
0
 public virtual void DocumentGotFocus(ProjectItemCodeDocument doc)
 {
     ActiveDocument = doc;
 }
 public CompilerArgument(ProjectItemCodeDocument codeitem, CodeTypeDeclarationEx initialparent)
 {
     Codeitem = codeitem;
     Initialparent = initialparent;
 }
        /// <summary>
        /// Occurs when the CodeDoucument Collection has been changed
        /// </summary>
        protected virtual void OnCodeDocumentRemoved(ProjectItemCodeDocument doc)
        {
            if(CodeDocumentRemoved != null)
                CodeDocumentRemoved(this, new EventArgs<ProjectItemCodeDocument>(doc));

            _ASTManager.Remove(doc);
        }
        public override bool Add(string fileToOpen)
        {
            string name = Path.GetFileName(fileToOpen);
            string targetLocation = Path.Combine(_projectPath, name);

            if(!targetLocation.Equals(fileToOpen, StringComparison.InvariantCultureIgnoreCase)) {
                File.Copy(fileToOpen, targetLocation);
            }

            var file = new ProjectItemCodeDocument(name, this.Language, this);

            if(file != null) {
                this.Add(file);
                file.ShowInWorkSpace();
                return true;
            } else
                return false;
        }
 public CodeMemberMethodExAHK(ProjectItemCodeDocument codeDocumentItem)
     : base(codeDocumentItem)
 {
     IsTraditionalCommand = false;
     IsDefaultMethodInvoke = true;
 }
Beispiel #29
0
 public IEnumerable<ErrorItem> GetErrorsFromDocument(ProjectItemCodeDocument codeDocument)
 {
     return _errors.FindAll(x => x.CodeItem.Equals(codeDocument));
 }
 public CodePropertyReferenceExpressionEx(ProjectItemCodeDocument codeDocumentItem, CodeExpression target, string propertyName, CodeTypeDeclarationEx enclosingType)
     : base(target, propertyName)
 {
     _enclosingType = enclosingType;
         _codeDocumentItem = codeDocumentItem;
 }