Bug 1360557. Fix the Web IDL parser to report more useful errors when extended attributes are used on constructs that don't allow them. r=qdot

This commit is contained in:
Boris Zbarsky 2017-05-01 13:25:47 -04:00
Родитель 5e08107df0
Коммит 12bc4392d8
1 изменённых файлов: 25 добавлений и 6 удалений

Просмотреть файл

@ -573,7 +573,10 @@ class IDLExternalInterface(IDLObjectWithIdentifier, IDLExposureMixins):
return False
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
if len(attrs) != 0:
raise WebIDLError("There are no extended attributes that are "
"allowed on external interfaces",
[attrs[0].location, self.location])
def resolve(self, parentScope):
pass
@ -1932,7 +1935,10 @@ class IDLDictionary(IDLObjectWithScope):
[member.location] + locations)
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
if len(attrs) != 0:
raise WebIDLError("There are no extended attributes that are "
"allowed on dictionaries",
[attrs[0].location, self.location])
def _getDependentObjects(self):
deps = set(self.members)
@ -1966,7 +1972,10 @@ class IDLEnum(IDLObjectWithIdentifier):
return True
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
if len(attrs) != 0:
raise WebIDLError("There are no extended attributes that are "
"allowed on enums",
[attrs[0].location, self.location])
def _getDependentObjects(self):
return set()
@ -2139,7 +2148,11 @@ class IDLType(IDLObject):
return self.nullable() and self.inner.callback._treatNonObjectAsNull
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
if len(attrs) != 0:
raise WebIDLError("There are no extended attributes that are "
"allowed on types, for now (but this is "
"changing; see bug 1359269)",
[attrs[0].location, self.location])
def resolveType(self, parentScope):
pass
@ -2707,7 +2720,10 @@ class IDLTypedef(IDLObjectWithIdentifier):
return True
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
if len(attrs) != 0:
raise WebIDLError("There are no extended attributes that are "
"allowed on typedefs",
[attrs[0].location, self.location])
def _getDependentObjects(self):
return self.innerType._getDependentObjects()
@ -5108,7 +5124,10 @@ class IDLImplementsStatement(IDLObject):
pass
def addExtendedAttributes(self, attrs):
assert len(attrs) == 0
if len(attrs) != 0:
raise WebIDLError("There are no extended attributes that are "
"allowed on implements statements",
[attrs[0].location, self.location])
class IDLExtendedAttribute(IDLObject):