<commit_before>import {
  CancellationToken, Position, DefinitionProvider,
  TextDocument, Definition, Location, Uri, workspace
} from 'vscode';
import * as path from 'path';
import * as fs from 'fs';
import * as ts from 'typescript';

export class AngularDefinitionHtmlProvider implements DefinitionProvider {

  provideDefinition(document: TextDocument, position: Position, token: CancellationToken) {
    const lineText = document.lineAt(position).text;
    
    let propertyName: string;

    // Parse interpolation
    if (!propertyName) propertyName = this.parseByRegexp(lineText, position, /{{\s*(\w+)[\.\s\w]*}}/g);

    // Parse attribute
    if (!propertyName) propertyName = this.parseByRegexp(lineText, position, /\[[\w\.\-?]*\]=\"!?(\w+)[\.\w]*\"/g);

    if (propertyName)
    {
      const componentFilePath = document.fileName.substr(0, document.fileName.lastIndexOf('.')) + '.ts';
      console.log('## Potential findings ##');
      console.log('Property name: ' + propertyName);
      console.log('Component: ' + componentFilePath);

      if (fs.existsSync(componentFilePath)) {
        return workspace.openTextDocument(componentFilePath).then((document) => {
          const text = document.getText();
          const sourceFile = this.getSourceFile(componentFilePath, text);
          const position = this.getPropertyPosition(sourceFile, propertyName);
          return position ? new Location(Uri.file(componentFilePath), position) : null;
        });
      }
    }

    return null;
  }<commit_msg>Capture properties used in two-way binded attributes [()]<commit_after>import {
  CancellationToken, Position, DefinitionProvider,
  TextDocument, Definition, Location, Uri, workspace
} from 'vscode';
import * as path from 'path';
import * as fs from 'fs';
import * as ts from 'typescript';

export class AngularDefinitionHtmlProvider implements DefinitionProvider {

  provideDefinition(document: TextDocument, position: Position, token: CancellationToken) {
    const lineText = document.lineAt(position).text;
    
    let propertyName: string;

    // Parse interpolation
    if (!propertyName) propertyName = this.parseByRegexp(lineText, position, /{{\s*(\w+)[\.\s\w]*}}/g);

    // Parse attribute
    if (!propertyName) propertyName = this.parseByRegexp(lineText, position, /\[\(?[\w\.\-?]*\)?\]=\"!?(\w+)[\.\w]*\"/g);

    if (propertyName)
    {
      const componentFilePath = document.fileName.substr(0, document.fileName.lastIndexOf('.')) + '.ts';
      console.log('## Potential findings ##');
      console.log('Property name: ' + propertyName);
      console.log('Component: ' + componentFilePath);

      if (fs.existsSync(componentFilePath)) {
        return workspace.openTextDocument(componentFilePath).then((document) => {
          const text = document.getText();
          const sourceFile = this.getSourceFile(componentFilePath, text);
          const position = this.getPropertyPosition(sourceFile, propertyName);
          return position ? new Location(Uri.file(componentFilePath), position) : null;
        });
      }
    }

    return null;
  }
{'fraction_non_alphanumeric': 0.14234990316333118, 'fraction_numerical': 0.0006455777921239509, 'mean_word_length': 3.6601503759398497, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1069268', 'n_tokens_mistral': 853, 'n_tokens_neox': 838, 'n_words': 201}