本文整理汇总了Java中com.google.javascript.rhino.jstype.Property类的典型用法代码示例。如果您正苦于以下问题:Java Property类的具体用法?Java Property怎么用?Java Property使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Property类属于com.google.javascript.rhino.jstype包,在下文中一共展示了Property类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitEnumMember
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Override
protected boolean visitEnumMember(Property enumMember) {
Field enumField = new Field();
enumField.setName(enumMember.getName());
enumField.setType(getJavaTypeRegistry().createTypeReference(enumMember.getType()));
enumField.setStatic(true);
enumField.setNativeReadOnly(true);
enumField.addAnnotation(
Annotation.builder()
.type(JS_PROPERTY)
.nameAttribute(enumMember.getName())
.namespaceAttribute(enumMember.getType().getDisplayName())
.build());
getCurrentJavaType().addField(enumField);
return true;
}
开发者ID:google,项目名称:jsinterop-generator,代码行数:17,代码来源:EnumMemberCollector.java
示例2: getOwnProperties
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private Map<String, InstanceProperty> getOwnProperties(ObjectType object) {
ObjectType definingType = object;
if (definingType.isFunctionPrototypeType()) {
definingType = definingType.getOwnerFunction();
} else if (definingType.isInstanceType()) {
definingType = definingType.getConstructor();
}
Map<String, InstanceProperty> properties = new HashMap<>();
for (String name : object.getOwnPropertyNames()) {
if (!"constructor".equals(name)) {
Property property = object.getOwnSlot(name);
properties.put(
property.getName(),
InstanceProperty.builder()
.setOwnerType(getFirst(registry.getTypes(definingType), null))
.setDefinedByType(definingType)
.setName(property.getName())
.setType(getType(object, property))
.setNode(property.getNode())
.setJsDoc(JsDoc.from(property.getJSDocInfo()))
.build());
}
}
return properties;
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:27,代码来源:TypeInspector.java
示例3: getPropertyData
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private com.github.jsdossier.proto.Property getPropertyData(
String name,
JSType type,
Node node,
PropertyDocs docs,
@Nullable NamedType definedBy,
Iterable<InstanceProperty> overrides) {
com.github.jsdossier.proto.Property.Builder builder =
com.github.jsdossier.proto.Property.newBuilder()
.setBase(getBasePropertyDetails(name, type, node, docs, definedBy, overrides));
TypeExpressionParser parser =
expressionParserFactory.create(linkFactory.withTypeContext(docs.getContextType()));
if (docs.getJsDoc().getType() != null) {
JSTypeExpression typeExpression = docs.getJsDoc().getType();
type = evaluate(typeExpression);
}
if (type != null) {
TypeExpression expression = parser.parse(type);
builder.setType(expression);
}
return builder.build();
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:26,代码来源:TypeInspector.java
示例4: caseRecordType
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private void caseRecordType(final ObjectType type) {
Iterable<Property> properties =
type.getOwnPropertyNames()
.stream()
.map(type::getOwnSlot)
.filter(input -> input != null && !input.getType().isNoType())
.sorted((o1, o2) -> o1.getName().compareTo(o2.getName()))
.collect(toList());
RecordType.Builder recordType = currentExpression().getRecordTypeBuilder();
for (Property property : properties) {
RecordType.Entry.Builder entry = recordType.addEntryBuilder();
entry.setKey(property.getName());
expressions.addLast(entry.getValueBuilder());
property.getType().visit(this);
expressions.removeLast();
}
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:19,代码来源:TypeExpressionParser.java
示例5: parseExpression_typeIsReferenceToNullableExtern
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void parseExpression_typeIsReferenceToNullableExtern() {
util.compile(
createSourceFile(
fs.getPath("source/modules/one.js"),
"var stream = require('stream');",
"/** @constructor */",
"function Writer() {}",
"/** @type {stream.Stream} */",
"Writer.prototype.stream = null;",
"exports.Writer = Writer"));
NominalType type = typeRegistry.getType("module$exports$module$source$modules$one.Writer");
Property property = type.getType().toMaybeFunctionType().getInstanceType().getSlot("stream");
TypeExpression expression =
parserFactory.create(linkFactoryBuilder.create(type)).parse(property.getType());
assertThat(expression).isEqualTo(unionType(namedTypeExpression("stream.Stream"), NULL_TYPE));
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:20,代码来源:TypeExpressionParserTest.java
示例6: parsesReturnDescription_oneLineB
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void parsesReturnDescription_oneLineB() {
util.compile(
path("foo/bar.js"),
"/** @constructor */",
"var Foo = function() {};",
"/**",
" * @return nothing.",
" */",
"Foo.bar = function() { return ''; };");
NominalType foo = getOnlyElement(typeRegistry.getAllTypes());
Property bar = getOnlyElement(getProperties(foo));
assertEquals("bar", bar.getName());
assertTrue(bar.getType().isFunctionType());
assertEquals("nothing.", JsDoc.from(bar.getJSDocInfo()).getReturnClause().getDescription());
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:17,代码来源:JsDocTest.java
示例7: parsesReturnDescription_twoLines
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void parsesReturnDescription_twoLines() {
util.compile(
path("foo/bar.js"),
"/** @constructor */",
"var Foo = function() {};",
"/**",
" * @return nothing over",
" * two lines.",
" */",
"Foo.bar = function() { return ''; };");
NominalType foo = getOnlyElement(typeRegistry.getAllTypes());
Property bar = getOnlyElement(getProperties(foo));
assertEquals("bar", bar.getName());
assertTrue(bar.getType().isFunctionType());
assertEquals(
"nothing over\n two lines.",
JsDoc.from(bar.getJSDocInfo()).getReturnClause().getDescription());
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:20,代码来源:JsDocTest.java
示例8: parsesReturnDescription_manyLines
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void parsesReturnDescription_manyLines() {
util.compile(
path("foo/bar.js"),
"/** @constructor */",
"var Foo = function() {};",
"/**",
" * @return nothing over",
" * many",
" * lines.",
" */",
"Foo.bar = function() { return ''; };");
NominalType foo = getOnlyElement(typeRegistry.getAllTypes());
Property bar = getOnlyElement(getProperties(foo));
assertEquals("bar", bar.getName());
assertTrue(bar.getType().isFunctionType());
assertEquals(
"nothing over\n many\n lines.",
JsDoc.from(bar.getJSDocInfo()).getReturnClause().getDescription());
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:21,代码来源:JsDocTest.java
示例9: extractsDefineComments_blockCommentAboveAnnotation
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void extractsDefineComments_blockCommentAboveAnnotation() {
util.compile(
path("foo/bar.js"),
"goog.provide('foo');",
"",
"/**",
" * Hello, world!",
" * @define {boolean}",
" */",
"foo.bar = false;");
NominalType type = getOnlyElement(typeRegistry.getAllTypes());
assertThat(type.getName()).isEqualTo("foo");
Property property = getOnlyElement(getProperties(type));
assertThat(property.getName()).isEqualTo("bar");
JsDoc doc = JsDoc.from(property.getJSDocInfo());
assertThat(doc).isNotNull();
assertThat(doc.getBlockComment()).isEqualTo("Hello, world!");
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:22,代码来源:JsDocTest.java
示例10: extractsDefineComments_commentInlineWithAnnotation
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void extractsDefineComments_commentInlineWithAnnotation() {
util.compile(
path("foo/bar.js"),
"goog.provide('foo');",
"",
"/**",
" * @define {boolean} Hello, world!",
" * Goodbye, world!",
" */",
"foo.bar = false;");
NominalType type = getOnlyElement(typeRegistry.getAllTypes());
assertThat(type.getName()).isEqualTo("foo");
Property property = getOnlyElement(getProperties(type));
assertThat(property.getName()).isEqualTo("bar");
JsDoc doc = JsDoc.from(property.getJSDocInfo());
assertThat(doc).isNotNull();
assertThat(doc.getBlockComment()).isEqualTo("Hello, world!\n" + " Goodbye, world!");
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:22,代码来源:JsDocTest.java
示例11: visitModule
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Override
protected boolean visitModule(StaticTypedSlot<JSType> module) {
String jsFqn =
module instanceof Property
? ((Property) module).getNode().getOriginalQualifiedName()
: module.getName();
Type javaType = createJavaType(jsFqn, NAMESPACE, false);
getJavaTypeRegistry().registerJavaType(javaType, module.getType());
super.pushCurrentJavaType(javaType);
return true;
}
开发者ID:google,项目名称:jsinterop-generator,代码行数:13,代码来源:TypeCollector.java
示例12: classHasToString
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
/**
* Checks whether class has overridden toString() method. All objects has native toString()
* method but we ignore it as it is not useful so we need user-provided toString() method.
*/
private boolean classHasToString(ObjectType type) {
Property toStringProperty = type.getOwnSlot("toString");
if (toStringProperty != null) {
return toStringProperty.getType().isFunctionType();
}
ObjectType parent = type.getParentScope();
if (parent != null && !parent.isNativeObjectType()) {
return classHasToString(parent);
}
return false;
}
开发者ID:google,项目名称:closure-compiler,代码行数:16,代码来源:TypeCheck.java
示例13: addInstanceProperties
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private void addInstanceProperties(JsType.Builder spec) {
TypeInspector.Report report = typeInspector.inspectInstanceType();
for (com.github.jsdossier.proto.Property prop : report.getProperties()) {
spec.addField(prop);
updateInstancePropertyIndex(spec, prop.getBase());
}
for (com.github.jsdossier.proto.Function func : report.getFunctions()) {
spec.addMethod(func);
updateInstancePropertyIndex(spec, func.getBase());
}
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:12,代码来源:RenderDocumentationTaskSupplier.java
示例14: getProperties
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
/** Returns the raw properties for the given type. */
public List<Property> getProperties(NominalType nominalType) {
JSType type = nominalType.getType();
ObjectType object = ObjectType.cast(type);
if (object == null) {
return ImmutableList.of();
}
List<Property> properties = new ArrayList<>();
for (String name : object.getOwnPropertyNames()) {
Property property = null;
if (type.isFunctionType()) {
if (!isBuiltInFunctionProperty(type, name)) {
property = object.getOwnSlot(name);
}
} else if (!"prototype".equals(name)) {
property = object.getOwnSlot(name);
}
if (property != null) {
if (property.getType().isConstructor()
&& isConstructorTypeDefinition(
property.getType(), JsDoc.from(property.getJSDocInfo()))) {
continue;
}
// If the property is another module and the inspected type is also a module, then count
// the property as a static property. Otherwise, if the property i registered as a nominal
// type, it does not count as a static property. It should also be ignored if it is not
// registered as a nominal type, but its qualified name has been filtered out by the user.
String qualifiedName = nominalType.getName() + "." + property.getName();
if (((inspectedType.isModuleExports() && registry.isModule(property.getType()))
|| registry.getTypes(property.getType()).isEmpty())
&& !typeFilter.test(qualifiedName)) {
properties.add(property);
}
}
}
return properties;
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:41,代码来源:TypeInspector.java
示例15: getType
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private static JSType getType(ObjectType object, Property property) {
JSType type = object.findPropertyType(property.getName());
if (type.isUnknownType()) {
type = property.getType();
}
return type;
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:8,代码来源:TypeInspector.java
示例16: shouldUsePropertyTypeDocs
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private boolean shouldUsePropertyTypeDocs(NominalType parent, Property property) {
JSDocInfo info = property.getJSDocInfo();
return (info == null && !isTheObjectType(property.getType()))
|| (parent.isModuleExports()
&& !parent.getModule().get().isEs6()
&& (info == null || isNullOrEmpty(info.getOriginalCommentString())));
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:8,代码来源:TypeCollectionPass.java
示例17: parsesReturnDescription_oneLineA
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
@Test
public void parsesReturnDescription_oneLineA() {
util.compile(
path("foo/bar.js"),
"/** @constructor */",
"var Foo = function() {};",
"/** @return nothing. */",
"Foo.bar = function() { return ''; };");
NominalType foo = getOnlyElement(typeRegistry.getAllTypes());
Property bar = getOnlyElement(getProperties(foo));
assertEquals("bar", bar.getName());
assertTrue(bar.getType().isFunctionType());
assertEquals("nothing.", JsDoc.from(bar.getJSDocInfo()).getReturnClause().getDescription());
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:15,代码来源:JsDocTest.java
示例18: getProperties
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private List<Property> getProperties(NominalType type) {
List<Property> properties = new ArrayList<>();
for (String name : type.getType().toObjectType().getOwnPropertyNames()) {
Property property = type.getType().toObjectType().getOwnSlot(name);
if (property != null) {
properties.add(property);
}
}
return properties;
}
开发者ID:jleyba,项目名称:js-dossier,代码行数:11,代码来源:JsDocTest.java
示例19: acceptEnumMember
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
private void acceptEnumMember(Property enumMember) {
visitEnumMember(enumMember);
}
开发者ID:google,项目名称:jsinterop-generator,代码行数:4,代码来源:AbstractClosureVisitor.java
示例20: visitEnumMember
import com.google.javascript.rhino.jstype.Property; //导入依赖的package包/类
protected boolean visitEnumMember(Property enumMember) {
return true;
}
开发者ID:google,项目名称:jsinterop-generator,代码行数:4,代码来源:AbstractClosureVisitor.java
注:本文中的com.google.javascript.rhino.jstype.Property类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论