Changeset 239
- Timestamp:
- 02/26/07 23:21:21 (2 years ago)
- Files:
-
- trunk/src/leds/LanguageD.d (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/src/leds/LanguageD.d
r237 r239 54 54 private import std.date; 55 55 private import std.stdio; 56 private import std.thread; 56 57 57 58 this(CodeView codeview) … … 418 419 { 419 420 420 421 421 422 //return (new CodeLookup(codeview)).getLookupList(codeview, start); 422 423 String[] list; … … 437 438 438 439 Module sourceModule = this.getCachedModule(); 439 CodeBlock container = sourceModule.getContainerForLine(codeview.getLineNumber());440 CodeBlock container = sourceModule.getContainerForLine(codeview.getLineNumber()); 440 441 if (!container) { 441 442 writefln("no container found?"); … … 450 451 } 451 452 // do lookup on '*.*' 452 453 453 454 Element lookupwith = null; 454 455 for(int i=0;i< bits.length-1; i++) { … … 464 465 } 465 466 // got a parent 466 container = type.moduleObj; // use the scope of the definition. 467 lookupwith = container.getTypeElement(type); 467 container = cast(CodeBlock)type.parent; // use the scope of the definition. 468 lookupwith = null; 469 if (container) { 470 lookupwith = container.getTypeElement(type); 471 } 468 472 if (!lookupwith) { 469 473 writefln("cant find defintion of type %s" , type.returnType); … … 511 515 } 512 516 } 517 513 518 514 519 /** … … 574 579 writefln("getPropValue(\"dmd\",\"dmd\") = ", l); 575 580 576 // dmd doesn't need to be a file if it's on the executables path 577 // if (!Path.isFile(l)) 578 // { 579 // //writefln("dmd command does not exist"); 580 // codeview.getWorkspace().getSystemConsole.print( 581 // "Can not find dmd '" ~ l.toString() ~ "' so compile test does not work\n"); 582 // return correct; 583 // } 581 584 582 585 583 version(Win32) … … 602 600 603 601 compileCommand = SystemConsole.expandCommand(compileCommand); 604 //debug(flow ) System.writefln("CodeView.checkSintax 7"); 605 codeview.getWorkspace().getSystemConsole.print("Compile Command: \n" ~ compileCommand.toString() ~ "\n"); 606 SpawnWrapper sp = new SpawnWrapper(compileCommand.toString()); 607 sp.start(); 608 while(1 && GtkD.eventsPending()) { 609 GtkD.mainIteration(); 610 if (sp.getState() == Thread.TS.TERMINATED) { 611 break; 612 } 613 } 614 615 //Spawn spawn = new Spawn(compileCommand.toString()); 616 //correct = spawn.commandLineSync()!=0; 617 //debug(flow ) System.writefln("CodeView.checkSintax 8"); 618 codeview.getWorkspace().getSystemConsole.print("Compile Result:\n" ~ sp.outputstring ~ "\n"); 619 //checkSyntax( spawn.getOutputString(), spawn.getErrorString()); 620 checkSyntax( SpawnWrapper.outputstring, SpawnWrapper.errorstring); 621 //workspace.getStatusbar().addBackgroundProcess(); 622 //debug(flow ) System.writefln("CodeView.checkSintax 9"); 602 603 604 // show message that we are compiling 605 codeview.getWorkspace().getSystemConsole.print( 606 "Compile Command: \n" ~ compileCommand.toString() ~ "\n......\n"); 607 608 // create a thread and wait for it to finish.. 609 auto compilethread = new CompilerThread(compileCommand); 610 int id = compilethread.id; 611 compilethread.start(); 612 char[] res; 613 while(true) 614 { 615 if (GtkD.eventsPending()) { 616 GtkD.mainIteration(); 617 } 618 res = getCompileCompleted(id); 619 if (res is null) { 620 continue; 621 } 622 break; 623 } 624 // display the results. 625 626 codeview.getWorkspace().getSystemConsole.print( 627 "Compile Command: \n" ~ compileCommand.toString() ~ "\n" ~ 628 "Compile Result:\n" ~ res ~ "\n"); 629 checkSyntax( res ); 630 623 631 codeview.endSintaxCheck(); 624 632 … … 627 635 return correct; 628 636 } 629 bool syntaxCorrect = false; 630 631 private import std.thread; 632 class SpawnWrapper : Thread 633 { 634 char[] command;; 635 this(char[] cmd) 636 { 637 command = cmd; 638 } 639 static char[] errorstring = ""; 640 static char[] outputstring = ""; 637 638 639 /** 640 * Support for threaded compile - which is usefull on slow filesystems 641 * (eg. davfs mounted) 642 * we store the results in a synconized static array 643 * 644 */ 645 static int compileNo = 0; 646 static char[][int] completedCompiles; 647 648 synchronized static void flagCompileCompleted(int id, char[] str) 649 { 650 completedCompiles[id] = str; 651 } 652 653 synchronized static char[] getCompileCompleted(int id) 654 { 655 if (id in completedCompiles) { 656 char[] ret = completedCompiles[id]; 657 completedCompiles.remove(id); 658 return ret; 659 } 660 return null; 661 662 } 663 664 class CompilerThread : Thread 665 { 666 String cmd; 667 int id; 668 669 this(String cmd) 670 { 671 this.id = LanguageD.compileNo++; 672 this.cmd = cmd; 673 } 641 674 642 675 int run() 643 676 { 644 Spawn spawn = new Spawn(command); 677 writefln("running %s", cmd.toString()); 678 Spawn spawn = new Spawn(cmd.toString()); 645 679 spawn.commandLineSync(); 646 setStrings(spawn); 680 681 writefln("completed %s", spawn.getOutputString()); 682 LanguageD.flagCompileCompleted(id, spawn.getOutputString()); 647 683 return 1; 648 684 } 649 synchronized void setStrings(Spawn spawn) 650 { 651 652 SpawnWrapper.outputstring = spawn.getOutputString() ; 653 SpawnWrapper.errorstring =spawn.getErrorString(); 654 655 } 656 } 657 658 bit checkSyntax(char[] grabOutput, char[] grabError) 685 686 } 687 688 689 690 691 bit checkSyntax(char[] grabOutput) 659 692 { 660 693 foreach ( String line ; (new String(grabOutput)).splitLines() ) … … 833 866 { 834 867 // tidy it up.. 835 836 868 837 869 String[] strs = s.split("("); 838 870 s = strs.length ? strs[0] : new String(""); … … 842 874 if (s.toString() in Token.stdKeyword) { 843 875 codeview.getWorkspace().getSystemConsole.print("D Keyword: " ~ s.toString()); 876 return; 844 877 } 845 878 … … 1103 1136 { 1104 1137 1138 1105 1139 // commStr ??? 1106 1140 //Function funct;
