org.netbeans.modules.parsing.api.Source.createSnapshot()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中org.netbeans.modules.parsing.api.Source.createSnapshot()方法的一些代码示例,展示了Source.createSnapshot()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Source.createSnapshot()方法的具体详情如下:
包路径:org.netbeans.modules.parsing.api.Source
类名称:Source
方法名:createSnapshot

Source.createSnapshot介绍

暂无

代码示例

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

@Override
@NonNull
protected final CharSequence createContent() throws IOException {
  final FileObject file = getHandle().resolveFileObject(false);
  if (file == null) {
    throw new FileNotFoundException("Cannot open file: " + toString());
  }
  final Source source = Source.create(file);
  if (source == null) {
    throw new IOException("No source for: " + FileUtil.getFileDisplayName(file));   //NOI18N
  }
  CharSequence content = source.createSnapshot().getText();
  if (hasFilter && source.getDocument(false) == null) {
    content = filter(content);
  }
  return content;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-javascript2-nodejs

TokenSequence<? extends JsTokenId> ts = LexUtilities.getJsTokenSequence(source.createSnapshot().getTokenHierarchy(), theFirst.getOffset());
if (ts == null) {
  return Collections.emptyList();

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-java-source-base

public CompilationController createCompilationController (final Source s) throws IOException, ParseException {
  Parameters.notNull("s", s);
  JavacParserFactory factory = JavacParserFactory.getDefault();
  final Snapshot snapshot = s.createSnapshot();
  final JavacParser parser = factory.createPrivateParser(snapshot);
  if (parser == null)
    return null;
  final UserTask dummy = new UserTask() {
    @Override
    public void run(ResultIterator resultIterator) throws Exception {
    }
  };
  parser.parse(snapshot,dummy, null);
  return CompilationController.get(parser.getResult(dummy));
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-css-prep

Snapshot snapshot = source.createSnapshot();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-ruby

if (element instanceof IndexedElement) {
  FileObject f = ((IndexedElement) element).getFileObject();
  snapshot = Source.create(f).createSnapshot();
} else if (info != null) {
  snapshot = info.getSnapshot();

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-html-angular

@Override
public void intercept(String name, JsObject globalObject, DeclarationScope scope, ModelElementFactory factory, Collection<FunctionArgument> args) {
  if (!AngularJsIndexer.isScannerThread()) {
    return;
  }
  for (FunctionArgument arg : args) {
    if (arg.getKind() == FunctionArgument.Kind.ANONYMOUS_OBJECT) {
      JsObject aObject = (JsObject) arg.getValue();
      JsObject url = aObject.getProperty(TEMPLATE_URL_PROP);
      JsObject controller = aObject.getProperty(CONTROLLER_PROP);
      FileObject fo = globalObject.getFileObject();
      if (url != null && controller != null && fo != null) {
        String content = null;
        Source source = Source.create(fo);
        content = source.createSnapshot().getText().toString();                   
        if (content != null) {
          String template = getStringValueAt(content, url.getOffsetRange().getStart());
          String controllerName = getStringValueAt(content, controller.getOffsetRange().getStart());
          if (template != null && controllerName != null) {
            AngularJsIndexer.addTemplateController(fo.toURI(), Utils.cutQueryFromTemplateUrl(template), controllerName);
          }
        }
      }
    }
  }
}

相关文章