• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java NameEnvironmentAnswer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer的典型用法代码示例。如果您正苦于以下问题:Java NameEnvironmentAnswer类的具体用法?Java NameEnvironmentAnswer怎么用?Java NameEnvironmentAnswer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



NameEnvironmentAnswer类属于org.eclipse.jdt.internal.compiler.env包,在下文中一共展示了NameEnvironmentAnswer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  try {
    final Function1<char[], String> _function = (char[] it) -> {
      return String.valueOf(it);
    };
    String _join = IterableExtensions.join(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function), "/");
    final String fileName = (_join + ".class");
    boolean _containsKey = this.cache.containsKey(fileName);
    if (_containsKey) {
      return this.cache.get(fileName);
    }
    final URL url = this.classLoader.getResource(fileName);
    if ((url == null)) {
      this.cache.put(fileName, null);
      return null;
    }
    final ClassFileReader reader = ClassFileReader.read(url.openStream(), fileName);
    final NameEnvironmentAnswer result = new NameEnvironmentAnswer(reader, null);
    this.cache.put(fileName, result);
    return result;
  } catch (Throwable _e) {
    throw Exceptions.sneakyThrow(_e);
  }
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:26,代码来源:InMemoryJavaCompiler.java


示例2: testRemoveClass

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Test
public void testRemoveClass() throws Exception {
  ResourceChangedEvent event =
      new ResourceChangedEvent(
          new File(BaseTest.class.getResource("/projects").getFile()),
          new ProjectItemModifiedEvent(
              ProjectItemModifiedEvent.EventType.DELETED,
              "test",
              "/test/src/main/java/org/eclipse/che/test/MyClass.java",
              false));
  NameEnvironmentAnswer answer =
      project
          .newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY)
          .findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));

  assertThat(answer).isNotNull();

  JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);

  answer =
      project
          .newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY)
          .findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));
  assertThat(answer).isNull();
}
 
开发者ID:eclipse,项目名称:che,代码行数:26,代码来源:DeltaProcessingTest.java


示例3: testRemoveFolder

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Test
public void testRemoveFolder() throws Exception {
  ResourceChangedEvent event =
      new ResourceChangedEvent(
          new File(BaseTest.class.getResource("/projects").getFile()),
          new ProjectItemModifiedEvent(
              ProjectItemModifiedEvent.EventType.DELETED,
              "test",
              "/test/src/main/java/org/eclipse/che/test",
              true));
  NameEnvironmentAnswer answer =
      project
          .newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY)
          .findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));

  assertThat(answer).isNotNull();
  JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);
  answer =
      project
          .newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY)
          .findType(CharOperation.splitOn('.', "org.eclipse.che.test.MyClass".toCharArray()));
  assertThat(answer).isNull();
}
 
开发者ID:eclipse,项目名称:che,代码行数:24,代码来源:DeltaProcessingTest.java


示例4: findClass

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public NameEnvironmentAnswer findClass(
    String binaryFileName, String qualifiedPackageName, String qualifiedBinaryFileName) {
  if (!isPackage(qualifiedPackageName)) return null; // most common case

  try {
    ClassFileReader reader = ClassFileReader.read(this.zipFile, qualifiedBinaryFileName);
    if (reader != null) {
      if (this.accessRuleSet == null) return new NameEnvironmentAnswer(reader, null);
      String fileNameWithoutExtension =
          qualifiedBinaryFileName.substring(
              0, qualifiedBinaryFileName.length() - SuffixConstants.SUFFIX_CLASS.length);
      return new NameEnvironmentAnswer(
          reader,
          this.accessRuleSet.getViolatedRestriction(fileNameWithoutExtension.toCharArray()));
    }
  } catch (IOException | ClassFormatException e) { // treat as if class file is missing
  }
  return null;
}
 
开发者ID:eclipse,项目名称:che,代码行数:20,代码来源:ClasspathJar.java


示例5: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Override
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName)
{
    StringBuilder result = new StringBuilder();
    int i = 0;
    for (; i < packageName.length; i++)
    {
        if (i > 0)
            result.append('.');
        result.append(packageName[i]);
    }
    if (i > 0)
        result.append('.');
    result.append(typeName);
    return findType(result.toString());
}
 
开发者ID:scylladb,项目名称:scylla-tools-java,代码行数:17,代码来源:JavaBasedUDFunction.java


示例6: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
/**
 * @see org.eclipse.jdt.internal.compiler.env.INameEnvironment#findType(char[][])
 */
public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
	if (compoundTypeName == null) return null;

	int length = compoundTypeName.length;
	if (length <= 1) {
		if (length == 0) return null;
		return find(new String(compoundTypeName[0]), null);
	}

	int lengthM1 = length - 1;
	char[][] packageName = new char[lengthM1][];
	System.arraycopy(compoundTypeName, 0, packageName, 0, lengthM1);

	return find(
		new String(compoundTypeName[lengthM1]),
		CharOperation.toString(packageName));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:21,代码来源:SearchableEnvironment.java


示例7: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
    final StringBuffer result = new StringBuffer();
    for (int i = 0; i < compoundTypeName.length; i++) {
        if (i != 0) {
            result.append('.');
        }
        result.append(compoundTypeName[i]);
    }

    if (result.toString().startsWith("java.")) {
        return fileSystem.findType(compoundTypeName);
    }

    return findType(result.toString());
}
 
开发者ID:drxaos,项目名称:jvmvm,代码行数:17,代码来源:NameEnv.java


示例8: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
private NameEnvironmentAnswer findType(String packageName, String typeName) {
  NameEnvironmentAnswer suggestedAnswer = null;
  Collection<ClasspathEntry> entries = !packageName.isEmpty() ? packages.get(packageName) : this.entries;
  if (entries != null) {
    for (ClasspathEntry entry : entries) {
      NameEnvironmentAnswer answer = entry.findType(packageName, typeName);
      if (answer != null) {
        if (!answer.ignoreIfBetter()) {
          if (answer.isBetter(suggestedAnswer)) {
            return answer;
          }
        } else if (answer.isBetter(suggestedAnswer)) {
          // remember suggestion and keep looking
          suggestedAnswer = answer;
        }
      }
    }
  }
  return suggestedAnswer;
}
 
开发者ID:takari,项目名称:takari-lifecycle,代码行数:21,代码来源:Classpath.java


示例9: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
protected NameEnvironmentAnswer findType(String className) {
	if (isPackage(className)) {
		return null;
	}
	String classResourceName = NameUtils.toBinaryName(className);

	// Find in binary store
	byte[] classBytes = getBinaryStore().read(classResourceName);
	if (classBytes != null) {
		// Found, produce answer
		return createFindTypeAnswer(className, classBytes);
	}

	// Find in class loader
	try (InputStream is = getClassLoader().getResourceAsStream(classResourceName)) {
		if (is != null) {
			// Found, produce answer
			return createFindTypeAnswer(className, ByteStreams.toByteArray(is));
		}
	} catch (IOException e) {
		// Ignore
	}
	return null;
}
 
开发者ID:MattiasBuelens,项目名称:junit,代码行数:25,代码来源:EclipseCompiler.java


示例10: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Override
public NameEnvironmentAnswer findType(final char[][] compoundTypeName) {
  final Function1<char[], String> _function = (char[] it) -> {
    return String.valueOf(it);
  };
  final QualifiedName className = QualifiedName.create(ListExtensions.<char[], String>map(((List<char[]>)Conversions.doWrapArray(compoundTypeName)), _function));
  return this.findType(className);
}
 
开发者ID:eclipse,项目名称:xtext-extras,代码行数:9,代码来源:IndexAwareNameEnvironment.java


示例11: testAddClass

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Test
public void testAddClass() throws Exception {

  File workspace = new File(BaseTest.class.getResource("/projects").getFile());
  ResourceChangedEvent event =
      new ResourceChangedEvent(
          workspace,
          new ProjectItemModifiedEvent(
              ProjectItemModifiedEvent.EventType.CREATED,
              "test",
              "/test/src/main/java/org/eclipse/che/test/NewClass.java",
              false));

  NameEnvironmentAnswer answer =
      project
          .newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY)
          .findType(CharOperation.splitOn('.', "org.eclipse.che.test.NewClass".toCharArray()));

  assertThat(answer).isNull();

  FileOutputStream outputStream =
      new FileOutputStream(
          new File(workspace, "/test/src/main/java/org/eclipse/che/test/NewClass.java"));
  outputStream.write("package org.eclipse.che.test;\n public class NewClass{}\n".getBytes());
  outputStream.close();
  JavaModelManager.getJavaModelManager().deltaState.resourceChanged(event);
  answer =
      project
          .newSearchableNameEnvironment(DefaultWorkingCopyOwner.PRIMARY)
          .findType(CharOperation.splitOn('.', "org.eclipse.che.test.NewClass".toCharArray()));
  assertThat(answer).isNotNull();
}
 
开发者ID:eclipse,项目名称:che,代码行数:33,代码来源:DeltaProcessingTest.java


示例12: getCompilationUnit

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public static NameEnvironmentAnswer getCompilationUnit(ICompilationUnit compilationUnit) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
	return new NameEnvironmentAnswer(compilationUnit, null);
	//
	// if (constrNameEnvAnsCompUnit2Args != null)
	// return constrNameEnvAnsCompUnit2Args.newInstance(new Object[] {
	// compilationUnit, null });
	// return constrNameEnvAnsCompUnit.newInstance(new Object[] {
	// compilationUnit });
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:10,代码来源:NameEnvironmentAnswerFactory.java


示例13: getClassFileReader

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public static NameEnvironmentAnswer getClassFileReader(ClassFileReader classFileReader) throws IllegalArgumentException, InstantiationException, IllegalAccessException, InvocationTargetException {
	return new NameEnvironmentAnswer(classFileReader, null);
	// if (constrNameEnvAnsBin2Args != null)
	// return constrNameEnvAnsBin2Args.newInstance(new Object[] {
	// classFileReader, null });
	// return constrNameEnvAnsBin.newInstance(new Object[] { classFileReader });
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:8,代码来源:NameEnvironmentAnswerFactory.java


示例14: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
	StringBuffer result = new StringBuffer();
	String sep = "";
	for (int i = 0; i < compoundTypeName.length; i++) {
		result.append(sep);
		result.append(compoundTypeName[i]);
		sep = ".";
	}
	return findType(result.toString());
}
 
开发者ID:OpenSoftwareSolutions,项目名称:PDFReporter-Studio,代码行数:11,代码来源:NameEnvironement.java


示例15: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
	if (typeName != null)
		return findClass(
			new String(CharOperation.concatWith(packageName, typeName, '/')),
			typeName);
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:8,代码来源:JavaSearchNameEnvironment.java


示例16: findClass

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public NameEnvironmentAnswer findClass(String sourceFileWithoutExtension, String qualifiedPackageName, String qualifiedSourceFileWithoutExtension) {
	SimpleLookupTable dirTable = directoryTable(qualifiedPackageName);
	if (dirTable != null && dirTable.elementSize > 0) {
		IFile file = (IFile) dirTable.get(sourceFileWithoutExtension);
		if (file != null) {
			return new NameEnvironmentAnswer(new ResourceCompilationUnit(file, file.getLocationURI()), null /* no access restriction */);
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:ClasspathSourceDirectory.java


示例17: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
/**
 * @see INameEnvironment#findType(char[], char[][])
 */
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
	NameEnvironmentAnswer result = this.env.findType(typeName, packageName);
	if (result != null) {
		return result;
	}
	return findType(CharOperation.arrayConcat(packageName, typeName));
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:11,代码来源:CodeSnippetEnvironment.java


示例18: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public NameEnvironmentAnswer findType(char[][] compoundName) {
	if (compoundName != null)
		return findClass(
			new String(CharOperation.concatWith(compoundName, '/')),
			compoundName[compoundName.length - 1],
			false);
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:9,代码来源:FileSystem.java


示例19: findClass

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
public NameEnvironmentAnswer findClass(char[] typeName, String qualifiedPackageName, String qualifiedBinaryFileName, boolean asBinaryOnly) {
	if (!isPackage(qualifiedPackageName))
		return null; // most common case

	ZipEntry sourceEntry = this.zipFile.getEntry(qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6)  + SUFFIX_STRING_java);
	if (sourceEntry != null) {
		try {
			InputStream stream = null;
			char[] contents = null; 
			try {
				stream = this.zipFile.getInputStream(sourceEntry);
				contents = Util.getInputStreamAsCharArray(stream, -1, this.encoding);
			} finally {
				if (stream != null)
					stream.close();
			}
			return new NameEnvironmentAnswer(
				new CompilationUnit(
					contents,
					qualifiedBinaryFileName.substring(0, qualifiedBinaryFileName.length() - 6) + SUFFIX_STRING_java,
					this.encoding,
					this.destinationPath),
				fetchAccessRestriction(qualifiedBinaryFileName));
		} catch (IOException e) {
			// treat as if source file is missing
		}
	}
	return null;
}
 
开发者ID:trylimits,项目名称:Eclipse-Postfix-Code-Completion,代码行数:30,代码来源:ClasspathSourceJar.java


示例20: findType

import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer; //导入依赖的package包/类
@Override
public NameEnvironmentAnswer findType(char[][] chars) {
    final S.Buffer result = S.buffer();
    for (int i = 0; i < chars.length; i++) {
        if (i != 0) {
            result.append('.');
        }
        result.append(chars[i]);
    }
    return findType(result.toString());
}
 
开发者ID:actframework,项目名称:actframework,代码行数:12,代码来源:AppCompiler.java



注:本文中的org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ScriptException类代码示例发布时间:2022-05-21
下一篇:
Java XView类代码示例发布时间:2022-05-21
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap