当前位置: 首页>>代码示例>>Java>>正文


Java NameEnvironmentAnswer类代码示例

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


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


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