1 | /**
|
2 | * Copyright (c) 2015 The Polymer Project Authors. All rights reserved.
|
3 | * This code may only be used under the BSD style license found at
|
4 | * http://polymer.github.io/LICENSE.txt
|
5 | * The complete set of authors may be found at
|
6 | * http://polymer.github.io/AUTHORS.txt
|
7 | * The complete set of contributors may be found at
|
8 | * http://polymer.github.io/CONTRIBUTORS.txt
|
9 | * Code distributed by Google as part of the polymer project is also
|
10 | * subject to an additional IP rights grant found at
|
11 | * http://polymer.github.io/PATENTS.txt
|
12 | */
|
13 | import * as parse5 from 'parse5';
|
14 | import { ParsedHtmlDocument } from '../html/html-document';
|
15 | import { SourcePosition } from '../model/model';
|
16 | export declare type LocationResult = AttributesSection | AttributeValue | TagName | EndTag | TextNode | ScriptContents | StyleContents | Comment;
|
17 | /** In the tagname of a start tag. */
|
18 | export interface TagName {
|
19 | kind: 'tagName';
|
20 | element: parse5.ASTNode;
|
21 | }
|
22 | /** In an end tag. */
|
23 | export interface EndTag {
|
24 | kind: 'endTag';
|
25 | element: parse5.ASTNode;
|
26 | }
|
27 | /** In the attributes section of a start tag. Maybe in an attribute name. */
|
28 | export interface AttributesSection {
|
29 | kind: 'attribute';
|
30 | /** The attribute name that we're hovering over, if any. */
|
31 | attribute: string | null;
|
32 | /** The element whose start tag we're in. */
|
33 | element: parse5.ASTNode;
|
34 | }
|
35 | /** In the value of an attribute of a start tag. */
|
36 | export interface AttributeValue {
|
37 | kind: 'attributeValue';
|
38 | attribute: string;
|
39 | element: parse5.ASTNode;
|
40 | }
|
41 | /** In a text node. */
|
42 | export interface TextNode {
|
43 | kind: 'text';
|
44 | textNode?: parse5.ASTNode;
|
45 | }
|
46 | /** In the text of a <script> */
|
47 | export interface ScriptContents {
|
48 | kind: 'scriptTagContents';
|
49 | textNode?: parse5.ASTNode;
|
50 | }
|
51 | /** In the text of a <style> */
|
52 | export interface StyleContents {
|
53 | kind: 'styleTagContents';
|
54 | textNode?: parse5.ASTNode;
|
55 | }
|
56 | /** In a <!-- comment --> */
|
57 | export interface Comment {
|
58 | kind: 'comment';
|
59 | commentNode: parse5.ASTNode;
|
60 | }
|
61 | /**
|
62 | * Given a position and an HTML document, try to describe what new text typed
|
63 | * at the given position would be.
|
64 | *
|
65 | * Where possible we try to return the ASTNode describing that position, but
|
66 | * sometimes there does not actually exist one. (for a simple case, the empty
|
67 | * string should be interpreted as a text node, but there is no text node in
|
68 | * an empty document, but there would be after the first character was typed).
|
69 | */
|
70 | export declare function getLocationInfoForPosition(document: ParsedHtmlDocument, position: SourcePosition): LocationResult;
|