Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GH-8313] Allow use of custom HTML-Tags in PHP #8315

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@
* @author marek
*/
@MimeRegistrations({
@MimeRegistration(mimeType = "text/html", service = HtmlExtension.class)
@MimeRegistration(mimeType = "text/html", service = HtmlExtension.class),
@MimeRegistration(mimeType = "text/x-php5", service = HtmlExtension.class)
})
public class CustomHtmlExtension extends HtmlExtension {

Expand All @@ -76,7 +77,7 @@ private Configuration getConfiguration(HtmlSource source) {
if (cache == null) {
//no cache - create
FileObject sourceFileObject = source.getSourceFileObject();
Project project = sourceFileObject == null ? null : FileOwnerQuery.getOwner(sourceFileObject);
Project project = sourceFileObject == null ? null : FileOwnerQuery.getOwner(sourceFileObject);
Configuration conf = project == null ? Configuration.EMPTY : Configuration.get(project);
cache = Pair.of(source, conf);
return cache.second();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ public static ElementVisitor getChecker(RuleContext context, Configuration conf,
Collection<ElementVisitor> visitors = new ArrayList<>();
visitors.add(new UnknownAttributesChecker(context, conf, snapshot, hints));
visitors.add(new MissingRequiredAttributeChecker(context, conf, snapshot, hints));

return new AggregatedVisitor(visitors);
}

public static class AggregatedVisitor implements ElementVisitor {

private final Collection<ElementVisitor> visitors;

public AggregatedVisitor(Collection<ElementVisitor> visitors) {
this.visitors = visitors;
}

@Override
public void visit(Element node) {
for(ElementVisitor visitor : visitors) {
Expand All @@ -63,9 +63,9 @@ public void visit(Element node) {
}

}

protected abstract static class Checker implements ElementVisitor {

protected RuleContext context;
protected Configuration conf;
protected Snapshot snapshot;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void visit(Element node) {
boolean lineHint = false;

//use the whole element offsetrange so multiple unknown attributes can be handled
OffsetRange range = new OffsetRange(snapshot.getEmbeddedOffset(ot.from()), snapshot.getEmbeddedOffset(ot.to()));
OffsetRange range = new OffsetRange(snapshot.getOriginalOffset(ot.from()), snapshot.getOriginalOffset(ot.to()));
hints.add(new UnknownAttributes(unknownAttributeNames, tagModel.getName(), context, range, lineHint));
}
}
Expand All @@ -125,7 +125,7 @@ public void visit(Element node) {
}
}

private static class MissingRequiredAttributeChecker extends Checker {
private static class MissingRequiredAttributeChecker extends Checker {

public MissingRequiredAttributeChecker(RuleContext context, Configuration conf, Snapshot snapshot, List<Hint> hints) {
super(context, conf, snapshot, hints);
Expand Down Expand Up @@ -157,6 +157,6 @@ public void visit(Element node) {
}
}
}


}
Loading