Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Side by Side Diff: compiler/java/com/google/dart/compiler/SystemLibrary.java

Issue 10907096: modify files view to use declared sdk libraries (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 package com.google.dart.compiler; 5 package com.google.dart.compiler;
6 6
7 import java.io.File; 7 import java.io.File;
8 import java.net.URI; 8 import java.net.URI;
9 import java.net.URISyntaxException; 9 import java.net.URISyntaxException;
10 10
11 /** 11 /**
12 * A library accessible via the "dart:<libname>.lib" protocol. 12 * A library accessible via the "dart:<libname>.lib" protocol.
13 */ 13 */
14 public class SystemLibrary { 14 public class SystemLibrary {
15 15
16 private final String shortName; 16 private final String shortName;
17 private final String host; 17 private final String host;
18 private final String pathToLib; 18 private final String pathToLib;
19 private final File dirOrZip; 19 private final File dirOrZip;
20 private String category;
21 private boolean documented;
22 private boolean implementation;
20 23
21 /** 24 /**
22 * Define a new system library such that dart:[shortLibName] will automaticall y be expanded to 25 * Define a new system library such that dart:[shortLibName] will automaticall y be expanded to
23 * dart://[host]/[pathToLib]. For example this call 26 * dart://[host]/[pathToLib]. For example this call
24 * 27 *
25 * <pre> 28 * <pre>
26 * new SystemLibrary("html.lib", "html", "dart_html.lib"); 29 * new SystemLibrary("html.lib", "html", "dart_html.lib");
27 * </pre> 30 * </pre>
28 * 31 *
29 * will define a new system library such that "dart:html.lib" to automatically be expanded to 32 * will define a new system library such that "dart:html.lib" to automatically be expanded to
30 * "dart://html/dart_html.lib". The dirOrZip argument is either the root direc tory or a zip file 33 * "dart://html/dart_html.lib". The dirOrZip argument is either the root direc tory or a zip file
31 * containing all files for this library. 34 * containing all files for this library.
32 */ 35 */
33 public SystemLibrary(String shortName, String host, String pathToLib, File dir OrZip) { 36 public SystemLibrary(String shortName, String host, String pathToLib, File dir OrZip, String category,
37 boolean documented, boolean implementation) {
34 this.shortName = shortName; 38 this.shortName = shortName;
35 this.host = host; 39 this.host = host;
36 this.pathToLib = pathToLib; 40 this.pathToLib = pathToLib;
37 this.dirOrZip = dirOrZip; 41 this.dirOrZip = dirOrZip;
42 this.category = category;
43 this.documented = documented;
44 this.implementation = implementation;
45 }
46
47 public String getCategory() {
48 return category;
49 }
50
51 public boolean isDocumented() {
52 return documented;
53 }
54
55 public boolean isImplementation() {
56 return implementation;
38 } 57 }
39 58
40 public String getHost() { 59 public String getHost() {
41 return host; 60 return host;
42 } 61 }
43 62
44 public String getPathToLib() { 63 public String getPathToLib() {
45 return pathToLib; 64 return pathToLib;
46 } 65 }
47 66
48 public String getShortName() { 67 public String getShortName() {
49 return shortName; 68 return shortName;
50 } 69 }
51 70
71 public File getLibraryDir() {
72 return dirOrZip;
73 }
74
52 public URI translateUri(URI dartUri) { 75 public URI translateUri(URI dartUri) {
53 if (!dirOrZip.exists()) { 76 if (!dirOrZip.exists()) {
54 throw new RuntimeException("System library for " + dartUri + " does not ex ist: " + dirOrZip.getPath()); 77 throw new RuntimeException("System library for " + dartUri + " does not ex ist: " + dirOrZip.getPath());
55 } 78 }
56 try { 79 try {
57 URI dirOrZipURI = dirOrZip.toURI(); 80 URI dirOrZipURI = dirOrZip.toURI();
58 if (dirOrZip.isFile()) { 81 if (dirOrZip.isFile()) {
59 return new URI("jar", "file:" + dirOrZipURI.getPath() + "!" + dartUri.ge tPath(), null); 82 return new URI("jar", "file:" + dirOrZipURI.getPath() + "!" + dartUri.ge tPath(), null);
60 } else { 83 } else {
61 return dirOrZipURI.resolve("." + dartUri.getPath()); 84 return dirOrZipURI.resolve("." + dartUri.getPath());
62 } 85 }
63 } catch (URISyntaxException e) { 86 } catch (URISyntaxException e) {
64 throw new AssertionError(); 87 throw new AssertionError();
65 } 88 }
66 } 89 }
67 90
68 public File getFile() { 91 public File getFile() {
69 return this.dirOrZip; 92 return this.dirOrZip;
70 } 93 }
71 } 94 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698